func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; vector<int> g[4111]; int f[4111], v[4111][4111]; int main() { int n, m; cin >> n >> m; while (m--) { int a, b; cin >> a >> b; if (a > b) swap(a, b); g[a].push_back(b); f[a]++; f[b]++; v[a][b] = v[b][a] = 1; }... |
#include <bits/stdc++.h> using namespace std; void smain(); int main() { ios::sync_with_stdio(false); smain(); return 0; } const int maxn = 300000 + 10; int num[maxn]; int num1[maxn], num2[maxn]; int tot = 1; int min1[maxn], min2[maxn]; int la1[maxn], la2[maxn]; int flo(int a, int b) {... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; void fast() { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } string t; bool solve(int m) { return t.substr(0, m) == t.substr(t.size() - m... |
#include <bits/stdc++.h> using namespace std; int query(int x) { printf( ? %d n , x); int res; fflush(stdout); scanf( %d , &res); return res; } int main() { int n; scanf( %d , &n); int m = n / 2; if (m % 2 == 1) { printf( ! -1 n ); exit(0); } int d = query... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; void solve() { long long int n; cin >> n; vector<long long int> a(n), b; for (auto i = 0; i < (n); i++) { cin >> a[i]; }; int cnt = 0, pos1 = 0, pos2 = 0; for (auto i = 0; i < (n); i++) if (a[i] != i + 1) ... |
#include <bits/stdc++.h> using namespace std; int sdf[30] = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645}; long long int a[71720], b, c, d, n, m, i, j, k, sum, sumend; bool ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int BASE = 27; const int N = 200000 + 2; const int LOGN = 20; const long long oo = 1e18; const double EPS = 1e-9; int n, q, a[N], mn[N], mx[N], freq[N], dsu[N], bst[N], sum[N]; int find(int i) { return dsu[i] == i ? i : dsu... |
#include <bits/stdc++.h> using namespace std; struct query { int t = 0, row = 0, col = 0; long long x = 0; }; int n, m; vector<vector<long long>> mat; void rotate_row(int row) { long long temp = mat[row][m]; for (int i = m; i > 1; i--) { mat[row][i] = mat[row][i - 1]; } mat[row... |
#include <bits/stdc++.h> using namespace std; int N, M; string s[2020]; long long dp[2020][2020][2], C[2020][2020][2], S[2020][2020][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> N >> M; for (int i = 1; i <= N; i++) { cin >> s[i]; s[i] = # + s[i]; } for (in... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf( %d , &n)) { int t = sqrt(n * 1.0); for (int i = t; i >= 1; i--) { if (n % i == 0) { cout << i << << n / i << endl; break; } } } } |
#include <bits/stdc++.h> using namespace std; int main() { int i; int a, b; int draw = 0, awin = 0, bwin = 0; cin >> a >> b; for (i = 1; i < 7; i++) { if (abs(i - a) == abs(i - b)) draw++; else if (abs(i - a) > abs(i - b)) bwin++; else awin++; } ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; const int N = 2e5 + 5, M = 998244353, INF = 0x3f3f3f3f; void Main(); void print() { cout << n ; } template <typename T, typename... U> void print(const T& x, const U&... y) { (... |
#include <bits/stdc++.h> using namespace std; int i; double x, y, n, a, b, rsa, rsb = 1; long long cmmdc(long long a, long long b) { while (a && b) (a > b ? a %= b : b %= a); return a + b; } int main() { ios_base::sync_with_stdio(0); cin >> x >> y >> n; for (b = 1; b <= n; ++b) { a... |
#include <bits/stdc++.h> using namespace std; int N, R, C, g[110][110]; vector<int> A, B; int main() { scanf( %d %d %d , &N, &R, &C); for (int i = 1; i <= (N); i++) { if (i & 1) A.push_back(i); else B.push_back(i); } for (int r = 1; r <= (R); r++) for (int c = 1... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int s[100005]; int mask[25]; struct Reg { int l, r; } reg[23][100]; bool test(int p) { if (p == n) return true; set<int> q[2]; set<int>::iterator pp; int now = 1, nxt = 1; q[0].insert(mask[p] - 1); for (int i = p; i < n... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, s; cin >> a >> b >> s; if (s < abs(a) + abs(b)) cout << NO << endl; else if (s == abs(a) + abs(b)) cout << YES << endl; else { s -= abs(a); s -= abs(b); if (s % 2 == 0) cout <... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { ios::sync_with_stdio(false); cin.tie(NULL); unordered_map<int, int> idx; int N, x; cin >> N; while (N--) { cin >> x; if (x) idx[x] = 1; } cout << idx.size() << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T extgcd(T a, T b, T &x, T &y) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300000; const long long INF = 1e18; const int sqrtConst = 550; const int alphabet = 26; const long long mod = 998244353; void solve() { string s; cin >> s; bool has1 = false; for (int i = 1; i < s.size(); i++) { if (s[i] ... |
#include <bits/stdc++.h> using namespace std; int Q, N, M, K, L; bool board[10001][3]; long long dp[10001][8]; int bitCheck[4][2][2] = { {{-2, 0}, {-1, 0}}, {{1, 0}, {2, 0}}, {{0, 1}, {0, 2}}, {{0, -1}, {0, -2}}}; void getNextStates(int n, int m, int thisState, int nextState, vect... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, mex = N, ans[N]; pair<int, int> a[N]; int main() { cin >> n >> m; for (int i = 1; i <= m; ++i) { int l, r; cin >> l >> r; a[i] = {l, r}; mex = min(mex, r - l + 1); } int cur = 0; cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, l, r, q, nr; string s; string t; cin >> n >> m >> q; cin >> s >> t; int cnt[1001] = {0}; for (int i = 0; i <= n - m; i++) { if (s.substr(i, m) == t) { cnt[i] = 1; } } l = 0; r = 0; ... |
#include <bits/stdc++.h> using namespace std; bool compare(string &s1, string &s2) { return s1.size() < s2.size(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector<string> s; string str; int n, i, j, flag = 0; cin >> n; for (i = 0; i < n; i++) { cin >> str; ... |
#include <bits/stdc++.h> using namespace std; int a, b, t, c, j, k, T, i, A[1028], B[1028], C[1028]; int main() { cin >> a >> b; while (a > 0) { a--; t++; if (t == b) { t = 0; a++; } j++; } cout << j; } |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const long long INF = 2e18; const int maxn = 1e6 + 6; const int mod = 1e9 + 6; const double eps = 1e-15; inline bool read(long long &num) { char in; bool IsN = false; in = getchar(); if (in == EOF) return false; whil... |
#include <bits/stdc++.h> using namespace std; const unsigned long long Mode = 1e9 + 7; void Modulo(unsigned long long &x) { x = ((x % Mode + Mode) % Mode); } unsigned long long Pow(unsigned long long x, unsigned long long y) { unsigned long long res = 1; for (unsigned long long i = 0; (1ULL << i) <= y; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int vals[N], found[N]; struct node { node *left, *right; int val, size, priority; node(int v) { val = v, size = 1, priority = rand(), left = NULL, right = NULL; } }; int sz(node* t) { return (t) ? t->size : 0; } voi... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int n, t[1000001]; struct data { int num, loc, vis; } b[1000001]; int a[1000001]; int lowbit(int x) { return x & (-x); } int Query(int x) { int sum = 0; while (x > 0) { sum = max(sum, t[x]); x -= lowbit(x); } ... |
#include <bits/stdc++.h> using namespace std; int n, k; string s; int main() { cin.tie(0); std::ios::sync_with_stdio(false); cin >> n >> k; cin >> s; if (k == 2) { string s1 = , s2 = ; for (int i = 0; i < s.size(); i++) if (i & 1) s1 += A , s2 += B ; ... |
#include <bits/stdc++.h> using namespace std; int conversion(string p) { int o; o = atoi(p.c_str()); return o; } string toString(int h) { stringstream ss; ss << h; return ss.str(); } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long lcm(long... |
#include <bits/stdc++.h> using namespace std; const int bignumlen = 2200; const int Blen = 8; const long long base = 100000000; struct bignum { int len; long long data[bignumlen]; long long &operator[](int x) { return (data[x]); } const long long &operator[](int x) const { return (data[x]); } ... |
#include <bits/stdc++.h> using namespace std; long long v2[34]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int i = 0; i <= 33; ++i) { if (i == 0) { v2[i] = 1; } else { v2[i] = 2 * v2[i - 1]; } } ... |
#include <bits/stdc++.h> const int N = 1000005; using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } int a[N]; int main() { long long n; cin >> n; long long d, d1, ans; for (l... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, m, n; int main() { cin >> a; cout << a / 2520; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> what(m); ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60777216 ) using namespace std; int err; vector<char> best; vector<char> curr; int n, r; int it; void go(int pos, int f1, int f2, int errors) { if (err <= errors) return; if (pos == -1) { err = errors; best = curr; } else {... |
#include <bits/stdc++.h> using namespace std; mt19937 rnnnd(chrono::steady_clock::now().time_since_epoch().count()); inline int read() { int x = 0, f = 1, c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c... |
#include <bits/stdc++.h> using namespace std; int b[105]; int main() { int n, t, m, k; cin >> t; while (t--) { cin >> n >> m >> k; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n - 1; i++) { if (b[i] + k < b[i + 1]) m -= (b[i + 1] - b[i] - k); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 500; const pair<double, double> inf = make_pair(-1, -1); pair<double, double> T[N << 2]; double f[N]; int n, m; inline int read() { int n = 0; char c; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) ; for (; c >... |
#include <bits/stdc++.h> using namespace std; bool endline = false; template <class T> istream& operator>>(istream& inp, vector<T>& v) { for (auto& it : v) inp >> it; return inp; } template <class T> ostream& operator<<(ostream& out, vector<T>& v) { for (auto& it : v) out << it << (endline ? ... |
#include <bits/stdc++.h> using namespace std; int main() { priority_queue<pair<int, int> > pq1, pq2; int n, w; cin >> n; for (int i = 0; i < n; i++) cin >> w, pq1.push({-w, i}); n <<= 1; for (int i = 0; i < n; i++) { char ch; cin >> ch; pair<int, int> cur; int ret; ... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = acos(-1); template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x;... |
#include <bits/stdc++.h> using namespace std; int n; long long val[100000], dp[100000][2]; vector<int> g[100000]; void dfs(int v, int p) { long long c1 = 0, c2 = 0; for (int i = 0; i < (g[v].size()); i++) { int next = g[v][i]; if (next != p) { dfs(next, v); c1 = max(c1, dp[... |
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f; using namespace std; int yh() { int ret = 0; bool f = 0; char c = getchar(); while (!isdigit(c)) { if (c == EOF) return -1; if (c == - ) f = 1; c = getchar(); } while (isdigit(c)) ret = (ret << 3) + (ret << 1) + (c ^ 4... |
#include <bits/stdc++.h> using namespace std; int last1[510][5010], last2[510][5100], pre[510][5100]; int main() { int s, d; cin >> s >> d; memset(last1, -1, sizeof(last1)); memset(last2, -1, sizeof(last2)); memset(pre, -1, sizeof(pre)); queue<pair<int, int> > q; q.push(make_pair(0, 0)... |
#include <bits/stdc++.h> using namespace std; int N, Q; vector<vector<int> > ad; vector<int> val, par; void fun(int c, int p) { par[c] = p; int i; for (i = 0; i < ad[c].size(); i++) { if (ad[c][i] != p) fun(ad[c][i], c); } } int gcd(int a, int b) { if (b == 0) return a; retur... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m(0), a(0), b(0), c(0), x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (i % 3 == 0) a += x; else if (i % 3 == 1) b += x; else c += x; } m = max(max(a, b), c); if (m == a... |
#include<bits/stdc++.h> using namespace std ; #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long int ////////////////////////////////////////////////////////////////////////////////////////////// void solve(); /////////////////////////////////////////////... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long months, monthlen, weeklen; cin >> months >> monthl... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long INF = 1e9; inline long long pwr(long long base, long long n, long long m) { long long ans = 1; while (n > 0) { if (n % 2 == 1) ans = (ans * base) % m; base = (base * base) % m; n /= 2; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (a <= b) cout << Second ; else cout << First ; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void file() { freopen( alost.in , r , stdin); freopen( output.txt , w , stdout); } bool ar[10000005]; void sieve() { ar[0] = ar[1] = 1; for (long long i = 2; i * i <= (int)1e7; i++) if (!ar[i]) for (... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 1e6 + 5; inline int readint() { char c = getchar(); int ans = 0; while (c < 0 || c > 9 ) { c = getchar(); } while (c >= 0 && c <= 9 ) { ans = ans * 10 + c - 0 , c = getchar(); } ... |
#include <bits/stdc++.h> const int32_t mod = 1e9 + 7; using namespace std; unordered_map<long long, long long> mp; void fun(vector<long long>& v, long long idx, long long sum) { if (idx == (long long)v.size()) { mp[sum]++; return; } fun(v, idx + 1, sum); fun(v, idx + 1, sum - v[idx])... |
#include <bits/stdc++.h> using namespace std; int main() { list<int> L; int N, M; cin >> N >> M; set<pair<int, int> > S; for (int i = 0; i < M; ++i) { int u, v; cin >> u >> v; S.insert(pair<int, int>(u, v)); } L.push_back(1); for (int i = 2; i <= N; ++i) { lis... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, ans = 0, n, k, a[100000]; scanf( %d%d , &n, &k); for (i = 0; i < n; ++i) { scanf( %d , &a[i]); } for (i = 0; i < k && a[i] < 0; ++i) a[i] *= -1; if (i < k) { sort(a, a + n); k -= i; if (k & 1) { ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll DIM = 1e6 + 7; const ll INF = 1e16 + 7; const ll MODULO = 1e9 + 7; ll n,m,nt,k,q; ll val,val1,last,res,c0,c1,c2; int main() { ios_base::sync_with_stdio(); cin.tie(); cout.tie(); ci... |
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1.0l); const long long MOD = 1e9 + 7; bool debug = 1; const int N = 3e3 + 10; int seg[2 * N]; int n, m; void build() { for (int i = n - 1; i > 0; i--) seg[i] = seg[i << 1] + seg[i << 1 | 1]; } int qry(int l, int r) { ... |
#include<bits/stdc++.h> using namespace std; #define pb push_back int i,j,n,m,e; vector<int>v,s; int main() { #ifndef ONLINE_JUDGE freopen( input.txt , r ,stdin); freopen( output.txt , w ,stdout); #endif int t; cin>>t; while(t--) { int k,sum=0; cin>>n>>k; int a[n+5... |
#include <bits/stdc++.h> using namespace std; int l, r, p, prim[100], cnt, a[4000000], n, f[4000000], ans; bool ok[4000000]; void DFS(int x, long long now) { if (x > cnt) return; while (now <= r) { DFS(x + 1, now); now = now * prim[x]; if (now <= r) a[++n] = now; } } int main()... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { int n; long long a = 1, b = 1; char s[10]; scanf( %d , &n); for (int i = int(1); i <= int(n); ++i) { scanf( %s , s); if (strlen(s) == 4) { a++; b++; } else { if (s[0] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long temp; long long a[n]; int fg = 0; for (int(i) = 0; (i) < (n); (i)++) { cin >> temp; fg++; a[i] = temp; } sort(a, a + n); for (int(i) = 0; (i) < (n - 1); (i)++) { if (a[i]... |
#include <bits/stdc++.h> using namespace std; int main() { int k, x, n, m; scanf( %d%d%d%d , &k, &x, &n, &m); for (int f1 = 0; f1 <= 1; f1++) { for (int f2 = 0; f2 <= 1; f2++) { for (int f3 = 0; f3 <= 1; f3++) { int h1 = n, h2 = m; if (f1) h1--; if (f1 || f3) ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vecto... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 1e9; const long long N = 1000 + 5; long long ar[N], done[N], cnt[N]; long long n; long long mex() { for (long long i = 0; i < n; i++) cnt[i] = 0; for (long long i = 0; i < n; i++) cnt[ar[i]] = 1; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:32100000 ) #pragma GCC optimize( O3 ) using namespace std; void solve() { int n, k; string str; cin >> n >> k >> str; string need; for (int i = 0; i < k - 1; i++) { need += () ; } for (int i = 0; i < (n - 2 * k + 2) / 2;... |
#include <bits/stdc++.h> using namespace std; int n, a[111111]; int isp2[222222]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } for (int i = 1, p = 1; i < 222222; i *= 2, ++p) { isp2[i] = p; } sort(a, a + n); int ans = 1e9; for (int... |
#include <bits/stdc++.h> inline int read() { int s = 0; char c; while ((c = getchar()) < 0 || c > 9 ) ; do { s = s * 10 + c - 0 ; } while ((c = getchar()) >= 0 && c <= 9 ); return s; } int n, l, r, ql, qr; long long ans; int main() { for (n = read(), l = r = read... |
#include <bits/stdc++.h> using namespace std; int main() { int k, a, b, v; cin >> k >> a >> b >> v; int x = (a + v - 1) / v; int t, y; t = b / (k - 1); y = t * k; while (y > x) { b--; t = b / (k - 1); y = t * k; } int c; c = b % (k - 1) + 1; int m; i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5, mum = 1e9 + 7; int Pow(int A, long long B) { int num = 1; while (B) { if (B & 1) num = 1LL * num * A % mum; A = 1LL * A * A % mum; B >>= 1; } return num; } int main() { ios::sync_with_stdio(0), cin.ti... |
#include <bits/stdc++.h> using namespace ::std; const int V = 1e5 + 25; int arr[V]; map<int, int> mmap; int main() { int n; cin >> n; int mx = INT_MIN; int mn = INT_MAX; for (int i = 0; i < n; i++) { cin >> arr[i]; mx = max(mx, arr[i]); mn = min(mn, arr[i]); mmap[ar... |
#include <bits/stdc++.h> using namespace std; const long double PI = atan(1.0) * 4.0; const long long int MOD = 1e9 + 7; const long long int INF = 1e5; const long double EPS = 0.0000001; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); int a[1005], k; a[0] = -1; a[1] = 0; fo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int n, k, q; int pref[200005]; int main() { cin >> n >> k >> q; int maxRight = 0; for (int i = 0; i < n; ++i) { int left, right; cin >> left >> right; maxRight = max(maxRight, ri... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; bool prev = false; for (int i... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, d; long long f(long long k) { return (d * b * k - 2 * a) * (k + 1) / -2; } int main() { int t; cin >> t; while (t--) { cin >> a >> b >> c >> d; if (a > b * c) { cout << -1 n ; continue; } double... |
#include <bits/stdc++.h> int main(void) { char a[100001]; long long current, jump[100001], n, i; int flag = 1, visited[100001]; memset(visited, 0, sizeof(visited)); scanf( %lld , &n); if (n == 1) { printf( FINITE ); return 0; } scanf( %s , a); for (i = 1; i <= n; i++) s... |
#include <bits/stdc++.h> using namespace std; long long arr1[26], arr2[26][26]; signed main() { string s; cin >> s; long long n = s.length(); for (long long i = 0; i < n; i++) { long long ct = s[i] - a ; for (long long j = 0; j < 26; j++) { arr2[j][ct] += arr1[j]; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; for (i = 1; i <= n; i++) { if (i % 4 == 1 || i % 4 == 2) cout << a ; else cout << b ; } cout << n ; } |
#include <bits/stdc++.h> using namespace std; char ss[5][5]; int num1, num2; int check() { int win1 = 0, win2 = 0; if (ss[1][1] == ss[1][2] && ss[1][2] == ss[1][3]) { if (ss[1][1] == X ) win1++; else if (ss[1][1] == 0 ) win2++; } if (ss[2][1] == ss[2][2] && ss[2][2]... |
#include <bits/stdc++.h> using namespace std; int m, n; int main() { int n; string vic1, vic2, tmp1, tmp2; cin >> vic1 >> vic2; cin >> n; cout << vic1 << << vic2 << endl; for (int i = 0; i < n; ++i) { cin >> tmp1 >> tmp2; if (vic1 == tmp1) vic1 = tmp2; else ... |
#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; char ch[6700][3000]; char c[3000]; int vis[2000]; vector<int> ans; int len; void shift(int x, int k) { int num = 0; for (int i = len - 1; i > len - 1 - x; i--) { ch[k][num++] = ch[k - 1][i]; } for (int i = 0; i < len - x; i++) { ch[... |
#include <bits/stdc++.h> using namespace std; char str[10]; bool check(int x, int y) { sprintf(str, %02d:%02d , x, y); return (str[0] == str[4] && str[1] == str[3]); } int main() { int i, j, n, m; scanf( %d:%d , &n, &m); for (i = n; i < 24; ++i) { for (j = 0; j < 60; ++j) { ... |
#include<bits/stdc++.h> #define fi first #define se second #define ll long long #define mod 1000000007LL #define endl n #define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define pb push_ba... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 255; const int MAXM = 30; const int MAX = 10000; const int INF = -1U >> 1; int arr[MAXN]; struct MinCostFlow { struct edge { int n, f, c; edge *next, *rev; edge(int _n, int _f, int _c, edge* _next) : n(_n), f(_f... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; while (n % 10 == 0) n /= 10; stringstream ss; ss << n; string str = ss.str(); string tmp = str; reverse(tmp.begin(), tmp.end()); if (str == tmp) cout << YES << endl; else cout ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; inline int read() { int x = 0, w = 1; char ch = 0; while (ch < 0 || ch > 9 ) { ch = getchar(); if (ch == - ) w = -1; } while (ch <= 9 && ch >= 0 ) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getc... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 500, Maxm = 500; int n, m, x[Maxn], y[Maxn], seq[Maxm]; bool canGet(int from) { bool taken[Maxm] = {}; vector<int> ans; for (int i = 0; i < n; i++) if ((i - from) % 2) ans.push_back(-1); else { int prv = (i - ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1}; int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } bool cmp(vecto... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename L> inline bool smax(T &x, L y) { return x < y ? (x = y, true) : false; } template <typename T, typename L> inline bool smin(T &x, L y) { return y < x ? (x = y, true) : false; } constexpr int MAXN = 1e5 + 15; int n; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1111; long long fact[N], invfact[N]; long long n, m, k; long long powmod(long long x, long long n, long long m = 1000000007) { long long ans = 1; while (n) { if (n & 1) { ans = ans * x % m; } x = x * x % m; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int data = 0, w = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) w = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) data = (data << 3) + (data << 1) + (ch ^ 48), ch = g... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); long long int n, l, r; cin >> n >> l >> r; if (n == 0) { cout << 0 << endl; return 0; } else if (n == 1) { cout << 1 << endl; return 0; } else if (n == 2) { vector<... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1010; const int INF = 1000000000; int n; int x[MaxN], y[MaxN], tx[MaxN], ty[MaxN]; long double L, R; long double det(long double x1, long double y1, long double x2, long double y2, long double x3, long double y3) { return... |
#include <bits/stdc++.h> using namespace std; template <typename T> istream& operator>>(istream& is, vector<T>& v) { for (T& x : v) is >> x; return is; } template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (int i = 0; i < (int)v.size(); i++) { os << v[i] << (i ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s1, s2; cin >> s1 >> s2; int len1 = s1.length(), len2 = s2.length(); int a[26] = {0}, mark = 0; multiset<char, greater<int> > st1, st2; for (int i = 0; i < len1; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 5; const long long SQRTN = 1003; const long long LOGN = 22; const double PI = acos(-1.0); const long long INF = 1e18; const long long MOD = 1e9 + 7; const long long FMOD = 998244353; const double eps = 1e-9; void __print(long... |
#include <bits/stdc++.h> using namespace std; int n, t[100005]; int l1, l2; int dp[100005]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &t[i]); l1 = 1; l2 = 1; for (int i = 1; i <= n; ++i) { while (t[i] - t[l1] > 89) ++l1; while (t[i] - t[l2] > 1439) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.