func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long int n, ar[100001], max_s[100001], max_e[100001], pre_s[100001], pre_e[100001], ans = INT_MIN; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> ar[i]; for (int i = 1; i < n; i++) pre_s[i] = pre_s[i - 1] + ar[i - 1]; for (int i =... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996); long long int n, h[1000007], d[1000007][2], mod = 1e9 + 7; void solve() { long long int i, j; cin >> n; for (i = 0; i < n; i++) { cin >> h[i]; h[i] -= 1; } h[n] = 0; d[0][0] = max((long long int)0,... |
#include <bits/stdc++.h> using namespace std; int setBit(int n, int pos) { return n | (1 << pos); } int resetBit(int n, int pos) { return n & ~(1 << pos); } bool checkBit(int n, int pos) { return n & (1 << pos); } inline long long bigmod(long long p, long long e, long long M) { long long ret = 1; whil... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx ) using namespace std; int n, q, fa[66666], aa[66666], kh[66666], a[66666], p[66666], fp[66666], siz[66666], ck, pa[66666]; vector<int> edge[66666]; int dd[66666]; void dfs(int u) { siz[u] = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; for (int i = 1; i <= 1000000000; i++) { if (i % 2 == 1) { if (a >= i) { a -= i; } else { cout << Vladik ; return 0; } } else { if (b >= i) { ... |
#include <bits/stdc++.h> using namespace std; int f[4005][4005]; int a[4005]; int main() { int i, j, k, n, m = 0; memset(f, 0, sizeof(f)); cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; k = 0; for (j = 0; j < i; j++) { f[i][j] = f[j][k] + 1; if (a[j] == a[i])... |
#include <bits/stdc++.h> using namespace std; inline long long isqrt(long long k) { long long r = sqrt(k) + 1; while (r * r > k) r--; return r; } inline long long icbrt(long long k) { long long r = cbrt(k) + 1; while (r * r * r > k) r--; return r; } inline long long mnz(long long& a,... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<string> res; for (int i = 0; i < t; ++i) { long long int a, b; cin >> a >> b; if (a > b) swap(a, b); if ((a + b) % 3 == 0 && 2 * a >= b) res.push_back( YES ); else res.pus... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 + 10; map<char, int> d, t; string s; string know[MAXN]; int pd[MAXN]; int n, m, ans, q, x; int main() { cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] != * ) x++; } if (x == s.size()) { ... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { int c; while (a != 0) { c = a; a = b % a; b = c; } return b; } int main() { ios_base::sync_with_stdio(0); int n, m, b = 0; cin >> n >> m; vector<vector<int> > arr(n, vector<int>(4, 0)); fo... |
#include <bits/stdc++.h> using namespace std; int a[1001], b[1001], c[1001], d[1001]; int ans[2][1001]; int main() { int n, m, c0, d0; cin >> n >> m >> c0 >> d0; for (int i = 0; i < m; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i]; ans[0][0] = 0; for (int i = 1; i <= n; ++i) { ans[0][i] = a... |
#include <bits/stdc++.h> using namespace std; using ld = long double; using ll = long long; using ull = unsigned long long; const int INF = 1 << 30; const ll LINF = 1LL << 60; const int SZ = 1 << 13; char buff[SZ], *pos = buff + SZ - 1; inline ll read() { ll x = 0; int f = 1, c = (++po... |
#include <bits/stdc++.h> using namespace std; const int N = 200002; vector<vector<pair<int, int> > > ans; vector<vector<int> > cs, twoCs, threeCs; int n, p[N]; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) cin >> p[i]; bool mark[N] = {}; for (int i = 1; i <... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) const int N = 550; using namespace std; int n; int m; int k; long long d[N][N][2]; long long cost[N][N]; vector<pair<int, long long> > R[N][N]; vector<pair<int, long long> > D[N][N]; vector<pair<int, long long> > nv; void normal(vector<pair<... |
#include <bits/stdc++.h> using namespace std; long long n, _C; long long lo, hi; set<long long> S; vector<long long> vec; int actual; long long offset; void ask(long long x) { S.insert(x); vec.emplace_back(x); if (actual) cout << ? << x << n ; if (actual) cin >> x; else ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, n; cin >> t; while (t--) { long long x; double sum = 0; cin >> n >> x; vector<long long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5 + 5; int n, m; ll c[N]; vector<int> adj[N]; map<vector<int>, ll> mp; ll custom_gcd(ll a, ll b) { ll c; while (b > 0) { c = a % b; a = b; b = c; } return a; } void solve() { mp.... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 1; char a[N][N]; int f[N * 2], head[1000001], vis[2 * N], d[N * 2], d1[N * 2], bj[N * 2]; int ask(int x) { return x == f[x] ? x : f[x] = ask(f[x]); } struct node { int next, to; } e[N * N]; int tot; void add(int x, int y) { e[+... |
#include <bits/stdc++.h> using namespace std; typedef long double ld; const long long inf = 1100000000000000000; #define maxn 1000005 #define mod 1000000007 //998244353 #define int long long #define PB push_back #define eb emplace_back #define all(c) (c).begin(),(c).end() #define pii pair <int,i... |
#include <bits/stdc++.h> using namespace std; long n, ps[1000], tp, q, ar[1000], ans, x, y, a, b; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[i]; ps[ar[i]] = i; } cin >> q; for (; q; --q) { cin >> tp; if (tp == 2) { ... |
#include <bits/stdc++.h> using namespace std; long long n, a = 0; int main() { cin >> n; n = abs(n); while ((a * (a + 1)) / 2 < n || ((a * (a + 1)) / 2) % 2 != n % 2) a++; cout << a; return 0; } |
#include <bits/stdc++.h> void solve() { int n; std::cin >> n; int a = 0; std::string s; std::cin >> s; bool flag = false; int x, y; x = y = 0; if (s[0] == U ) { ++y; } else { ++x; } if (x > y) flag = true; for (size_t i = 1; i < s.size(); ++i) { i... |
#include <bits/stdc++.h> using namespace std; int main() { long long d = 0, n, i; cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] > d) d++; } cout << d << endl; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int pos[N]; int main() { ios::sync_with_stdio(false); int n, a; while (cin >> n) { for (int i = 1; i <= n; ++i) { cin >> a; pos[a] = i; } int last = 0; for (int i = 1; i <= n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<long long> a(n + 1, 0); long long s1 = 0, s2 = 0, s3 = 0; for (int i = 1; i <= n; i++) { scanf( %lld , &a[i]); a[i] += a[i - 1]; } if (a[n] % 3) { cout << 0 n ; return; } ... |
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <algorithm> #include <numeric> #include <queue> #include <iomanip> #include <numeric> #include <cmath> using namespace std; int main() { int t; cin >> t; f... |
#include <bits/stdc++.h> using namespace std; const int N = 2.5 * 1e5 + 5; int n, m, k; int d[N]; struct Edge { int num; int next; } edge[4 * N]; int tot, last[N]; vector<int> q; vector<int> ans[N]; vector<int> path; int anss; bool flag; void Add(int i, int j) { tot++; edge[tot... |
#include <bits/stdc++.h> using namespace std; int main() { int test_case; cin >> test_case; while (test_case--) { int a, b, x, y; vector<int> akash; cin >> a >> b >> x >> y; int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0; temp1 = ((b - y) - 1) * a; temp2 = ((a - x) - ... |
#include <bits/stdc++.h> using namespace std; int a[20000]; int main() { ios_base::sync_with_stdio(NULL); int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (x == 1) { cout << HARD ; return 0; } } cout << EASY ; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a[105]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = n - 1; i >= 0; i--) cout << a[i] << ; cout << endl; } return 0; } |
#include <bits/stdc++.h> const int N = 1000000; int n; char str[N + 10]; int cdog = 0, fdog = 0, ldog = 0, cbone = 0, fbone = 0, lbone = 0; int cntd[N + 10], cntb[N + 10]; int nxtd[N + 10], nxtb[N + 10]; int lstd[N + 10], lstb[N + 10]; int tp1[N + 10], tp2[N + 10][2]; bool dp[N + 10]; bool chk(int x... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005, MAXM = 1000005, MAXT = 1 << 18; struct Edge { int to, val, next, id; } edge[MAXM]; struct MST { int u, v, w, id; } mst[MAXM]; int ppar[MAXN], head[MAXN], ist[MAXM], dep[MAXN], n, m, tot; void addedge(int u, int v, int w, int ... |
#include <bits/stdc++.h> using namespace std; int a[17][17]; int main() { int n, m, k, need; scanf( %d%d%d%d , &n, &m, &k, &need); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int x, y; scanf( %d%d , &x, &y); a[x][y] = 1; } } int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 5; vector<int> G[M]; int n, A[M], num, ok, res, ans[2][M], C; bool mark[M]; void ma(int a, int b) { if (a == b || mark[a] && mark[b]) return; printf( %d %d n , a, b); ans[0][C] = a; ans[1][C] = b; C++; mark[a] = mark[b... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int INF = 1e9 + 10; const int N = 1e2 + 5; int mark[N]; int ans; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; mark[x] = i + 1; } for (int i = 0; i < N;... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, len; char s[105]; cin >> s; len = strlen(s); for (i = 0; i < len; i++) { for (j = 0; j < len - i - 2; j += 2) { if (s[j] > s[j + 2]) { swap(s[j], s[j + 2]); } } } printf( %s , s); ... |
#include <bits/stdc++.h> int c[100]; int main() { int n, s, max = 0, i, j; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &s); c[s] += 1; if (s > max) max = s; } for (i = 0; i <= max; i++) for (j = 0; j < c[i]; j++) printf( %d , i); return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, k, m, d, i = 0, b = 1, ans = 0; int main(void) { cin >> n >> k >> m >> d; for (i = 1; i <= d && b <= n; i++, b += k) { ans = max(ans, min(m, n / b) * i); } cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; struct node { long long x; bool s; node(long long a, bool b) { x = a, s = b; } }; bool operator<(node a, node b) { return a.x > b.x; } priority_queue<node> pq; int main() { int n; long long temp; cin >> n; long long ans = 0; for (... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long ar[n + 1]; for (long long i = 1; i <= n; i++) { cin >> ar[i]; } for (long long i = 1; i <= n; i++) { long long f = ar[i]; long long ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MOD = 1e9 + 7, MAX = 1e6 + 5; const long long INF = 1e18 + 5; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int a[10] = {0}; int n; string d; cin >> n; cin >> d; for (int i = 0; i < d.size(); i++) { if (d[i] == L ) { for (int j = 0; j < 10; j++) { if (a[j] == 0) { a[j] = 1; break; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, mod = 1e9 + 7; int n, K, ans, cnt; char s[5]; struct DSU { int fa[N]; bool mark[N]; int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); } bool merge(int x, int y) { int fx = getfa(x), fy = getfa(y); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const double eps = 1e-9; const double pi = acos(-1); struct P { int x, y; } a[N]; int n, vi[N], t[N]; double l[N], r[N], q[N]; long long k; void change(int k, int v) { for (; k; k -= k & (-k)) t[k] += v; } int ask(int k)... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int n; long long a[1005][2]; long long mi = ((1ll << 62) - 1); void calc(long long x) { int i; long long sum = 0; int cnt = 0; vector<pair<int, int> > v; for (i = 0; i < n; i++) { if (a[i][0] <= x && a[i]... |
#include <bits/stdc++.h> using namespace std; void reverse_(vector<int> num) { vector<int> a; for (int i = num.size() - 1; i > -1; i--) a.push_back(num[i]); num = a; } int main() { int n, x; cin >> n >> x; vector<int> num(n), used(1e5 + 7, 0), step(1e5 + 7, 1e9); set<int> all; fo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; long long p[n], y; set<long long> c[4]; set<long long>::iterator it; c[1].insert(-1); c[2].insert(-1); c[3].insert(-1); int temp; for (int i = 0; i < n; i++) cin >> p[i]; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; int edge[510][510], vis[510], con, N, M, f, t; void dfs(int x) { vis[x] = 1; for (int i = 1; i <= N; i++) if (edge[x][i]) { if (!vis[i]) dfs(i); else if (vis[i] == 1) con++; if (con >= 2) break; } vis... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, g, a[100001], p[100001], maxi; vector<long long> v; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; p[a[i]] = i + 1; } g = 1; for (i = 1; i < n; i++) { if (p[i] <= p[i + 1]) { g++; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, i, j, k, cnt, tot, f[maxn]; char s[maxn]; int main() { scanf( %d%s , &n, s + 1); if (n & 1) return puts( 0 ), 0; tot = n >> 1; f[0] = 1; for (i = 1; i <= n; i++) { if (s[i] == ? ) for (j = i >> 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int count = 0; int groups = 0; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T checkmin(T &a, T b) { return (a < b) ? a : a = b; } template <class T> inline T checkmax(T &a, T b) { return (a > b) ? a : a = b; } template <class T> T GCD(T a, T b) { if (a < 0) return GCD(-a, b); if (b < 0) re... |
#include <bits/stdc++.h> using namespace std; int a[7][7][101]; int d[101], t[7]; char cd[101]; bool dfs(int now, int saw, int n) { if (saw == n) return true; for (int i = 0; i < 7; i++) if (a[now][i][0] > 0) { d[saw] = a[now][i][a[now][i][0]]; cd[saw] = + ; a[now][i][0]... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000009; int n, m, k; class Mat { public: long long e[2][2]; Mat mul(Mat u) { Mat s; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { s.e[i][j] = 0; for (int k = 0; k < 2; k++) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream &operator<<(ostream &out, const vector<T> &data) { out << [ ; for (int i = 0; i < data.size(); ++i) out << data[i] << (i == data.size() - 1 ? : , ); out << ] ; return out; } template <class T> ostream &opera... |
#include <bits/stdc++.h> const double eps = 1e-10; int n, a, b, cnta[100010], cntb[100010]; double p[100010], q[100010], f[100010]; void check2(double costa, double costb) { for (int i = 1; i <= n; i++) { f[i] = 0; cnta[i] = 0; cntb[i] = 0; f[i] = f[i - 1]; cnta[i] = cnta[i - 1... |
#include <bits/stdc++.h> using namespace std; using s64 = long long; const int M = 1000000007; int add(int a, const int &b) { a += b; return a >= M ? a - M : a; } int sub(int a, const int &b) { a -= b; return a < 0 ? a + M : a; } int mul(const int &a, const int &b) { return (s64)a * b % ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e9 + 7; map<long long, long long> factorize(long long n) { map<long long, long long> ans; for (long long i = 2; i * i <= n; i++) { while (n % i == 0) { ans[i]++; n /= i; } } if (n > 1) { ans[n]++; ... |
#include <bits/stdc++.h> using namespace std; const int infi = 1e9 + 7; const long long infl = (long long)1e18 + (long long)7; const long long mod = 998244353; long long sum[300500]; long long get_sum(int l, int r) { if (l > r) { return 0; } if (l) { return sum[r] - sum[l - 1]; }... |
#include <bits/stdc++.h> using namespace std; long a[1000000], m, n, i, j, k, l, ma, mi; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; if (n <= 2) { cout << -1 << endl; return 0; } for (i = 1; i <= n - 2; i++) if (a[i] != a[i + 2]) { if (a[i] == a[i + 1... |
#include <bits/stdc++.h> using namespace std; int main() { bitset<30> a; bitset<30> b; a.reset(); b.reset(); bool bigger = 0; cout << ? 0 0 << endl; fflush(stdout); int aa; cin >> aa; if (aa == -1) { bigger = 1; } bitset<30> adda; bitset<30> addb; for ... |
#include <bits/stdc++.h> using namespace std; int n, m, q; int arr[26]; string s; long long dp[1001][1001]; int mn = 1 << 20, mx = 0; long long solve(int idx, int sz, int mn) { if (sz > mn) return 0; mx = max(mx, sz); if (idx == n) return 1; if (dp[idx][sz] != -1) return dp[idx][sz] % 1000... |
#include <bits/stdc++.h> using namespace std; int n, m, k; string a[12]; int b[12], vis[40]; vector<string> v; void solve(int i, int rem) { if (i == k + 1) { if (rem == 0) { string s = ; for (int j = 1; j <= k; j++) { if (vis[j]) s += a[0][j]; else... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; void MAIN(); int main() { MAIN(); return 0; } const int N = (int)1e5 + 32; char s[N]; int n; void MAIN() { scanf( %d , &n); scanf( %s , s); vector<int> cnt(26, 0); for (int i = 0; i < int(n); i++) cnt[s... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, x, i, j; cin >> n >> x; long long int mm = 0; long long int mx = 0; for (i = 0; i < n; i++) { long long int a, b; cin >> a >> b; mm = max(mm, a - b); mx = max(mx, a); } if (x <= mx) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 5010 + 10; const int mod = 1e9 + 7; char s[N]; char t[N]; int d[N][N]; int main() { int n, m; cin >> n >> m; scanf( %s%s , s + 1, t + 1); int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, k; cin >> n >> k; long long ans[6][3] = {0, 1, 2, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 0, 1, 0, 2, 1}; cout << ans[n % 6][k] << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T> T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> T ModInv(T ... |
#include <bits/stdc++.h> using namespace std; char str[10000 + 1]; int M; char tmp[10000 + 1]; int main() { scanf( %s , str); scanf( %d , &M); for (int t = 0; t < M; t++) { int l, r, k; scanf( %d %d %d , &l, &r, &k); int s_len = (r - l + 1); k = k % s_len; --l, --r; ... |
#include <bits/stdc++.h> using namespace std; int n, m, h, t, r, x, y, dis[210][210], h1[210], t1[210], h2[210], t2[210], bfs[210 * 210][2], L, R; void renew(int x, int y, int v) { if (x + y > r) return; if (dis[x][y] == -1) { dis[x][y] = v; bfs[++R][0] = x; bfs[R][1] = y; } ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 200011; long long n, i, j, cntx, cnty, x, y, z; long long vx[maxN]; map<long long, long long> Mx, My; map<pair<long long, long long>, long long> M; pair<long long, pair<long long, long long> > low; vector<vector<long long> > data; vector<l... |
#include <bits/stdc++.h> using namespace std; int n, k, mod = 1000000007; bool ok[1005]; char a[1005], b[1005]; int cnt[2][1005], tp, tn; int solve() { scanf( %s , a); scanf( %s , b); n = strlen(a); scanf( %d , &k); int cg = 0; for (int i = 0; i < n; i++) { ok[i] = true; ... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5; int v[NMAX + 5], ans[NMAX + 5]; inline void GenerateAnswer(int n) { int i, state = 1, st = 1, dr = n, dim = 0; sort(v + 1, v + n + 1); while (st <= dr) { if (st != dr) { if (state == 1) ans[++dim] = v[st], an... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; string s; cin >> s; if (s[0] == @ || s.back() == @ || (s.find( @ ) == -1)) { cout << No solution ; return 0; } vector<int> v; for (in... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4010; int N; long long V[MAXN], D[MAXN], P[MAXN]; set<int> st; int main() { if (fopen( input.txt , r )) { freopen( input.txt , r , stdin); } ios::sync_with_stdio(false); cin >> N; for (int i = 1; i <= N; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 10; const int INF = 0x3f3f3f3f; const double EPS = 1e-10; inline int read() { int ret = 0, f = 0; char ch = getchar(); while (ch > 9 || ch < 0 ) f ^= ch == - , ch = getchar(); while (ch <= 9 && ch >= 0 ) ret = ret * 10... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; constexpr long long mod = 998244353; const long long INF = mod * mod; const long double eps = 1e-12; const long double pi = acosl(-1.0); long long mod_pow(long long x, long long n, long long m =... |
#include <bits/stdc++.h> const int N = 1000001; using namespace std; vector<int> a[N]; bool st[N], vis1[N]; void f(int u) { st[u] = true; vis1[u] = true; for (int v : a[u]) { if (st[v]) { cout << Draw ; exit(0); } if (!vis1[v]) { f(v); } } s... |
#include <bits/stdc++.h> using namespace std; int n, m, k; bool a[2501][2501]; int sum[2501][2501]; long long ans = 0; int get(int x1, int x2, int y1, int y2) { return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1]; } void solve(int x1, int y1, int x2, int y2) { if (x1 == ... |
#include <bits/stdc++.h> using namespace std; int nf, ne, ns, rf, re, rs, df, de; double disf, dise, diss; int num[22]; double f[22][22][22]; double ans; double valf[22], vale[22]; inline double cover(double l1, double r1, double l2, double r2) { return max(0.0, min(r1, r2) - max(l1, l2)); } voi... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int mod(int x, int m) { if (x < 0) x += m; return x % m; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); int m... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char now[1 << 16], *S, *T; if (T == S) { T = (S = now) + fread(now, 1, 1 << 16, stdin); if (T == S) return EOF; } return *S++; } inline long long read() { register long long x = 0, f = 1; char ch = gc(); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long a[n]; for (int i = 0, ggdem = n; i < ggdem; ++i) cin >> a[i]; long long yo = -1; for (int i = 0, ggdem = n; i < ggdem; ++i) { if (a[... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { int t = 1; cin >> t; while (t--) solve(); return 0; } int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } void solve() { int n; cin >> n; vector<int> a(n); int maxEle = -1; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int sum = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) { sum = (sum << 1) + (sum << 3) + (c ^ 48); c = getchar(); } return sum; } int n, k, a, m; set<int> s; set<int>::iterat... |
#include <bits/stdc++.h> using namespace std; int main() { long int n; cin >> n; int flag = 0; while (flag == 0 && n != 0) { if ((n % 10) == 1) n = n / 10; else if ((n % 10) == 4) { if (((n / 10) % 10) == 1) n = n / 100; else if (((n / 10) % 10) == 4) { ... |
#include <bits/stdc++.h> using namespace std; int mx[8] = {-1, 0, 1, -1, 1, -1, 0, 1}, my[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; char a[n + 2][m + 2]; memset(a, 0, sizeof a); for (int i = 1; i <= n; i++) for (int j = 1; j ... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) const long long maxn = 1e5 + 10, LG = 30, mod = 1e9 + 7, inf = 1e18; long long n, m, f[maxn]; vector<long long> in[maxn], out[maxn]; bool mk[maxn], km[maxn]; void dfs(long long v) { mk[v]... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, x; scanf( %d%d , &n, &x); if (n < 2) n = 2; int ans = ((n - 2) + x - 1) / x + 1; printf( %d n , ans); } int main() { int t; scanf( %d , &t); while (t--) solve(); return 0; } |
#include <bits/stdc++.h> using namespace std; string a, b; int main() { cin >> a >> b; int l1 = a.size(); int l2 = b.size(); int maxx = 0; for (int i = 0; i < l1; ++i) { for (int j = i; j < l1; ++j) { int p = 0; for (int k = 0; k < i; ++k) { if (p < l2) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; array<long, 2> a[n], b[n]; long i; for (i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } for (i = 0; i < n; i++) { if (a[i][0] != a[i][1]) { cout << rated ; return 0; } } ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, k, t; cin >> n >> m >> k >> t; pair<long long, long long> p[k]; string s[3] = { Carrots , Kiwis , Grapes }; for (int i = 0; i < k; i++) { cin >> p[i].first >> p[i].second; } sort(p, p + k); for (int ... |
#include <bits/stdc++.h> using namespace std; int n; vector<pair<pair<int, int>, int> > v; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; v.push_back(pair<pair<int, int>, int>(pair<int, int>(x / 20... |
#include <bits/stdc++.h> using namespace std; int m[200001], k, cd; int val[2000001]; void inp() { cin >> cd >> k; for (int i = 1; i <= cd; i++) { cin >> m[i]; val[m[i]]++; } sort(m + 1, m + 1 + cd); } bool check(int i) { if (m[i] <= m[i - 1] + k && m[i] > m[i - 1]) return tr... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } long long ksm(long long a, long long b) { long long r = 1; while (b) { if (b & 1) ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)(1e9 + 7); const long long INF = (long long)(1e9 + 10); const int MAXN = (int)(2e5 + 5); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string caso; cin >> caso; while (caso == start ) { ... |
#include <bits/stdc++.h> using namespace std; int t, n, freq[201][212345]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); vector<int> pos[201]; for (int i = 0; i < 201; ++i) for (int j = 0; j <= n; ++j) freq[i][j] = 0; for (int x, i = 1; i <= n; ++i) s... |
#include <bits/stdc++.h> using namespace std; const double INF = 1e100; int N, T, P[200000], L[200000], S[200000]; struct AddChange { int id; double dif; AddChange(const int i) : id(i) { if (S[i] == L[i]) dif = -INF; else dif = P[i] * ((double)(S[i] + 1) / (S[i] + 1 + L[i... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n, m, q; cin >> n >> m >> q; int grid[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) grid[i][j] = 0; vector<vector<int>> instr(q); for (int ... |
#include <bits/stdc++.h> using namespace std; const int N = 300001; int n, a, b, c, d, start, len; vector<int> T; long long dp[2][N + 2], seg[4 * N]; void build(int p, int s, int e) { if (s == e) { seg[p] = dp[1][s]; return; } build(2 * p, s, (s + e) / 2); build(2 * p + 1, (s + e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.