func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = 500; const int MAXM = (int)1e5; vector<int> g[MAXN + 1]; int x[MAXM + 1], y[MAXM + 1]; int ok[MAXN + 1]; bool flag; vector<int> edge; void dfs(int nod) { ok[nod] = 1; edge.push_back(nod); for (auto it : g[nod]) { if (flag... |
#include <bits/stdc++.h> using namespace std; struct infmt { char name[15]; int region; int score; } a[100005]; bool cmp(infmt a, infmt b) { if (a.region == b.region) return a.score > b.score; else return a.region < b.region; } int main() { int m, n, i, j, k; scanf( %... |
#define _CRT_SECURE_NO_WARNINGS /* To Be or Not To Be !! Allah_Almost3aan Make it happens :) */ #include<bits/stdc++.h> #include<unordered_map> //#include<unorderd_set> using namespace std; using ll = long long; using ld = long double; const ll OO = 1e16; #define ed n #define F first //#def... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5; int main() { int t; cin >> t; int f[t]; memset(f, 0, sizeof(0)); for (int i = 0; i < t; ++i) { int x, y; cin >> x >> y; if (x > 0) f[i] = 1; else if (x < 0) f[i] = 0; } int sum = 0;... |
#include <bits/stdc++.h> using namespace std ; int i , j , n , m , a ; int main() { ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL) ; int mp[100] ; memset( mp , 0 , sizeof( mp)); cin >> n >> m ; for( i=0 ; i<n ; i++ ) cin >> a , !mp[a] ? mp[a] = i+1 : 1 ; ... |
#include <bits/stdc++.h> using namespace std; int locked[1000][1000], n, m, edges = 0; int mark[1000][1000]; void printGraph(vector<int> graph[]) { for (int i = 0; i < n; i++) { printf( %d -> , i + 1); for (auto j : graph[i]) printf( %d , j + 1); printf( n ); } } int main() { ... |
#include <bits/stdc++.h> using namespace std; long long t, n, m, u, v, q, k; const int N = 3e6 + 500; const int LN = 21; const long long mod = 1e9 + 7; const long long INF = 1LL << 57; long long arr[N]; string str, ss; vector<int> pos[N]; string s[N]; int pointer[N]; int main() { ios_base::s... |
#include <bits/stdc++.h> using namespace std; long long n, k, ans; bool chk_odd(long long lim) { long long get = 0, bas = 1, val = lim * 2 + 1; for (int i = 1; i <= 60; ++i, bas *= 2) { long long start = val * bas; if (start > n) break; get += min(bas, n - start + 1); } return ge... |
#include <bits/stdc++.h> using namespace std; struct point { double x, y; double angle; } a[1200000], chs[1200000]; bool cmp1(point a, point b) { if (a.y == b.y) return a.x < b.x; else return a.y < b.y; } bool cmp2(point a, point b) { if (a.angle == b.angle) return a.x ... |
#include <bits/stdc++.h> using namespace std; struct node { long long t, d, g, h, s, ds, dq, dis, sum; } A[100100]; int p[100100], nxt[2 * 100100], C[2 * 100100], V[2 * 100100], f[100100], g[100100][19], n, q, i, ed; int gi() { int s = 0; char c = getchar(); while (c < 0 || c > 9 ) c ... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long modulo(long long a, long long b) { ... |
#include <bits/stdc++.h> using namespace std; namespace FGF { int n; const int N = 5005; int dp[N], l[N], sum[N]; void work() { scanf( %d , &n); for (int i = 1, x; i <= n; i++) scanf( %d , &x), sum[i] = sum[i - 1] + x; memset(dp, 0x3f, sizeof(dp)), memset(l, 0x3f, sizeof(l)); dp[0] = l[0] = ... |
#include <bits/stdc++.h> int n; char s[500]; int main() { gets(s + 1); n = strlen(s + 1); int i = 1, ok = 0; if (s[1] == d && s[2] == o && s[3] == t ) printf( dot ), i = 4; for (; i <= n; i++) { if (i == n - 2 && s[i] == d && s[i + 1] == o && s[i + 2] == t ) { printf( d... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long int, long long int> a, pair<long long int, long long int> b) { return a.first < b.first; } bool check(int a) { int sum = 0; while (a > 0) { sum += (a % 10); a /= 10; } if (sum == 10) return true; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 4e5 + 1; int a[MAXN], b[MAXN]; const int MOD = 1e9 + 7; int bit[MAXN]; void add(int pos, int val) { while (pos < MAXN) { (bit[pos] += val) %= MOD; pos += pos & -pos; } } int query(int pos) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> houses, shops; int lasthouse = -1, lastshop = -1; bool check(int k, int t, string s) { int l = s.length(), min_index = -1, ans = 0, ct = 0; int ans2 = t + 1; if (lasthouse > lastshop) { if (lastshop == -1) { if (k < houses[lasth... |
#include <bits/stdc++.h> using namespace std; int n, m, a[101]; void read(int &x) { char ch; x = 0; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - 0 ; ch = getchar(); } } void init() { read(n), read(m); for (int i = 1; i <= n; ++i) rea... |
#include <bits/stdc++.h> using namespace std; double x, y, z, s; int n, a, b, c, v[300010], p[300010], l[300010], r[300010]; bool cmp(int x, int y) { return v[x] < v[y]; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &v[i]), l[i] = i - 1, r[i] = i + 1, p[i] = i; sor... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n, count = 1, ans = 0, a, b, freq[N] = {0}, pf, v; cin >> n; for (int i = 0; i < n; i++) {... |
#include <bits/stdc++.h> using namespace std; long long dp[200005][2]; long long a[200005], b[200005]; void solve() { long long n, c; cin >> n >> c; for (int i = 0; i < n - 1; i++) cin >> a[i]; ; for (int i = 0; i < n - 1; i++) cin >> b[i]; ; dp[1][1] = c; for (int i = 2; i < n +... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 1) cout << 8 << endl; else if (!n) cout << 1 << endl; else if (n % 4 == 0) cout << 6 << endl; else if (n % 4 == 1) cout << 8 << endl; else if (n % 4 == ... |
#include <bits/stdc++.h> const int maxn = 100100; int t, T, n, m, n0, n1; int l[maxn], r[maxn], c[maxn], vis[maxn]; std::vector<int> v[maxn]; std::queue<int> q; inline void dfs(int x) { if (vis[x]) return; vis[x] = 1; for (auto i : v[x]) c[i] = !c[x], dfs(i); } int main() { std::ios::syn... |
#include <bits/stdc++.h> using namespace std; int ans = 0; vector<vector<int> > data; void relax(int &a, int &b, int c) { if (c > a) { b = a; a = c; } else b = max(b, c); } pair<int, int> dfs(int vertex, int last) { int take = 0, take2 = 0, non = 0, non2 = 0; for (int i = 0... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << = << a << n ; err(++it, args...); } const int M = 1e9 + 7, N = 2e5 + 5; int main() { io... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1e9) + 7; bool mark[2501][101]; long long a[2501][101]; long long dp(int x, int y) { if (x > 0 && y == 0) return 0; if (x == 0 && y == 0) return 1; if (mark[x][y]) return a[x][y]; long long ans = 0; for (int i = 0; i <= min(25... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; long long deg[123456]; long long N, S, i, s, e; long long cnt; long double ans; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> S; for (i = 1; i < N; i++) { cin >> s >> e; deg... |
#include <bits/stdc++.h> using namespace std; template <class T> int read(T& x) { int c = getchar(), f = (x = 0); while (~c && (c < 48 || c > 57)) { if (c == - ) { f = 1; } c = getchar(); } if (!~c) { return 0; } while (c > 47 && c < 58) { x = (x << 3... |
#include <bits/stdc++.h> int main() { using namespace std; ios_base::sync_with_stdio(false), cin.tie(nullptr); int tt; cin >> tt; while (tt--) { int N; cin >> N; string s; cin >> s; auto solve = [&](void) -> void { for (int i = 0; i < N - 10; ++i) { ... |
#include <bits/stdc++.h> using namespace std; long long int calculate(long long int p, long long int q) { long long int modx = 998244353, expo; expo = modx - 2; while (expo) { { if (expo & 1) p = (p * q) % modx; } q = (q * q) % modx; expo >>= 1; } return p % modx;... |
#include <bits/stdc++.h> using namespace std; const int inf = 987654321; const long long int INF = 123456789987654321; FILE *fin, *fout; int V, edge_cnt, source, sink; vector<int> last_edge, nxt_edge, oppo, capa; void init() { edge_cnt = 0, last_edge.clear(), nxt_edge.clear(), oppo.clear(), capa.clear... |
#include <bits/stdc++.h> using namespace std; int dpr[107]; int dps[107]; int dpc[107]; int a[107]; int main() { int n; scanf( %d , &n); for (int i = 1; i < n + 1; i++) scanf( %d , a + i); dpr[1] = 1; dps[1] = (a[1] == 2 || a[1] == 3) ? 0 : -1; dpc[1] = (a[1] == 1 || a[1] == 3) ? 0 :... |
#include <bits/stdc++.h> using namespace std; vector<int> adjl[4009]; set<pair<int, int> > st; int main() { int n, m, a, b; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a >> b; adjl[a].push_back(b); adjl[b].push_back(a); st.insert(pair<int, int>(a, b)); st.inser... |
#include <bits/stdc++.h> const int Maxn = 50005; int N, A[Maxn]; double L[Maxn], P[Maxn], Sum[Maxn], Ans; using namespace std; bool Cmp(const int &i, const int &j) { return (L[i] * P[i] * (1 - P[j] / 100)) > (L[j] * P[j] * (1 - P[i] / 100)); } int main() { scanf( %d , &N); for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long int fact[2 * 10000... |
#include <bits/stdc++.h> using namespace std; unsigned int gcd(unsigned int x, unsigned int y) { unsigned int temp; if (x < y) { temp = x; x = y; y = temp; } for (unsigned int i = y; i > 0; i--) { if ((x % i == 0) && (y % i == 0)) return i; } return x; } int main(... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, i; cin >> a >> b; int n; for (i = 0; i < 10; i++) { if (a < b) { a = a * 3; b = b * 2; } else if (a > b) { cout << i; break; } else if (a == b) { cout << i + 1; brea... |
#include <bits/stdc++.h> using namespace std; int a[1500][1500]; int visited[1500][1500]; int n, m; struct node { int x, y; }; node vis[1500][1500]; int main() { int sx, sy; char x; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { scanf( n ); for (int j = 0; j < m; j... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long int t = 0; long long int i, x = 0; while (1) { t = 0; long long int l = s.length(); if (s.length() == 1) { break; } for (i = 0; i < l; i++) { t += s[i] - 0 ; ... |
#include <bits/stdc++.h> using namespace std; const long long M = (long long)1e9 + 7; const double PI = 2 * acos(0.0); const long long oo = 1e17 + 100; const string DIGITS = 0123456789 , alph = abcdefghijklmnopqrstuvwxyz , ALPH = ABCDEFGHIJKLMNOPQRSTUVWXYZ ; const long long N = (long long)... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n, m; cin >> n >> m; string s[n], v[n], a[n], o[n], b[n]; bool t[n]; string buf; for (long long i = 0; i < n; i++) { cin >> s[i]; cin >> buf; cin >> buf; t[i] = isdigit(buf[0]); if (t[i]) ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; int arr[m]; for (int i = 0; i < m; i++) cin >> arr[i]; int amount = 0; sort(arr, arr + m); int count = 0; for (int j = 0; j < m; j++) { if (arr[j] < 0 && count < n) { amount += (-arr[j])... |
#include <bits/stdc++.h> using namespace std; int pd(int ans) { if (ans == 1 || ans == 2 || ans == 3 || ans == 5 || ans == 7 || ans == 11) return -1; int num = ans / 4 - ans % 2; return num ? num : -1; } int main() { int n, m; while (~scanf( %d , &n)) { for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> int main() { long long int a, b; double n = 1.000000011, g, h; scanf( %lld %lld , &a, &b); g = pow(n, b); h = a * g; printf( %.10lf , h); return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 9; int book[maxn]; int main() { int q, x; scanf( %d%d , &q, &x); int now = 0; int hu = 0, ans = 0; while (q--) { int y; scanf( %d , &y); int h = y % x; book[h]++; if (h == now) { ans++;... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 999998727899999ll, MAXN = 300001; long long c[MAXN]; vector<long long> g[MAXN]; set<long long> s[MAXN]; string t; bool mark[MAXN]; long long base = 101; long long diff[MAXN]; long long ans[MAXN]; long long n; void dsu(long long ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct TMat { long long a[16][16]; } base, start; int n, i, c; long long k, a, b; void init() { memset(base.a, 0, sizeof(base.a)); for (int i = 0; i < 16; i++) base.a[i][i] = 1; start = base; } TMat cur(const int &c... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops,no-stack-protector,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; using i32 = int; using i64 = long long; using u8 = unsigned char; using u32 = unsigned; using u64 = unsigned... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int UNDEF = -1; const long long INF = 1e18; template <typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; } template <typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ?... |
#include <bits/stdc++.h> using namespace std; long long int spf[100001]; void sieve(); set<long long int> factors(long long int x); void getZarr(string str, long long int Z[]); int n; vector<int> ans; vector<bool> vis; vector<int> mas; vector<int> del; vector<int> koll; vector<vector<int>> edges... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, sum1 = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] >= 0) { sum += a[i]; } else sum1 += a[i]; } cout << sum - sum1 << endl; } |
#include <bits/stdc++.h> using namespace std; int N, cnt1 = 0, cnt2 = 0; int main(int argc, char *argv[]) { string a, b; cin >> N; for (int i = 1; i <= N; i++) cin >> a >> b, cnt1 += (b == soft ), cnt2 += (b == hard ); for (int i = 1; i <= N; i++) { int q1 = i * i / 2, q2 = (i * i + ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int hm = 0, wm = 0; for (int i = 0; i < (int)(n); i++) { char c; int h, w; cin >> c >> h >> w; if (h < w) { swap(h, w); } if (c == + )... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, k; char str[MAXN]; vector<int> loc[2]; int main() { scanf( %d%d%s , &n, &k, str); for (int i = 0; i < n; i++) loc[str[i] - 0 ].push_back(i); if (loc[0].empty() || loc[1].empty()) return 0 * printf( tokitsukaze n ); ... |
#include <bits/stdc++.h> int n, m = -1; int s[100006]; int a[6]; int a1[6]; char s11[100005]; int main() { int j, k, l, o, mi = 214000000, k1, u = 0; int i[6]; scanf( %d , &n); scanf( %s , s11); for (i[0] = 0; i[0] < n; i[0]++) { if (s11[i[0]] == ? ) s[i[0]] = 0; if (s11[i[0... |
#include <bits/stdc++.h> using namespace std; int n, m, d; long long din[2][150003]; long long a[303]; long long mx[150003]; long long b[303]; long long t[303]; deque<long long> deq; int main() { cin >> n >> m >> d; t[0] = 0; for (int i = 0; i < m; i++) { cin >> a[i + 1] >> b[i + 1] ... |
#include <bits/stdc++.h> using namespace std; int main() { int l, p, q; cin >> l >> p >> q; double ans; ans = (double)l * p / ((p + q)); cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; int k = s.size(); if (s[k - 1] == o ) cout << FILIPINO << endl; else if (s[k - 1] == u ) cout << JAPANESE << endl; else ... |
#include <bits/stdc++.h> using namespace std; double w, h, d; const double pi = acos(-1); int main() { scanf( %lf%lf%lf , &w, &h, &d); if (d >= 90) d = 180 - d; if (w < h) swap(w, h); if (d == 0 || d == 180) printf( %.10f n , w * h); else if (d == 90) printf( %.10f n , min(w, h) ... |
/* cerberus97 - Hanit Banga */ #include <iostream> #include <iomanip> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> #include <numeric> ... |
#include <bits/stdc++.h> using namespace std; int main() { float a, b, l, s = 0; cin >> a >> b >> l; s = (b * a) / (b + l); cout << s << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, x, y, z; cin >> a >> b >> c >> x >> y >> z; long long int a1, b1, c1; a1 = a - x; b1 = b - y; c1 = c - z; long long int pol = 0, otr = 0; pol += max(a1 / 2, (long long)0) + max(b1 / 2, (long long)0) + ... |
#include <bits/stdc++.h> using namespace std; int N, M; vector<vector<int> > G; vector<long long> cnt; vector<long long> dp; int main(int argc, char const* argv[]) { cin >> N >> M; for (int i = 0; i < N; i++) { G.push_back(vector<int>()); cnt.push_back(0); dp.push_back(1); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int x, y, z; cin >> x >> y >> z; int a_rest = 0, a_sh = 0, b_rest = 0, b_sh = 0, c_sh = 0, c_rest = 0; if (a > x) { a_rest = a - x; if (a_rest % 2 == 1) a_rest--; a_sh = 0; } els... |
#include <bits/stdc++.h> using namespace std; struct SCC { int n; vector<int> comp, order; vector<bool> used; vector<vector<int> > G, RG; SCC(int _n = 0) : n(_n), comp(_n, -1), used(_n, false), G(_n), RG(_n) {} void add_edge(int from, int to) { G[from].push_back(to); RG[to].push_... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; if (n == m) { cout << n - 1 << << n; } else if (n > m) { cout << n - 1 << << m; } else cout << m - 1 << << n; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v, v1; for (int i = 0; i < n; i++) { int t, y; cin >> t >> y; v.push_back(t); v1.push_back(y); } sort(v.begin(), v.end()); sort(v1.begin(), v1.end()); long long ans = n; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 100009; struct query { long long a, b, op, s; } q[N * 9], b[N * 9]; long long n, m, a[N], ans[N], cnt, cntq, tr[N]; set<long long> Set[N]; inline void add(long long x, long long c) { while (x <= n) { tr[x] += c, x += (x & -x);... |
#include <bits/stdc++.h> using namespace std; long long int func(char c) { if (c >= a && c <= z ) { return 1; } if (c >= A && c <= Z ) { return 2; } return 0; } void solve() { string s; cin >> s; long long int lw = 0; long long int up = 0; long long int ... |
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n, k, l, r, sall, sk, i, res, ext, j, a, b; while (scanf( %d %d %d %d %d %d , &n, &k, &l, &r, &sall, &sk) == 6) { v.clear(); if (sk % k == 0) { res = sk / k; for (i = 0; i < k; i++) { v.push... |
#include <bits/stdc++.h> using namespace std; bool pr[10000005] = {false}; vector<long long> prime; void prim() { pr[0] = true; pr[1] = true; for (long long i = 2; i <= sqrt(100005); i++) { for (long long j = i * 2; j <= sqrt(100005); j += i) { pr[j] = true; } } } vector<... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; string s; cin >> s; n = s.size(); int z = 0, o = 0; for (int i = 0; i < n; i++) { if (s[i] == 1 ) o++; else z++; } if (min(o, z) & 1) { cout << DA n ; } else { cout << N... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; getline(cin, s1); getline(cin, s2); int a; for (int i = 0; i < s2.size(); i++) { if (s2[i] == ) continue; a = 0; for (int j = 0; j < s1.size(); j++) if (s1[j] == ) continue; ... |
#include <bits/stdc++.h> int x[30]; template <class T> inline void read(T &num) { num = 0; char c = getchar(); T sign = 1; while (c < 0 || c > 9 ) { if (c == - ) sign = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { num = (num << 1) + (num << 3) + (c ^ 48); ... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; const int N = 155; int old[N][N * N]; int now[N][N * N]; int q[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, k, s; cin >> n >> k >> s; for (int i = 0; i < n; i++) cin >> q[i]; for (int... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; vector<int> col; int n, m; void dfs(int v) { int cnt = 0; for (size_t i = 0; i < g[v].size(); i++) if (col[g[v][i]] == col[v]) cnt++; if (cnt > 1) { col[v] ^= 1; for (size_t i = 0; i < g[v].size(); i++) ... |
#include <bits/stdc++.h> using namespace std; int cnt0, cnt1, timer; void dfs(int v, vector<int> &colour, vector<int> &comp, vector<vector<pair<int, int>>> &g) { if (colour[v] == 0) cnt0++; else cnt1++; comp[v] = timer; for (auto &now : g[v]) if (colour[now.first] == -... |
#include <bits/stdc++.h> using namespace std; template <class T> using VV = vector<vector<T>>; template <class T> inline T SMIN(T& a, const T b) { return a = (a > b) ? b : a; } template <class T> inline T SMAX(T& a, const T b) { return a = (a < b) ? b : a; } template <class Iter> void __ku... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long n, k; vector<long long int> v[50005]; long long ans; vector<long long int> dfs(long long node, long... |
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 9; int Pow(int x, int e) { int ret = 1; while (e) { if (e & 1) ret = 1ll * ret * x % Mod; x = 1ll * x * x % Mod; e >>= 1; } return ret; } const int N = 1e5 + 10; char S[N]; int main() { int n, a, b, k... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, su = 0; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; ++i) { cin >> a[i]; su += a[i]; } if (su % 2) { cout << NO n ; return; } long long s = 0, ind = -1; for (long ... |
#include <bits/stdc++.h> int main() { int vladik, valera; std::cin >> vladik >> valera; int vladik_rounds = sqrt(vladik); int valera_rounds = valera > vladik_rounds ? sqrt(valera - vladik_rounds) : 0; if (valera_rounds >= vladik_rounds) { std::cout << Vladik n ; } else { std::cout... |
#include <bits/stdc++.h> const int NUM = 100010; const double eps = 1e-10, pi = acos(-1.0); using namespace std; int n; vector<int> g[NUM]; pair<int, int> node[NUM], edge[NUM]; int tot, cnt; void dfs(int u, int p, int x) { for (int i = 0; i < g[u].size(); i++) if (g[u][i] != p) { node[... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, c0, c1, h; cin >> n >> c0 >> c1 >> h; string second; cin >> second; int cost1 = 0, z = 0, o = 0; for (int i = 0; i < second.length(); i++) { if (second[i] == 0 ) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j, b, p, f, h, c, sum; cin >> t; while (t--) { cin >> b >> p >> f >> h >> c; sum = 0; b /= 2; if (h < c) { if (b < f) { sum += (c * b); b = 0; } else if (b > f) { su... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long s, x; cin >> s >> x; bool flag = true; bool valid = true; if ((s & 1) != (x & 1)) valid = false; long long ans = 1; for (int i = 62; i >= 1; i--) { long long sb = (s >> i) & 1; ... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ... |
#include <bits/stdc++.h> int a[2005]; int n, k; int main() { scanf( %d , &k); k += 2; int len = 0; a[len++] = -1; int res; while (k > 1000000) { k++; a[len++] = 1000000; k -= 1000000; } a[len++] = k; printf( %d n , len); for (int i = 0; i < len; i++) print... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int sz[N], col[2]; int n; long long ans = 0, odd; vector<int> V[N]; void dfs(int a, int fa, int zt) { sz[a] = 1; col[zt]++; for (int i = (0); i < (((int)(V[a]).size())); ++i) { int nxt = V[a][i]; if (nxt == fa) co... |
#include <bits/stdc++.h> using namespace std; int ara[100010]; int cnt[50]; int func(int x) { if (x == 0) return 0; if (x % 2 == 0) { return func(x / 2); } else { return 1 + func(x - 1); } } int main() { std::ios_base::sync_with_stdio(false); ; int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; long long m, mi, mid; long long v[3]; v[0] = a; v[1] = b; v[2] = c; sort(v, v + 3); a = v[2]; b = v[0]; c = v[1]; if (a - b < c) { cout << 0 ; } else { m... |
#include <bits/stdc++.h> using namespace std; template <class T> void printArray(const T* a, int n, ostream& out = cerr); template <class T> void printArray(const vector<T>& arr, ostream& out = cerr); const long long mod = 1e9 + 7; const double PI = acos(-1); int n, i, j, k, t; int m; int a[200002];... |
#include <bits/stdc++.h> using namespace std; std::vector<long long> a; long long sm = 0; long long n, m; bool doo(long long x) { long long res = 0; for (long long i = 0; i < x; ++i) { res += a[i]; long long k = i + x; long long count = 1; while (k < n and a[k] - count > 0) { ... |
#include <bits/stdc++.h> using namespace std; vector<long long> v1[1000100]; vector<long long> v2; map<long long, long long> m1; map<long long, long long> m2; map<long long, long long> m3; map<char, long long> ms1; map<string, long long> ms2; stack<long long> sta; long long big = 999999999999999999,... |
#include <bits/stdc++.h> using namespace std; int segtree[400001]; int val[100001]; int inf = (1 << 30) - 1; void build(int l, int r, int pos) { if (l == r) { segtree[pos] = val[r]; return; } int mid = (l + r) / 2; build(l, mid, 2 * pos + 1); build(mid + 1, r, 2 * pos + 2); ... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { int t; cin >> t; for (; t--;) { cin >> n >> m; if (n == 1) { cout << 0 << endl; continue; } int ansl = 0, ansr = n, ans = (ansl + ansr) / 2; for (; ansl < ansr; ans = (ansl + ansr) / 2) {... |
#include <bits/stdc++.h> using namespace std; const int N = 102; pair<int, int> ar[N]; bool used[N]; vector<deque<int>> vc; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> ar[i].first >> ar[i].second; for (int i = 1; i <= n; ++i) { if (used[i]) continue; deque<i... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long rnd(long long l, long long r) { return l + rng() % (r - l + 1); } const long long N = 5e5 + 5; const long long K = 5005; long long n, a[N], k; long long f[2][K][2]; void minimize(... |
#include <bits/stdc++.h> using namespace std; using namespace std; int n1, n2, m, R, B, mxn, E[10005], nxt[10005], hd[10005], to[10005], adj[10005], cost[10005], cur[10005], dis[10005], D[10005], second, T, s, t, tot = 0, mnc = 0; bool vis[10005], inq[10005]; char s1[10005], s2[10005]; inline vo... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int C = 26; void add(int &x, int y) { x += y; while (x >= MOD) x -= MOD; while (x < 0) x += MOD; } int fix(int x) { while (x >= MOD) x -= MOD; while (x < 0) x += MOD; return x; } int pw(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m, o, p, x, y, z; vector<long long> a, b, c, d; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { cin >> n; string s; cin >> s; int leftFirst = -1; int ri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.