func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int inft = 1000000009; const int mod = 1000000007; const int MAXN = 100006; int f[MAXN]; const int N = MAXN, P = MAXN; vector<int> G[N]; pair<int, int> E[MAXN], Q[MAXN]; int C[MAXN]; namespace LCAO { vector<pair<int, int> > pyt[N]; int LCA[P]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; double lift[n], land[n]; for (int i = 0; i < (n); i++) cin >> lift[i] >> land[i]; double ans = 0; for (int i = n - 1; i >= 0; i--) { ans = (ans + m / ... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; long long int a[N], l[N]; int main() { int n; long long int ans(0); scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %lld , &a[i]), a[i]++; long long int o(a[n] + 1); for (int i = n; i >= 1; --i) l[i] = o = max(--o, ... |
#include <bits/stdc++.h> using namespace std; inline int add(int a, int b, int m = 1000000007) { a += b; if (a >= m) a -= m; return a; } inline int mul(int a, int b, int m = 1000000007) { return (int)(((long long)a * (long long)b) % m); } inline int norm(int x, int m = 1000000007) { if (... |
#include <bits/stdc++.h> using namespace std; const long double PI = acosl(-1.0); const double EPS = 1e-12; void combination(long long com[][1005]) { com[0][0] = 1; int sz = 1000; for (int i = 1; i <= sz; i++) { com[i][0] = 1; for (int j = 1; j <= i; j++) { com[i][j] = com[i - 1]... |
#include <bits/stdc++.h> using namespace std; long long n, i, rs, j; vector<long long> ball; vector<long long>::iterator pos; int main() { scanf( %lld , &n); for (i = 0; i < n; i++) scanf( %lld , &j), ball.push_back(j); sort(ball.begin(), ball.end()); rs = 0; i = 0; if (n % 2 == 0) { ... |
#include <bits/stdc++.h> using namespace std; long long n; int main() { char c; scanf( %I64d%1c , &n, &c); c -= a ; long long ans = 0; n -= 1; if (n % 4 <= 1) { ans += ((n / 4) * 2 + n % 4) * 6 + n; } else { ans += ((n / 4) * 2 + (n % 4 - 2)) * 6 + n - 2; } if (c <... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:10240000 ) using namespace std; const int MAXN = 100010; int a[MAXN], cnt[MAXN]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } memset(cnt, 0, sizeof(cnt)); int sta = 1, n... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 3005; const int MOD = 1000000007; const double eps = 1e-8; const double PI = acos(-1.0); long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n, long long... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; string s; cin >> s; for (long long i = 1; i <= n; i++) if (!(n % i)) reverse(s.begin(), (s.begin() + i)); cout << s << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010, inf = 1e9; int n, ty, l, r, x; bitset<maxn> v[26], ans; char s[maxn], s2[maxn], c; inline void read(int &k) { int f = 1; k = 0; char c = getchar(); while (c < 0 || c > 9 ) c == - && (f = -1), c = getchar(); while... |
#include <bits/stdc++.h> using namespace std; int arr[500005], brr[500005]; vector<int> vv[500005], ans; int Now[500005]; int total[500005]; int tree[500005 * 4]; void update(int node, int b, int e, int i, int v) { if (i < b || i > e) return; if (b == e && b == i) { tree[node] = v; ret... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2) { cout << 7; n -= 3; } while (n) { cout << 1; n -= 2; } return 0; } |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long INF = 0x3f3f3f3f3f3f3f3f; const long long llinf = (1LL << 62); const int inf = (1 << 30); const long long nmax = 3e5 + 50; const int mod = 1e9 + 7; const int lim ... |
#include <bits/stdc++.h> using namespace std; string s, s1, s2; bool fn() { int i, j, k, flag = 0; int len = s.size(); int len1 = s1.size(); int len2 = s2.size(); for (i = 0; i < len; i++) { for (j = i, k = 0; k < len1; j++, k++) { if (s[j] != s1[k] || j >= len) break; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005, MOD = 1e9 + 7; long long fact[N], inv[N]; long long qpow(long long a, int b) { long long ans = 1; do { if (b & 1) ans = ans * a % MOD; a = a * a % MOD; } while (b /= 2); return ans; } int main() { int n; ... |
#include <bits/stdc++.h> using namespace std; // #define int long long int #define mod 1000000007 #define pb push_back #define mp make_pair #define bs binary_search #define lb lower_bound #define ub upper_bound #define gcd __gcd #define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #defi... |
#include <bits/stdc++.h> using namespace std; int n, d[100005], g[100005]; bool vis[100005]; char str[100005]; void get() { bool sign = 1; int cur = 1; while (cur >= 1 && cur <= n) { if (vis[cur]) { sign = 0; break; } vis[cur] = 1; cur += g[cur] * d[cur]; ... |
#include <bits/stdc++.h> using namespace std; int n, k; vector<char> s; int main() { cin >> n >> k; if (k > n) { cout << -1; cin >> n; return 0; } if (k == 1 && n > 1) { cout << -1; cin >> n; return 0; } for (int i = 0; i < n; i++) { if (i % 2 ==... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x7fffffff; inline int reint() { int d; scanf( %d , &d); return d; } inline long relong() { long l; scanf( %ld , &l); return l; } inline char rechar() { scanf( ); return getchar(); } inline double redouble(... |
#include <bits/stdc++.h> using namespace std; #define int long long void solve() { int n; cin >> n; int a[n]; for(int i = 0; i < n; i++) cin >> a[i]; cout<<(n/2)*6<<endl; for(int i = 1; i <= n; i+=2){ int j = i + 1; cout<<1<< <<i<< <<j<<endl; ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; const int N = 2.5e5; vector<int> adj[N]; int dep[N], par[N]; bool leaf[N]; bool dfs(int u, int p = -1, int d = 1) { if (dep[u] > 0) return false; dep[u] = d; par[u] = p; leaf[u] = true; for (int v : adj[u]) { if ... |
#include <bits/stdc++.h> using namespace std; char s[1000010], a[1000010], b[1000010]; char perm[300]; char used[300]; char savedPerm[300]; char savedUsed[300]; int k; bool fit(char from, char to) { if (perm[from] != 0) { if (perm[from] != to) return false; } else { if (used[to] != 0... |
#include <bits/stdc++.h> using namespace std; const int B = 20; const int N = 1e5 + 7; int n, m, a[N]; struct ND { int l0, r0; ND() {} ND(int l0, int r0) : l0(l0), r0(r0) {} void init(int p, int v) { l0 = v == 0 ? p : n + 1; r0 = v == 0 ? p : 0; } void merge(const ND &a, co... |
#include <bits/stdc++.h> using namespace std; long long a[200010]; int main() { int n; long long sum = 0, MAX = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %I64d , a + i); sum += a[i]; MAX = max(a[i], MAX); } long long ans; if (sum % (n - 1) == 0) ... |
#include <bits/stdc++.h> using namespace std; long long n, d, b; int nl[100100], nr[100100]; int find(int *next, int x) { if (next[x] == x) return x; return next[x] = find(next, next[x]); } long long bit[100100]; inline int lowbit(int x) { return x & -x; } void add(int x, long long y) { whil... |
#include <bits/stdc++.h> using namespace std; int main(void) { int t, n; cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; ++i) cout << i << ; cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int cmp(char a, char b) { return a > b; } int main() { char s[300050]; char str[300050]; char ans[300050]; scanf( %s%s , s, str); int len = strlen(s); sort(s, s + len); sort(str, str + len, cmp); if (len == 1) { printf( %s n , s);... |
#include <bits/stdc++.h> using namespace std; int l[50000]; int p[50000]; pair<pair<double, int>, int> prod[50000]; int main() { std::ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> l[i] >> p[i]; if (p[i] == 100) prod[i].first.first =... |
#include <bits/stdc++.h> using namespace std; bool sip; char A[100005], B[100005]; int C[35], D[35], tam1, tam2, res = 0, puede = 0, quedan; int main() { scanf( %s%s , A, B); for (tam1 = 0; A[tam1] != 0 ; tam1++) ; for (tam2 = 0; B[tam2] != 0 ; tam2++) ; if (tam2 > tam1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (b < a) swap(a, b); if (b - a > 10) { cout << fixed << (int)ceil((double)(b - a) / 10) << n ; ... |
#include <bits/stdc++.h> using namespace std; void sprint(string s) { for (int i = 0; i < (int)s.size(); ++i) printf( %c , s[i]); printf( n ); } long long f(long long n, long long r) { long long ans = 1; for (long long i = 0; i < r; ++i) { ans = (ans * (n - i)) / (i + 1); } return... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 2; const int INF = 1e9 + 1; const double EPS = 1e-9; int n, m; int a[MAXN]; int r[MAXN], t[MAXN]; int b[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> int a[1005]; int main() { int x, i, j; while (scanf( %d%*c , &x) != EOF) a[x] = 1; bool flag = false; for (i = j = 1; i < 1001; i = ++j) if (a[i]) { for (j = i; a[j]; ++j) ; --j; if (!flag) flag = true; else ... |
#include <bits/stdc++.h> using namespace std; const long long logN = 20; const long long M = 1000000007; const long long INF = 1e12; const long long N = 505; const long long K = 250505; long long dp[K]; void solve() { long long n, k; cin >> n >> k; long long A[n], B[n]; for (long long i ... |
#include <bits/stdc++.h> using namespace std; map<long long, vector<long long> > mp; long long a[200005]; long long t[200005]; set<long long> s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; for (long long i = 0; i < n; i++) cin >> a[i], s.insert(a[... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e6 + 7; int N, a[maxN], f[(1LL << 22) + 7]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; memset(f, -1, sizeof f); for (int i = 1; i <= N; i++) { cin >> a[i]; f[a[i]] = a[i]; } ... |
#include <bits/stdc++.h> using namespace std; inline long long rd() { char c; while (c = getchar(), c < 0 || c > 9 ) ; long long X = c - 48; while (c = getchar(), c >= 0 && c <= 9 ) X = X * 10 + c - 48; return X; } template <class T> inline void print(T x) { if (x < 0) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const long long INF = (long long)1e14 + 5; long long N, cur = 1, last = 0, ans[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; for (int i = 1; i <= N; i += 2) { long long x; cin >> x; ... |
#include <bits/stdc++.h> using namespace std; typedef int nod[100010]; typedef int edg[200010]; int n, m; int e = 1; nod h; edg link, v, u; nod vis; nod fz; int ju; void creat(int x, int y) { link[++e] = h[x]; h[x] = e; v[e] = y; link[++e] = h[y]; h[y] = e; v[e] = x; } ... |
#include <bits/stdc++.h> using namespace std; const int K = 5; void NO() { puts( unfair ); exit(0); } int main() { int n, b, q; scanf( %d%d%d , &n, &b, &q); vector<pair<int, int>> w; w.push_back(make_pair(b, n)); while (q--) { int a, b; scanf( %d%d , &a, &b); w.pu... |
#include <bits/stdc++.h> using namespace std; char W[1000 + 10]; int N[1000 + 10]; int main() { int n, m; scanf( %d%d%s , &n, &m, W); for (int i = 0; i < n; ++i) (N[i] = W[i] - a ); bool fixed = false; for (int i = n - 1; i >= 0; --i) { while (true) { N[i]++; if (N[i] ... |
#include <bits/stdc++.h> using namespace std; int matriz[1010][1010]; void verifica(int i, int j); int main(void) { int n, m, d; d = 0; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char a; cin >> a; if (a == # ) { matriz[i][j... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long large = 1e11, remi2 = 998244353; const long long remi = 1e9 + 7, inf = LLONG_MAX; const long double Pi = acos(-1); long long PowI(long long a, long long b, long long m) { ... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; bool Finish_read; template <class T> inline void read(T &x) { Finish_read = 0; x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; if (ch == EOF) return; ch = getchar();... |
#include <bits/stdc++.h> using namespace std; int i, j, n, t, k1[10000], k2[10000], cz1 = 0, cz11 = 0; char s1[10000], s2[10000]; int main() { scanf( %d , &n); while (n--) { scanf( %d , &t); scanf( %s , s1); scanf( %s , s2); for (i = 0; i < strlen(s1); i++) { k1[i] = s1[i... |
#include <bits/stdc++.h> using namespace std; long long n, p; int get(int x) { int sum = 0; while (x) { if (x & 1) sum++; x >>= 1; } return sum; } int main() { scanf( %lld%lld , &n, &p); int sum = 0; while (n - sum * p > 0) { int s = get(n - sum * p); if (su... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<long long> a(n), b(n), idxs(n + 1), ans(n, n); multiset<long long> s1, s2; for (long long i = 0; i < n; i++) { cin >> a[i]; idxs[a[i]] = i; ... |
#include <bits/stdc++.h> using namespace std; long long dp[300005]; int main() { long long n, k; cin >> n >> k; for (int i = 1; i <= n; i++) for (int j = i + i; j <= n; j += i) dp[j]++; long long sum = 0, m = 0; for (int i = 1; i <= n; i++) { sum += dp[i]; if (sum >= k) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, s, p, x[100001], t[100001], w[100001]; void sort1(int l, int r) { int i, j, y, z; i = l; j = r; y = x[(l + r) / 2]; do { while (x[i] < y) { i++; } while (x[j] > y) { j--; } if (!(i > ... |
#include <bits/stdc++.h> using namespace std; long long n, k; priority_queue<pair<long long, pair<long long, long long>>> pq; long long divide(long long x, long long y) { if (x < y) return 1e16; long long t = x / y, rm = x % y; t += rm / y; rm %= y; return rm * (t + 1) * (t + 1) + (y - rm) *... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define inf INT_MAX #define minf INT_MIN #define infl LLONG_MAX #define minfl LLONG_MIN #define mod 1000000007 /*----------------------Debugger-----------------------------------*/ #ifndef ONLIN... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } 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 >> ... |
/*************************************************************** File name: CF1517F.cpp Author: ljfcnyali Create time: 2021年04月27日 星期二 10时19分32秒 ***************************************************************/ #include<bits/stdc++.h> using namespace std; #define REP(i, a, b) for ( int i = (a), _e... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); int n, q, i; cin >> n; int arr[106] = {}; for (i = 1; i <= n; i++) { cin >> arr[i]; } cin >> q; int x, y; while (q--) { cin >> x >> y; arr... |
#include <bits/stdc++.h> using namespace std; struct bus { double t, v; double cost, time; }; bus bus[100000]; int main() { int n, a, d; scanf( %d%d%d , &n, &a, &d); double fastest = 0.0; double x, y; for (int i = 0; i < n; i++) { scanf( %lf%lf , &bus[i].t, &bus[i].v); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100050; vector<int> E[N]; queue<int> q[2]; int c, in[N], col[N], sol; int main() { int n, m, u, v, i; scanf( %i %i , &n, &m); for (i = 0; i < n; i++) scanf( %i , &col[i]); while (m--) { scanf( %i %i , &u, &v); E[v].push_... |
#include <bits/stdc++.h> const int mod = 1e9 + 7; using namespace std; bool sortcol(const vector<int>& v1, const vector<int>& v2) { return v1[1] < v2[1]; } void fastio() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool compare(const pair<long long int, long long int>& a, ... |
#include <bits/stdc++.h> using namespace std; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b % 2) ans = ans * a; a = a * a; b = b / 2; } return ans; } vector<int> pos; stack<long long> num; stack<char> ch; long long cal(string s) { whi... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 7; bitset<N> a[60]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n, m; cin >> m >> n; for (int i = 0, t; i < m; i++) { cin >> t; for (int j = 0, x; j < t; j++) cin >> x, a[i].set(x); ... |
#include <bits/stdc++.h> using namespace std; vector<int> build(int n) { map<int, bool> s; for (int i = 2; i * i <= n; i++) { if (s[i] == false) { for (int j = 2 * i; j <= n; j = j + i) s[j] = true; } } vector<int> t; for (int i = 2; i <= n; i++) { if (s[i] == false) t.... |
#include <bits/stdc++.h> using namespace std; int main() { long sum, i, j; cin >> sum; vector<long> length(3); for (i = 0; i < 3; i++) cin >> length[i]; vector<vector<long> > dp(2, vector<long>(sum + 1, INT_MIN)); dp[3 % 2][0] = 0; for (i = 2; i >= 0; i--) { for (j = 0; j <= sum; j... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long add(long long x, long long y) { x += y; if (x >= mod) x -= mod; return x; } long long mul(long long x, long long y) { return (x * y) % mod; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ... |
#include <bits/stdc++.h> using namespace std; uint64_t rnd_data = 0xDEADBEEFDULL; inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; } inline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; } template <typename T> void my_... |
#include <bits/stdc++.h> using namespace std; int n, x, ans = 0; vector<int> a, b; bool cmp(const int &a, const int &b) { return a > b; } int main(int argc, char *argv[]) { scanf( %d%d , &n, &x); a.resize(n); b.resize(n); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } for (i... |
#include <bits/stdc++.h> using namespace std; const int N = 30; int n, m, T; string s[N], t[N]; int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < m; i++) cin >> t[i]; cin >> T; while (T--) { int x; ... |
#include <bits/stdc++.h> using namespace std; struct Hungary { vector<int> g[1005]; int from[1005], mx[1005], ans; bool use[1005]; int n, sume; int nume[1005]; bool match(int x, int exp) { for (int i = int(0); i < int(g[x].size()); ++i) { if (g[x][i] == exp) continue; i... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 1e6 + 10; int main() { int n; cin >> n; map<int, int> mc; for (int i = 1; i <= n; i++) { int x; cin >> x; mc[x] = i; } pair<int, int> ans = {INF, INF}; for (auto &p : mc) { ... |
#include <bits/stdc++.h> using namespace std; long long const INF = 1e18; long long s[300100], a[300100]; int n, k; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; s[n + 1] = 0; for (int i = n; i >= 1... |
#include <bits/stdc++.h> using namespace std; double tux, pur, foo, bar, baz, quz = 1; int main() { cin >> tux; for (int i = 1; i <= tux; i++) { cin >> pur; foo += pur; bar++; if (foo * quz > baz * bar) { baz = foo; quz = bar; } } printf( %.6lf , baz /... |
#include <bits/stdc++.h> int main(int argc, char **argv) { long count = 0; std::cin >> count; long sum = 0; long tmp; long size; do { sum += (tmp = count); size = (count / 2) + 1; int offset = (count % 2) ? 2 : 1; int start = (count % 2) ? 3 : 2; for (long i = sta... |
#include <bits/stdc++.h> using namespace std; int n, men = 0, pluss = 0, nol = 0; long long a, ans = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) { cin >> a; if (a < 0) { ans += (-1 - a); m... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; if (d == 0) cout << Hermione << endl; else if (c == 0) cout << Ron << endl; else if (b == 0) cout << Hermione << endl; else if (a == 0) cout... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long long; using ld = long double; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; vector<ll> a(n); vector<pair<ll, ll>> b; for (int i = 0; i < (n); i++) { cin >> a[... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e3 + 5; string s, p; int nxt[MAX]; vector<int> cost; int memo[MAX][MAX]; int roll(int idx, int val) { if (idx >= (int)cost.size()) { return 0; } int &ans = memo[idx][val]; if (~ans) { return ans; } ans = rol... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 9; vector<int> g[N]; int a[N], cnt[N], b[N << 1], c[N << 1]; int *vis = b + N, *val = c + N; set<int> S, now; int main() { int n; scanf( %d , &n); for (int i = (1); i < (n + 1); ++i) scanf( %d , &a[i]), cnt[a[i]]++, g[a[i]... |
#include <bits/stdc++.h> using namespace std; const int MAX = int(5e3); const int MOD = int(1e9 + 7); const int oo = INT_MAX; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, d, h; while (cin >> n >> d >> h) { if (2 * h < d) { cout << -1 << n ; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int n = 0, f = 1; char c; for (c = getchar(); c != - && (c < 0 || c > 9 ); c = getchar()) ; if (c == - ) c = getchar(), f = -1; for (; c >= 0 && c <= 9 ; c = getchar()) n = n * 10 + c - 48; return n * f; } s... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; void query() { int n, m; cin >> n >> m; vector<string> t(n); for (auto& i : t) cin >> i; vector<vector<int>> col(n, vector<int>(m, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) col[i][j] = (i > ... |
#include <bits/stdc++.h> using namespace std; void add(long long &a, long long b) { a += b; if (a >= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + 23333 * 7 + 2333 + 233 * 4 + 23 * 3 + 2 + 2 + 2 + 3 + 3 + 3)) { a -= (233333333 * 4 + 23333333 * 2 + 2333333 * 8 + 233333 * 5 + ... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 101; long long mat[MAX][MAX], ans[MAX][MAX], arr1[MAX], arr2[MAX]; int main() { long long n, m, h; cin >> n >> m >> h; for (long long i = 0; i < m; i++) cin >> arr2[i]; for (long long i = 0; i < n; i++) cin >> arr1[i]; for (... |
#include <bits/stdc++.h> using namespace std; int main() { long long int s, v1, v2, t1, t2, q1, q2; cin >> s >> v1 >> v2 >> t1 >> t2; q1 = 2 * t1 + s * v1; q2 = 2 * t2 + s * v2; if (q1 < q2) { cout << First n ; } else if (q1 > q2) { cout << Second n ; } else { cout <<... |
#include <bits/stdc++.h> using namespace std; long long int n, k, ans; long long int check(long long int v) { long long int sum = 0; while (v > 0) { sum += v; v /= k; } return sum; } void BS(long long int l, long long int r) { while (l <= r) { long long int mid = (l + (r ... |
#include <bits/stdc++.h> using namespace std; void qmax(long long &x, long long y) { if (x < y) x = y; } void qmin(long long &x, long long y) { if (x > y) x = y; } inline long long read() { char s; long long k = 0, base = 1; while ((s = getchar()) != - && s != EOF && !(isdigit(s))) ... |
#include <bits/stdc++.h> using namespace std; struct wut { int op; int val; int nval; wut() {} wut(int a, int b) : op(a), val(b) {} }; struct node { long long sum[5]; int ile; node() { for (int i = 0; i < (5); ++i) sum[i] = 0; ile = 0; } }; const int N = 10001... |
#include <bits/stdc++.h> const int maxn = 1e5 + 10; using namespace std; int head[maxn], deep[maxn], k; int f[maxn][23]; int n, q, root; struct edge { int v, next; } e[maxn << 1]; void adde(int u, int v) { e[k].v = v; e[k].next = head[u]; head[u] = k++; } void init() { k = 0; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; constexpr int LG = 60; int N; long long int ai, bi, bs; long long int x[LG + 1]; inline bool ins(long long int v) { for (int i = LG; i >= 0; --i) { if (!((v >> i) & 1)) continue; if (x[i]) { v ^= x[i]; ... |
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; using namespace std; int a[105]; int b[105]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } int x = 0; int y = 0; i... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } const int N = 2010; bitset<N> base[N... |
#include <bits/stdc++.h> using namespace std; long long f[200]; int main() { int n; cin >> n; f[1] = 0; for (int i = 0; i < 101; i++) { f[i] = f[i - 1] + (i / 2); } cout << f[n] << endl; for (int i = 1; i <= n; i++) { int x = i - 1; while (x > 0) { cout << i <... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k = 0; cin >> n; int arr[n], brr[n], crr[n]; for (int i = 0; i < n; i++) { cin >> arr[i] >> brr[i]; crr[i] = arr[i]; } sort(crr, crr + n); for (int i = 0... |
#include <bits/stdc++.h> inline char gc() { static char buf[10000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; int f = 1; char c = gc(); for (; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, p, q, x = 0, y = 0, ans; cin >> n >> k; p = q = n; while (p % 2 == 0) { p /= 2; x++; } while (q % 5 == 0) { q /= 5; y++; } p = k - x; q = k - y; if (p < 0) p = 0; if (q < 0)... |
#include <bits/stdc++.h> using namespace std; const int inf = 2000000000; const int N = 1e5 + 5; bool ok = false; int mid, lx, ly, first, second, n, down, up, level[N]; vector<pair<int, int>> g[N]; int dfs(int v, int size, int ¢er, int pr = 0) { int sum = 1; for (int i = 0; i < g[v].size(); i+... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; long long w; cin >> n >> w; pair<long long, int> wt[n]; for (int i = 0; i < n; i++) { cin >> wt[i].first; wt[i].second = i + 1; } vector<int> taken; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1e4 + 100; struct Date { int x, y; bool z; }; stack<Date> S; int n, m, x, y, flag; struct dsu { int f[Maxn]; bool odd[Maxn]; void clear() { for (int i = 1; i <= n; i++) f[i] = i, odd[i] = false; } int find(int... |
#include <bits/stdc++.h> const int N = 110000; using namespace std; set<pair<int, int> > elements; set<pair<int, int> >::iterator it; int n; int ar[N]; int next_lucky[N], prev_lucky[N]; bool is_lucky[N]; vector<int> luck; long long ans; long long BIN[N]; set<int> banned_set; set<pair<int, int>... |
#include <bits/stdc++.h> using namespace std; int n, xa, ya; int i, j, viz[501][501], light[501][501], d[501][501]; string ans; void paint(int x, int y) { viz[x][y] = 1; if (light[x][y] == 0) light[x][y] = 1, ans += 1 ; int up, down, right, left; up = down = right = left = 0; for (j = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int mod = 998244353; const int inv = 332748118; int n; long long ans, js[N], ni[N]; inline long long C(int x, int y) { if (x < 0 || y < 0 || x < y) return 0; return js[x] * ni[y] % mod * ni[x - y] % mod; } inline long l... |
#include <bits/stdc++.h> using namespace std; bool f[501][501]; long long P[501]; int main(int argc, char *argv[]) { int N, M, i, u, v, k, l; cin >> N >> M; for (i = 1; i <= N; i++) cin >> P[i]; for (i = 1; i <= N; i++) for (k = 1; k <= N; k++) f[i][k] = false; for (i = 1; i <= M; i++)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.