func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; const double PI = acos(-1.0); const long long mod = 1e18; const int MAXN = 100000 + 5; const int INF = 0x3f3f3f3f; const int N = 100 + 10; int main() { ios::sync_with_stdio(false); int n, f[26], num = 0, ans = 0; char opr... |
#include <bits/stdc++.h> using namespace std; inline int read() { int fh = 1, x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while ( 0 <= ch && ch <= 9 ) { x = (x << 3) + (x << 1) + ch - 0 ; ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; struct fastIO { inline fastIO operator>>(int& num) { num = 0; char c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); bool foo = 0; if (c == - ) { foo = 1; c = getchar(); } while (c >= 0... |
#include <bits/stdc++.h> using namespace std; int main() { int word[4]; for (int i = 0; i < 4; i++) { cin >> word[i]; } int number = 0; sort(word, word + 4); for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { if (word[i] == word[j]) { number++; ... |
#include <bits/stdc++.h> using namespace std; int a[101], res; int b[101]; int main() { int n, i, k, t; cin >> n >> k; for (i = 0; i < n; i++) { cin >> t; a[t]++; } while (1) { for (i = 1; i <= k; i++) b[i] = 0; t = 0; for (i = 1; i < k; i++) if (a[i] > ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; while (~scanf( %d , &t)) { while (t--) { int n; scanf( %d , &n); char a[n + 1]; scanf( %s , a); int ans = 0; for (int i = 0; i < n; i++) { if (a[i] == > || a[n - i - 1] == < ... |
#include <bits/stdc++.h> using namespace std; const int64_t INF = (1 << 30) - 1; const long long oo = (1ll << 62) - 1; const long double PI = 3.1415926535898; const int64_t N = 100000 + 5; int64_t n; vector<int64_t> a[N]; int64_t d[5][N]; int64_t mau[N]; int64_t c[5][5]; int64_t dfs(int64_t u, int... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } int binomial(int n, int k) { if (k == 0 || k == n) ret... |
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> a[2][100010]; bool used[100010]; int fat[100010]; int main() { int i, j, c, v; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d %d , &c, &v); a[c][++a[c][0].first] = make_pair(v, i); } sort(a[0] + 1, a[0... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; long long modexp(long long a, long long n) { if (a == 0) return 0; if (n == 0) return 1; long long p = modexp(a, n / 2); p = p * p % MOD; if (n & 1) p = p * a % MOD; return p; } int main() { ios_base::sy... |
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 30005; const int Maxk = 205; const int Inf = 1000000000; int n, k; int a[Maxn]; int dp[Maxn][Maxk][2]; int res = -Inf; int Add(int val, int sgn) { return sgn == 0 ? -val : val; } int main() { scanf( %d %d , &n, &k); for (int i = ... |
#include <bits/stdc++.h> using namespace std; inline long long getint() { long long _x = 0, _tmp = 1; char _tc = getchar(); while ((_tc < 0 || _tc > 9 ) && _tc != - ) _tc = getchar(); if (_tc == - ) _tc = getchar(), _tmp = -1; while (_tc >= 0 && _tc <= 9 ) _x *= 10, _x += (_tc - 0 ), _t... |
#include <bits/stdc++.h> using namespace std; char str[50][30]; char p[30]; char t[30]; int n; int solve() { for (int i = 0; i < n; i++) { if (strstr(str[i], t) != NULL) { return 0; } } return 1; } int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int main() { ios_base::sync_with_stdio(0); long long cnt1, cnt2, cnt3, cnt4; cin >> cnt1 >> cnt2 >> cnt3 >> cnt4; cnt3 = (cnt3 != 0 ? 1 : 0); cnt1 -= cnt3; cnt4 -= cnt3; if (cnt1 >= 0 && cnt4 >= 0 && cnt1 == cnt4... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { long long int res = 1; while (y) { if (y & 1ll) { res *= x; } x *= x; y >>= 1ll; } return res; } int main() { long long int l, r, k; cin >> l >> r >> k; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; bool notfine = true; for (int i = 0; i < n - 1; ++i) { if (v[i] <= v[i + 1]) { notfi... |
#include <unordered_set> #include <unordered_map> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <cmath> #include <set> #include <map> using namespace std; typedef long long ll; const int Z ... |
#include <bits/stdc++.h> using namespace std; long long ans[2]; int z[100], zn; int main() { int n; scanf( %d , &n); int m, x; for (int i = 1; i <= n; i++) { scanf( %d , &m); for (int i = 0; i < m; i++) { scanf( %d , &x); if (m % 2 && i == m / 2) { z[zn++] =... |
#include <bits/stdc++.h> using namespace std; bool pr(int x) { bool p = 0; if (x % 2 == 0) p = (x == 2); else { long long d = 3; while (d * d <= x && x % d != 0) { d += 2; } if (d * d > x) p = (x != 1); } return p; } int main() { ios_base::sync_with_... |
#include <bits/stdc++.h> const int N = 1005; int size[N], to[N << 1], edge, Next[N << 1], last[N], G, siz, cnt, w[N << 1], n, x, y, tag[N]; void add(int x, int y) { to[++edge] = y; Next[edge] = last[x]; last[x] = edge; } void dfs(int x, int fa) { size[x] = 1; int mx = 0; for (int... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int q; cin >> q; vector<unsigned long long int> V; for (unsigned long long int i = 2; i * i <= q; i++) while (q % i == 0) { V.push_back(i); q /= i; } if (q != 1) V.push_back(q); if (V.si... |
#include <bits/stdc++.h> using namespace std; template <typename elemType> inline void Read(elemType &T) { elemType X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == - ; ch = getchar(); } while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar(); T = (... |
#include <bits/stdc++.h> inline long long read() { char c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); long long k = 1, kk = 0; if (c == - ) c = getchar(), k = -1; while (c >= 0 && c <= 9 ) kk = kk * 10 + c - 0 , c = getchar(); return kk * k; } using namespace ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 320; const int inf = 2147483647; const int mod = 1000000007; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 )... |
#include <bits/stdc++.h> using namespace std; const int M = 1000005; const int P = 1e9 + 9; int Hash[2][M]; int base[M]; int getHash(int *h, int L, int R) { return (h[R] - 1LL * h[L - 1] * base[R - L + 1] % P + P) % P; } char A[M], B[M], C[M]; int main() { int n; cin >> n; n--; sca... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << 1) + (c & 15); ... |
#include <bits/stdc++.h> using namespace std; void main0(); int main() { clock_t start, end; ios::sync_with_stdio(false); cin.tie(0); main0(); return 0; } const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1}; const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1}; const int N = 2e5 + 5; const int M ... |
#include <bits/stdc++.h> using namespace std; const int maxx = 2e5 + 20, mod = 1e9 + 7; int main() { int t; cin >> t; while (t--) { string s; int n, sum = 0, ans = 0; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == ( ) sum++; else s... |
#include <bits/stdc++.h> using namespace std; int res[2000000]; int main() { ios::sync_with_stdio(false); int n, q; scanf( %d%d , &n, &q); int re = 0, ro = 0; bool sw = 0; for (int i = 0; i < q; ++i) { int t; scanf( %d , &t); if (t == 1) { int x; scanf( %d... |
#include <bits/stdc++.h> using namespace std; long long t, a, b, ans = 0; int main() { scanf( %lld , &t); while (t--) { scanf( %lld%lld , &a, &b); ans = 0; if (b >= 9) ans++; if (b >= 99) ans++; if (b >= 999) ans++; if (b >= 9999) ans++; if (b >= 99999) ans++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int s = 0, c = 0; int a[120]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; c += a[i]; } while (1) { s = 0; sort(a, a + n); if (a[n - 1] == a[0]) { break; } for (int... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > data; vector<bool> used; vector<int> cycle; void dfs(int vertex, int last, vector<int> &path) { used[vertex] = true; path.push_back(vertex); for (int i = 0; i < data[vertex].size(); ++i) { int to = data[vertex][i]; if (... |
#include <bits/stdc++.h> using namespace std; long long a[4]; vector<int> order, to; bool cmp(int x, int y) { return a[x] < a[y]; } int main() { cin >> a[1] >> a[2] >> a[3]; order = {1, 2, 3}; sort(order.begin(), order.end(), cmp); to = order; cout << First << endl; for (;;) { ... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265359; template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } template <typename T> void chmin(T &x, T y) { x = min(x, y); } template <typename T> vo... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int MOVX[2] = {0, 1}; const int MOVY[2] = {1, 0}; int n, m; string fore[501]; vector<pair<int, int> > dep[1001]; int pid[501][501]; long long tbl[2][501][501]; inline bool valid(int x, int y) { return x >= 0 && x < n ... |
#include <bits/stdc++.h> using namespace std; inline void update(long long &x, long long y) { x += y; } struct Point { long long x, y; Point() {} Point(long long a, long long b) : x(a), y(b) {} Point operator-(Point b) { return Point(x - b.x, y - b.y); } bool operator<(const Point &b) const { ... |
#include <bits/stdc++.h> using namespace std; int n, m, q, a[200010], b[200010], pos[200010], lst[200010]; int f[200010][30], G[200010][30], L[200010]; int amax(int a, int b) { return a > b ? a : b; } int main() { int i, j, cnt, poss, t, l, r; scanf( %d%d%d , &n, &m, &q); for (i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int k; cin >> k; string s; cin >> s; unordered_map<char, int> ourmap, ourmap1; int flag = 0; for (int i = 0; i < k; i++) { if (s[i] == 1 || s[i] == 4 || s[i] ==... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; vector<int> g[100100]; int deg[100100]; bool vis[100100]; void dfs(int v) { vis[v] = true; for (int to : g[v]) if (!vis[to]) { dfs(to); } } int main() { int N, M; scanf( %d%d , &N, &M); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; long long x = a + b + c; long long y = 2 * (a + b); x = min(x, 2 * (a + c)); x = min(x, 2 * (b + c)); cout << min(x, y) << endl; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; long long n, q, op, root = 1; long long a[maxn]; long long head[maxn], to[maxn << 1], nxt[maxn << 1], cnt; inline void add(long long u, long long v) { nxt[++cnt] = head[u]; to[cnt] = v; head[u] = cnt; } namespace Tree_ch... |
#include <bits/stdc++.h> using namespace std; int main() { long long q = 1; while (q--) { long long n, k; cin >> n >> k; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long sum = 0, ans; for (long long i = 0; i < k; i++) sum += a[i]; ans = sum; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return false; while (c != - && (c < 0 || c > 9 )) c = getchar(); sgn = (c == - ) ? -1 : 1; ret = (c == - ) ? 0 : (c - 0 ); while (c = getcha... |
#include <bits/stdc++.h> using namespace std; const int N = 4005; int n, a[N], sum[N], f[50000005]; int h(int l, int r, int k, int now) { return ((((l * 4000) + r) * 100 + k) * 2 + now) % 50000000; } int dfs(int l, int r, int k, int now) { if (r - l + 1 < k) return 0; if (r - l + 1 == k) { ... |
#include <bits/stdc++.h> using namespace std; int n; int a, b; vector<int> arr; vector<vector<int> > dp; void solve1(string x, int a, int b) { int n = x.length(); int l = n + 1; int r = -1; for (int i = 0; i < n; i++) { if (x[i] == 1 ) { l = min(l, i); r = max(r, i); ... |
#include <bits/stdc++.h> using namespace std; long long n, a, b; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; if (a > b) { cout << b * (b + 1) / 2 << endl; } else { cout << a * (a - 1) / 2 + 1 << endl; } } } |
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod (ll)1e9+7; #define test ll t;cin>>t;while(t--) #define endl n #define pb push_back #define vi vector<int> #define vvi vector<vi> #define vl vector<ll> #define vvl vector<vl> #define vp vector<pair<int,int>> #define ... |
#include <bits/stdc++.h> using namespace std; long long const INF = (long long)1e9; long long const INF64 = (long long)4e18; long long const v10e5 = (long long)100000; long long const v10e6 = (long long)1000000; long long const v10e9 = (long long)1000000000; long long const s10e5 = (long long)100000 + 10;... |
#include <bits/stdc++.h> using namespace std; inline int read() { char c; int ret = 0, sgn = 1; do { c = getchar(); } while ((c < 0 || c > 9 ) && c != - ); if (c == - ) sgn = -1; else ret = c - 0 ; while ((c = getchar()) >= 0 && c <= 9 ) ret = ret * 10 + (c - ... |
#include <bits/stdc++.h> using namespace std; using u128 = __uint128_t; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; while (t--) { long long n; cin >> n; vector<long long> ans(n, 0); cout << ? << 1 << << n << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = 10100, M = 1001000, oo = 1000000000; int i, j, k, n, m, ch, Pn, Tn, En, x, y, fx, fy, rt, nm; int h[N * 2], p[N * 2], g[N * 2], tmp[N * 2]; struct edge { int s, n; } E[N * 4]; struct edge2 { int s, n, v; }; struct tree { int l, r;... |
#include <bits/stdc++.h> using namespace std; const int N = 3 * 1e5 + 5; int main() { int t; cin >> t; double a[1005], b[1005]; for (int i = 1; i <= t; ++i) { int d; cin >> d; if (d < 4 && d > 0) { a[i] = -1; b[i] = -1; continue; } double discr... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 6100, EMAX = 13000, VMAX = 6100; struct Edge { int x; int y; int next; }; int N, R[NMAX], ans; short f[NMAX][NMAX], g[NMAX][NMAX]; int V[VMAX], eid; Edge E[EMAX]; void insert(int x, int y) { E[++eid] = (Edge){x, y, V[x]}; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; int a[3007]; while (~scanf( %d , &n)) { for (i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); for (i = 0; i < n; i++) if (a[i] != i + 1) break; printf( %d n , i + 1); } return 0; } |
#include <bits/stdc++.h> using namespace std; stringstream ss; long long p[1000010], h1[1000010], h2[1000010]; int main() { p[0] = 1; for (int i = 1; i < 1000010; i++) h1[i] = p[i] = p[i - 1] * 127LL; int n, m, a, b; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a >> b; h1... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int i = 0; while (a <= b) { a *= 3; b *= 2; i++; } cout << i; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 123; char res[maxn][maxn]; int a[maxn]; int n; int sumx, maxy, miny, nowy; int main() { scanf( %d , &n); sumx = maxy = miny = nowy = 0; int flag = 1; for (int i = 0; i < n; ++i) { scanf( %d , a + i); sumx += ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, N = 1010, P = 1e9 + 7; template <class T> inline bool chkmin(T &A, T B) { return B < A ? A = B, 1 : 0; } template <class T> inline bool chkmax(T &A, T B) { return A < B ? A = B, 1 : 0; } template <class T, class _> inl... |
#include <bits/stdc++.h> using namespace std; int binarySearch(long long int arr[], long long int l, long long int r, long long int x) { if (r >= l) { long long int mid = l + (r - l) / 2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; double u, v, w, x, y, l = 1e9, r = 0; cin >> n >> w >> v >> u; while (n--) { cin >> x >> y; l = min(l, x - y / u * v);... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); long long n, k, cnt = 0, flag = 0; cin >> n >> k; if (n > k * (k - 1)) { cout << NO ; return 0; } cout << YES n ; for (long long i = 1; i <= k; i+... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> m >> n; cout << (m * n) / 2; return 0; } |
#include <bits/stdc++.h> using namespace std; #define int long long //#define int unsigned int //#define pb push_back //#define mp make_pair #define mod 1000000007 #define double long double #define all(x) x.begin(), x.end() #define debug(x) cout << #x << = << x << n const int inf=1e18; ... |
#include <bits/stdc++.h> using namespace std; long long ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) { int dx1 = b.first - a.first; int dy1 = b.second - a.second; int dx2 = c.first - a.first; int dy2 = c.second - a.second; return 1ll * dx1 * dy2 - 1ll * dy1 * dx2; } long long di... |
#include <bits/stdc++.h> using namespace std; int n, a[100005]; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) { printf( ? %d %d n , i, n); fflush(stdout); scanf( %d , &a[i]); } for (int i = 1; i < n - 1; i++) a[i] -= a[i + 1]; printf( ? %d %d n , n - 2, n - 1); ... |
#include <bits/stdc++.h> using namespace std; int const nmax = 100000; int const domain = 1000000; struct Person { int x; int v; bool operator<(Person other) const { return (x < other.x); } }; int n, nl, nr; int s; Person pl[1 + nmax], pr[1 + nmax]; bitset<1 + domain> okl, okr; double ti... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, a[N], maxi[4 * N]; pair<int, int> p[N]; vector<int> v[3]; bool cmp(pair<int, int> p1, pair<int, int> p2) { if (p1.first == p2.first) return p1.second > p2.second; else return p1.first < p2.first; } void merge... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9, PI = acos(-1.); const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int N = 1e5 + 5; int n, x, v; long long sm; int main() { scanf( %d%d , &n, &x); for (int i = 0; i < n; ++i) scanf( %d , &v), sm += v; printf( %s n , sm +... |
#include <bits/stdc++.h> using namespace std; int main() { int x[100], n, a, b, i, dem = 0; scanf( %d , &n); for (i = 0; i < n - 1; i++) scanf( %d , &x[i]); scanf( %d , &a); scanf( %d , &b); for (i = a - 1; i != b - 1; i++) dem = dem + x[i]; printf( %d , dem); return 0; } |
#include <bits/stdc++.h> using namespace std; const int SIZE = 500 + 10; int data[SIZE]; map<int, int> all_nums; int n; bool used[SIZE * SIZE]; int gcd(int a, int b) { if (a % b == 0) return b; return gcd(b, a % b); } void make_data() { srand(time(0)); int n = 5; int data[SIZE]; ... |
#include <bits/stdc++.h> using namespace std; const int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; const int N = 1e6 + 10; const int mod = 1e9 + 7; const double pi = acos(-1); const double eps = 1e-8; const long long INF = 2e10; template <class T> void _print(T arg) { cout << arg << ; } templa... |
#include <bits/stdc++.h> using namespace std; template <typename X> ostream& operator<<(ostream& x, const vector<X>& v) { for (long long i = 0; i < v.size(); ++i) x << v[i] << ; return x; } template <typename X> ostream& operator<<(ostream& x, const set<X>& v) { for (auto it : v) x << it << ... |
#include <bits/stdc++.h> using namespace std; long long int d[200060], cost[200060]; long long int m, tank; vector<pair<int, int>> temp; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int src; cin >> src >> tank >> m; d[0] = 0; cost[0] = 0; d[m + 1] = src; cost[m + ... |
#include <bits/stdc++.h> using namespace std; int solveA(vector<int> a, vector<int> b) { int n = (int)((a).size()); vector<int> m(n); for (int i = (0); i <= ((n)-1); i++) m[b[i]] = i; for (int i = (0); i <= ((n)-1); i++) a[i] = m[a[i]]; b[0] = a[0]; for (int i = (1); i <= ((n - 1)); i++) b[i... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10, inf = 1e18; struct SegTree { long long l[N << 2], r[N << 2]; long long mn[N << 2], tag[N << 2]; inline void push_up(long long i) { mn[i] = min(mn[i << 1], mn[i << 1 | 1]); } inline void push_down(long long i) { mn[i ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int MOD(1e9 + 7); const int MAXN(1e5 + 11); int n, first, z, a, l; int main() { scanf( %d%d%d%d%d , &n, &first, &z, &a, &l); int ans = 0; for (int ptr = 0; ptr < n;) { if (ptr) pt... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; const int MX = 1111 * 1111 * 2; int n, m; const double pi = acos(-1.0); int len, res[MX], mx; struct Complex { double r, i; Complex(double r = 0, double i = 0) : r(r), i(i){}; Complex operator+(const Complex &rhs) { r... |
#include <bits/stdc++.h> using namespace std; const int N = 10009; const int D = 5001; int n; vector<vector<pair<int, int>>> hs(N, vector<pair<int, int>>()); vector<vector<pair<int, int>>> vs(N, vector<pair<int, int>>()); vector<vector<int>> ds(N, vector<int>()); class FenwickTree { public: Fenwi... |
#include <bits/stdc++.h> using namespace std; stack<int> s; int a[(int)(1e+6) * 5]; bool b[(int)(1e+6) * 5]; int main() { ios_base::sync_with_stdio(0); int n, i, t, x; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; cin >> t; while (t > 0) cin >> x, b[x] = 1, t--; for (i = n; i > 0... |
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long test; test = 1; while (test--) { int a, b, c, d; cin >> a >> b >> c >> d; int misha = max((3 * a) / 10.0... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); const int inf = 2147483647; int n, w; int a[1005]; bool first; int MIN; void output(int x) { if (first) first = false; else printf( ); if (x == MIN) x = 0; else if (... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], b[n], c = 0, d = 0, e = 0, i; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (a[i] > b[i]) c++; else if (b[i] > a[i]) d++; else e++; } if (c > d) cou... |
#include <bits/stdc++.h> using namespace std; const int MM = 600005; const long long MOD = 1000000007; double a[MM], sum[MM]; char s[MM]; int main() { sum[0] = a[0] = 0; for (int i = 1; i < MM; i++) { a[i] = a[i - 1] + 1.0 / i; sum[i] = sum[i - 1] + a[i]; } scanf( %s , s + 1); ... |
#include <bits/stdc++.h> using namespace std; int n, p, out[1010]; struct node { int v, c; }; vector<node> e[1010]; int t1[1010], t2[1010], r[1010], k; void dfs(int i, int fa, int mi) { if (e[i].size() == 0) { t1[k] = fa; t2[k] = i; r[k] = mi; k++; return; } m... |
#include <bits/stdc++.h> using namespace std; int read() { int p = 0, q = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) ch == - ? q = -1 : 0, ch = getchar(); while (ch >= 0 && ch <= 9 ) p = p * 10 + ch - 0 , ch = getchar(); return p * q; } long long readll() { long long p = ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5; int n, m, head[N], cnt, dep[N], fa[N], pid[N]; long long c[N], val[N]; bool vis[N], use[N]; struct edge { int to, nxt, id; } e[N << 1]; void finish() { cout << YES n ; for (int i = 1; i <= m; ++i) cout << val[i] << n ; e... |
#include <bits/stdc++.h> using namespace std; void readi(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = v * 10 + c - 0 ; while (isdigit(c = getchar())) v = v * 10 + c - 0 ; x = v * f; } void ... |
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.push_back(move(x)); return move(v); } void err(vector<string>::iterator it) {} template <typename T, typename... Args> ... |
#include <bits/stdc++.h> using namespace std; int main() { int q; unsigned long long int n; cin >> q; for (int i = 0; i < q; i++) { cin >> n; if (n < 4) { cout << 4 - n << endl; } else { if (n % 2 == 0) { cout << 0 << endl; } else { cout ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T abs(T t) { return t < 0 ? -t : t; } const long long modn = 1000000007; inline long long mod(long long x) { return x % modn; } const int N = 1000009; int a[N], t[N]; int gcd(int a, int b) { if (b == 0) return a; re... |
#include <bits/stdc++.h> using namespace std; string solve(string s) { if (s.size() & 1) { return s; } string a = solve(s.substr(0, s.size() / 2)); string b = solve(s.substr(s.size() / 2)); if (a < b) { return a.append(b); } else { return b.append(a); } } int main()... |
#include <bits/stdc++.h> using namespace std; int c[500]; int main() { string s, t; int n, i, j, k; cin >> s >> t; bool ok = 1; vector<pair<char, char> > ans; n = s.length(); vector<char> v(500, 0 ); for (i = 0; i < n; i++) { if (s[i] == t[i]) { if (c[s[i]] == -2) ok... |
#include <bits/stdc++.h> using namespace std; int main() { string s; string ans; cin >> s; int i = 0; int j = 0; while (i < s.size() & j < 3) { if (j == 0) { if (s[i] == f ) { ans = ftp:// ; i = 3; } else { ans = http:// ; i = ... |
#include <bits/stdc++.h> using namespace std; const int N = 200100; const long long OO = 1e18; const int oo = 2e9; const int md = 998244353; set<int> st; set<int>::iterator ite; int sto, n, p[N], obr = 1, ans = 0, mul[N], q, psm[N]; bool mrk[N]; int mult(int x, int y) { return (1ll * x * y) % md; } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; vector<long long> v(n); for (long long i = 0; i < n; i++) cin >> v[i]; vector<long long> peaks(n, 0); for (long long i = 1; i < n - 1; i++) {... |
#include <bits/stdc++.h> using namespace std; const int size = 508; int num[size]; int Abs(int x) { return x > 0 ? x : -x; } int main() { int n, sum, m, i, x, L, R, c, t, v, up; cin >> n; sum = m = 0; up = 1000000; for (i = 1; i <= 2 * n - 1; i++) { cin >> num[i]; if (num[i] < ... |
#include <bits/stdc++.h> using namespace std; int main() { double a, d; int n; cin >> a >> d >> n; scanf( %lf%lf%d , &a, &d, &n); for (int i = 0; i < n; i++) { double temp = fmod((i + 1) * d, 4 * a); if (temp < a) printf( %lf %lf n , temp, 0.0); else if (temp < a * 2) ... |
#include <bits/stdc++.h> const int mxn = 105; const int inf = 505; int n; int m; int ans; int row[mxn]; int col[mxn]; int mat[mxn][mxn]; inline void calcRow() { for (int i = 1; i <= n; ++i) { row[i] = inf; for (int j = 1; j <= m; ++j) if (row[i] > mat[i][j]) row[i] = mat[i][j];... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1; const long long MOD = 1; long long _gcd(long long a, long long b) { if (b == 0) return a; return _gcd(b, a % b); } long long gcd(long long a, long long b) { a = abs(a), b = abs(b); if (a < b) swap(a, b); return _gcd(a, b);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.