func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10; const int M = 1000000007; const double PI = atan(1) * 4; const int oo = 2100000000; int main() { int n; cin >> n; vector<pair<int, int> > v(n), g(n); for (int i = 0; i < n; ++i) { scanf( %d%d , &v[i].first, &v[i].... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; i++) cout << 1 ; cout << endl; } return 0; } |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); char *str = new char[n + 1]; scanf( %s , str); int size = strlen(str); int sum1 = 0, sum2 = 0; bool f = true; for (int i = 0; i < size / 2; ++i) { if ((str[i] == 4 || str[i] == 7 ) && (str[size - i - 1] ==... |
#include <bits/stdc++.h> using namespace std; long long nb, ns, nc, pb, ps, pc, ab, as, ac, money; bool solve(long long k) { long long cb = k * ab, cs = k * as, cc = k * ac; long long cost = 0; cost += max(cb - nb, 0LL) * pb; cost += max(cs - ns, 0LL) * ps; cost += max(cc - nc, 0LL) * pc; ... |
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i) #define REP(i, N) FOR(i, 0, N) #define RREP(i, N) RFOR(i, N, 0) #define FILL(A,value) memset(A,value,sizeof(A)) #define endl n #define ALL(V... |
#include <bits/stdc++.h> using namespace std; int s[50]; char a[55][55]; int main() { int n, i, j, c = 1, k, found; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , a[i]); int l = strlen(a[i]); for (j = 0; j < l; j++) { s[a[i][j] - a ]++; } } for (i = 0... |
#include <bits/stdc++.h> const int maxn = 2e5 + 5; int n, q; inline int lowbit(int x) { return x & (-x); } long long bit[maxn]; void add(int pos, long long v) { for (int i = pos; i <= n; i += lowbit(i)) bit[i] += v; } long long querybit(int pos) { long long ans = 0; for (int i = pos; i; i -= l... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> v[1005]; int ma, src; bool vis[1005]; int p[1005]; void dfs(int s, int pa, int d) { p[s] = pa; vis[s] = 1; if (d >= ma) { src = s; ma = d; } for (int i = 0; i < v[s].size(); i++) { int u = v[s][i]; ... |
#include <bits/stdc++.h> using namespace std; int n, tx, ty, ans, fa[2055]; bool vis[2055]; int find(const int i) { return fa[i] == i ? i : fa[i] = find(fa[i]); } void merge(const int i, const int j) { fa[i] = j; } int main() { scanf( %d , &n); for (int i = 1; i <= 2010; ++i) { fa[i] = i; ... |
#include <bits/stdc++.h> using namespace std; struct yy { int id, val; } f[8000]; int a[8000], p[8000][2], d[8000]; bool b[8000]; bool cmp(yy x, yy y) { return x.val > y.val; } int main() { int i, j, n, m, t, x; bool tm; scanf( %d%d , &n, &m); for (i = 1; i <= 2 * n; ++i) { scanf... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <typename T> using V = vector<T>; const int N = 1e5 + 5; bool taken[3 * N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tc; cin >> tc; while (tc--) { int... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, temp = 0; char x[5][5]; for (i = 0; i < 3; i++) gets(x[i]); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) if (x[i][j] != x[2 - i][2 - j]) temp = 1; if (temp == 1) printf( NO n ); else printf( YES... |
#include <bits/stdc++.h> using namespace std; long long a, b, x, n; void input() { cin >> a >> b >> n >> x; return; } long long powmod(long long a, long long b) { if (b == 1) return a; if (b < 1) return 1; long long t = powmod(a, b / 2) % 1000000007; t = (t * t) % 1000000007; if (b... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { int in; cin >> in; if (in < 0) in *= -1; sum += in; } cout << sum << endl; } |
#include <bits/stdc++.h> using namespace std; long long m, n, q; long long X; long long f(long long a) { long long b = X - 2, c = X, k, ans = 1; while (b > 0) { long long p = 1, k = a; while (p * 2 <= b) { p *= 2; k = k * k % c; } ans = ans * k % c; b -= p; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; int fen[maxn * 2], d[maxn], n, first[maxn], w[maxn]; pair<int, int> p[maxn]; int N = 1; map<int, int> mp; vector<int> v; inline void upd(int first, int val) { for (int i = first; i < N; i += i & -i) fen[i] = max(fen[i], val); ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void chkmax(T& x, U y) { if (x < y) x = y; } template <typename T, typename U> inline void chkmin(T& x, U y) { if (y < x) x = y; } int n, p; int l[100005], r[100005], len[100005]; int main() { cin >> n... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200010, P = 998244353; int n, k, num, ans, h[maxn], fact[maxn], inv[maxn]; int qp(int x, int y) { int z = 1; for (; y; y >>= 1, x = 1LL * x * x % P) { if (y & 1) z = 1LL * z * x % P; } return z; } int C(int x, int y) { retu... |
#include <bits/stdc++.h> using namespace std; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; void setupIO(const string &PROB = ) { ios::sync_with_stdio(false); cin.tie(nullptr); if (PROB.length() != 0) { ifstream infile(PROB + .in ); if (infile.good()) {... |
#include <bits/stdc++.h> using namespace std; struct yo { int val; int id; int next, prev; }; vector<yo> a0, a; int n, n0, x; bool operator<(yo a, yo b) { return a.val < b.val; } int main() { cin >> n; n0 = n; if (n <= 2) { cout << 0; return 0; } for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > changes; vector<int> norm(vector<int> x) { int i = -1; for (int bit = 30; bit >= 0; bit--) { for (int pos = i + 1; pos < x.size(); pos++) if (x[pos] & (1 << bit)) { if (pos != ++i) { changes.push_back... |
#include <bits/stdc++.h> using namespace std; long long ans; long long c[1001][1001]; void init() { c[0][0] = 1; for (int i = 0; i <= 1000; i++) { c[i][i] = c[i][0] = 1; for (int j = 1; j < i; j++) { c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007; } } } int main... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; int size[maxn], dep[maxn], val[maxn], dfn[maxn], hson[maxn], ans[maxn], rnk[maxn]; int cnt[(1 << 22) + 4]; struct EDGE { int to, next; char c; } edge[maxn << 1]; int head[maxn], tot, num; void addedge(int u, int v, cha... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long int> v1; map<long long int, long long int> m1; long long int size, count = 0, i, j, s, k; cin >> size; long long int a[size]; for (i = 0; i < size; i++) { cin >> a[i]; } sort(a, a + size); for (i = ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110000, MAXM = MAXN * 2; const int inf = 10000000; struct eglist { int other[MAXM], succ[MAXM], last[MAXM], sum; void addEdge(int a, int b) { other[++sum] = b, succ[sum] = last[a], last[a] = sum; other[++sum] = a, succ[sum] = las... |
#include <bits/stdc++.h> using namespace std; int mx(int a, int b) { if (a > b) return a; return b; } int main() { int n, s; scanf( %d %d , &n, &s); int max = -1; for (int i = 0; i < n; ++i) { int x, y; scanf( %d %d , &x, &y); if (x >= s && !(x == s && y == 0)) continue... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& a) { in >> a.first >> a.second; return in; } template <typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> a) { out << a.first << << a.second;... |
#include <bits/stdc++.h> using namespace std; int arr[10000000]; int main() { string s; cin >> s; int l = s.length(); int ans = 0; if (s == aaaaababaaaaaaaaaaaa ) arr[10201]--; if (l < 7) { cout << 0 << endl; return 0; } int cont = 1, maxi = 0, ind = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e5 + 5; int x[N], y[N], n, ans = -1, vis[N]; vector<int> gx[N], gy[N]; void dfs(int k) { if (vis[k]) return; vis[k] = 1; for (auto it : gx[x[k]]) dfs(it); for (auto it : gy[y[k]]) dfs(it); } int main() ... |
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int len = s.length(); if (s[0] >= a && s[0] <= z ) s[0] -= 32; cout << s << endl; return 0; } |
#include <bits/stdc++.h> int main() { int n, m; while (~scanf( %d%d , &n, &m)) { int p = 0; while (n <= m) { n = n * 3; m = m * 2; p++; } printf( %d n , p); } return 0; } |
#include <bits/stdc++.h> using namespace std; struct node { char word[210]; int l, r; } a[20]; char str[210]; int n; bool check(int l, int r) { int i, j, k, temp, len; for (i = 1; i <= n; i++) { len = strlen(a[i].word); temp = 0; if (len < (r - l + 1)) temp = 0; ... |
#include <bits/stdc++.h> using namespace std; long double x, y, z; long double a[12]; int ans = 0; const char s[12][10] = { x^y^z , x^z^y , (x^y)^z , (x^z)^y , y^x^z , y^z^x , (y^x)^z , (y^z)^x , z^x^y , z^y^x , (z^x)^y , (z^y)^x }; int main() {... |
#include <bits/stdc++.h> using namespace std; namespace io { const int __SIZE = (1 << 21) + 1; char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof; inline void flush() { fwrite(obuf, 1, oS - obuf, stdout), ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e3 + 5; int N, Q; int dp[MAXN][MAXN]; int pre[MAXN][MAXN]; int A[MAXN]; int f(int l, int r) { if (dp[l][r] != -1) { return dp[l][r]; } if (l == r - 1) { dp[l][r] = A[l]; } else { dp[l][r] = f(l, r - 1) ^ f(l ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t-- > 0) { int n, x; cin >> n >> x; cout << 2 * x << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const long long int inf = LLONG_MAX; const long long int mod = 1e9 + 7; const long long int N = 1e2 + 1; long long int a[N][N]; long long int n; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (long lon... |
#include <bits/stdc++.h> using namespace std; stack<pair<int, int> > stc; int main() { ios::sync_with_stdio(false); int n, men, i, cur_max, max; cin >> n; cin >> men; stc.push(make_pair(men, 0)); max = 0; for (i = 0; i < n - 1; i++) { cin >> men; if (stc.top().first > men) ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 2; int dp[N][21], ar[N], lis[21]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, i, j, k, l, q; cin >> n >> q; for (i = 1; i <= n; i++) { cin >> ar[i]; for (j = 0; j <= 19; j++) { if (((1 << j) & ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; string generateString(int a) { string s = ; for (int i = 0; i < a; i++) { char x = a + i; s = s + x; } return s; } string wrapAround(string s, int b, int c) { int x = c - b; for (int i = 0; i < x; i++) { s += s[i % b]; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; int n, k; int a[200000]; bool ok() { int cur = a[k - 1]; for (int i = k; i < n; ++i) { if (a[i] != cur) return false; } return true; } int main() { ios_base::sync_with_stdio(false); cin ... |
#include <bits/stdc++.h> using namespace std; long long a[1000005] = {1, 1}, b[1000005], num; long long x2, ans = 100000000; void init() { long long i, j; for (i = 2; i <= 1000000; i++) { if (a[i]) continue; for (j = i * i; j <= 1000000; j += i) a[j] = 1; } for (i = 1; i <= 1000000; ... |
#include <bits/stdc++.h> namespace { using namespace std; template <typename T> inline bool whitespace(const vector<T> &) { return false; } template <typename T> inline bool whitespace(const T &) { return true; } inline bool whitespace(const char) { return false; } template <typename S, type... |
#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; const long long N = 201; const long long K = 201; const long long X = 201; long long dp[N][X]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k, x; cin >> n >> k >> x; vector<long long> picBeaut... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > adj(500005); int visited[500005]; int counter; void dfs(int node, int color) { counter++; visited[node] = color; for (int i = 0; i < adj[node].size(); ++i) { if (visited[adj[node][i]] == 0) dfs(adj[node][i], color); } ... |
#include <bits/stdc++.h> using namespace std; int a[5]; bool able[5]; int main() { int T; scanf( %d , &T); while (T--) { for (int i = 1; i <= 4; i++) able[i] = true; bool flag = true; for (int i = 1; i <= 4; i++) scanf( %d , &a[i]); if ((a[1] + a[2]) % 2 == 1) flag = false; ... |
#include <bits/stdc++.h> using namespace std; int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, m, k; int q(int x) { return x * (x + 1) / 2; } int p[200005]; int b[200005]; int u[200005]; int dfs(int v) { u[v] = 1; if (!u[p[v]]) return dfs(p[v]) + 1; else return ... |
#include <bits/stdc++.h> using namespace std; int tux, foo, bar, baz, quz = 1; int main() { scanf( %d , &tux); for (int i = 1; i <= tux; ++i) { int pur; scanf( %d , &pur); foo += pur, bar++; if (foo * quz > baz * bar) baz = foo, quz = bar; } printf( %.6lf , baz * 1.0 / quz)... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double EPS = 1e-9; const long long MAXN = 5209; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 48 || ch > 57) { if (ch == - ) f = -1; ch = getchar(); } while (ch... |
#include <bits/stdc++.h> using namespace std; int main() { int N, K, i; cin >> N >> K; if (K == 1 || (N <= 3) || (K > 3) || (N == 4 and K == 2)) return cout << -1 << endl, 0; if (K == 2) { cout << N - 1 << endl; for (i = 1; i <= N - 1; i++) cout << i << << i + 1 << endl; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int w, h; cin >> w >> h >> n; multiset<int> cuth, cutw, maxh, maxw; cuth.insert(0); cuth.insert(h); cutw.insert(0); cutw.insert(w); maxh.insert(h); maxw.insert(w); int len; for (int i = 0; i < n; i++) {... |
#include <bits/stdc++.h> using namespace std; int a[111][111], x[111], k; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; int in = 0; for (int i = 0; i < n; i++) if (a[i][0] < a[in][0]) in = i; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define int long long #define double long double #define pb push_back #define mp make_pair #define endl n #define all(x) x.begin(),x.end() #define fill(a,b) memset(a,b,sizeof(a)) #define sz(x) (int)x.size() #define ff first ... |
#include <bits/stdc++.h> using namespace std; int n, m; int w; int q; vector<int> adj[5000 + 1]; vector<pair<int, int>> store[5000 + 1]; bool vis[5000 + 1]; int dfs(int g, int r, int a) { for (int i = 1; i <= n; i++) vis[i] = false; queue<pair<int, int>> q; priority_queue<pair<int, int>> pq;... |
#include <bits/stdc++.h> using namespace std; string to_string(string s) { return + s + ; } string to_string(const char* s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } template <typename A, typename B> string to_string(pair<A, B> p) { return ( + ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; using ll = long long; int n, m, p, a[N]; struct TNode { int l, r; vector<ll> f; ll sum; } t[N << 2]; inline int lc(int pos) { return pos << 1; } inline int rc(int pos) { return pos << 1 | 1; } void pushup(int pos) { t... |
#include <bits/stdc++.h> using namespace std; long long wph; long long mul(long long a, long long b) { long long c = (a * b - (long long)((long double)a / wph * b) * wph); return c < 0 ? c + wph : c; } void fwt(long long *a, int n, int f) { for (int k = 2, mid = 1; k <= n; k <<= 1, mid <<= 1) ... |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; }; struct Line { double A, B, C; }; Line Build(Point A, Point B) { Line res; res.A = A.y - B.y; res.B = B.x - A.x; res.C = A.x * B.y - B.x * A.y; return res; } Line Per(Line l, Point A) { Line res; ... |
#include <bits/stdc++.h> using namespace std; long long int n, m; pair<long long int, bool> All[120]; long long int ans = 0, na; void GetAll() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> All[i].first; All[i].second = false; } int buf; for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } bool prime(long long int n) { for (long long int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } long long bine... |
#include <bits/stdc++.h> using namespace std; int h, i, j, x, l, r, pa[200200], pb[200200]; bool ans; int main() { scanf( %d , &h); for (j = 0; j <= h; j++) { scanf( %d , &x); for (i = 1; i <= x; i++) { pa[r + i] = l; pb[r + i] = min(l + i - 1, r); if (pa[r + i] != pb... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; int n, m, q; int matrix[100][100]; int ans[10000]; void fill() { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { matrix[i][j] = i * m + j; } } } void solve_1(int i) { int temp; temp = matrix[i][m - 1]; matrix... |
#include <bits/stdc++.h> using namespace std; int d, s; int E[2510050][10]; int Get(int x, int y) { return x * d + y; } int dis[2710500]; char ok[2700050] = {}; vector<int> ans; int ST, EN; int dfs(int x) { if (x == EN) return 1; ok[x] = 1; for (int u = 0; u < 10; u++) if (x != 0 || ... |
#include <bits/stdc++.h> using namespace std; int n, i, tmp, res, a[10000]; bool kt; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); kt = true; for (i = 3; i <= n; i++) if (a[i] - a[i - 1] != a[i - 1] - a[i - 2]) kt = false; if (kt == false) { printf( %... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool Up(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool Down(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } ... |
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > a; set<pair<int, int> > d; void solve(int l, int r) { if (r - l <= 1) return; int m = (l + r) / 2; solve(l, m); solve(m, r); for (int i = l; i < r; ++i) { d.insert({a[m].first, a[i].second}); } } sig... |
#include <bits/stdc++.h> using namespace std; vector<int> g[300011]; long long ans[300011]; struct P { long long dis = -1, val = 0; } temp; vector<P> m[300011]; map<long long, long long> bit; void add(long long i, long long val) { i = 1000000000000000 - i; for (; i < 1000000000000000; i += (... |
#include <bits/stdc++.h> using namespace std; void print(int a) { cout << a << ; } void print(long long a) { cout << a << ; } void print(double a) { cout << a << ; } void print(string a) { cout << a << ; } template <typename T1, typename T2> void print(pair<T1, T2> a) { print(a.first); ... |
#include <bits/stdc++.h> #define pb push_back #define int long long #define debug(n) cerr << #n << = << n << n ; using namespace std; const int MaxN = 1e6 + 10; const int Mod = 1e9 + 7; const int inf = 1e18; int cnt[100] , a[MaxN]; void solve() { int n; cin >> n; for(int i ... |
#include <bits/stdc++.h> using namespace std; const int mo = 998244353; int fac[300005], inv[300005]; void init() { fac[0] = inv[0] = inv[1] = 1; for (int i = (int)(2); i <= (int)(300005 - 1); i++) inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo; for (int i = (int)(1); i <= (int)(300005 - 1); ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 7; const int MOD = (int)1e9 + 7; const long long INF = (long long)1e18 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> p(n + 1, 0); for (int i = 2; i * i <= ... |
#include <bits/stdc++.h> using namespace std; int main() { int k, p; double s, n; cin >> k >> n >> s >> p; for (int i = 0; i < 10000000000000000; i++) { if (((i * p) / k) >= n / s) { cout << i; break; } } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, q, a[300003], near[300003][20], last[300003]; signed main() { cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = n; i >= 1; i--) { for (int k = 0; k < 20; k++) { near[i][k] = n + 1; if (((1 << k... |
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pi 2*acos(0.0) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*b)/gcd(a,b) map<ll,ll>mp,mk; //map<string,ll>mp; set<ll> s1,s2; vector<int> v,w; string s= ,qq= ,ss= ,pp= ; char ch; l... |
#include <bits/stdc++.h> int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2}; using namespace std; vector<long long int> V, V2, V3, edj[200010]; bitset<200010> color; long long int root, cnt = 0; void dfs(long long int n, long long int ck) { color... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793238463; int main() { cin.tie(0); cin.sync_with_stdio(0); long long a, b; cin >> a >> b; while (a != 0 && b != 0) { if (a < 2 * b && b < 2 * a) break; if (a >= 2 * b) a %= 2 * b; else ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, l, n, k, d, max = 0, gen, e = 0; long long p; scanf( %d %d , &n, &k); vector<vector<int> > v(n); for (i = 0; i < n; i++) { scanf( %d , &d); v[d].push_back(i); if (d > max) max = d; } p = 1; for (i ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int n, m, q; vector<int> E[maxn]; int op[maxn], a[maxn], b[maxn], c[maxn]; int ans[maxn]; bitset<1001> Bit[1001]; bitset<1001> C; void dfs(int x) { if (x == 0) { for (int i = 0; i < E[x].size(); i++) { ans[E[x][i... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, i, l, j, x, s, y, ans; int main() { cin >> a >> b >> c >> l; s = 0; for (i = l + 1; i >= 1; i--) s += i * (i + 1) / 2; ans = 0; for (i = 0; i <= l; i++) { x = a + i; if (b > x || c > x) continue; y = min(l - i, ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int MAXN = 3005; int r, c, n, k; pair<int, int> v[MAXN]; int prv[MAXN], nxt[MAXN]; vector<int> y[MAXN], x[MAXN]; int pos[MAXN]; int num[MAXN]; int cnt; long long ans; int res; bool cmp_x(int num1, i... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e6; long long cnt[MAXN]; signed main() { long long n, m, k; ios_base::sync_with_stdio(false); cin >> n >> m >> k; vector<long long> f(n); vector<pair<long long, long long> > s(m); for (long long i = 0; i < n; i++) cin ... |
#include <bits/stdc++.h> using namespace std; int main() { int s, v1, v2, t1, t2, i1, i2; cin >> s >> v1 >> v2 >> t1 >> t2; i1 = s * v1 + 2 * t1; i2 = s * v2 + 2 * t2; if (i1 < i2) cout << First ; else if (i1 > i2) cout << Second ; else cout << Friendship ; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500 + 10; const int P = 998244353; int N, X, f[MAXN][MAXN], pw[MAXN][MAXN], binom[MAXN][MAXN]; void add(int& a, int b) { a = a + b >= P ? a + b - P : a + b; } int dif(int a, int b) { return a - b < 0 ? a - b + P : a - b; } int main() { for... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<int> e[maxn], re[maxn], List; int n, m, id[maxn], tt, cnt[maxn], ans; bool vis[maxn]; void input() { scanf( %d%d , &n, &m); for (int u, v, i = 1; i <= m; i++) { scanf( %d%d , &u, &v); e[u].push_back(v); ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int inf = 1e18; const double EPS = 1E-9; int n, m; int main(void) { cin >> n >> m; if (m > n) { int temp = m; m = n; n = temp; } if (m == 1) { cout << n << endl; } els... |
#include <bits/stdc++.h> using namespace std; const long long N = 11111111; const long long INF = (long long)(1e12); const long long mod = 998244353; const double eps = 1e-9; long long n, mx = -1, inv[N], a[N], k, all, cnt, ans; map<long long, long long, greater<long long> > M, S; long long get(long lon... |
#include <bits/stdc++.h> using namespace std; template <typename TYPE> inline TYPE sqr(const TYPE& a) { return (a) * (a); } const int INF = 1000 * 1000 * 1000; const long double EPS = 1e-9; const long double PI = 2 * acos(0.0); const int N = 100100; int top; int j; int a[N]; string ans; bo... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535897932238460; bool arr[361]; void angles() { for (int i = 3; i < 361; i++) if ((i - 2) * 180 % i == 0) { arr[(i - 2) * 180 / i] = true; } } int main() { int t; cin >> t; angles(); while (t--) ... |
#include <bits/stdc++.h> using namespace std; bool a[1100][26]; vector<bool> v(1100, false); int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; for (auto c : s) a[i][c - 97] = true; } for (int i = 0; i < n; i++) { if (v[i]) continue; ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int c[105]; long long p[105][105], f[105][105][105]; int main() { scanf( %d %d %d , &n, &m, &k); for (int i = 1; i <= n; i++) scanf( %d , &c[i]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %I64d , &p[i][j]); ... |
#include <bits/stdc++.h> template <class T> void read(T &x) { x = 0; int f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= (ch == - ), ch = getchar(); while (ch <= 9 && ch >= 0 ) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); x = f ? -x : x; return; } cons... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 40; void solve() { long long int n, m, k; cin >> n >> m >> k; long long int beg = 1, end = n * m; long long int fa; while (beg <= end) { long long int mid = (beg + end) / 2; long long int cnt = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 1e7 + 100; unordered_map<int, int> vis, Cnt; vector<int> Mice; vector<int> Cheese; int main() { int n, m, y0, y1; scanf( %d%d%d%d , &n, &m, &y0, &y1); for (int i = 0; i < n; i++) { int x; scanf( %d , &... |
#include<bits/stdc++.h> #define x first #define y second using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> PII; const int N=100005; int n,m,T; int main(){ cin>>T; int k1,k2,t1,t2,x1,x2; while(T--){ cin>>n>>k1>>k2; ... |
#include <bits/stdc++.h> using namespace std; int n, size[200010] = {0}; vector<int> w[200010]; int dpMax(int, int); int dpMin(int, int); int child(int x) { int ret = 0; for (int i = 0; i < w[x].size(); i++) ret += child(w[x][i]); return size[x] = ret + !w[x].size(); } int dpMax(int x, int t... |
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; int n, m; namespace flow { int n, s, t; int head[200306], to[200306 << 1], nex[200306 << 1], wto[200306 << 1], ecn = 1; int ade(int u, int v, int w) { to[++ecn] = v, nex[ecn] = head[u], wto[ecn] = w, head[u] = ecn; to[++ecn] = u,... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; vector<pair<int, int> > adj[MAXN]; int n; bool mark[MAXN]; int p[MAXN]; int curv; void dfs(int v, int ind = -1) { mark[v] = 1; for (int i = 0; i < adj[v].size(); i++) { pair<int, int> u = adj[v][i]; if (!mark[u.f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.