func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> int n, m, k; std::set<int> r; std::set<std::pair<int, int> > e; std::string getAnswer(bool b) { if (b != 0) return possible ; else return impossible ; } bool check(int x, int y) { if (x > y) std::swap(x, y); return e.find(std::make_pair(x, y)) == e.end(... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long tt = 1; while (tt--) { long long n; cin >> n; long long arr[n + 1]; for (long long i = 0; i < n; i++) cin >> arr[i]; arr[n] = arr[n - 1]; ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; int N; char A[2020]; char B[2020]; long long D[2020][4040]; long long E[2020][4040]; int main() { int tc; scanf( %d , &tc); while (tc--) { scanf( %d , &N); scanf( %s , A + 1); scanf( %s , B + 1)... |
#include <bits/stdc++.h> using namespace std; struct st { int x, p; }; bool myfun(st a, st b) { return a.x < b.x; } int main() { int i, sum = 0, c = 0, n, k; st a[110]; cin >> n >> k; for (i = 0; i < n; ++i) { a[i].p = i + 1; cin >> a[i].x; } sort(a, a + n, myfun); ... |
#include <bits/stdc++.h> using namespace std; constexpr long long maxn = 2e5 + 5, inf = 0x3f3f3f3f; vector<long long> e[maxn]; long long n, m, k, c[maxn], ans; void dfs(long long u, long long fa) { for (auto v : e[u]) { if (v == fa) continue; dfs(v, u); c[u] += c[v]; ans += min(c[v... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; long long seg[5000000]; long long scn[5000000]; void update(long long pos, long long x, long long l = 0, long long r = 300000, long long ind = 1) { if (l == r && l == pos) s... |
#include <bits/stdc++.h> using namespace std; void sol() { long long int n, k; cin >> n >> k; if (n == k) cout << -1 << n ; else { long long int ar[n]; for (long long int i = 0; i < k; i++) { ar[n - 1 - i] = n - i; } ar[n - 1 - k] = 1; for (long long int... |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; bool prime[1000001] = {true}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> arr(m); if (m == 0) { cout << YES ; return 0; } for (int i = 0; i < m; i+... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ar[100010], flag = 1, cnt = 1; char s[100010]; scanf( %d , &n); getchar(); for (int i = 1; i <= n; i++) scanf( %c , &s[i]); for (int i = 1; i <= n; i++) scanf( %d , &ar[i]); for (int i = 1; i <= n; i++) { if (s[cnt] ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long qsm(long long a, int b) { a %= mod; long long ret = 1; while (b) { if (b & 1) ret = ret * a % mod; b >>= 1; a = a * a % mod; } return ret; } long long a[220000], b[220000], f[220000]; ... |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ii = pair<int, int>; using vii = vector<ii>; using l = long long; using vl = vector<l>; using vvl = vector<vl>; using ll = pair<l, l>; using vll = vector<ll>; using vvll = vector<vll>; using lu = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 1; cin >> n; vector<vector<int>> graph(n + 1); vector<bool> visit(n + 1); vector<int> color(n + 1); for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back... |
#include <bits/stdc++.h> using namespace std; int a[105][105]; int main() { int n, m, q; cin >> n >> m >> q; vector<pair<pair<int, int>, pair<int, int> > > t(q); for (int i = 0; i < q; ++i) { cin >> t[i].first.first >> t[i].first.second; if (t[i].first.first == 3) cin >> t[i].second.fi... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAX = 103; long long dp[MAX][MAX][MAX]; long long tmp[MAX][MAX]; long long ncr[MAX][MAX]; long long res[MAX]; int sub[MAX]; vector<int> adj[MAX]; int modulo(int a, int b, int c) { long long res = 1; for (int i =... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; int xp, yp, xc, yc; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> xp >> yp >> xc >> yc; vector<pair<int, int>> store; while (xc != 0 || yc != 0) { store.push_back({xc, yc}); xc--; ... |
#include <bits/stdc++.h> using namespace std; long long int A(int n, int k) { if (n < k) { return 0; } long long int res = 1; for (int i = n; i > n - k; --i) res *= i; return res; } int fact(int n) { int res = 1; for (int i = 2; i <= n; ++i) res *= i; return res; } int ... |
#include<bits/stdc++.h> #define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++) #define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--) #define ll long long #define pii pair<int, int> #define db double #define x first #define y second #define ull unsigned long long #define sz(a) ((int) (a).siz... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &dig) { int flg; char c; flg = dig = 0; while (c = getchar(), !isdigit(c)) if (c == - ) flg = 1; while (isdigit(c)) dig = dig * 10 + c - 0 , c = getchar(); if (flg) dig = -dig; } template <... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, ways = 0; int c[100]; cin >> n; for (int i = 0; i < n; ++i) { cin >> c[i]; sum = sum + c[i]; } for (int i = 0; i < n; ++i) { if ((sum - c[i]) % 2 == 0) ways++; } cout << ways << endl; ret... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n]; long long int f[100005]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int x = a[n - 1] - a[0]; long long int y = 1; int i = 1; while (a[i] == a[... |
#include <bits/stdc++.h> using namespace std; using pqboro = priority_queue<long long, vector<long long>, less<long long>>; using pqchoto = priority_queue<long long, vector<long long>, greater<long long>>; template <typename T> string toString(T Number) { stringstream ss; ss << Number; retur... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, a[200001] = {0}; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } if (n == 1) { s = 0; } else { int m = 0, y = 0, f = 0; m = a[0]; if (a[0] == 1) { y = 1; } else ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string st; cin >> st; bool ev = false, od = false; for (int i = 0; i < n; i++) { if (st[i] % 2 == 1 and i % 2 == 0) od = true; else if (st[i] % 2 == 0 and i % 2 == 1) ev = true; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 305; const int inf = 0x3f3f3f3f; const double eps = 1e-5; int n, c; int dp[605][N][N], a[N][N]; int max(int a, int b, int c, int d) { return max(max(a, b), max(c, d)); } int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int inf = 2012345678; const int N = 2e5 + 10; string s, ans, tmp; bool ch() { int i = 0; while (s[i] == tmp[i] && i < tmp.length()) ++i; return i == tmp.length(); } int main() { int n, k; cin >> n >> k >>... |
#include <bits/stdc++.h> using namespace std; char d[8][8]; int i, j, sch, k, m; int main() { k = 0; m = 0; for (i = 0; i < 8; i++) { sch = 0; for (j = 0; j < 8; j++) { cin >> d[i][j]; if (d[i][j] == B ) sch++; } if (sch == 8) k++; else if (sch ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { if (n % 10 == 0) n = n / 10; else n--; } cout << n; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, nn = 0, range; int a, b, c, d, pos, neg, ok = 1, finddd = 0; int ara[200], ara2[200]; scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { scanf( %d %d , &ara[i], &ara2[i]); if (ara2[i] == m || ara[i] == m) { ... |
#include <bits/stdc++.h> using namespace std; int n, k; char s[8][10]; int i; vector<int> p; int cnt() { int v[8]; int i, j; for (i = 0; i < n; i++) { v[i] = 0; for (j = 0; j < k; j++) v[i] = v[i] * 10 + (int)(s[i][p[j]] - 0 ); } int minv = v[0]; int maxv = v[0]; for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long t, n, h, i, j, x, y, z, k, e, m; string s; cin >> n >> m; x = 0; for (i = 1; i <= n; i++) { y = i / 5; z = (i + m) / 5; x += (z - y); } cout << x; return 0; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c< 0 | c> 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x *= sg... |
#include <bits/stdc++.h> using namespace std; int main() { int i, u, v, a, b, A, B, C; A = B = C = 0; cin >> a >> b; for (i = 1; i <= 6; i++) { u = abs(i - a); v = abs(i - b); if (u < v) A++; else if (u == v) B++; else C++; } cout << A <<... |
#include <bits/stdc++.h> using namespace std; const int n = 10000000; bitset<n> b; vector<int> v; void sieve() { b.set(); b[0] = 0; b[1] = 0; for (long long i = 2; i <= n; i++) { if (b[i]) { v.push_back(i); for (long long j = i * i; j <= n; j = j + i) { b[j] = 0... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; void checkmin(int &x, int y) { if (x > y) x = y; } void checkmax(int &x, int y) { if (x < y) x = y; } inline int read() { int x = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -1;... |
#include <bits/stdc++.h> using namespace std; const long long p = 1000000007; char s[100005]; long long w[100005]; long long te[100005] = {1}; void build() { for (int i = 1; i <= 100000; i++) { te[i] = (te[i - 1] * 10) % p; } } long long quick_mod(long long a, long long b) { long long ... |
#include <bits/stdc++.h> using namespace std; const long long int MAX = 1e6 + 5; const int N = 2e5 + 5; const long long int mod = 1e9 + 7; const long long int mx = 1e16; bool comp(const int a, const int b) { return a > b; } const double PI = 2 * acos(0.0); long long int fac[N]; void pre() { fac[0]... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { char s1[15], s2[15], s3[15]; int p[15]; scanf( %s%s , s1, s2); int len = strlen(s1); int pos = 0; for (int i = 0; i < len; i++) { if (s1[i] == + ) pos++; else pos--; }... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; string s; int main() { cin >> s; int len = s.size(); int index7[20], index2[20], index5[20], index0[20]; int sum7 = 0, sum0 = 0, sum5 = 0, sum2 = 0; for (int i = 0; i < len; i++) { if (s[i] == 5 ) { index5... |
#include <bits/stdc++.h> using namespace std; int n, m, cnt, ans, tot; unordered_map<long long, int> id; int op[400010], d[400010], fa[400010], rk[400010], lg[400010], hs[400010]; struct node { int u, v; long long h; void bb() { if (u > v) swap(u, v); h = (long long)u << 30 | v; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; int x; int dfs(int xx, int yy, int cc) { if (cc == 0) { if (xx == 1 || yy == 1) { int tt = xx * yy; if (tt % 2 == 0) return tt / 2; else return tt / 2 + 1; } else return ((xx + yy) * 2 - 4... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; const long long mod = 1e9 + 7; long long kissme(long long x, long long t) { long long ans = 1; while (t > 0) { if (t & 1) ans = ans * x % mod; x = x * x % mod; t >>= 1; ... |
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> cnt(200002, 0); for (int i = 0; i < n; i++) { cnt[a[i]]++; } int mx = 0; int res = 0; for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; int main() { istream& in = cin; int n; in >> n; vector<string> v; for (int i = 0; i < n; i++) { string str; in >> str; v.push_back(str); } set<char> use; map<char, set<char> > use2; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> i... |
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f = (ch == - ) ? -1 : 1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return f * x; } const int N = 500 + 5; const... |
#include <bits/stdc++.h> using namespace std; inline int gotcha() { int a = 0, b = 1, c = getchar(); while (!isdigit(c)) b ^= c == - , c = getchar(); while (isdigit(c)) a = a * 10 + c - 48, c = getchar(); return b ? a : -a; } int main() { ios::sync_with_stdio(false); cin.tie(0); cou... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int maxn = 1e5 + 5; vector<int> a[maxn]; vector<int> ans[maxn]; int n, m, cas = 0; void change2(int t) { ans[t].resize(m + 1); ans[t + 1].resize(m + 1); for (int i = 1; i <= m; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, u = 0, ans1 = 0, ans2 = 0; cin >> n >> m >> k; bool a[n][m]; long long sum[n + 2][m]; memset(sum, 0, sizeof(sum)); for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { cin >> a[i][j... |
#include <bits/stdc++.h> using namespace std; struct ii { string zl; int x, id; } zl[1000005]; bool cmp1(ii a, ii b) { if (a.x < b.x) return 1; if (a.x > b.x) return 0; return a.zl < b.zl; } bool cmp2(ii a, ii b) { return a.id < b.id; } int n, cnt, zhi[1000005], sz[1000005], i; long ... |
#include <bits/stdc++.h> using namespace std; int primes[10001]; int p[10001]; int numbers[10001]; int cnt; void sieve() { for (int a = 2; a <= 10000; ++a) if (primes[a] == 0) for (int b = 2; b * a <= 10000; b++) primes[a * b] = 1; int c = 0; for (int a = 2; a <= 10001; ++a) ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, m; int i = 0, tmp; int P, Q; cin >> n >> m; i = n; cin >> P; while (i--) { cin >> tmp; } cin >> Q; i = m; while (i--) { cin >> tmp; } int sm = 1, sn = 1; if (P < 0) sn = -1; ... |
#include <bits/stdc++.h> using namespace std; const int A = 1e7 + 10; const int B = 1e6 + 10; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; inline int read() { char c = getchar(); int x = 0, f = 1; for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = g... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007LL; long long large = 2000000000000000000LL; bitset<20011> vis; vector<int> primes; void sieve(long long n) { vis.set(); vis[0] = 0; vis[1] = 0; for (long long i = 2; i <= n; i++) { if (vis[i]) primes.push_back((in... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n; int a[N]; int f[N]; int sumf[N]; long long sum; long long best; vector<int> freq; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , a + i); f[a[i]]++; sum += a[i]; } if ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; struct par { ll l; ll r; }; int n; ll s; par mas[200100]; bool cmp(par a, par b) { return (a.l < b.l); } bool good(ll m) { vector<par> grp1; vector<par> grp2; vector<par> grp3; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, siz = 1e6 + 5; long long t, n, m, k, a[siz], dp[5002][5002], dp2[5002]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; string s; cin >> s; s = 0 + ... |
#include <bits/stdc++.h> using namespace std; double mod(double a, double b) { long long int val = a / b; return a - val * b; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); double a, b, m, vx, vy, vz; cin >> a >> b >> m >> vx >> vy >> vz; double sx, sy, sz, t, x0... |
#include <bits/stdc++.h> using namespace std; char F1[2000000]; char F2[2000000]; void computeLPSArray(string pat, int M, int* lps); void KMPSearch(string pat, string txt, vector<int>& st, vector<int>& end) { int M = pat.size(); int N = txt.size(); int lps[M]; computeLPSArray(pat, M, lps); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); char a[9][9], c; int i, j, x, y; string s; for (i = 0; i < 9; i++) { for (j = 0; j < 3; j++) { cin >> s; a[i][3 * j] = s[0]; a[i][3 * j + 1] = s[1]; a... |
#include <bits/stdc++.h> using namespace std; void Fast() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int RD() { int i; cin >> i; return i; } inline float RF() { float i; cin >> i; return i; } inline double RDO() { double i; cin >> i; ... |
#include <bits/stdc++.h> using namespace std; long long n, x, summ; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; summ += (x - 1); if (summ % 2) cout << 1 << endl; else cout << 2 << endl; } } |
#include <bits/stdc++.h> using namespace std; double t, k, d, start = 0, sum = 0; int main() { scanf( %lf%lf%lf , &k, &d, &t); if ((long long)k % (long long)d == 0) printf( %.1f n , t); else if (k >= t) printf( %.1f n , t); else { if (k > d) { long long a = k / d; ... |
#include <bits/stdc++.h> using namespace std; int N, M, i, dx, dy, y; int main() { scanf( %d %d , &N, &M); if ((N == 5 || N == 6) && M == 3) { printf( -1 n ); return 0; } dx = 9; dy = 5; y = 0; for (i = 0; i < M; i++) { printf( %d %d n , dx * i, y); y += dy * (i... |
#include <bits/stdc++.h> using namespace std; long long pos[11], neg[11], n, x, zero; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x == 0) zero++; if (x > 0) pos[x]++; if (x < 0) neg[abs(x)]++; } long long cnt = 0; cnt += zero * (zero - 1) / 2; ... |
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<int, pair<int, int>> a, const pair<int, pair<int, int>> b) { if (a.first == b.first) { return a.second.first > b.second.first; } else { return a.first < b.first; } } int main() { ios_base::sync_with_stdio(false); i... |
#include <bits/stdc++.h> int main() { int n, k, i, st = 0, cnt = 0; scanf( %d %d , &n, &k); int a[n]; for (i = 0; i < n; i++) { scanf( %d , &a[i]); } for (i = 0; i < n && k > 0; i++) { if (a[i] <= 8) { k -= a[i], cnt++; if (st > 0 && st <= (8 - a[i])) k -=... |
#include <bits/stdc++.h> using namespace std; struct Edge { int id; int u, v, w; } edges[100005]; int n, m; int d[100005], cost[100005]; bool path[100005]; vector<Edge> G[100005], ans; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < m; i++) { i... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9, MOD = INF + 7; long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); } long long power(long long a, long long b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); } long long mod(long long... |
#include <bits/stdc++.h> int main() { long n, m; scanf( %ld %ld , &n, &m); std::vector<long> a(n + 2, 0); a[n + 1] = m; for (long p = 1; p <= n; p++) { scanf( %ld , &a[p]); } long orig(0), off(0), mx(0); for (long p = n; p >= 0; p--) { if (p % 2) { off += a[p + 1] -... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int k = (n + 1) / 2; vector<int> A(k); for (int& a : A) scanf( %d , &a); int x; scanf( %d , &x); A.resize(n, x); long long sum = accumulate(begin(A), begin(A) + k, 0LL); long long min_sum = sum... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void smn(T &a, const T &b) { if (b < a) a = b; } template <class T> inline void smx(T &a, const T &b) { if (b > a) a = b; } template <class T> inline T rev(const T &a) { T _ = a; reverse(_.begin(), _.end()); re... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 10, md = 1e9 + 7; vector<long long> child[MAXN]; long long dp[2][MAXN], dp1[2][MAXN], dp2[2][2][MAXN]; void dfs(long long v) { long long s = child[v].size(); for (long long i = 0; i < s; ++i) { long long now = child[v][i]... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long t, a, b, x, y, n, z, z2; cin >> t; while (t--) { cin >> a >> b >> x >> y >> n; if (abs(a - x) + abs(b - y) < n) { n = abs(a - x) + abs(b - y); } long... |
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; void solve() { long long n, r; cin >> n >> r; long long ans = 0; if (r >= n) ans++; r = min(r, n - 1); if (r % 2) ans += r * ((r + 1) / 2); else ans += (r / 2) * (r + 1); cout << ans << n ; } int... |
#include <bits/stdc++.h> using namespace std; int n, q; void read() { scanf( %d%d , &n, &q); } void solve() { int p0 = 0, p1 = 0, l = 0; while (q--) { int t; scanf( %d , &t); if (t == 1) { int x; scanf( %d , &x); p1 = (p1 + x) % n; p0 = (p0 + x) % n; ... |
#include <bits/stdc++.h> using namespace std; bool o[30]; int main() { int m, n, i, x, mid; cin >> m >> n; for (i = 0; i < n; i++) { cout << m << endl; cin >> x; if (!x) return printf( %d n , m), 0; o[i] = x == -1; } i = -1; int l = 1, r = m - 1; while (l <= r) ... |
#include <bits/stdc++.h> using namespace std; int main() { int ans, h, r; double tmp; scanf( %d%d , &r, &h); ans = h / r * 2; tmp = h % r; if (r / 2.0 - tmp > 1e-8) ans++; else if (sqrt(3) / 2 * r - tmp > 1e-8) ans += 2; else ans += 3; printf( %d , ans); ret... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5; vector<long long> adj[N]; vector<pair<long long, long long> > lol[N]; long long x[N], y[N], z[N], vis[N], tin[N], low[N], bridge[N], comp[N], artificat[N], depth[N], par[N], path[N], timer, cur; void dfs1(long long node, long l... |
#include <bits/stdc++.h> using namespace std; const int N = 500000; const int M = 70; const int C = 300; const int MOD = 1e9 + 7; struct Point { int x[5]; Point() { for (int i = 0; i < 5; i++) x[i] = 0; } }; int n; Point a[N]; vector<int> res; Point diff(const Point &a, const Poi... |
#include <bits/stdc++.h> using namespace std; vector<int> eg[400005]; long long dep[400005]; int dfn[400005], sz[400005]; int a[400005]; int p[400005], w[400005]; int dfcnt = 0; int fa[400005][20]; void dfs(int a) { sz[a] = 1, dfn[a] = ++dfcnt; for (auto v : eg[a]) { if (v == p[a]) conti... |
#include <bits/stdc++.h> int n, k, a, b; int ask(int x, int y) { if (x == n) return 1; fflush(stdout); printf( 1 %d %d n , x, y); fflush(stdout); char s[5]; scanf( %s , s); fflush(stdout); return s[0] == T ; } int xxx(int l, int r) { int mid, res = 0; while (l <= r) { ... |
#include <bits/stdc++.h> int main() { int n; int x, y; int k; int l; scanf( %d , &n); for (x = 4; 2 * x < n; x++) { y = n - x; k = 0; l = 0; for (int i = 2; i < x; i++) { if (x % i == 0) k = 1; } for (int j = 2; j < y; j++) { if (y % j == 0) ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; using ii = pair<int, int>; using ll = long long; const int N = 2005; const int mod = 1e9 + 7; ll a[2005], b[2005]; ll lena[2005], lenb[2005]; int n, m; int main() { ios_base::sync_with_stdio(0);... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int nax = 1e6 + 10; long long fac[nax], ifac[nax], inv[nax]; long long ncr(int n, int k) { if (n < 0 || k < 0 || k > n) return 0; return fac[n] * ifac[k] % mod * ifac[n - k] % mod; } int main() { fac[0] = ifac... |
#include <bits/stdc++.h> using namespace std; int main() { long long T, i, j, n; char c[2], ca[4] = { v , < , ^ , > }, a, b; cin >> a >> b; map<char, long long> m; m[ca[0]] = 1; m[ca[1]] = 2; m[ca[2]] = 3; m[ca[3]] = 4; cin >> n; n = n % 4; if (n == 0) cout << u... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double PI = acos(-1); const int oo = 1e9, bpr = 1e9 + 7, N = 0; long long f[110]; int a[110]; long long d[110][4][4]; int n; inline long long calc(int ps, int v1, int v2) { if (ps == n) return v1 == 0 && v2 == 0; if (... |
#include <bits/stdc++.h> using namespace std; int main(void) { int level[26]; for (int i = 0; i < 26; i++) cin >> level[i]; string s; cin >> s; long long ans = 0; for (char ch = a ; ch <= z ; ch++) { map<long long, long long> m; long long sum = 0; for (int i = 0; i < s.le... |
#include <bits/stdc++.h> void stderr_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } using namespace std; struct flist { int val; int pos; }; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int i, j, k... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > q; struct node { int left, right, num[3]; } tree[4 * 100010]; struct NODE { int begin, end, value, next; } edge[50 * 100010 + 10];... |
#include <bits/stdc++.h> using namespace std; struct lex_compare { bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) const { return lhs.second > rhs.second; } }; void solve() { int n; cin >> n; vector<long long> v(n); for (int i = 0; i < n; i++) { cin >> v... |
#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,avx2,tune=native ) using namespace std; long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) {... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); int n; long long m, x; set<long long> v1; set<long long> v2; v1.insert(0); v2.insert(0); cin >> n >> m; long long ans = 0; for (int i = 0; i < n / 2; i++) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<vector<int> > v; bool transponer; void escribe() { if (transponer) { vector<vector<int> > nextv(m + 2, vector<int>(n + 2, 0)); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) nextv[j][i] = v[i][j]; swap(n... |
#include <bits/stdc++.h> int main() { int a, i; char b, c, x; scanf( %d , &a); scanf( %c , &b); for (i = 1; i <= a - 2; i++) scanf( %c , &x); scanf( %c , &c); if (b == S && c == F ) printf( YES ); else printf( NO ); } |
/* Jai Maa Saraswati!! */ #include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<string.h> #include<math.h> #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define ll long long #define pb push_back #define mod 1000000007 #define F first... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include <bits/stdc++.h> using namespace std; int read() { int f = 1, x = 0; char c = getchar(); while (c < 0 || 9 < c) { if (c == - ) f = -1; c = getchar(); } while ( 0 <= c && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return f * x; } const int... |
#include <bits/stdc++.h> using namespace std; static int N, K, M, G, U[500003], V[500003], W[500003], fa[500003], sup[500003], dep[500003]; static bool spe[500003]; static vector<pair<bool, int>> edge[500003]; static long long ans; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } voi... |
#include <bits/stdc++.h> int main() { int k, a, b, v; int sections; scanf( %d%d%d%d , &k, &a, &b, &v); sections = a / v; sections += ((a % v) != 0); int box = 0; k--; while (b > 0) { box++; if (b >= k) { b -= k; sections -= (k + 1); } else { se... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<vector<char> > v; v.resize(n, vector<char>(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> v[i][j]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.