func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> template <class T> using pt = std::pair<T, T>; using namespace std; struct poledia { int lx, ly, rx, ry; int cnt = 0; poledia() : lx(- -1e9), ly(- -1e9), ry(-1e9), rx(-1e9){}; poledia(bool is_dw) : lx(- -1e9), ly(-1e9), ry(- -1e9), rx(-1e9){}; }; struct poleos { ... |
#include <bits/stdc++.h> using namespace std; template <class T> void read(T& x) { T res = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { res = (res << 3) + (res << 1) + c - 0 ; c = getchar(); } x... |
#include <bits/stdc++.h> using namespace std; const int LIM = 200 * 1000, MAXN = 300 * 1000; int fen[MAXN]; void add(int pos, int val) { pos++; while (pos < MAXN) { fen[pos] += val; pos += pos & -pos; } } int sum(int pos) { pos++; int tot = 0; while (pos) { tot += f... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t = 1; cin >> t; while (t--) { long long int n, i, j; cin >> n; long long int a = n / 3, b = n / 3; if (n % 3 == 1) cout << a + 1 << << b; else if (n % 3 == 2) cout << a << << b... |
#include <bits/stdc++.h> using namespace std; const int N = 20005; const int M = 400005; vector<pair<int, int> > E[N]; int dep[N], fa[N][16], fav[N][16]; int n, m, S, T, nd, jud[N * 2]; int head[M], vis[M], tot = 1; int dis[M], q[M]; struct edge { int to, next, f; } e[M * 5]; void add(int x, i... |
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> M; set<pair<int, int> > tmp; char s[77777][11]; int main() { int n; scanf( %d , &n); for (int ii = 0; ii < n; ii++) { scanf( %s , s[ii]); for (int i = 0; i < 9; i++) { for (int j = i; j < 9; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int b = 1e4 + 200; int ans[b]; int n = 0, ez1, ez2; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> ez1 >> ez2; ans[i] = (ez2 - (ez1 % ez2)) % ez2; } for (int i = 0; i < n; i++) { cout << ans[i] << end... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; const long long inf = 1e18; long long n, m, Q, E[N][3], l[N], r[N], op[N]; long long hd[N], ht = 1, tf[N], id[N]; long long cnt = 0; struct edge { long long v, w, n; } e[N * 2]; void addedge(long long u, long long v, long ... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 2010, LOG = 20; int n, m, k, u, v, x, y, t, a,... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1000000007; int L; ll sum[8040]; int len[8040]; int last[8040]; int lazy[8040]; void init(int v, int l, int r, const vector<int> &xs) { len[v] = xs[r] - xs[l - 1]; if (l < r) { int md = (l + r) >> 1; ... |
#include <bits/stdc++.h> int main() { int n, next = 0; scanf( %d , &n); int a[n], b[n]; for (int i = 0; i < n; i++) { scanf( %d %d , &a[i], &b[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[j] == b[i] && j != i) { next++; a[j] =... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } int main() { int t, n, x; cin >> n; vector<pair<int, int>> arr; vector<int> arr2(n + 2, 0); set<int, greater<int>> st; for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, ans = 0, a, b; cin >> n; ans = 1; for (int i = sqrt(n); i >= 1; i--) { if (n % i == 0) { k = i; break; } } cout << k << << n / k << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, count = 0; cin >> a; for (long long i = 0; i < 31; i++) { if (a & (1 << i)) { count++; } } long long c = powl(2, count); cout << c <<... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ll MAX = 1e18 + 1; const int NN = 1e5 + 5; const int mod = 1e9 + 7; void solve() { string s1; cin >> s1; char vow[] = { a , e , o , u , i }; vector<int> ans; int i = 0; while (i < ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int a, num, res; while (cin >> n) { num = 0; for (int i = 0; i < n; i++) { cin >> a; if (a % 2 == 0) { num++; } if (num % 2 == 1) { res = 1; } else { res = ... |
#include <bits/stdc++.h> using namespace std; int Day12[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int prime100[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103}; template <typename T> inline bool isLeap(T y) { ... |
#include <bits/stdc++.h> constexpr const int64_t mod = 998244353; int64_t dp[1005][2005][4]; int n, k; int main(int argc, char* argv[]) { scanf( %d%d , &n, &k); std::fill(dp[1][0], dp[1][0] + 4, 1LL); for (int i = 2; i <= n; ++i) { for (int j = 0; j < k; ++j) { dp[i][j][0] = dp[i - 1][... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int n, m, W, H, a[N][N], b[N][N]; long long s[N][N]; int q[N]; inline long long S(int x1, int y1, int x2, int y2) { return s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1]; } struct BIT { int c[N][N]; inline vo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500000; template <typename T> class graph { public: struct edge { int from; int to; T cost; }; vector<edge> edges; vector<vector<int>> g; int n; graph(int _n) : n(_n) { g.resize(n); } virtual int add(... |
#include <bits/stdc++.h> using namespace std; long long arr[3005][3005]; long long zkw[3005 << 2], M; inline long long query(long long l, long long r) { long long ret = 1234567891; for (l += M - 1, r += M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) { if (~l & 1) ret = min(ret, zkw[l ^ 1]); if (r & 1) ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0 || b == 0) { return 0; } long long s; while (a != 0) { b = b % a; s = a; a = b; b = s; } return b; } int main() { long long a, b; cin >> a >> b; lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, mx = 0, my = (1 << 31) - 1, m2x = 0, m2y = (1 << 31) - 1, a, b; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d %d , &a, &b); mx = max(mx, a); my = min(my, b); } scanf( %d , &n); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; void solve(long long tc) { long long n, m, k; cin >> n >> m >> k; vector<long long> v(n); for (long long i = (0), ed = (n); i < (ed); ++i) { cin >> v[i]; } sort(v.begin(), v.end()); unsigned long long mx1 = v[n - 1], mx2 = v[n - 2]; ... |
#include <bits/stdc++.h> using namespace std; int get() { int f = 0, v = 0; char ch; while (!isdigit(ch = getchar())) if (ch == - ) break; if (ch == - ) f = 1; else v = ch - 0 ; while (isdigit(ch = getchar())) v = v * 10 + ch - 0 ; if (f) return -v; else ... |
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N |= (1LL << pos); } int Reset(int N, int pos) { return N &= ~(1LL << pos); } bool Check(int N, int pos) { return N & (1LL << pos); } int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; inline void cn(long... |
#include <bits/stdc++.h> using namespace std; void out() { cout.flush(); cerr << endl << OUT << endl; int bred; cin >> bred; exit(0); } void updMax(int& x, int y) { if (y > x) x = y; } int sum10(int x, int y) { x += y; if (x >= 10) x -= 10; return x; } int cs[10]; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int mof = 1000000007; const int inf = 1000000010; const long long llinf = 1000000007000000007; const double pi = 3.14159265359; int a[211111]; int a2[211111]; int t[211111]; int t2[211111]; int n, k, A, B, q; int sum(in... |
#include <bits/stdc++.h> using namespace std; const int maxn = 210; const double eps = 1e-9; int n; int lsh[maxn * 2], ln, K; map<int, int> mt; int To[maxn]; int li[maxn], ri[maxn]; double f[2][maxn][maxn]; double ans[maxn][maxn]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> int ans[1000010], p[1000010], mem[1000010], q[1000010]; int main() { int n, t, i, j; memset(q, 0, sizeof(q)); scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &p[i]); scanf( %d , &t); for (i = 0; i < t; i++) { scanf( %d , &j); q[j - 1] = 1; } ... |
#include <bits/stdc++.h> using namespace std; int t, n, k; char s[4000]; int opx[4000]; int opy[4000]; int count2; void Reverse(char *s, int a, int b) { for (int i = a, j = b; i < j; i++, j--) { char c = s[i]; s[i] = s[j]; s[j] = c; } } int main() { cin >> t; while (t... |
#include <bits/stdc++.h> using namespace std; const int N = 5004; int main() { int a = 1, b = 1, n; string s; cin >> n; while (n--) { cin >> s; if (s == UL || s == DR ) ++a; else if (s.size() == 2) ++b; else ++a, ++b; } printf( %lld n , 1l... |
#include <bits/stdc++.h> using namespace std; int main() { int k = 8; int t = 4; int p = 2; int s = 6; int n; while (cin >> n) { if (n == 0) cout << 1 << endl; else if (n % 4 == 1) cout << k << endl; else if (n % 4 == 2) cout << t << endl; else... |
#include <bits/stdc++.h> using namespace std; const int NMAX = (int)(1e5) + 10; int n, m, a, b; vector<pair<int, pair<int, int> > > ed; pair<int, int> res[NMAX]; int last; int now[NMAX]; bool func(pair<int, pair<int, int> > i, pair<int, pair<int, int> > j) { if (i.first == j.first) return (i.s... |
#include <bits/stdc++.h> using namespace std; int st[610], aim[(300010)], nxt[(300010)], ln; int flow[(300010)], con[(300010)], cost[(300010)]; int inq[610], dis[610]; int g[610], e[610]; int q[610]; int a[610]; int d[610 << 3], tag[610 << 3], dn; int num[610]; int N, source, remit; int ans; int... |
#include <bits/stdc++.h> using namespace std; bool poate[5020][510]; pair<int, int> from[5020][510]; int last[5020][510]; queue<pair<int, int>> de_calc; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int d, s; cin >> d >> s; for (int i = 1; i <= 9; i++) { poate[i][i % d] = ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; signed main() { ios::sync_with_stdio(false); long long n, a, b; cin >> n >> a >> b; long long ans = 0; vector<long long> x(n), y(n); for (long long i = 0; i < n; i++) { cin >> x[i] >> y[i]; for (long lo... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; if (n & (n - 1)) { cout << NO << n ; } else { cout << YES << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ttt; cin >> ttt; while (ttt--) { int n, m; cin >> n >> m; vector<pair<int, int>> v(n * m); for (int i = 0; i < n * m; i++) { cin >> v[i].first; ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; bool flg = false; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) flg = true; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return flg ? -x : x; } int n, m; c... |
#include <bits/stdc++.h> using namespace std; struct per { string name; int score; } store[55]; bool cmp(per a, per b) { return a.score > b.score; } int main() { int n, tmp; cin >> n; for (int i = 0; i < n; i++) { cin >> store[i].name; cin >> tmp; store[i].score = 0; ... |
#include <bits/stdc++.h> using namespace std; int n, k; int f[50005][65], a[50005], po[50005], cnt, tr[65][200005], la[65][200005]; void pushup(int num, int id) { tr[num][id] = max(tr[num][id << 1], tr[num][id << 1 | 1]); } void pushdo(int num, int id) { if (la[num][id] != 0) { la[num][id << 1... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n], b[n], o = 0, z = 0, sorted = 1; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0 && a[i] < a[i - 1]) sorted = 0; } for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; void dfs(const vector<vector<int> >& edge_list, vector<bool>& visited, int i, int& edges) { visited[i] = true; for (int j : edge_list[i]) { if (!visited[j]) dfs(edge_list, visited, j, edges); if (j >= i) ++edges; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int N = 100111; long long n, arr[N], x, k; int main() { cin >> n; while (n--) { cin >> k >> x; long long u = 9 * k; cout << u - (9 - x) << endl; } } |
#include <bits/stdc++.h> int main() { int q; std::cin >> q; std::vector<int> V; for (int i = 0; i < q; ++i) { int n; std::cin >> n; std::vector<int> v1; std::vector<int> v2(n); for (int j = 0; j < n; ++j) { std::cin >> v2[j]; v1.push_back(j + 1); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 5001; int n, tmp[N]; vector<int> g[N]; bool vst[N]; void dfs(int c, int p) { bool dp[N]; fill(dp, dp + n + 1, false); dp[0] = true; tmp[c] = 1; for (int ch : g[c]) { if (ch != p) { dfs(ch, c); tmp[c] += tmp... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const unsigned long long base = 311; unsigned long long TH[maxn][3], L[3], P[maxn]; int Sol, lona, lonb; void calc_Hash(string& a, int id) { int lon = L[id]; for (int i = (1); i <= (lon); i += (1)) { TH[i][id] = TH[i - 1][... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e6 + 5; long long n, k, a[N], res; void solo() { cin >> n; for (int i = 1; i <= n; i++) cout << i + 1 << ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t = 1; cin >> t; wh... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; vector<string> vec[1003], v; bool mat[26][26], flag, ok[26], vis[26], run[26]; int ind[26]; inline bool func(int ... |
#include <bits/stdc++.h> using namespace std; int n1, n2, k1, k2; long long aa[105][105][2]; long long foo(int u, int v, int a) { if (u == 0 && v == 0) { return 1; } if (u < 0 || v < 0) { return 0; } if (aa[u][v][a] != -1) return (aa[u][v][a]); long long s = 0; if (a) { ... |
#include <bits/stdc++.h> using namespace std; using lint = long long; using pi = pair<int, int>; const int MAXN = 1005; const int MAXM = 1005; struct edge_color { int deg[2][MAXN]; pi has[2][MAXN][MAXN]; int color[MAXM]; int c[2]; void clear(int n) { for (int t = 0; t < 2; t++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string start, end; cin >> start >> end; string srev = start; reverse(srev.begin(), srev.end()); vector<int> vs[26], vr[26]; int slen = start.length(); for (int i = 0; i < slen; i++) { vs[start[i] - a ].push_back(i); ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long s, x1, x2, t1, t2, p, d; cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d; long long ans = abs(x1 - x2) * t2; long long i = p, t = 0; while (i != x1) { i += d; t += t1; if (i == s) d = -1; else if (i... |
#include <bits/stdc++.h> using namespace std; const int mo = (int)1e9 + 7; const int maxn = 1000010; int n; long long fac[maxn], ans; int a[maxn], num[maxn], num1[maxn], pos[maxn], mul[maxn]; int pre[maxn], ne[maxn]; vector<int> v[maxn]; inline void init() { fac[0] = 1; for (int i = 1; i <= n ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int tmp; int ans = 0; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { tmp = i * i + j * j; if (tmp <= n * n && int(sqrt(tmp)) * int(sqrt(tmp)) == tmp) { ans++; } ... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0}; const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1}; const int MAX = 2 * 1000 + 10; const long long INF = 1e18; const int MOD = 1e9 + 7; long long n, m, x, y, a[MAX], b[MAX], c[MAX], d[MAX]; long long dp[MAX][20]; l... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> A(n); for (int& a : A) scanf( %d , &a); sort(A.begin(), A.end()); int m = A[n - 1]; vector<bool> B(m + 2); for (int a : A) { if (a > 1 && !B[a - 1]) B[a - 1] = true; els... |
#include <bits/stdc++.h> using namespace std; long long numbit(long long x) { return (1LL << x) - 1LL; } long long getbit(long long x, long long i) { return (x >> i) & 1LL; } long long onbit(long long x, long long i) { return x | (1LL << i); } long long offbit(long long x, long long i) { return x & (~(1LL << ... |
#include <bits/stdc++.h> using namespace std; int p, n, a[100100], b[100100]; bool ok(double t) { double charging = t * p; for (int i = 0; i < n; ++i) { double x = b[i] - a[i] * t; if (x >= 0) continue; else charging += x; if (charging < 0) return 0; } retur... |
#include <bits/stdc++.h> using namespace std; int n, m, tot, vis[50005]; pair<long double, long double> stk[50005 << 1]; int bit[50005 << 1]; const long double Pi = acos(-1); struct Point { long double x, y; Point() {} Point(long double a, long double b) { x = a, y = b; } Point operator+(Poi... |
#include <bits/stdc++.h> using namespace std; int n, k, a[5001], b[1000001], d[1000001]; void doc() { for (int i = 1; i <= n; i++) cin >> a[i]; } void xuli() { sort(a + 1, a + n + 1); for (int i = 1; i < n; i++) for (int j = i + 1; j <= n; j++) d[a[j] - a[i]]++; int m = 0; while (tru... |
#include <bits/stdc++.h> using namespace std; int exgcd(int a, int b, int &x, int &y) { if (b == 0) { y = 0; x = 1; return a; } int r = exgcd(b, a % b, x, y); int tmp = y; y = x - (a / b) * y; x = tmp; return r; } int t, n, a[200005], s, ans[200005], k1, k2, len, no... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; const int INF = (int)1E9; const long long INF64 = (long long)1E18; const double EPS = 1E-9; const double PI = acos((double)0) * 2; const int MAXN = 210000; struct pt { int x, y, id; bool operator<(const pt&... |
#include <bits/stdc++.h> using namespace std; struct matrix { int a[25][25]; }; struct matrix g, b, e; int l, r, mod = 1000000007; int ans; void init() { int i, j; g.a[7][2] = 1; g.a[10][3] = 1; g.a[11][3] = 1; g.a[8][5] = 1; g.a[10][6] = 1; g.a[11][6] = 1; g.a[2][7] = ... |
#include <bits/stdc++.h> #define fi first #define se second #define DB double #define U unsigned #define P std::pair #define LL long long #define LD long double #define pb emplace_back #define MP std::make_pair #define SZ(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define CLR(i,a) me... |
#include <bits/stdc++.h> using namespace std; int n; int a[510]; vector<pair<int, int> > edges; vector<int> leaf, nonleaf; int d = 0; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { if (a[i] == 1) leaf.push_back(i); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1234567; const long long MOD = 998244353; void solve() { long long n, m, i, j = 0, k, l = 0, ok = 0, o = 0, p, ans = 0, x, y, a[30]; string s; cin >> n >> k >> s; for (long long i = 0; i < k / 2; i++) { map<char, long long> ... |
#include <bits/stdc++.h> using namespace std; int main() { tuple<long long, long long, long long> p[200010]; int n; cin >> n; long long k, a, x, y, m; long long b; long long ans = 0; long long cnt = 0; long long sm = 0; for (int i = 0; i < n; i++) { cin >> k >> a >> x >> y ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 210; const double eps = 1e-9; int n; int lsh[maxn * 2], ln, K; map<int, int> mt; int To[maxn]; int li[maxn], ri[maxn]; double f[2][maxn][maxn]; double ans[maxn][maxn]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<string> ans; string email = ; bool isPoss = true; for (int i = 0; i < s.length(); i++) { if (s[i] == @ ) { if ((i + 1 < s.length()) && (s[i + 1] != @ )) { if (email == ) { ... |
#include <bits/stdc++.h> using namespace std; char s[1000005]; int main() { int k, a[10], i, sum, num, maxr; while (~scanf( %d%s , &k, s)) { memset(a, 0, sizeof(a)); num = sum = 0; maxr = -1; for (i = 0; s[i]; i++) { int t = s[i] - 0 ; maxr = max(maxr, t); ... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n; scanf( %d , &n); memset(a, -1, sizeof(int) * 100005); int cnt = 1; for (int i = 2; i <= n; i++) { if (a[i] == -1) { for (int j = i; j <= n; j += i) { if (a[j] == -1) a[j] = cnt; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s, i, h, m; cin >> n >> s; int a[110]; a[0] = 0; for (i = 1; i <= n; i++) { cin >> h >> m; a[i] = h * 60 + m; } if (a[1] - a[0] - 1 >= s) { cout << 0 0 ; return 0; } for (i = 2; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; bool isprime[2000005]; void setprime() { for (long long i = 0; i < 2000005; i++) isprime[i] = true; isprime[0] = false; isprime[1] = false; for (long long i = 2; i < 2000005; i++) { for (long long j = 2; i * j < 2000005; j++) isprime[i * j] = fal... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; const int MAXN = 107; int A[50007]; int F[107][107]; unsigned long long b[107][107]; struct matrix { int n, m; int arr[MAXN][MAXN]; matrix() {} matrix(int x, int y, int V = 0) { n = x; m = y; for (i... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) void f() { int n; string s, t; cin >> n >> s >> t; map<char, int> d1, d2; for (int i = 0; i < n; i++) { ++d1[s[i]]; ++d2[t[i]]; }... |
#include <bits/stdc++.h> using namespace std; int dp[1000000 + 10], cnt[1000000 + 10]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { int a; scanf( %d , &a); int t = 0, temp = a; while (temp <= 1e6) { dp[temp] += t; cnt[temp]++; t++; ... |
#include <bits/stdc++.h> using namespace std; bool compare(int a, int b) { return a > b; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (long long int i = 0; i < n + 1; i++) { for (long long int j = 0; j < 2 * (n - i); j++) { cout << ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 9; int n; long long a[N], l[N], r[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n - 1; ++i) cin >> a[i]; long long tmp; l[1] = 0; for (int i = 2;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; for (int i = 1; i <= n; ++i) { if (n % i == 0) { reverse(s.begin(), s.begin() + i); } } cout << s << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n]; int freq[101] = {0}; for (int i = 0; i < n; i++) { cin >> arr[i]; freq[arr[i]]++; } sort(freq, freq + 101, greater<int>()); int max = freq[0]; int num = 0; for (int i =... |
#include <bits/stdc++.h> using namespace std; bool color[200005], vis[200005]; int height[200005], dp[200005]; vector<vector<int> > v(200005); int ans; void dfs(int a) { vis[a] = true; dp[a] = 0; for (int i = 0; i < v[a].size(); i++) { if (!vis[v[a][i]]) { dfs(v[a][i]); ans... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; unordered_map<int, int> mp; vector<int> v[n + 1]; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; v[x].push_back(y); v[y].push_back(x); } vector<int> t; int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; const int M = 1e9 + 7; const ll MLL = 1e18L + 9; #pragma unused(M) #pragma unused(MLL) template <ostream& out = cout, class... T> void prints(T&&...) {} template <ostream& out = cout, class... T> void pr... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f; unordered_map<int, int> cnt; int maxi = 0; int x[100005]; int head[100005], ne[200005], to[200005]; int idx = 0; int son[100005]; int sz[100005]; long long sum = 0; long long s[100005]; void Insert(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int n, q; vector<pair<int, int> > query[maxn]; vector<int> G[maxn]; long long ans[maxn]; long long add[maxn]; void dfs(int v, int p, int d, long long sum) { for (auto p : query[v]) { int l = d; int r = d + p.first + ... |
#include <bits/stdc++.h> using namespace std; const int inf = -1e9; const int maxn = 400; int dp[maxn][maxn][maxn]; int a[maxn][maxn]; int main() { int n; cin >> n; for (int i = 0; i <= n + 1; i++) for (int j = 0; j <= n + 1; j++) a[i][j] = inf; for (int i = 1; i <= n; i++) for (... |
#include<bits/stdc++.h> using namespace std; # define ll long long # define read read1<ll>() # define Type template<typename T> Type T read1(){ T t=0; char k; bool vis=0; do (k=getchar())== - &&(vis=1);while( 0 >k||k> 9 ); while( 0 <=k&&k<= 9 )t=(t<<3)+(t<<1)+(k^ 0 ),k=getchar(); return vis?... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x1, y1, x2, y2; cin >> n >> m >> x1 >> y1 >> x2 >> y2; int dx = abs(x1 - x2) - 1; int dy = abs(y1 - y2) - 1; if (dx > 3 || dy > 3) { cout << Second << endl; } else if (dx <= 2 && dy <= 2) { cout << First << ... |
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int t, x; string s; char ch; string transform(string x) { string s = ; for (char ch : x) if ((ch - 0 ) % 2) s += 1 ; else s += 0 ; while (s.size() < 20) s = 0 + s; return s; } int main()... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7; long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f * x; ... |
#include <bits/stdc++.h> using namespace std; int n; char s[200002]; int cnt[200001][26]; void init() { for (int i = 1; s[i]; ++i) { for (int j = 0; j < 26; ++j) cnt[i][j] = cnt[i - 1][j]; cnt[i][s[i] - a ]++; } } int main() { scanf( %s , s + 1); init(); int q, l, r; s... |
#include <bits/stdc++.h> using namespace std; queue<int> s1, s2; int main() { int n, k1, k2; cin >> n; cin >> k1; int a, b; for (int i = 0; i < k1; i++) { cin >> a; s1.push(a); } cin >> k2; for (int i = 0; i < k2; i++) { cin >> b; s2.push(b); } int a... |
#include <bits/stdc++.h> const int maxn = 100005; int n, m, a[maxn], pos[maxn]; std::pair<int, int> b[maxn]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); b[i] = std::make_pair(a[i], i); } std::sort(b + 1, b + n + 1); for (int i = 1; i <= n; ++i... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; const int N = 3e5 + 7; long long arr[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n, m, k; cin >> n >> m >> k; long long mn = INT_MAX; for (int i = 0; i < n; i++) { cin >> arr[... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; if ((n / 2 == x || n / 2 + 1 == x) && (n / 2 == y || n / 2 + 1 == y)) { cout << NO n ; return 0; } cout << YES n ; return 0; } |
#include <bits/stdc++.h> using namespace std; struct ooxx { int k, x, y; } a[100]; int alla, allb, dp[250000][121], n; int main() { memset(dp, -1, sizeof(dp)); scanf( %d , &n); int s = 1 << n; for (int i = 0; i < s; ++i) dp[i][0] = 0; for (int i = 0; i < n; ++i) { char x = getcha... |
#include <bits/stdc++.h> using namespace std; struct ned { int x, y; bool operator<(const ned &a) const { return x == a.x ? (y < a.y) : x < a.x; } }; ned ned[4000010]; int n, m, cnt; int a[2010], b[2010], c[2010], d[2010]; int sma[4000010]; int main() { scanf( %d%d , &n, &m); for (int i ... |
#include <bits/stdc++.h> using namespace std; long long a[3]; int main() { scanf( %I64d%I64d%I64d , &a[0], &a[1], &a[2]); long long ans = a[0] + a[1] + a[2]; for (int i = 0; i <= 2; i++) { long long A = a[i], B = a[(i + 1) % 3]; if (((A - B) < 0 ? -(A - B) : (A - B)) & 1) continue; a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.