func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> int main() { char a[3][4]; int i, f; for (i = 0; i < 3; i++) scanf( %s , a[i]); if (a[0][0] == a[2][2] && a[0][1] == a[2][1] && a[0][2] == a[2][0] && a[1][0] == a[1][2]) f = 1; else f = 0; if (f == 1) printf( YES n ); else printf( NO... |
#include <bits/stdc++.h> using namespace std; const int T = 31; const int mod = 1000000007; const long long oo = 1LL << 60; long long N; int K; long long B[T][T]; long long power[70]; long long dp[70][T][T]; bool bio[70]; long long rot[T][T][T]; long long mult(long long a, long long b) { if ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); int n, p, q; cin >> n; vector<pair<int, int>> v1; int x1, x2; for (size_t i = 0; i < n; i++) { cin >> x1 >> x2; v1.push_back(make_pair(x1, x2)); } bool s = tru... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n; double f1[N], f2[N], f3[N], a[N], ans; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; f1[i] = a[i] * (f1[i - 1] + 1); f2[i] = a[i] * (f2[i - 1] + 1 + 2 * f1... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); printf( %d , n % 2); } |
#include <bits/stdc++.h> using namespace std; vector<int> t; int n, x, i, j, h, sol, temp; int main() { ios::sync_with_stdio(false); cin >> n; for (i = 0; i < n; i++) { cin >> x; t.push_back(x); } cin >> h; sort(t.begin(), t.end()); sol = 0; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 305; int n, m; class Point { public: long long x, y; Point() : x(0), y(0) {} Point(long long _x, long long _y) : x(_x), y(_y) {} void read() { scanf( %lld%lld , &x, &y); } Point operator+(const Point &o) const { return Point(x... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, x; cin >> n >> x; string second; cin >> second; long long ans = 0; long long sm = 0; for (long long i = 0; i < n; i++) { if (second[i] == 0 ) sm++; else sm--; } long long c = 0;... |
#include <bits/stdc++.h> using namespace std; struct sort_pred { bool operator()(const std::pair<int, int> &left, const std::pair<int, int> &right) { return right.first > left.first; } }; int n, m, k, t; int r = 0; vector<bool> visited; vector<vector<int>> v; vector<int... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = 1e9 + 5; long long powmod(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % mod; a = (a * a) % mod; b >>= 1; } return ret; } const int maxn = 3e5 + 5... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1002000, CAN = 34; int n, m, p, vis[MAXN], pr[MAXN], pcnt; char w1[MAXN], w2[MAXN]; vector<int> can[300]; int muln(int x, int y) { return 1LL * x * y % p; } int mo(int x) { while (x >= p) x -= p; while (x < 0) x += p; return x; }... |
#include <bits/stdc++.h> using namespace std; int n; int a[100007], ans[100007], vis[100007]; int count(int x) { int cnt = 0, now = 0; memset(vis, 255, sizeof(vis)); for (int i = 1; i <= n; i++) { if (vis[a[i]] == now) continue; vis[a[i]] = now; if (++cnt > x) { cnt = 1; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; vector<long long> good, bad; for (long long i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; const int MAX = (1 << 22) + 5; int n, m; bool is[MAX], seen[MAX]; int conj(int x) { int r = 0; for (int i = 0; i < n; ++i) if (!(x & (1 << i))) r += (1 << i); return r; } void dfs(int st, bool p = 0) { if (seen[st]) return; seen[st] =... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n, x; cin >> n; vector<vector<long long int> > a(n); for (long long int i = 0; i < n; i++) { cin >> x; for (long long int j = 0; j < x; j++) { long long int tp; cin >> tp; a[i].push_back(... |
#include <bits/stdc++.h> using namespace std; const int maxN = 3 * (int)1e5 + 100; int b[maxN]; int t[4 * maxN]; int a[maxN]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = a[tl]; return; } int tm = (tl + tr) / 2; build(v + v, tl, tm); build(v + v + 1, tm + 1, tr)... |
#include <bits/stdc++.h> using namespace std; int a[11]; int main() { int i, n, m, x; while (scanf( %d , &a[0]) > 0) { int c[33] = {0}; c[a[0]]++; for ((i) = 0; (i) < (5); (i)++) { scanf( %d , &a[i + 1]); c[a[i + 1]]++; } bool f = 0; int mx = 0; fo... |
#include <bits/stdc++.h> const int MAXN = 2000 + 10; const int INF = std::numeric_limits<int>::max(); const double EPS = 1e-6; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; int a[MAXN][MAXN]; std::deque<std::pair<std::pair<int, int>, int>> q; using std::cin; using std::cout; using ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops,no-stack-protector,fast-math,inline ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; ... |
#include <bits/stdc++.h> using namespace std; int n, m; int g[405][405]; vector<int> v[405]; double ans; double gai[405]; double pos[405]; double suan(int yi, int juli) { memset(gai, 0, sizeof(gai)); for (int i = 1; i <= n; i++) { if (g[i][yi] == juli) { for (int j = 0; j < (int)v[... |
#include <bits/stdc++.h> using namespace std; bool voltea; int A[100005], B[100005], I[100005], D[100005], R[100005], ctos, hay, x, y, mid, en; int Z[100005], grande; void lis() { B[1] = A[1]; if (voltea) D[ctos] = 1; else I[1] = 1; hay = 1; for (int i = 2; i <= ctos; i++... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c; cin >> a >> b >> c; if (a >= c || b >= c) { cout << 0 ; } else if (a <= 0 && b <= 0) { cout << -1 ; } else { long long int count = 0; while (a < c && b < c) { if (a > b) { ... |
#include <bits/stdc++.h> char map[2][9][9]; int now[2][9][9], dx[] = {-1, -1, 0, 1, 1, 1, 0, -1, 0}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1, 0}; int main() { for (int i = 0; i < 8; i++) scanf( %s , map[0][i]); bool a = 0; now[a][7][0] = 1; int sta = 0; while (sta == 0) { m... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}; int par[200010], r[200010], lar[200010]; void i... |
#include <bits/stdc++.h> using namespace std; const int N = 100 + 7; int n; map<pair<int, int>, int> id; vector<int> g[N]; long double rep(long double x) { if (x >= 2) { x -= 2; } return x; } void dfs(int a, int p = 0, long double t = 0) { int deg = (int)g[a].size(); long doubl... |
#include <bits/stdc++.h> const double eps = 1e-8; const double pi = acos(-1.0); const int INF = 0x7f7f7f7f; const double inf = 1e50; template <class T> inline T minx(T a, T b) { return (a == -1 || b < a) ? b : a; } template <class T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000009; const int maxn = 1000010; long long p[maxn], q[maxn]; int main() { int i, n; long long nAns = 0; cin >> n; n /= 2; p[1] = 2; q[1] = 1; for (i = 2; i <= n; i++) { p[i] = p[i - 1] * 2 % mod; q... |
#include <bits/stdc++.h> const int maxn = 1e5 + 7; int main(int argc, char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, k; std::set<std::pair<int, int> > t[maxn], s; std::cin >> n >> k; int u, v, w; int ans = 0; for (int i = 0; i < n - 1; i++) { std::cin... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e3 + 5; const int MOD = 1e9 + 7; int N, M, A, B; int G[MAXN * MAXN], X, Y, Z; int H[MAXN][MAXN]; int P[MAXN][MAXN]; int T[MAXN][MAXN]; long long ans; deque<pair<int, int> > qu; void reset() { qu.clear(); } void push(int v, int p) { ... |
#include <bits/stdc++.h> using namespace std; int withoutzero(int x); int main() { int a, b, c, d, e, f; cin >> a >> b; d = withoutzero(a); e = withoutzero(b); c = a + b; f = withoutzero(c); if ((d + e) == f) { cout << YES ; } else { cout << NO ; } } int witho... |
#include <bits/stdc++.h> using namespace std; long long f[100000 + 1], a[100000 + 1], n, d, b; int main() { scanf( %lld%lld%lld , &n, &d, &b); for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); f[0] = 0; for (int i = 1; i <= n; i++) f[i] += f[i - 1] + a[i]; long long a1 = 0, a2 = 0; for (l... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, ans1, ans2; long long a[1010][1010]; long long c[1010], x, y, s, t, temp; int main() { scanf( %d%d , &n, &m); for (i = 0; i < m; i++) { for (j = 1; j <= n; j++) { scanf( %lld , &a[i][j]); c[i]... |
#include <bits/stdc++.h> using namespace std; long long N = 500005; long long MAX = 9223372036854775807; long long MOD = 1000000007; long double PI = 4 * atan(1); long long int t, a, b, res; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); long long int T; cin >> T; while (T--) { long long int n; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; if (a[n - 1] > a[0])... |
#include <bits/stdc++.h> using namespace std; int n, siz[200005], l[200005], r[200005], a[200005], p[200005], an = 0, b[200005]; bool vis[200005]; vector<int> vt[200005], vec; set<int> st; set<int>::iterator it; int root(int node) { whi... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int maxi = 0; int ind = 0; string ret = ; for (int i = 0; i < n; i++) { string temp; int d = 10 - (s[i] - 48); int j = i; int ctr = 0; while (ctr < n) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n; cin >> n; vector<vector<long long> > p(2, vector<long long>(n)), suf(2, vector<long long>(n + 1)), ebalVLevo(2, vector<long long>(n + 1)), ebalVPravo(2, vector<long long>(n + 1))... |
#include <bits/stdc++.h> using namespace std; long long dp[300005]; vector<long long> g[300005]; long long ans = 1; long long subs[300005]; long long f[300005][2]; void dfs(long long s, long long p) { dp[s] = 0; long long mx1 = 0; long long mx2 = 0; long long cnt = 0; for (auto it : g[... |
#include <bits/stdc++.h> using namespace std; const int N = 18; long long dp[(1 << N)][105]; string n; int qwq; int m, pw[20]; bool used[10]; void init() { pw[0] = 1; for (int i = 1; i <= n.size(); i++) pw[i] = pw[i - 1] * 10 % m; } int main() { cin >> n >> m; dp[0][0] = 1; init(... |
#include <bits/stdc++.h> using namespace std; const int MAXM = 500 + 5; const int MAXN = 500 + 5; const int MAXQ = 300 + 5; const int MAXK = 800 + 5; const int P = 5; const int MOD = 1e9 + 7; int n, m, q, a[MAXN][MAXK]; int inv[P], ans = 1; char buf[MAXM]; int main() { for (int i = 0; i < P; i... |
#include <bits/stdc++.h> using namespace std; vector<int> st[100000], edge[200000], topo; vector<pair<int, int> > ps; int incnt[200000], tol; priority_queue<int> que; bool visit[200000]; int main(void) { int n, m, in; while (scanf( %d %d , &n, &m) == 2) { for (int i = 0; i < m; ++i) st[i].cl... |
#include <bits/stdc++.h> using namespace std; map<string, int> mp; map<int, string> mp_back; vector<int> way[5005 * 2]; int n, j, i, ans[5005 * 2] = {}; int main() { cin >> n; int w = 0; for (i = 1; i <= n; i++) { int v1, v2; string s1, s2; cin >> s1 >> s2; if (!mp[s1]) ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx2 ) #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; void solve() { int n; cin >> n; vector<int... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, i, j, sum, p[3][3]; stack<int> s; queue<int> q1, q2; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) p[i][j] = (j + 3 - i) % 3; while (s.size()) s.pop(); while (q1.size()) q1.pop(); while (q2.size()) q2.pop(); ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; const int MOD = 1e9 + 7; const long long INFLL = 0x3f3f3f3f3f3f3f3f; const int INF = 0x3f3f3f3f; const int MAXN = 4e5 + 5; char s[MAXN]; int vis[200], t[200]; int check(int n, int l) { int need = (l / 2) * n, cnt = 0; for (... |
#include <bits/stdc++.h> using namespace std; int n, a[100001]; vector<vector<pair<int, int>>> o[6], ans; void relax(vector<int>& m) { o[m.size()].push_back({}); for (size_t i = 0; i < m.size(); i++) o[m.size()].back().push_back({m[i], m[(i + 1) % m.size()]}); m.resize(1); } void gao(int x... |
#include <bits/stdc++.h> using namespace std; int n, m, tot, a[100010], ans[100010]; vector<pair<int, int> > q[100010]; set<int> s; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1, l, x; i <= m; i++) { scanf( %d%d , &l, &x); q[l].empl... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << : << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; long long n, sav, mn = 1e9; struct point { long long x, y, uz; } p[2005]; string s; int det(point A, point B, point C) { if (A.x * B.y + A.y * C.x + B.x * C.y - A.x * C.y - A.y * B.x - B.y * C.x < 0) return -1; return 1; } int main() { ... |
#include <bits/stdc++.h> using namespace std; struct node { int va, id; } a[200015], b[200015]; int n, Q, rv[200015]; long long dp[200015]; inline bool cmp(node x, node y) { return x.va > y.va; } int main() { scanf( %d%d , &n, &Q); for (int i = 1; i <= n; i++) scanf( %d , &a[i].va), a[i].id = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; vector<string> ss; bool possible = false; for (int i = 0; i < n; ++i) { string s; cin >> s; if (!possible) { if (s.substr(0, 2) == OO ) { possible = true; ... |
#include <bits/stdc++.h> using namespace std; long long int maxd(long long int n) { long long int temp = 10 * n, mm = 0; while (temp /= 10) mm = max(mm, temp % 10); return mm; } int main() { long long int n, ans = 0; cin >> n; while (n) { n -= maxd(n); ans++; } cout <... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 1; const int N = 100123; int z, n; int a[N]; int best[N]; long long ans[N]; long long res; pair<int, int> tree[N << 2]; void build(int v, int l, int r) { if (l == r) { tree[v] = {a[l], l}; return; } int mid =... |
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; const int N = 2e6 + 34; char s[N]; long long p[N]; int n, k, m; int lst[100]; int c, cur, mn; int main() { scanf( %d %d n , &n, &k); gets(s); m = strlen(s); for (int i = 0; i < k; i++) lst[i] = -1; p[0] = 0... |
#include <bits/stdc++.h> using namespace std; map<string, string> mp; set<string> st; int n; char in[30]; string read() { scanf( %s , in); return (string)in; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i += 1) { string a = read(); string b = read(); if (st.... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<vector<int>> p; bool is(int val) { int c = 0; vector<bool> pres(n, 0); bool flag = 0; for (int i = 0; i < m; i++) { c = 0; for (int j = 0; j < n; j++) { if (p[i][j] >= val) { pres[j] = true; c+... |
#include <bits/stdc++.h> using namespace std; int dp[80][80][80][80]; int dfs(int l1, int r1, int l2, int r2, int dep) { if (l1 > r1 || l2 > r2) return 0; if (l1 == l2 && r1 == r2) return r1 - l1 + 1; if (r1 < 80 && r2 < 80 && dp[l1][r1][l2][r2] != -1) return dp[l1][r1][l2][r2]; int mid = (1 << de... |
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 123; long long n, m, k; int num[maxn]; int dp[maxn][5]; int presum[maxn]; int tmp[maxn]; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); std::cin >> n; for (... |
#include <bits/stdc++.h> using namespace std; long long int cnt(long long int x) { long long int ans = 0; while (x) { x /= 2; ans++; } return ans; } int main() { int t; cin >> t; while (t--) { long long int d, m; cin >> d >> m; long long int temp = cnt(d... |
#include <bits/stdc++.h> using namespace std; inline int nextint() { int res = 0; char c = 0; while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) { res = res * 10 + c - 0 ; c = getchar(); } return res; } int n; long long a[200000], b[200000]; bool good... |
#include <bits/stdc++.h> using namespace std; vector<int> edges[8]; int calc(int a, int b) { vector<int> cnt(8); for (auto e : edges[a]) cnt[e]++; for (auto e : edges[b]) cnt[e]++; int sol = 0; for (int i = 1; i <= 7; i++) if (cnt[i] == 2) sol++; return sol; } int main() { io... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; const int M = 1000010; const int MOD = 1000000007; const int INF = 2e9; const double eps = 1e-8; const double PI = acos(-1.0); int fx[] = {1, -1, 0, 0}; int fy[] = {0, 0, 1, -1}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a;... |
#include <bits/stdc++.h> using namespace std; int n, e = 0, st[100005], d[100005], T[100005], s[100005], Time; struct Node { int v, t; double p; }; struct { int v, t, nx; } edge[200005]; vector<Node> E[100005]; bool cmp(Node a, Node b) { return a.p < b.p; } void add(int u, int v, int t) { ... |
#include <bits/stdc++.h> const int INT_INF = 0x3f3f3f3f; const int INT_M_INF = 0x7f7f7f7f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const long long LL_M_INF = 0x7f7f7f7f7f7f7f7f; const double pi = acos(-1.0); using namespace std; inline void debug(char ch) { for (int __ii = 0; __ii < 20; ++__ii) p... |
#include <bits/stdc++.h> using namespace std; int main() { int nump; int arr[7]; scanf( %d , &nump); scanf( %d , &arr[0]); for (int i = 1; i < 7; i++) { scanf( %d , &arr[i]); arr[i] += arr[i - 1]; } int tmp = (nump / arr[6]), idx = 0; if (tmp && arr[6] * tmp >= nump) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, s1, s2; getline(cin, s); getline(cin, s1); getline(cin, s2); int substr = s.find(s1), substr1; int forward = 0, backward = 0; if (substr != -1) { substr1 = s.find(s2, substr + s1.length()); if (substr1 != -1... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 50005; char str[Maxn]; int hs[26]; int main() { scanf( %s , str); int len = strlen(str), cCnt = 0; int xNum = 0, sta = 0; bool ok = false; int i; for (i = 0; i < len; i++) { if (i - sta >= 26 && cCnt + xNum == 26) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 30; int n, a[maxn]; long long k, res; bool check(long long x) { long long sum = 0; for (int i = 0; i < n; ++i) { sum += min((long long)a[i], x); if (sum > k) return false; } return true; } int main() { sca... |
#include <bits/stdc++.h> using namespace std; int x[3], y[3], r[3]; double ansx, ansy; bool bisecting_normal(double x1, double y1, double x2, double y2, double &a, double &b, double &c) { double xm = (x1 + x2) * 0.5; double ym = (y1 + y2) * 0.5; double xl = x2 - x1; doubl... |
#include <bits/stdc++.h> using namespace std; const long long inf = 2000000002; pair<long long, long long> p[100005]; long long minl[100005], maxl[100005], minr[100005], maxr[100005]; int main() { int i, j, n, a, b; while (~scanf( %d , &n)) { for (i = 0; i < n; i++) { scanf( %d%d , &a, &... |
#include <bits/stdc++.h> int map[2001][2001] = {0}; int ans[2001] = {0}; int n, m, k; char ss[2001]; void show() { int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { printf( %d , map[i][j]); } printf( n ); } } int main() { int i, j, k; scanf( %d %d... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n & 1) cout << (n - 1) / 2; else { int v = 1; while (v * 2 <= n) v = v * 2; cout << (n - v) / 2; } return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f; int main() { int n, m, array1[100][100], mini, maxi = -OO, i, j; scanf( %d %d , &n, &m); for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) { scanf( %d , &array... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long i, j, k, l, n, m; long long t; cin >> t; while (t--) { cin >> n >> m; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > bord(312345); vector<int> ans; int main() { std::ios::sync_with_stdio(false); int n, a, b, k; cin >> n >> a >> b >> k; string s; cin >> s; int i, sumi = 0, counter = 0; for (i = 0; i < n; i++) { if (s[i] == 1 )... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 10; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const double eps = 1e-10; const double pi = acos(-1); int T, cases, n, m; int main() { ios::sync_with_stdio(false); ; cin >> n >> m; int ans; if (n == 1 || m... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1610; typedef int MAP[maxn][maxn]; int n, m; MAP A, B, flag, used; int total; int num[maxn * maxn], que[maxn * maxn * 2]; MAP temp; int px[] = {0, 0, 1, -1, 0}, py[] = {1, -1, 0, 0, 0}; bool isok(int x, int y) { return x >= 1 && x <= n &... |
#include <bits/stdc++.h> int main(void) { int n, sum = 0; scanf( %d , &n); getchar(); char str[n]; gets(str); for (int i = 0; i < n; i++) { if (str[i] == + ) sum++; else if (str[i] == - && sum != 0) sum--; } printf( %d n , sum); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; int a[n], s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } if (s >= m) cout << m << endl; else cout <... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, inf = 0x3f3f3f3f; int sa[N]; int rk[N]; int tmp[N]; int lcp[N]; char s[N], t[N]; int n, k; bool cmp(int i, int j) { if (rk[i] != rk[j]) return rk[i] < rk[j]; else { int ri = i + k <= n ? rk[i + k] : -1; int... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2000; int n, m, k, t, a[MAX_N + 1], b[MAX_N + 1], p[MAX_N + 1]; vector<int> x; vector<int> y; int main() { int i, j, ans = 0; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , a + i); for (i = 1; i <= n; i++) scanf( %d , b +... |
#include <bits/stdc++.h> using namespace std; char c; int v[300], a; int main() { v[ > ] = 0; v[ < ] = 1; v[ + ] = 2; v[ - ] = 3; v[ . ] = 4; v[ , ] = 5; v[ [ ] = 6; v[ ] ] = 7; while (cin >> c) a = (a * 16 + 8 + v[c]) % 1000003; cout << a << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; cout << fixed << setprecision(7) << a * pow(double(1.000000011), b) << endl; } |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000000; long long mod = 1000000007LL; long long mod2 = 998244353LL; int n, m, k; bool a[1000005]; int main() { cin >> n >> m >> k; memset(a, false, sizeof(a)); for (int i = 1; i <= n; ++i) { int ai; scanf( %d , &ai);... |
#include <bits/stdc++.h> using namespace std; int cnt[5005][5005]; int len; char st[5005]; bool palin[5005][5005]; void updateFreq(int r, int c) { int cc; while (r <= len) { cc = c; while (cc <= len) { cnt[r][cc]++; cc += (cc & (-cc)); } r += (r & (-r)); }... |
#include <bits/stdc++.h> const int maxn = 1e5 + 51; const int mod1 = 1e9 + 7; const int mod2 = 1e9 + 9; std::vector<std::pair<int, int>> g[maxn]; int dfn[maxn], idx = 0; int f[maxn], fw[maxn]; int xr; std::vector<std::vector<int>> V; void dfs(int u, int fa) { dfn[u] = ++idx; for (auto x : g[u]... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 9; const long long mod = 998244353; long long dp[N][1 << 7]; int s[N][1 << 7], st[N], Log[1 << 7]; struct node { int v, id; } a[N]; bool cmp(node a, node b) { return a.v > b.v; } void upd(long long &a, long long b) { if (a < b) ... |
#include <bits/stdc++.h> using namespace std; long long ans[100010]; long long ans2[100010]; int main() { int n, p; int l, r; while (cin >> n >> p) { for (int i = 0; i < n; i++) { scanf( %d%d , &l, &r); ans[i] = r / p - l / p; ans2[i] = r - l + 1; if (l % p == 0... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int IT_MAX = 1 << 17; const long long MOD = 5000000; const int INF = 1034567891; const long long LL_INF = 1234567890123456789ll; const double PI = 3.141592653589793238; const double ERR = 1E-11; int in[200050]; int lr[2000... |
#include<bits/stdc++.h> #define LL long long #define dl double #define P pair<int,int> using namespace std; const int N = 2e5 + 10; int n; struct ghb{ int a,b; bool operator < (const ghb &o)const{ return min(a,b) < min(o.a,o.b); } }f[N]; LL ans; int mx; int main(){ /... |
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); } bool isPrime(int x) { for (int i = 2; i <= sqrt(x); i++) if (x % i == 0) return 0; return 1; } bool C[26]; int main() { int n, a; cin >> n >> a; vector<int... |
#include <bits/stdc++.h> using namespace std; long long a, b; long long c, d; int main() { while (cin >> a >> b) { cin >> c >> d; for (int i = 0; i <= 1000; ++i) { for (int j = 0; j <= 1000; ++j) { if ((b + a * i) == (d + c * j)) { cout << b + a * i << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int mid, i, j; string a; cin >> a; if ((a.length()) % 2) { cout << NO n ; continue; } mid = (a.length()) / 2; j = mid; i = 0; while (i < mid) {... |
#include <bits/stdc++.h> const int N = 100100; const long long mod = 1e9 + 7; using namespace std; int n, Xa, Ya, Xb, Yb; int Smallest(int a, int b, int c, int d) { int min_ = a; if (min_ > b) min_ = b; if (min_ > c) min_ = c; if (min_ > d) min_ = d; return min_; } int main() { ios... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d %d , &n, &k); int a[500005]; map<int, vector<int>> m; set<int> s; for (int i = 0; i < n; i++) s.insert(i); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); m[a[i]].push_back(i); } int llas... |
#include <bits/stdc++.h> using namespace std; map<int, int> glosy; map<pair<int, int>, int> parki; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = (0); i < (n); i++) { int a, b; scanf( %d%d , &a, &b); if (a > b) swap(a, b); if (glosy.find(a) != glosy.end()) ... |
#include <bits/stdc++.h> const int LG = 21; const int N = 500005; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long INFLL = 1e18; using namespace std; void dfs(int v, int paint, vector<int> &col, vector<vector<pair<int, int> > > &graph, vector<int> &need, int &cnt0, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<int> v; set<pair<int, int> > st; int bfs(int x) { queue<int> q; q.push(x); int cnt = 0; while (!q.empty()) { int u = q.front(); q.pop(); cnt++; int len = v.size(); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; bool essentiallyEqual(float a, float b) { return fabs(a - b) <= ((fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * 1e-6); } struct TVector { long long x, y; TVector operator+(TVector q) const { return {x + q.x, y + q.y}; } TVector operator-(TVector q) const ... |
#include <vector> #include <iostream> #include <algorithm> #include <string> #include <cmath> #include <map> #define ll long long using namespace std; int main() { ll t; cin >> t; while (t--) { ll n, m; cin >> n >> m; string s; vector<ll>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.