func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int MOD = 1e9 + 7; long long INF = 1e18; int n, q, a[200005]; int d[200005] = {}; int solve() { cin >> n >> q; for (int i = 0; i < n; i++) cin >> a[i]; while (q--) { int l, r; cin >> l >> r, l--, r--; d[l]++; d[r + 1]--; }... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 1e3 + 10; long long dis[N][N][4]; int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; char c[N][N]; queue<pair<int, int>> q[4]; int n, m; long long check(int o) { long long d[4] = {0, INF * INF, INF * INF,... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; inline int read() { int ret = 0, t = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) t = -1, c = getchar(); while (c >= 0 && c <= 9 ) ret = ret * 10 + c - 0 , c = getcha... |
#include <bits/stdc++.h> using namespace std; int n, m, k, arr[1005], ro[1005], co[1005]; char s[2000000]; int main() { int a, b; cin >> s + 1; a = count(s + 1, s + strlen(s + 1) + 1, x ); b = count(s + 1, s + strlen(s + 1) + 1, y ); for (int i = 1; i <= a - b; i++) cout << x ; for (i... |
#include <bits/stdc++.h> auto clk = clock(); const int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0}; const int dx8[] = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8[] = {-1, 0, 1, 1, 1, 0, -1, -1}; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long Gcd(long long... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; long long n, m, nn, cnt, tot, k, k_, x, y, ww, rt, ans; long long to[N], nextn[N], h[N]; long long mxsize[N], size[N]; long long w[N]; struct dis { long long d, d_; bool operator<(const dis &x) const { return x.d > d; } ... |
#include <bits/stdc++.h> using namespace std; long long a, b, d[1001], y[100001], dp[1001][1001]; int main() { scanf( %lld%lld , &a, &b); for (int i = 1; i <= a; i++) { scanf( %lld , &d[i]); } sort(d + 1, d + a + 1); long long pp = 1; for (int i = d[1]; i <= 100000; i++) { whil... |
#include <bits/stdc++.h> using namespace std; const int N = 505; int n, m, x, cnt[N], ne[N][10], g[15], f[15], dp[N][N][15], sd[N], tot; char s[N]; void dfs(int x) { for (int i = 0; i < 10; i++) if (ne[x][i]) dfs(ne[x][i]); for (int i = 0; i <= sd[x]; i++) { memset(f, 0, sizeof f); f... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == - && ans > 0) ans--; if (s[i] == + ) ans++; } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; int find_set(int v, vector<int> &p) { if (v == p[v]) return v; return p[v] = find_set(p[v], p); } void union_set(int a, int b, vector<int> &p) { a = find_set(a, p); b = find_set(b, p); if (a != b) { p[b] = a; } } long long int ans =... |
#include <bits/stdc++.h> using namespace std; int n; int num[30]; char ans[100050]; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { cin >> n; int neven = 0; int sut = 0; for (int i = 0; i < n; i++) { cin >> num[i]; if (num[i] % 2) neve... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, b, g, x, y; bool women[100], man[100]; cin >> n >> m; cin >> b; for (int i = 0; i < n; i++) man[i] = 0; for (int i = 0; i < m; i++) women[i] = 0; for (int i = 0; i < b; i++) { cin >> x; man[x] = 1; } ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); bool in_quotes{false}; string sub; vector<string> vec; for (int i{}; i < s.size(); ++i) { if (s[i] == ) { if (!in_quotes) { in_quotes = true; if (!sub.empty()) vec.push_... |
#include <bits/stdc++.h> using namespace std; const long long inf = INT_MAX, df = 4e5 + 7; priority_queue<pair<long long, long long>> que[df]; int i, j, k, l, m, n, o, q, s, t, u, v, w, x, y, z, tot, cur[df], pos[df]; long long r[df], p[df], d[df], b[df], a[df]; inline long long read() { long long x = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, flag = 0, cnt = 0, temp; cin >> n >> m; char a[108][106]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cnt = 0; if (a[i][j] == . ) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n; cin >> n; vector<pair<long long, long long>> a(n); for (long long i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; a[i].first *= 2; a[i].second *= 2; } if (n % 2) { cout << NO ; r... |
#include <bits/stdc++.h> using namespace std; int main() { int n, res; cin >> n; res = n / 5; if (n % 5 != 0) res++; cout << res; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; set<long long> d[n + 1]; vector<long long> kingdom(n + 1, 0); for (long long i = 1; i < n + 1; i++) { long long k, x; cin >> k; for... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b; cin >> a >> b; if (a == b) { cout << a << endl; return; } else if (a > b) { cout << a + b << endl; return; } else { if (b % a == 0) { cout << b << endl; return; } else... |
#include <bits/stdc++.h> using namespace std; int n, t1, t2, k, a[1005], b[1005]; vector<pair<double, int> > ans; bool cmp(pair<double, int> x, pair<double, int> y) { if (fabs(x.first - y.first) < 1e-5) return x.second < y.second; return x.first > y.first; } double h(int x, int y) { return (doub... |
#include <bits/stdc++.h> using namespace std; int F[100000], S[100000]; int main(int argc, char *argv[]) { int n, x, adg, i, j, k, L, A, B; cin >> n >> x; for (i = 0; i < n; i++) cin >> F[i]; for (i = 0; i < n; i++) cin >> S[i]; if (n == 1) cout << 1 << << 1; else { cout <<... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) { return b; } else { return gcd(b % a, a); } } long long int lcm(long long int a, long long int b) { return a * b / gcd(a, b); } int f(char c) { return (int)c - 48; } ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 500005; int n; int a[Maxn]; long long L[Maxn], R[Maxn]; int delt[Maxn]; long long res; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); L[i] = L[i - 1] + a[i]; } if (L[n] % 3) ... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 1000000007; const int N = 100000 + 7; int power(int x, unsigned int y) { int res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } int GCD(int A, int B) { if (B =... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, t[N]; int main() { scanf( %d , &n); set<int> st; int ans = 0; for (int i = 0; i < n; i++) scanf( %d , &t[i]); for (int i = 1; i <= n; i++) { set<int>::iterator it = st.lower_bound(t[i - 1]); int cur = *it;... |
#include <bits/stdc++.h> using namespace std; typedef int STDD[1010]; struct lst { int po; int num; lst* nxt; }; lst* hd[1001]; int n, m, sx, sy, ans = 2E9 + 1, a1, a2; STDD seq, tseq, fa, clr, far; int x[30010], y[30010], z[30010]; bool vis[1001]; int getfa(int x) { return (fa[x] != x) ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3; const long long MOD = 1e9 + 7; const long long INF = 2e9; const int fullmask = (1 << 10) - 1; long long fpow(int n, int p) { if (!p) return 1; if (p == 1) return n; long long tmp = fpow(n, p / 2); if (p & 1) return tmp * tm... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int n, m; int f[2][25][25][25][25][2][2]; int x[6], y[6]; int tpx[1 << 6], tqx[1 << 6], tpy[1 << 6], tqy[1 << 6]; inline void update(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; } inline bool check(int now, int px, int ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a = -2147483647, b = 0; for (int i = 0; i < n - 1; ++i) { int x; cin >> x; a = max(a, x); } cin >> b; a = max(a, b); cout << (int)(a ^ b); } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) { string input; cin >> input; cout << No << endl; return 0; } stack<char> parenthesis; char input; bool flag = true; cin >> input; parenthesis.push(input); fo... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300100; const int MOD = 998244353; inline int mnoz(long long a, long long b) { a *= b; a %= MOD; return a; } inline int dodaj(long long a, long long b) { a += b; a %= MOD; return a; } long long quick_pow(int i, int x... |
#include <bits/stdc++.h> using namespace std; const long long int MAX = 1000000007; const long long int MAXN = 100005; int solve() { int n, sx = 0, sy = 0, ans = -1; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; sx += x[i]; sy += y[i]; } i... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100; string v[maxn]; long long cn[26]; char mp[101][10000]; signed main() { long long n; cin >> n; string ts = aouie ; for (long long i = 5; i < n && n / i >= 5; i++) { if (n % i) continue; for (long long j = 0... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t = 0; char ch = getchar(); int f = 1; while ( 0 > ch || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } do { (t *= 10) += ch - 0 ; ch = getchar(); } while ( 0 <= ch &&... |
#include <bits/stdc++.h> using namespace std; string mirror = AHIMOTUVWXY ; string letter = ABCDEFGHIJKLMNOPQRSTUVWXYZ ; int main() { long long n, m, i, j, k, x, y, z, t; cin >> x >> y; if ((x == 0 || x == 1) && y == 0) { cout << 0 << endl; return 0; } if (x == 1 && y == 1) { ... |
#include <bits/stdc++.h> int main() { long long int n; scanf( %lld , &n); printf( %lld , 6 * n * (n + 1) / 2 + 1); } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int b, g, n; cin >> b >> g >> n; cout << min(g, n) - max(0LL, n - b) + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int a[1000000], b = 0, c = 0, d = 0; long long int n, i; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; d += a[i]; } d = d / n; for (i = 1; i <= n; i++) { b += a[i] - d; c += abs(b); } ... |
#include <bits/stdc++.h> using namespace std; struct s { char g; long s, e; }; int main() { long n, i, j, c, ans = 0, day = 0, m = 0, f = 0; struct s a[5005]; cin >> n; for (i = 0; i < n; ++i) cin >> a[i].g >> a[i].s >> a[i].e; for (day = 1; day <= 366; ++day) { m = 0; f ... |
#include <bits/stdc++.h> using namespace std; int arr[100007]; int main() { int i, n, k, distinct, r; map<int, int> M; while (scanf( %d%d , &n, &k) == 2) { bool flag = true; M.clear(); distinct = 0; for (i = 0; i < n; i++) { scanf( %d , &arr[i]); if (M[arr[i]] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i; scanf( %d%d , &n, &k); int sum = 0; int gave = 0; for (i = 0; (i < n) && gave < k; i++) { int curr; scanf( %d , &curr); sum += curr; int thisDay = min(sum, 8); sum -= thisDay; gave += this... |
#include <bits/stdc++.h> using namespace std; long long a[100]; struct node { long long l; long long r; long long x; } p[100]; bool cmp(node aa, node bb) { return aa.x > bb.x; } int main() { long long n, h, m, i, ans = 0; cin >> n >> h >> m; for (i = 1; i <= n; i++) { a[i] = -1... |
#include <bits/stdc++.h> const double pi = acos(-1.0), eps = 1e-9; const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1}; const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1}; const int MO = (int)(1e9 + 7); using namespace std; string s[2001]; int n, k, l[1001][1001]; int lcp(int a, int b) { int ret = 0; while... |
#pragma GCC optimize ( Ofast ) #include<bits/stdc++.h> using namespace std; void*wmem; char memarr[96000000]; template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){ static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void*)( ((char*)(*mem)) + sk... |
#include <bits/stdc++.h> using namespace std; string s[3]; int a[200][200]; int n; int main() { char card, team; int tm, player; cin >> s[0] >> s[1]; cin >> n; for (int i = 0; i < n; i++) { cin >> tm >> team >> player >> card; if (card == y ) a[team][player]++; e... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5; int arr[N + 100]; vector<pair<long long, int> > v; set<int> st; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { long long c; cin >> c; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, q, fa[N]; double p[N], sum[N], ans; vector<int> son[N]; void dfs(int x, int f) { fa[x] = f; for (int i = 0; i < son[x].size(); ++i) { int y = son[x][i]; if (y == f) continue; dfs(y, x); sum[x] += 1 - ... |
#include <bits/stdc++.h> using namespace std; const int N = 1100; int n, m, t; int a[N]; int main() { scanf( %d , &n); memset(a, 0, sizeof(a)); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); a[x]++; } scanf( %d , &t); int mx = -1; for (int i = 1; i <= 1000... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j; int n, a = 1, b = 1, c = 0, x; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &x); if (x == 1) { if (a == 0) { printf( NO n ); break; } else if (b == 0) { b = 1; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; long long A[100005]; map<long long, long long> mp; int main() { long long n, a, i; cin >> n; for (i = 1; i <= n; i++) { cin >> a; mp[a] += a; } A[1] = mp[1]; A[0] = 0; for (i = 2; i <= 100000; i++... |
#include <bits/stdc++.h> using namespace std; struct elem { int i1, i2, p1, p2, tipo; elem() {} elem(int i1, int i2) : i1(i1), i2(i2) { tipo = 0; } elem(int i1, int i2, int p1, int p2) : i1(i1), i2(i2), p1(p1), p2(p2) { tipo = 1; } }; int inverso(int x) { if (x == 2) return 3; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; string s; cin >> n >> s; if (s.find( 0 ) == string::npos) { cout << 1 << << n / 2 << ; cout << 2 << << n / 2 + 1; return; } else { for (int i = 0; i < n / 2; i++) { if (s[i] == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, k, i, j, x, y, z, c, f, t, s, p; cin >> k >> n >> s >> p; if (n % s == 0) { z = (n / s) * k; if (z % p == 0) { cout << z / p << endl; } else { cout << z / p + 1 << endl; } } else { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) const int nmax = 3e5 + 1; using namespace std; struct node { int ind; int cur; node() {} node(int cur, int ind) : cur(cur), ind(ind){}; }; node bolshe(node a, node b) { return (a.cur == b.cur ? (a.ind > b.ind ? a : b) : (a.cur > b.cu... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma G++ optimize(2) using namespace std; const int MAX_N = 2e3 + 5; char s[MAX_N], t[MAX_N]; int sufs[MAX_N][26], suft[MAX_N][26]; int dp[MAX_N][MAX_N]; int solve(int i, int j) { if (j == 0) return 0; if (~dp[i][j]) return dp[i][j]; int re... |
#include <bits/stdc++.h> using namespace std; const long long int mxn = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int i, j, k, n, m; cin >> n >> k; string s; cin >> s; map<long lon... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:167772160000 ) using namespace std; void redirectIO() { ios::sync_with_stdio(false); cin.tie(0); } int sc1, sc2; int best; vector<pair<int, int> > bestAns; vector<pair<int, int> > solve() { best = -10; bestAns.clear(); for (int... |
#include <bits/stdc++.h> using namespace std; long long pw(long long x, long long a) { if (a == 0) return 1; long long t = pw(x, a / 2); if (a % 2 == 0) return (t * t); else return (t * t * x); } bool prime(int x) { if (x < 2) return false; for (int i = 2; i <= sqrt(x); i++) ... |
#include <bits/stdc++.h> using namespace std; long long fpow(long long n, long long k, long long p = 1000000007) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; n = n * n % p; } return r; } long long inv(long long a, long long p = 1000000007) { return fpow(a, p ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int is0(int d) { return d << 1; } int is1(int d) { return d << 1 | 1; } struct TwoSat { static const int N = ::N << 1; vector<int> G[N]; int pre[N], dfn[N], dfs_clock; int scc[N], sccn; int mark[N], n; stack<int> S; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n, m, w, a, b, v; cin >> n >> m >> a >> b >> v; set<int> s; set<int> l; for (int i = 0; i < a; ++i) { int x; cin >> x; s.insert(... |
#include <bits/stdc++.h> const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-9; using namespace std; double xp, yp, vp, x, y, v, r, R; double P, len, L; pair<double, double> pos[2]; double f(double dphi) { if (dphi > pi) d... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> perm; void generate(vector<int>& curr, int n) { if (n == 4) perm.push_back(curr); else { for (int i = n; i < 4; i++) { swap(curr[n], curr[i]); generate(curr, n + 1); swap(curr[n], curr[i]); } } ... |
#include <bits/stdc++.h> using namespace std; map<int64_t, int> mp1, mp2; int fnc(int n) { int ans = n + 1; for (auto i = mp1.begin(); i != mp1.end(); i++) { if (i->second >= (n + 1) / 2) return 0; if (i->second + mp2[i->first] >= ((n + 1) / 2)) ans = min(ans, (n + 1) / 2 - i->second);... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10, MAXM = 2e6 + 10, INF = INT_MAX; const int MOD = 1e9 + 7, mod = 998244353; char s[MAXN]; char p[] = twone ; char k[] = two ; char z[] = one ; int main() { int t; scanf( %d , &t); while (t--) { scanf( %s , s + 1)... |
#include <bits/stdc++.h> using namespace std; int a[10][10], b[10][10]; int f(int x) { int o = 0; while (x) { o += (x & 1); x >>= 1; } return o; } int main() { int n, ans = 999; char o1; int o2; cin >> n; for (int i = 1; i <= n; i++) { int x, y; cin ... |
#include <bits/stdc++.h> int main() { int s = 0, ar[5], t = 0; for (int i = 0; i < 5; ++i) { scanf( %d , &ar[i]); s += ar[i]; } if (s % 5 || s == 0) printf( -1 n ); else { for (int i = 0; i < 5; ++i) if (ar[i] % 2) ++t; if ((((s / 5) % 2) && (t == 1 || t == 3 ... |
#include <bits/stdc++.h> using namespace std; const long long M = 100 + 19; long long d[M][M][M], n, m, k; char c; struct tuplee { long long x, y, z; }; vector<tuplee> v1, v2; long long go(long long x1, long long y1, long long z1, long long x2, long long y2, long long z2) { if (x1... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int h[3000]; for (int i = 0; i < n; i++) { cin >> h[i]; } sort(h, h + n); cout << h[b] - h[b - 1]; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2000005; const int inf = 1000000009; int c, Len, Ans, id; char String[N], s[N]; int D[N], num[N], n, Q[N], h, t, x; vector<int> e[N]; vector<char> v[N]; void getstr(char *s, int &l) { l = 0; while (String[c] != , && c < Len) s[l++] ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, x, y, z; cin >> t; while (t--) { cin >> x >> y >> z; if ((x != y && y != z && x != z) || ((x == y && x < z) || (y == z && y < x) || (z == x && z < y))) { cout << NO n ; continue; } else { ... |
#include <bits/stdc++.h> const int mod = 998244353, g = 3, _g = 332748118, maxn = 2e5 + 9; inline int Pow(int base, int b) { int ret(1); while (b) { if (b & 1) ret = 1ll * ret * base % mod; base = 1ll * base * base % mod; b >>= 1; } return ret; } int r[maxn], W[maxn]; inline ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int d, k, a, b, t; cin >> d >> k >> a >> b >> t; long long int res = 0; if (d > k) { if (t + a * k > b * k) { res = k * a + (d - k) * b; } else { long long int x = ((d % k) * b < (d % k) * a ... |
#include <bits/stdc++.h> using namespace std; bool vis[100005]; int main() { int n; while (cin >> n) { int i, tag = 0, num = 0; for (i = 5;; i += 5) { int x = i; while (x % 5 == 0 && x) { num++; x /= 5; } if (num == n) { tag = 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; void qread(int &x) { int neg = 1; x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = 10 * x + c - 0 , c = getchar(); x *= ne... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int k, t; int a[11]; long long b[16], c[11], ele[11], hash_val; map<pair<int, long long>, long long> vis; void add(int i) { c[b[i]]--; hash_val -= ele[b[i]]; b[i]++; c[b[i]]++; hash_val += ele[b[i]]; } void remove... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); } const long long maxn = 1e5; long long n, k; vector<long long> freq(maxn, 0);... |
#include <bits/stdc++.h> using namespace std; int n, a[100010], dp[100010][2], cum[100010]; int calc(int at, int flag) { if (at == n + 1) return 0; int &ret = dp[at][flag]; if (~ret) return ret; ret = 0; if (flag) { ret = max(ret, calc(at + 1, 1) - a[at]); ret = max(ret, calc(at + ... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } string toString(long long n) { stringstream second; second << n; return second.str(); } long long toNumber(string s) { stringstream second; long long n; second << s; seco... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) using namespace std; const double PI = acos(-1.0); const double eps = 1e-9; const unsigned long long MOD = 1e9 + 7; const unsigned long long INF = 1e18 + 7; const unsigned long long MAXN = 2e5 + 7; unsigned long long n, m, A, B, C, ans... |
//================code===================// //#define TLE #ifdef TLE #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #endif #include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #include <random> #include <ctime> ... |
#include <bits/stdc++.h> using namespace std; vector<string> v; string s; int n; int main() { cin >> n >> s; v.push_back(s); for (int i = 0; i < n; i++) { string s1 = s; if (s[i] != 0) { int kl = 10 - (s[i] - 48); for (int j = 0; j < n; j++) { int zn = s[j] - ... |
#include <bits/stdc++.h> using namespace std; struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } } _io; const long long maxn = 3e5 + 10, mod = 1e9 + 7; template <typename... T> long long madd(T... args) { long long res = 0; for (auto i : {args...}) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int a[2010]; bool vis[2010]; long long sum; vector<int> edge[2010]; long long DFS(int u, int d, int fa, int root) { long long ret = 1; for (int i = 0; i < edge[u].size(); i++) { int v = edge[u][i]; if (v != fa... |
#include <bits/stdc++.h> using namespace std; const int MAXK = 21; long long dp[(1 << MAXK)]; int n, m; string s; long long d[MAXK][MAXK]; long long solve(int mask) { if (mask == ((1 << m) - 1)) return 0ll; long long &ret = dp[mask]; if (ret != -1) return ret; ret = 1e10; long long cos... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long n, k; cin >> n >> k; long long len = 2 * n; long long temp = k * 2 / len; long long ans = k * 2 % len == 0 ? temp : temp + 1; cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } template <class T> void read(vector<T> &v) { T x; cin >> x; v.push_back(x); } int n, a, b, x... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long a[maxn]; pair<long long, long long> st[maxn]; long long top, n, m, k, l, r, rec, rec2; long long ans; int main() { cin >> n >> k >> m; for (long long i = 1; i <= n; i++) cin >> a[i]; for (long long i = 1; i <= n... |
#include <bits/stdc++.h> using namespace std; vector<int> t; void set_val(int p, int x) { t[p + int(t.size()) / 2] = x; for (p = (p + int(t.size()) / 2) / 2; p > 0; p /= 2) { t[p] = max(t[2 * p], t[2 * p + 1]); } } int leftmost(int left, int y) { if (left >= int(t.size()) / 2) return -1;... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 1000000001; const long long LINF = 1000000000000000001LL; int len[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string days[] = { monday , tuesday , wednesday , thursday , friday , satu... |
#include <bits/stdc++.h> using namespace std; long long n, k, a[200], m; int main() { cin >> n >> m; k = n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); while (m > 0) m -= a[n--]; if (n < 0) n = 0; cout << k - n << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<string> words(4 * n); string S; int aabb = 0, abab = 0, abba = 0, aaaa = 0, NO = 0; for (int i = (0); i < (4 * n); ++i) { cin >> S; int size = S.size(); int Kth = 0; string newS... |
#include <bits/stdc++.h> using namespace std; const int MN = 1e6 + 44; const int mod = 1e9 + 9, b = 8888; long long rcshnt[MN]; int n; char a[MN]; bool check(int len) { ; long long curr = 0; for (int i = 0; i < len; ++i) curr = (curr * b + a[i]) % mod; long long pre = curr; ; for (... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long add(long long a, long long b) { a += b; if (a >= MOD) a -= MOD; if (a < 0) a += MOD; return a; } long long mul(long long a, long long b) { return a * 1ll * b % MOD; } void solve() { long long n; string s... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; } void sd() { int n; cin >> n; n = 2 * n; vector<vector<pair<int, long long>>> adj(n + 1); vector<int> cnt(n + 1, 1); int i;... |
#include <bits/stdc++.h> using namespace std; inline int read() { int n = 0; char c; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) ; for (; c >= 0 && c <= 9 ; c = getchar()) n = n * 10 + c - 48; return n; } const int maxn = 1e5 + 5, N = 1 << 18, mo = 998244353; int i, j, ... |
#include <bits/stdc++.h> using namespace std; int a[1000009]; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); int v = 0; int min1 = 0x3f3f3f3f; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); } for (int i = n; i >= 1; --i)... |
#include <bits/stdc++.h> using namespace std; int dp[100005], ans[100005]; struct node { int x, y, t; } a[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int r, n; cin >> r >> n; a[0].x = a[0].y = 1; a[0].t = 0; for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; const int N = 200100; const int oo = (N << 1); int dp[19][N][2][2]; int d1[N], d2[2][N]; char mat[2][N]; int cal(int x1, int y1, int x2, int y2) { if (x1 == x2) { return d2[x2][y1]; } return min(d1[y1] + d2[x2][y1], d2[x1][y1] + d1[y2]); } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a; cin >> a; int n, s, t; while (a--) { cin >> n >> s >> t; cout << max(n - s + 1, n - t + 1) << n ; } return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.