func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct str { long long num; long long id; } st[666666]; long long arr[666666]; bool cmp(str a, str b) { return a.num < b.num; } signed main() { long long n; cin >> n; for (long long i = 1; i <= n; i++) { cin >> arr[i]; } long lo... |
#include <bits/stdc++.h> using namespace std; int n, q; int a[100005]; long long tree[2 * 100005], tree2[2 * 100005]; vector<long long> mapa; int mp(double val) { return upper_bound(mapa.begin(), mapa.end(), val) - mapa.begin(); } void update(int pos, int val) { for (int i = pos; i < 2 * 100005;... |
#include <bits/stdc++.h> using namespace std; int cnt = 0; int SM[100000]; int ans[500][500][2], FC[500][500][2], H[5]; vector<int> Q[500]; int dfs(int a, int b) { int sum = 0; bool A = false, B = false; for (int i = 0; i < 5; i++) { if (Q[a][i] > 0) { for (int j = 0; j < 5; j++) ... |
#include <bits/stdc++.h> using namespace std; int n; void solve() { scanf( %d , &n); int tmp, tot; if (n == 0) { printf( O-|-OOOO n ); return; } while (n) { tmp = n % 10; if (tmp >= 5) { tot = tmp - 5; printf( -O| ); } else { tot = tmp; ... |
#include <bits/stdc++.h> using namespace std; void getint(int &v) { char ch, fu = 0; for (ch = * ; (ch < 0 || ch > 9 ) && ch != - ; ch = getchar()) ; if (ch == - ) fu = 1, ch = getchar(); for (v = 0; ch >= 0 && ch <= 9 ; ch = getchar()) v = v * 10 + ch - 0 ; if (fu) v = -v; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int b[m]; for (int i = 0; i < m; cin >> b[i++]) ; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (b[j] <= i + 1) { cout << b[j] << ; break; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 10; int n, m, c = 0, ans = 0; vector<int> adj[maxn], bkadj[maxn], components, nodes[maxn], sink; bool mark[maxn]; int cmp[maxn], d[maxn], o[maxn]; stack<int> st; queue<int> q; void input() { cin >> n >> m; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int a[150000], b[510000], arr[226660]; int main() { int n, x, k; cin >> n >> k >> x; int cnt = 1; int l = 0; cin >> arr[0]; for (int i = 1; i < n; i++) { cin >> arr[i]; if (arr[i] == arr[i - 1]) { cnt++; } else { ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; n /= 2; vector<long long> x(n); for (long long i = 0; i < n; ++i) { cin >> x[i]; } vector<vector<pair<long long, long long>>> as(n); for (long long i = 0; i < n; ++i) { for (long long a =... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long int t, a, b, a1, b1; cin >> t; while (t--) { cin >> a >> b; a1 = max(a, b); b1 = min(a, b); if (a1 >= (2 * b1)) { cout << b1 << endl; } else { cout << (a1 - b1) + (2 * ((b1 - (a1 - b1))... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); unsigned char a[200042]; int main() { ios:... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 12; int a[maxn], n; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); int cnt = 0; for (int i = 2; i < n; i++) { if (a[1] < a[i] && a[i] < a[n]) cnt++; } cout << cnt... |
#include <bits/stdc++.h> int main() { int n, k; scanf( %d %d , &n, &k); while (k--) { if (n % 10 != 0) { n = n - 1; } else { n = n / 10; } } printf( %d n , n); } |
#include <bits/stdc++.h> int in() { int r = 0, c; for (c = getchar(); c <= 32; c = getchar()) ; if (c == - ) return -in(); for (; c > 32; r = (r << 1) + (r << 3) + c - 0 , c = getchar()) ; return r; } using namespace std; const int INF = int(1e9 + 7); long long v[100010]; i... |
#include <bits/stdc++.h> using namespace std; int N, K = 0; int ans[1005]; int main() { scanf( %d , &N); int i, j, tmp = 0; for (i = 1; i * 2 < N; i++) { ++K; ans[K] = i; N -= i; } printf( %d n , K + 1); for (i = 1; i <= K; i++) printf( %d , ans[i]); printf( %d n ,... |
#include <bits/stdc++.h> using namespace std; int w[1010000], n, Res[1010000], Mod = 1000000007; long long S[1010000], K; vector<int> E[1010000], G[1010000], d; void DFS(int a) { S[a] = w[a]; for (auto &x : E[a]) { DFS(x); S[a] += S[x]; } } void Go(int a) { int i, c = 0; fo... |
#include <bits/stdc++.h> using namespace std; string s, dum; int idx = 0; int A[5000]; stack<int> S; int main() { while (cin >> dum) { s += dum; } for (int i = 0; i < s.length(); i++) { dum = ; while (s[i] != > ) { dum += s[i]; i++; } dum += > ; ... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.141592653589793; const long long MOD = 1000000007; const long double EPS = 1e-9; const long long MAX = LLONG_MAX; const long long MIN = LLONG_MIN; const int N = 2e5 + 7; long long power(long long base, unsigned long long exp, const l... |
#include <bits/stdc++.h> using namespace std; int sum[101000 << 2], lsum[101000 << 2], rsum[101000 << 2], lazy[101000 << 2]; int L[105]; int ans[105]; int max(int a, int b) { return a > b ? a : b; } void pushup(int rt, int len) { sum[rt] = max(sum[rt << 1], sum[rt << 1 | 1]); sum[rt] = max(sum[rt], ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; const int mod = 998244353; int n; int p[N]; namespace fft { struct num { double x, y; num() { x = y = 0; } num(double x, double y) : x(x), y(y) {} }; inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y)... |
#include <bits/stdc++.h> using namespace std; int T, N; int P; vector<int> v, A, B; long long pw(long long a, int n) { long long ret = 1; while (n) { if (n & 1) ret = ret * a % 1000000007; a = a * a % 1000000007; n >>= 1; } return ret; } int main() { scanf( %d , &T); ... |
#include <bits/stdc++.h> using namespace std; int sieve(vector<bool> &arr, vector<int> &ans) { int res = INT_MAX; for (int i = 2; i <= sqrt(arr.size()); i++) { if (arr[i]) { for (int j = i * i; j < arr.size(); j += i) { arr[j] = false; if (ans[j] == ans[i]) ans[j]++; ... |
#include <bits/stdc++.h> long long MOD = 1000000007; long long C[2000 + 200][2000 + 200]; int pos = 0; bool notfree[2000 + 200]; int n; void combin() { C[0][0] = 1; for (int i = 1; i <= 2000; i++) { C[0][i] = 1; C[i][i] = 1; for (int j = 1; j < i; j++) C[j][i] = (C[j][i - 1] + C[j ... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = 1 << 29; inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return n & two(b); } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(i... |
#include <bits/stdc++.h> using namespace std; int n, a[100010], b[100010], c[100010]; int main(int argc, char* argv[]) { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); for (int i = 0; i < n - 1; i++) scanf( %d , &b[i]); sort(b, b + n - 1); for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[500001]; map<int, int> cnt, pos; vector<int> ans; struct mypair { int left; int right; int value; }; mypair Mypair[500001]; int pointer = 0; void writeans(int a, int b) { ans.push_back(a); ans.push_back(b); ans.push_b... |
#include <bits/stdc++.h> using namespace std; int main() { int num; string str; cin >> num; cin >> str; if (str[3] >= 6 ) str[3] = 0 ; if (num == 12) { if (str[0] >= 2 || (str[0] == 1 && str[1] > 2 ) || (str[0] == 0 && str[1] == 0 )) { str[0] = 0 ; ... |
#include <bits/stdc++.h> int main() { int vis[5] = {0}; int dir[5][5] = {{4, 3, 2}, {1, 4, 3}, {2, 1, 4}, {3, 2, 1}}; int viss[5] = {0}; for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { int a; scanf( %d , &a); if (a) { viss[dir[i][j]] = 1; v... |
#include <bits/stdc++.h> using namespace std; vector<int> pos[8]; vector<int> construct_vector(int a, int b, int c) { vector<int> ret; ret.push_back(a); ret.push_back(b); ret.push_back(c); return ret; } long long dist(vector<int> p1, vector<int> p2) { return (long long)(p1[0] - p2[0]) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int max_n = (1 << 21) + 100; vector<int> ans; int a[max_n]; void de(int i) { int l = i << 1; int r = (i << 1) | 1; if (a[l] == 0 && a[r] == 0) { a[i] = 0; return; } else { if (a[l] > a[r]) { ... |
#include <bits/stdc++.h> using namespace std; const int p = 998244353, maxn = 1000011; int Fact[maxn], nFact[maxn]; char s[maxn]; inline int C(int n, int m) { if (n < m || m < 0) return 0; return 1LL * Fact[n] * nFact[m] % p * nFact[n - m] % p; } int main() { scanf( %s , s + 1); int n = st... |
#include <bits/stdc++.h> using namespace std; long long K, statc; int qc; bool query(long long l, long long r) { qc++; assert(qc <= 4499); cout << l << << r << n ; fflush(stdout); string ans; cin >> ans; if (l == r && ans[0] == Y ) { exit(0); } if (ans[0] == B )... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int mod = 20010905; const int inf = 0x3f3f3f3f; const long long linf = 0x3f3f3f3f3f3f3f3f; long long lowbit(long long x) { return x & (-x); } long long qpow(long long a, long long b, long long c) { long long res = 1; a ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 239; int n; vector<vector<int>> g; vector<vector<pair<int, int>>> g2; namespace Lca { const int LIM = 20; int timer = 0; vector<int> tin; vector<int> tout; vector<int> p; vector<int> c; vector<int> h; vector<vector<int>> uc;... |
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 1; long long arr[N]; long long n, k; long long sum; long long mnm = -1; long long mxm = -1; void input() { cin >> n >> k; for (long long i = 0; i < n; ++i) { cin >> arr[i]; sum += arr[i]; } sort(arr, arr ... |
#include <bits/stdc++.h> using namespace std; int n, m, i, val[300005]; struct node { multiset<int> val; int p, v; node *chd[26], *fail; node() { memset(chd, 0ll, sizeof(chd)); fail = 0ll; p = v = 0; val.clear(); } }; node *root; node *place[300005]; void resetA... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int INF = 2000; int gauss(vector<vector<double> > a, vector<double> &ans) { int n = (int)a.size(); int m = (int)a[0].size() - 1; vector<int> where(m, -1); for (int col = 0, row = 0; col < m && row < n; ++col) { in... |
#include <bits/stdc++.h> using namespace std; bool pr(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return true; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; char a[51][51]; bool f = false; for (int i =... |
#include <bits/stdc++.h> using namespace std; char mat[6][40]; int t[6], n, v[6]; int solve() { if (t[v[4]] != t[v[1]] + t[v[3]] - 1) return 0; if (t[v[5]] != t[v[0]] + t[v[2]] - 1) return 0; if (mat[v[0]][0] != mat[v[1]][0]) return 0; if (mat[v[0]][t[v[0]] - 1] != mat[v[4]][0]) return 0; if... |
#include <bits/stdc++.h> using namespace std; int main() { char a[200000], *s; cin >> a; if ((s = strstr(a, AB )) && (strstr(s + 2, BA ))) puts( YES ); else if ((s = strstr(a, BA )) && strstr(s + 2, AB )) puts( YES ); else puts( NO ); return 0; } |
#include <bits/stdc++.h> using namespace std; int shi(int a[], int k, int len) { int s = 0, j; for (j = len - 1; j >= 0; j--) { s = s * k + a[j]; } return s; } int bian(int n, int k) { int i; for (i = 0; n > 0; i++) { n /= k; } return i; } int change(int a[1000], ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i; cin >> n; long long cnt = 0; while (n >= 10) { n++; while (n % 10 == 0) { n = n / 10; } cnt++; } cout << cnt + 9 << endl; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; const int MX = 1e9 + 7; const long long int INF = 1e18 + 9LL; int n, k, r; bool spec[N]; vector<int> G[N]; int id[N]; queue<int> Q; int rep[N]; int tr[N], add[N]; set<pair<int, int> > S[N]; int lvl[N]; int jump[18][N]; in... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; for (int i = 1; i < n; i++) { if (s[i] < s[i - 1]) { cout << YES << n ; cout << i << << i + 1 << n ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 10; int A[N][N * N], B[N][N * N], C[N][N * N]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < m; j++) cin >> A[i][j] >> B[i][j] >> C[i][j]; } int... |
#include <bits/stdc++.h> using namespace std; long long PM(long long a, long long b) { return ((a % b) + b) % b; } void solve() { int n; cin >> n; string a; cin >> a; long long sum = 0; long long ans = 0; map<long long, long long> m; m[0] = 1; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int tinf = (int)1e9 + 7; const long long inf = (long long)1e18 + 7; const int N = 1e3 + 5; int main() { { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long n, k; cin >> n >> k; long long a[n], Min = inf, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1000000001, INF = (ll)1e18 + 1; const int maxn = 1e6; int n, m; vector<int> a, b; pair<ll, ll> fact[maxn]; ll power(ll a, ll b) { ll result = 1; while (b) { if (b % 2) result = (result * a) % m; a = (a... |
#include <bits/stdc++.h> using namespace std; int main() { long long l1, r1, l2, r2, k; cin >> l1 >> r1 >> l2 >> r2 >> k; l1 = max(l1, l2); r1 = min(r1, r2); if ((l1 <= k) && (r1 >= k)) cout << r1 - l1; else cout << max((long long)0, r1 - l1 + 1); return 0; } |
#include <bits/stdc++.h> using namespace std; int x[100100], y[100100], id[100100]; bool cmp(int i, int j) { if (y[i] >= 0 && y[j] < 0) return true; else if (y[i] < 0 && y[j] >= 0) return false; if (y[i] == 0 && y[j] == 0) { return x[j] < 0; } return x[i] * y[j] >= x[j] * y[i... |
#include <bits/stdc++.h> using namespace std; string vow = aeiou ; int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2}; const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1}; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p; string A; cin >> n >> p >> A; int i = n - 1; while (i >= 0 && i < n) { A[i]++; if (A[i] - 96 > p) { A[i] = 96; i--; continue; } if (i > 0 && A[i] == A[i - 1]) continue; if (... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 5; long long C[N][5], dif_fact[5]; void calc() { for (long long i = 0; i < N; i++) { for (long long j = 0; j <= min(i, 4LL); j++) { if (j == 0 || j == i) { C[i][j] = 1; } else { C[i][j] = C[i - ... |
#include <bits/stdc++.h> long long a[10000]; using namespace std; int main() { long long n, i, j, c; cin >> n; for (i = 1; i < n + 1; i++) cin >> a[i]; for (i = 1; i < n + 1; i++) { for (j = i + 1; j < n + 1; j++) { if (a[i] > a[j]) { c = a[i]; a[i] = a[j]; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[200010]; int main() { bool bo = 0; int X, Y = -1, t, Mx = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); Mx = max(Mx, a[i]); } for (int i = 2; i <= n; i++) { t = abs(a[i] - a[i - 1]); ... |
#include <bits/stdc++.h> int a[18]; int sum(int i, int n) { int j, s = 0; for (j = i; j < n; j++) s = s + a[j]; return s; } void print(int n) { int i; printf( %d n , n); for (i = 1; i <= n; i++) printf( %d , i); } int main() { int n, i, sum1 = 0, sum2 = 0; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); const double EPS = 1e-6; int main() { char s[1005]; scanf( %s , s); int n; scanf( %d , &n); int len = strlen(s); int cnt[26] = {0}; for (int i = 0; i < len; i++) cnt[s[i] - a ]++; bool found = false... |
#include <bits/stdc++.h> using namespace std; void solve(); int main(int argc, const char** argv) { int t = 1; cin >> t; while (bool(t--)) { solve(); cout << n ; } } void solve() { vector<int> v(3); int s = 0; for (int i = 0; i < 3; i++) { cin >> v[i]; s +... |
#include <bits/stdc++.h> using namespace std; const int N = 5 * 100 + 10; int n, dp1[N][N], dp2[N][N], k, par[N][N]; string s; void printpath(int i, int j) { if (j == 0) return; printpath(i - par[i][j], j - 1); if (j > 1) cout << + ; if (par[i][j] == 1) cout << s[i - 1]; else { ... |
#include <bits/stdc++.h> using namespace std; inline long long R() { char c; long long res, sign = 1; while ((c = getchar()) > 9 || c < 0 ) if (c == - ) sign = -1; res = c - 0 ; while ((c = getchar()) >= 0 && c <= 9 ) res = res * 10 + c - 0 ; return res * sign; } priority_... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int INF = (int)(1e9 + 1337); const long long LINF = (long long)(2e18); const double EPS = 1e-11; const int MAXN = 200100; string a; void solve() { cin >> a; a += # ; int cur = 0; int sz = 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 3002; int n, m, a, b; long long G[N][N], x, y, z, g[N * N], r[N][N], ans; deque<int> q; void init() { for (int i = 1; i <= (n - 1) * m + m - 1; i++) { g[i] = (g[i - 1] * x % z + y) % z; } for (int i = 1; i <= n; i++) { for (... |
#include <bits/stdc++.h> using namespace std; int n, m, t, o, s; char A[1000005], B[1000005]; int main() { scanf( %s , A); scanf( %s , B); n = strlen(A); m = strlen(B); for (int i = 0; i < m - 1; i++) t ^= (B[i] != B[i + 1]); for (int i = 0; i < m; i++) o ^= (B[i] ^ A[i]); if (o % 2 ... |
#include <bits/stdc++.h> int main() { long long a, b, c; while (~scanf( %I64d%I64d%I64d , &a, &b, &c)) { if (c == 0) { if (a == b) printf( YES n ); else printf( NO n ); } else { long long d = (b - a) / c; long long h = (b - a) % c; if (d ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int n, k; double h; struct lms { int i, m, v; } a[100005]; int pos[100005]; inline int put(double t) { int ptr = 1; for (int i = 0; i < n; ++i) { if ((double)ptr <= t * a[i].v) { pos[ptr] = a[i].i; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 9; int a[MAX_N]; void mergesort(int l, int r, int &k, int &remain) { if (k > 0 && r - l > 1) { k -= 2; int m = (l + r) / 2; mergesort(l, m, k, remain); mergesort(m, r, k, remain); } else { int c = r - l; ... |
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; string m; cin >> m; sort(m.begin(), m.end()); int cn = 0; int cm = 0; int res = 0; for (int i = 0; i < m.length(); i += cm) { cm = count(m.begin(), m.end(), m[i]); cn = count(n.begin(), n.e... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int A[200010]; int fri[100010]; for (int i = 0; i < N; i++) { int p, q; cin >> p >> q; fri[i] = p; A[p] = q; A[q] = p; } int res[200010] = {}; for (int i = 1; i <= 2 * N; i++) { ... |
#include <bits/stdc++.h> using namespace std; namespace WorkSpace { const int max_num = 100010; unsigned int F[max_num >> 1]; void Main() { register int N; scanf( %d , &N); if (N & 1) { printf( 0 n ); return; } static char S[max_num]; register int Half = N >> 1; scanf( ... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e5 + 5; int v[N]; int c[N]; bool viz[N]; bool check(int len, vector<int> v) { int n = v.size(); for (int i = 0; i < len; i++) { int p = (i + len) % n; while (v[p] == v[(p + len) % n] && p != i) { p = (p + len) % n; ... |
#include <bits/stdc++.h> using namespace std; void sol() { long long int n, x; cin >> n >> x; if (n <= 2) cout << 1 n ; else { n = n - 2; long long int ans = 1; long long int z = n / x; if (n - z * x > 0) z++; ans += z; cout << ans << n ; } } int ... |
#include <bits/stdc++.h> using namespace std; long long ans, n, k, m, v, l, r, asdfghjkl, qwertyui, zxcvbnm, oiuytre, lkjgfdsa, mnbvcxz, x, y; long long i, j, a[100002], b[100002], d[100002], l1, l2, r1, r2; long long mn, xm, ym, mnd, mnv, pos; long long s; char c; int main() { ios_base::sync_wi... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(const T& a) { return a * a; } const long double EPS = 1e-9; const long double PI = 2 * acos(0.0); const int N = 100000; int counts[N]; int xors[N]; vector<int> g[N]; queue<int> qq; vector<pair<int, int> > ans; in... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b; cin >> n; if (n == 1) { cout << 9 8 << endl; } else { cout << n * 3 << << n * 2 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; vector<int> flavors[300001]; vector<int> adj[300001]; int color[300001]; void dfs(int v, int p) { set<int> colors; for (auto f : flavors[v]) if (color[f] != -1) colors.insert(color[f]); int first = 1; for (auto f : flavors[v]) if (color... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int alpha[26], kitta = 0; for (int i = 0; i < 26; i++) alpha[i] = 0; for (int i = 0; i < s.length(); i++) { alpha[s[i] - a ]++; if (alpha[s[i] - a ] == 1) kitta++; } if (kitta > 4 || kitta < 2) {... |
#include <bits/stdc++.h> using namespace std; const long long len = 40; long long n, next_free = 0; long long a[2][200500 * len]; void add(long long x) { vector<long long> b; long long i; for (i = 0; i < len; i++) { long long last = x % 2; b.push_back(last); x /= 2; } rev... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; int res = 1; int n = s.length(); int cur = 1; for (int i = 0; i < n; i++) { if (s[i] == A or s[i] == E or s[i] == I or s[i] ... |
#include <bits/stdc++.h> template <typename Iter> long long maxsum(Iter begin, Iter end) { long long mins = 0, s = 0; long long maxs = 0; long long max = *begin; while (begin != end) { s += *begin; max = std::max(max, *begin); maxs = std::max(maxs, s - mins); mins = std::min(... |
#include <bits/stdc++.h> using namespace std; const long long int INF = (1LL << 60) - 1; const long long int MAX = 1000000001; const long long int mod = 1000000007; long long int s[1000001] = {0}; long long int f[1000001] = {0}; long long int po[1000001] = {0}; long long int fast_exp(long long int base,... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; const long double pi = 3.14159265358979323846; const char nl = n ; const long long inf = 1e15; long long mul(long long x, long long y) { return (1ll * (x) * (y)); } long long power(long long x, long long y) { long long z = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long mypow(int n, int m) { long long ans = 1, a = 3; while (n > 0) { if (n & 1) ans = ans * a % m; a = a * a % m; n >>= 1; } return ans; } int main() { while (~scanf( %d%d , &n, &m)) { long long ans = mypo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300000; int n, balance[MAXN + 9] = {0}; int min_balance = MAXN; int main() { cin >> n; for (int i = 1; i <= n; i++) { char ch; cin >> ch; balance[i] = balance[i - 1] + ((ch == ( ) ? 1 : -1); min_balance = min(min_b... |
#include <bits/stdc++.h> using namespace std; const int MAXK = 60; const int MAXT = 1E4 + 10; const int LIM = 1E5 + 10; namespace Pollard_Rho { const int pr[] = {2, 3, 5, 7, 11, 23, 43, 79}; const int M = (1 << 8) - 1; mt19937 RandEngine(chrono::steady_clock::now().time_since_epoch().count()); long lo... |
#include <bits/stdc++.h> using namespace std; void scan() {} template <typename F, typename... R> void scan(F &f, R &...r) { cin >> f; scan(r...); } int di_; string dnms_, co_ = , ; void debug_() { cout << endl; } template <typename F, typename... R> void debug_(F f, R... r) { while (dn... |
#include <bits/stdc++.h> using namespace std; long long dis(long long x1, long long x2, long long y1, long long y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } int main() { int n; cin >> n; long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long x[n + 1], y[n + 1];... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { int temp1, temp2; if (a[i] != i) { temp1 = a[a[i]]; temp2 = a[a[a[i]]]; if (i == temp2) { c... |
#include <bits/stdc++.h> using namespace std; int n, a[101], dp[101], ans; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == 0) { dp[i] = 0; ans++; } else if (a[i] == 3) { if (dp[i - 1] == 0 || dp[i - 1] == 3) dp[i] = 3; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b; cin >> c >> d; cout << max(abs(c - a), abs(b - d)); } |
#include <bits/stdc++.h> using namespace std; int max(int a, int b) { if (a > b) return a; else return b; } int min(int a, int b) { if (a < b) return a; else return b; } int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int b) { return a * ... |
#include <bits/stdc++.h> using namespace std; int n, i, nr, k[7], m; int main(void) { cin >> n; m = 0; for (i = 1; i <= n; i++) { cin >> nr; k[nr]++; } if ((k[1] + k[2] * 2 + k[3] * 3 + k[4] * 4 == 5) || (k[1] + k[2] * 2 + k[3] * 3 + k[4] * 4 < 3)) { cout << -1 ; ... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1), eps = 1e-10; int n, m, k, Q, id[100005], rt, siz[100005], f[100005]; int fir[100005], tot; int sgn(double x) { return x > -eps && x < eps ? 0 : 1; } struct node { double ang; int to, s; bool operator<(const node &p) const ... |
#include <bits/stdc++.h> using namespace std; const int N = 500010; struct E { int u, v, w, I; } e[N]; int n, m, F[N], T[N], q, k, a[N], A[N], V, d, L[N], C[N]; vector<int> G[N]; bool M(E a, E b) { return a.w < b.w; } int P(int x) { return x == A[x] ? x : A[x] = P(A[x]); } void D(int b, int x) { ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { int x1, x2, y1, y2, dx, dy, px, py; cin >> x1 >> y1 >> x2 >> y2 >> px >> py; dx = abs(x2 - x1); dy = abs(y2 - y1); if (dx % px != 0 || dy % py != 0) { cout << NO ; exit(0); } int a = dx / ... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[100005]; int p[100005]; long long size[100005]; struct edge { int u, v, w; edge(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {} bool operator<(const edge &e1) const { return w > e1.w; } } eList[100005]; int findR(int x) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, p; set<int> ss; int idx[500500]; char str[500500], op[500500]; int main() { cin >> n >> m >> p; scanf( %s%s , str + 1, op + 1); stack<int> s; ss.insert(0); for (int i = 1; i <= n; i++) { ss.insert(i); if (str[i] == ( ) ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 10; const long long INF = 1e18; int n, m, h[MAXN], a[MAXN], c[MAXN]; double x, ans[MAXN]; vector<pair<int, int>> g[MAXN]; vector<int> going; bool visited[MAXN], b, res, f; void dfs(int v, int hi, int p) { visited[v] = true;... |
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; void solve() { int n, m, k; cin >> n >> m >> k; vector<int> A(n); for (int i = 0; i < n; ++i) { cin >> A[i]; } int x = min(k, m - 1); int y = m - 1 - x; vector<int> b; for (int i = 0; i + n - m < n; ++i)... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10, INF = 1e9 + 7; int r[N][N], n, a[N], o[N], t[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { o[i] = o[i ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); int qq = 1; cin >> qq; for (int qqq = 0; qqq < qq; qqq++) { int n, first, v; cin >> n >> first; int maxx = 0; int maxxd = 0; for (int i = 0; i < n; i++) { cin ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.