func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int h1, h2, n; int v[111]; char c[111]; int a[111]; int b[111]; const double eps = 1e-9; int main() { cin >> h1 >> h2 >> n; for (int i = (0); i < (n); i++) cin >> v[i] >> c[i] >> a[i] >> b[i]; int best = 0; for (int i = -200; i <= 200; i++) {... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, i, j, b, c, a; cin >> a >> b >> c; long long int y = a + b + c; y--; cout << y << endl; } } |
#include <bits/stdc++.h> using namespace std; int n, k, s, a[5][205]; struct node { int id, x, y; }; vector<node> ans; inline void park() { for (int i = 0; i <= 2 * n - 1; ++i) if (a[1][i] && a[1][i] == a[0][i]) { ans.push_back(node{a[1][i], i / n ? 4 : 1, i % n + 1}); a[1][i] ... |
#include <bits/stdc++.h> #define int long long using namespace std; signed main(){ int t; cin >> t; while(t--){ int k, n, m; cin >> k >> n >> m; int a[n + 1], b[m + 1]; for(int i = 0;i < n;i++){ cin >> a[i]; } for(int i = ... |
#include <bits/stdc++.h> const int M = 2000; int T, n, x, ans, f0[M + 10], f1[M + 10]; inline int min(int x, int y) { return x < y ? x : y; } inline int max(int x, int y) { return x > y ? x : y; } void work() { for (int i = 0; i <= M; ++i) f0[i] = i; scanf( %d , &n), ans = 114514; while (n--) { ... |
#include <bits/stdc++.h> using namespace std; const int L = 332748118, M = 998244353, N = 1e6 + 5; int l[N]; int ksm(int a, long long b) { int an = 1; while (b) { if (b & 1) an = 1ll * an * a % M; a = 1ll * a * a % M; b >>= 1; } return an; } int main() { int n, c = 1, a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, d; cin >> n >> k >> d; vector<int> U(k, 0); for (int i = 0; i < k; i++) U[i] = i + 1; vector<int> V(d - 1, 0); for (int i = 0; i < d - 1; i++) V[i] = i + 1; vector<long long> dp2(n + 1, 0); vector<long long> dp1(n +... |
#include <bits/stdc++.h> using namespace std; struct triple { int x, y, z; }; int n, x1, y11, x2, y22; string s[9]; int main() { cin >> n; while (n--) { for (__typeof(8) i = 1; i <= 8; i++) cin >> s[i], s[i] = # + s[i]; bool tmp = false; for (__typeof(8) i = 1; i <= 8; i++) {... |
#include <bits/stdc++.h> using namespace std; int n, b; int t[200005], d[200005]; queue<pair<int, pair<int, int> > > Q; long long ans[200005]; int main() { int i, j; scanf( %d , &n); scanf( %d , &b); for (i = 1; i <= n; i++) { scanf( %d , &t[i]); scanf( %d , &d[i]); } mem... |
#include <bits/stdc++.h> using namespace std; constexpr int SIZE = (int)1e6; int n, k, from, to; vector<int> g[SIZE], h[SIZE]; vector<int> ord; vector<bool> check; string ans; int component[SIZE]; int comp; void dfs1(int v) { check[v] = true; for (int i : g[v]) { if (!check[i]) { ... |
#include <bits/stdc++.h> using namespace std; long long p, k, ans, cnt, num[1000005], check[1000005], a, now, fac[100005]; int main() { fac[0] = fac[1] = 1; ans = 1; scanf( %lld%lld , &p, &k); if (k == 0) { for (int i = 1; i < p; i++) { ans *= p; ans %= 1000000007; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; long long tmp = sqrt(n); vector<long long> ans; ans.push_back(0); for (long long i = 1; i <= tmp; i++) { ans.push_back... |
#include <bits/stdc++.h> using namespace std; int is_prime(long long int n) { for (long long int i = 2; i * i <= n; i++) { if (n % i == 0) return 0; } return 1; } int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int a, b, c, d, k; cin >> a >> b >> c >> d >> k... |
#include<iostream> #include<cmath> using namespace std; long long l,r,d; int main() { int t; cin >> t; while(t--) { scanf( %lld %lld %lld ,&l,&r,&d); if(min(l,r) * d >= max(l,r) - min(l,r)) cout << YES << endl; else cout << NO << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; char st[100000 + 123]; bool inm[256]; int main() { scanf( %s , st); memset(inm, 0, sizeof(inm)); inm[ A ] = true; inm[ H ] = true; inm[ I ] = true; inm[ M ] = true; inm[ O ] = true; inm[ T ] = true; inm[ U ] = true; inm[ V ] =... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) long long niz[300005]; long long ima[605][605]; long long res[300005]; long long dp[300005]; struct strukt { int a, b, ind; } query[300005]; bool cmp(strukt a, strukt b) { return a.b < ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; int m; cin >> n >> m; int l; int r; int arr[n]; int pos = 0; int neg = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == -1) { ... |
#include <bits/stdc++.h> using namespace std; const int MX = 1147483646; const long long MX2 = 9223372036854775800; const int MOD = 1000000007; int p[30]; int find(int n) { if (p[n] < 0) return n; return p[n] = find(p[n]); } void uni(int e1, int e2) { e1 = find(e1); e2 = find(e2); if... |
#include <bits/stdc++.h> using namespace std; void solve() { int i, j, k, n, m, ans = 0, cnt = 0, sum = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; vector<int> res; res.push_back(a[0]); int last = a[0], flag = 1; for (int i = 1; i < n - 1;) { if (abs(a[i] - ... |
#include <bits/stdc++.h> using namespace std; bool valid(int i, int j, int n, int m) { return i >= 0 && i < n && j >= 0 && j < m; } void solve() { int n, m; int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; cin >> n >> m; char a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e3 + 5; const int md = 1e9 + 7; string mat[2], pat; long long n, m, dp[2][maxn][2], pr[2][maxn][2], re, is[2][maxn][maxn], ris[2][maxn][maxn]; long long sum(long long a, long long b) { return (a + b) % md; } long long mul(long long a, l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; int main() { int T; cin >> T; while (T--) { int n, k; cin >> n >> k; int mn = INF, mx = -1; for (int i = 1; i <= n; ++i) { int x; scanf( %d , &x); m... |
#include <bits/stdc++.h> using namespace std; int main() { #ifdef DEBUG freopen( a.in , r , stdin); #endif ios_base::sync_with_stdio(false), cin.tie(0); int T; cin >> T; while (T--) { int a[2]; cin >> a[0] >> a[1]; string s; cin >> s; int n = a[0] + a[1]; ... |
#include <bits/stdc++.h> int main() { int n, k, i, j, swap; scanf( %d %d , &n, &k); int ara[n + 1][3]; for (i = 1; i <= n; i++) { scanf( %d , &ara[i][1]); ara[i][2] = i; } for (i = 1; i <= n; i++) { for (j = 1; j <= (n - i); j++) { if (ara[j][1] > ara[j + 1][1]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p[n + 1]; for (int i = 1; i <= n; i++) cin >> p[i]; bool done[n + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) done[j] = false; int start = i; while (1) { if (done[sta... |
#include <bits/stdc++.h> using namespace std; const int dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1}; const double EPS = 1e-8; const double PI = acos(-1.0); int popcount(int n) { return __builtin_popcount(n); } int popcount(long long n) { return __builtin_popcountll(n); } template <class T> int SIZE(T a) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, val, i, j, k, n, m, val2; vector<pair<long long, long long> > ans; cin >> x; for (n = 1; n <= (3000000); n++) { val = x; val -= (n - 1) * n * (2 * n - 1) / 6; val += n * n * (n - 1) / 2; val2 = n * n - ((... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, m, f[N], vis[N], cnt; int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); } struct node { int x, y, w; } a[N]; bool cmp(node a, node b) { return a.w < b.w; } int main() { while (cin >> n >> m) { int ans = ... |
#include <bits/stdc++.h> using namespace std; long long n, m; long long x[105]; double f[105][105525]; double sum[105525]; inline void read() { cin >> n >> m; for (long long i = 0; i <= n - 1; i++) { cin >> x[i]; } } inline void solve() { long long ms = n * m; if (m == 1) { ... |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::fixed; using std::make_pair; using std::max; using std::min; using std::pair; using std::set; using std::sort; const long long base = (long long)(5 * 1e8 + 5); const long long coefficient = (long long)(4 * 1e9); long long conve... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; string s; cin >> s; long long int n = s.length(); long long int dp[s.length() + 5][27]; for (int i = 0; i <= s.length(); i++) { for (int j = 0; j < 27... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c... |
#include <bits/stdc++.h> class state { public: int d[4]; int e; state() : d{0, 0, 0, 0}, e(1) {} bool operator<(const state &x) const { for (int i = 0; i < 4; ++i) { if (d[i] == x.d[i]) continue; return d[i] > x.d[i]; } return e > x.e; } bool operator!=(con... |
#include <bits/stdc++.h> using namespace std; int arr[15], cnt[7] = {0}, ans = 0; int j, hr = 0, mi = 0; int se[100] = {0}; vector<int> na, ma; void rec(int pos, int a) { int i; if (pos == -1) { ans++; return; } if (pos == mi - 1) { for (i = 0; i <= na[pos]; i++) { ... |
#include <bits/stdc++.h> using namespace std; int a[55][55]; int main() { int n; scanf( %d , &n); memset(a, 0, sizeof(a)); int p = 1, q = 2, nn = n / 2 + 1; for (int i = 1; i <= n; ++i) { a[nn][i] = p; p += 2; } for (int i = 1; i <= n; ++i) { if (i != nn) { a[... |
#include <bits/stdc++.h> using namespace std; int max(int a, int b) { return (a > b) ? a : b; } struct player { int i; int j; int pos; }; int main() { bool firstwon1 = false; bool secondwon1 = false; bool firstwon2 = false, firstwon3 = false, firstwon4 = false; bool secondwon2 = fa... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const double pi = acos(-1.0); void cp(); long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } long long fact(long... |
#include <bits/stdc++.h> using namespace std; using namespace std; void enumerateSubmasks(int m) { for (int s = m;; s = (s - 1) & m) { if (s == 0) { break; } } } int mpow(int a, int b, int m) { if (b == 0) return 1; int x = mpow(a, b / 2, m); x = (x * x) % m; if (b ... |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; const int OO = 1e18; const int md = 1e9 + 7; int X[] = {0, 0, 1, -1}, Y[] = {1, -1, 0, 0}; void fast() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int dp[int(1e4 + 4)], t = 0, x, y, z, n, q, g[int(1e4 + 4)]... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int Maxn = 10010; int a[Maxn]; int tot = 0; int main() { int n; cin >> n; long long sum = 0; for (int i = 2; i <= n; i++) { for (int j = 2 * i; j <= n; j += i) { sum += 4ll * (j / i); } } ... |
#include <bits/stdc++.h> using namespace std; struct PR { int to; int ne; } Prise[200010]; bool compare(PR a, PR b) { return (a.to - a.ne) < (b.to - b.ne); } int main(int argc, char const *argv[]) { int n, k; cin >> n >> k; int i; for (i = 0; i < n; i++) { cin >> Prise[i].to; ... |
#include <bits/stdc++.h> using namespace std; long long far(long long x, long long y) { return x * x + y * y; } vector<long long> val; vector<long long> dsu; vector<long long> rang; long long pred(long long a) { if (a == dsu[a]) { return a; } else { long long to = pred(dsu[a]); if ... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846; const double EPS = 1e-15; const int INF = 1e9 + 7; const long long LINF = 8e18 + 7; const int N = 2e5 + 7; vector<long long> t[4 * N]; int a[N]; long long s[N]; void build(int v, int L, int R) { if (L + 1 == ... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 3; int t; long long m, n; pair<long long, long long> v[MX]; long long p[MX]; int main() { scanf( %d , &t); while (t--) { scanf( %lld %lld , &n, &m); long long ans = 0; for (int i = 0; i < m; i++) { scanf( ... |
#include <bits/stdc++.h> using namespace std; string equalString(string a) { int len = a.size(); if (len % 2 == 1) return a; string a1 = a.substr(0, len / 2); string a2 = a.substr(len / 2, len / 2); a1 = equalString(a1); a2 = equalString(a2); return a1.compare(a2) < 0 ? a1 + a2 : a2 + a1... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > seq; const int mod = 1e6; const long long A = 42344; const long long B = 333; int seed = 239; int mrand() { static int now = -1; if (now == -1) now = seed; else now = (A * now + B) % mod; return now; } st... |
#include <bits/stdc++.h> using namespace std; string express(int layers) { string ans = ; for (int i = 1; i <= layers; i++) { if (i % 2 == 1) { if (i == layers) { ans += I hate it ; } else { ans += I hate that ; } } else { if (i == layers)... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> vec; vec.push_back(0LL); for (int i = 0; i < n; i++) { long long k; cin >> k; vec.push_back(k); } int m; cin >> m; vector<long long> v; long long x = 0, y = 0; ... |
#include <bits/stdc++.h> using namespace std; const int mx1 = 20; const int mx2 = 405; const int mx3 = 2005; const int mx4 = 30005; const int mx5 = 100005; const int mx6 = 1000005; int _toggle(int N, int pos) { return N = N ^ (1 << pos); } int _set(int N, int pos) { return N = N | (1 << pos); } int ... |
#include <bits/stdc++.h> using namespace std; long long l, r, lim[60]; long long f[60][60][2][2]; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { (x *= 10) += ch - ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000100, mod = 998244353; inline int read() { int x = 0, f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= ch == - , ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return f ? -x :... |
#include <bits/stdc++.h> using namespace std; long long n; long long N[100006]; long long sum[1000006], S[1000006]; long long t[1000006]; long long t1[1000006]; long long lowbit(long long u) { return u & (-u); } void add(long long u, long long w) { while (u <= n) { t[u] += w; u += lowbit... |
#include <bits/stdc++.h> using namespace std; int n, nq, tr, tg, z, tot, root; int ls[7000010], rs[7000010], s[7000010]; long long mod, ans, x, y; long long b[100010], a[100010]; void push_down(int p) { if (!ls[p]) ls[p] = ++tot; if (!rs[p]) rs[p] = ++tot; if (s[ls[p]] == 0 || s[p] < s[ls[p]]) s... |
#include <bits/stdc++.h> using namespace std; template <class T> istream &operator>>(istream &in, vector<T> &arr) { for (auto &x : arr) in >> x; return in; } long long n, m; const long long N = 1e6 + 100; vector<pair<long long, long long>> g[N]; long long col[N]; bool cyc; long long res[N]; ... |
#include <bits/stdc++.h> using namespace std; char s1[1010000]; char s2[1010000]; int main() { scanf( %s , s1); scanf( %s , s2); int len1, len2, i; len1 = strlen(s1); len2 = strlen(s2); int ans; if (len1 - len2) ans = 0; else if (len1 == 1) { if (s1[0] == s2[0]) ... |
#include <bits/stdc++.h> using namespace std; int N, M, lb[300010], ind[300010]; vector<int> g[300010], g2[300010]; int val[300010]; bool viz[300010]; int dfs(int nod, int v) { val[nod] = v; viz[nod] = 1; for (int nxt : g2[nod]) { if (viz[nxt]) continue; return dfs(nxt, v + 1); }... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 9223372036854775807LL; #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroint-loops ) long long int power(long long int b, long long int e, long long int m) { if (b == 0) return 0; if ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 55; int x[MAX]; long long poww(long long x, long long y) { if (y == 0) return 1; long long s = poww(x, y / 2); s = (s * s); if (y % 2 == 1) s = (s * x); return s; } int main() { string s = OYGR ; string c = BIV... |
#include <bits/stdc++.h> int a[1511]; int main() { int n, m, i, j, s(0); scanf( %d , &n); for (i = 0; i < n; ++i) scanf( %d , &a[i]); for (i = 0; i < n; ++i) for (j = i + 1; j < n; ++j) if (a[i] > a[j]) s ^= 1; scanf( %d , &m); while (m--) { scanf( %d%d , &i, &j); i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1000000000 ) #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) using namespace std; const int maxn = (int)1e5 + 10; struct vt { long double x, y; }; vt operator-(vt a, vt b) { a.x -= b.x; a.y -= b.y; return a; } vt op... |
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define pb push_back #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define faster() ios_base::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL); typedef lon... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long sum = 0, ff = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) { ff = -1; } ch = getchar(); } while (ch >= 0 && ch <= 9 ) { sum = sum * 10 + ch - 48; ch... |
#include <bits/stdc++.h> using namespace std; const int N = 2010; struct point { point(int xx, int yy) : x(xx), y(yy) {} int x, y; }; int n, m; char a[N][N]; queue<point> q; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; long long pp; bool uniq(int xx, int yy) { if (a[xx][yy] !=... |
#include <bits/stdc++.h> using namespace std; int n, i, ans; map<long long, long long> m, ind; long long b[150001], a; int main() { scanf( %d , &n); ans = n; for (i = 1; i <= n; i++) { scanf( %I64d , &a); m[a]++; b[i] = a; while (m[a] > 1) { ans--; m[a] = 0;... |
#include <bits/stdc++.h> using namespace std; vector<vector<pair<int, string> > > regions; int main() { int n, m; cin >> n >> m; regions.resize(m); string name; int r, s; for (int i = 0; i < n; ++i) { cin >> name >> r >> s; regions[r - 1].push_back(make_pair(s, name)); } ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 7; const long long INF = 3e18 + 7; long long n, t; long long a[MAXN], p[MAXN], l[MAXN], r[MAXN]; long long ans[MAXN]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> t; for (long long i = 0; i ... |
#include <bits/stdc++.h> using namespace std; void JIZZ(string output = ) { cout << output; exit(0); } const long double PI = 3.14159265358979323846264338327950288; const long double eps = 1e-13; const long long mod = 1e9 + 7; struct node { node *l, *r; int mx; node() : l(0), r(0), m... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; int n, cnt; int ans[1005]; bool prime(int x) { for (int i = 2; i < x; i++) if (x % i == 0) return 0; return 1; } int main() { scanf( %d , &n); for (int i = 2; i <= n; i++) { if (... |
#include <bits/stdc++.h> using namespace std; int NewMessages(int right, int left, int k, int size) { int right_border = min(right + k, size - 1); int left_border = max(min(left + k, size - 1), max(0, right - k - 1)); return right_border - left_border; } int main() { int n, k; cin >> n >> k;... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INFLL = 0x3f3f3f3f3f3f3f3fll; const int maxn = 2e5 + 5; const int mod = 1e9 + 7; int n, k; char ans[55][3]; int main() { cin >> n >> k; char ch1 = A , ch2 = a ; for (int i = 0; i < n - k + 1; i++) {... |
#include <bits/stdc++.h> using namespace std; int n, m, k, a[100][100], ans, ma[100]; bool mark[10]; int seen[100000]; void BT(int n) { if (n > ::n) { int ans = 0; for (int i = 1; i <= ::n; i++) { if (a[i][ma[i]] == 0 && ma[i] != 0) return; ans += a[i][ma[i]]; } see... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int f[maxn], n; struct struc { long long a[maxn]; int go[19][maxn], nxt[maxn]; void build(int ty = 0) { if (!ty) { for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = n; i; i--) a[i] += a[i + 1];... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> l >> s; int first = s[0] - 0 ; int second = s[1] - 0 ; if (s.length() == 2 && first >= second) { cout << NO << endl; continue; ... |
#include <bits/stdc++.h> using namespace std; template <typename arg> void debugger(const char* varname, arg&& var) { cout << varname << = << var << endl; } template <typename arg, typename... args> void debugger(const char* varnames, arg&& var, args&&... vars) { const char* comma = strchr(varna... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 2e9 + 9; int n, m, p; pair<int, int> a[maxn], b[maxn]; pair<pair<int, int>, int> mon[maxn]; struct segment_tree { int val[maxn * 4], lazy[maxn * 4]; void build(int x, int l, int r) { if (l == r) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, w; cin >> w >> n; if (w <= 3) { cout << YES << endl; return 0; } while (n > 0) { if (n % w > 1 && n % w... |
#include <bits/stdc++.h> using namespace std; int Read() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int t = c - 0 ; c = getchar(); while (c >= 0 && c <= 9 ) t = (t << 3) + (t << 1) + c - 0 , c = getchar(); return t; } int n, Q, s; int Head[900001], To[3200001]... |
#include <bits/stdc++.h> const int INF = (int)1e9 + 7; int f(const std::vector<int> &arr, int k, int d) { std::list<std::pair<int, int>> events, se; for (auto &it : arr) { events.push_back({it - d, 0}); se.push_back({it + d, 1}); } events.merge(se); int bal = 0; for (auto it : ev... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; char a[n][m]; int num = 0; int mn[m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < m; i++) { num = 0; for (int j ... |
#include <bits/stdc++.h> using namespace std; const int N = 105; char arr[N], dp[N][N * N], ndp[N][N * N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int sz = 0; for (int i = 0; i < n; i++) { int x; cin >> x; arr[x... |
#include <bits/stdc++.h> using namespace std; ifstream in( in.txt ); bool needToDelete(char c) { return tolower(c) == a || tolower(c) == o || tolower(c) == y || tolower(c) == e || tolower(c) == u || tolower(c) == i ; } int main(int argc, char** argv) { string s; cin >> s; ... |
#include <bits/stdc++.h> long long MAX(long long x, long long y) { return (x > y) ? x : y; } long long MIN(long long x, long long y) { return (x < y) ? x : y; } const int MAXN = 123; const int MAXNM = 223; const int MAXK = 7; const int inf = 0x3f3f3f3f; using namespace std; inline int Read() { regis... |
#include <bits/stdc++.h> using namespace std; vector<int> getPrimes(int n) { vector<bool> sieve(n + 1, true); sieve[0] = sieve[1] = false; for (int i = 2; i * i <= n; i++) if (sieve[i]) for (int j = i * i; j <= n; j += i) sieve[j] = false; vector<int> primes; for (int i = 2; i <= n... |
#include <bits/stdc++.h> using namespace std; int n, q, p, p1, maxi, a[1000000], idx; stack<int> t, t1, id; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); maxi = -1; id.push(0); t.push(200000); t1.push(-1); for (int i = 1; i < n; i++) { p = 0; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int i, n, m; cin >> n >> m; vector<int> a(n + m); for (i = 0; i < n + m; i++) { ... |
#include <bits/stdc++.h> using namespace std; auto fio = (ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)); int32_t main() { long long n; cin >> n; vector<long long> g(n); for (long long& x : g) cin >> x; vector<vector<long long>> idx(8192); for (long long i = 0; i < n; i++) idx[g[i]].pus... |
#include <bits/stdc++.h> using namespace std; struct _ { _() { ios_base::sync_with_stdio(0); } } _; template <class T> void PV(T a, T b) { while (a != b) cout << *a++, cout << (a != b ? : n ); } template <class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; } templa... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( popcnt ) using namespace std; mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count()); const long long N = 2e5 + 100; const long long mod = 1e9 + 7; const long long big = 1e17; long long t, n, h; long long a[N]; int... |
#include <bits/stdc++.h> using namespace std; int in(char &c) { return scanf( %c , &c); } int in(char s[]) { return scanf( %s , s); } int in(int &x) { return scanf( %d , &x); } int in(long long &x) { return scanf( %lld , &x); } int in(double &x) { return scanf( %lf , &x); } int in(pair<int, int> &p) { ret... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k = -1, c, d; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= m; i++) { scanf( %d %d , &c, &d); if (k == -1 || (d - c + 1) < k) { k = d - c + 1; } } printf( %d n , k); c = 0; for (i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; int main() { long long xa, ya, xb, yb, xc, yc; cin >> xa >> ya >> xb >> yb >> xc >> yc; long long s1 = (ya - yb) * (xa - xc); long long s2 = (xa - xb) * (ya - yc); if (s1 == s2) { cout << TOWARDS ; return 0; } if (s1 > s2) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int big = 0, small = 1000000000; int a[1000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > big) { big = a[i]; } if (a[i] < small) { small = a[i]; } } cout <<... |
#include <bits/stdc++.h> using namespace std; int a, ta, b, tb, hh, mm, res1, res2; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> a >> ta >> b >> tb; char tmp; cin >> hh >> tmp >> mm; hh -= 5; mm += hh * 60; if (mm - tb >= 0) res1 = (mm - tb) / b + 1... |
#include <bits/stdc++.h> using namespace std; int maxl[300005][20], minl[300005][20]; int vis[2 * 300005]; int a[300005]; int lmax[300005], lmin[300005], rmax[300005], rmin[300005]; int min(int a, int b) { if (a > b) return b; return a; } int max(int a, int b) { if (a > b) return a; retu... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string K; cin >> K; if (K.size() == 1 and k != 0) { cout << 0; return 0; } if (k == 0) { cout << K; return 0; } if (K[0] != 1 ) { K[0] = 1 ; k -= 1; for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, p, a[100000], sum = 0; cin >> n >> p; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; sum %= p; } sum = (sum + p - (a[0] % p)) % p; int cur ... |
#include <bits/stdc++.h> using namespace std; int main() { int r, c, i, j, flag = 0; cin >> r >> c; char a1[r][c]; for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { cin >> a1[i][j]; } } for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { if (a1[i][j] == .... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; long long w, m, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); cin >> w >> m >> k; long long aa = 0; int nc = 0; while (aa <... |
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> w; vector<int> v; bool volt[1111]; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> x; v.push_back(x); } reverse(v.begin(), v.end()); for (int i = 0; i < v.si... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2005; int n, m; int a[maxn]; int cnt[maxn], vis[maxn]; int ans2 = 0; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int ans1 = n / m; int p = n % m; for (int i = 1; i <= n; i++) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.