func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long long oo = 0x3f3f3f3f3f3f3f3fll; const int LGN = 25; const int MOD = 1e9 + 7; const int N = 3e5 + 5; const int hashmod[] = {(int)1e9 + 7, (int)1e9 + 9}; const int hashlen = sizeof(hashmod) / sizeof(int); struct Hash { static long long mul; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, m; int popCount(int x) { int count = 0; while (x) { ++count; x &= x - 1; } return count; } inline bool Okay(int x) { return (((1 << m) - 1) & x) == ((1 << m) - 1); } int main() { ios::syn... |
#include <bits/stdc++.h> using namespace std; int n, l, k; double probs[200]; int bags[200]; double dp[201][410][201]; double solve(int index, int currCapacity, int wonTours) { if (index == n) { if (wonTours >= l) { if (currCapacity >= 0) return 1.0; else return... |
#include <bits/stdc++.h> using namespace std; int main() { int i, n, sum = 0, t; vector<int> a; cin >> n; for (i = 0; i < n; i++) { cin >> t; sum += t; a.push_back(sum); } cin >> n; for (i = 0; i < n; i++) { cin >> t; cout << lower_bound(a.begin(), a.end(), ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; if (n != 2) { cout << 1 << n ; } else { cout << 2 << n ; } } |
#include <bits/stdc++.h> using namespace std; void DBG() { cerr << ] << n ; } template <class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << , ; DBG(t...); } template <class H> void DBG(vector<H> v) { for (int i = 0; i < (int)v.size(); i++)... |
#include <bits/stdc++.h> using namespace std; char str[1000010]; int dp[1000010][2]; int a[1000010], b[1000011]; int main() { scanf( %s , str); int n = strlen(str); n++; for (int i = 0; i < n - 1; i++) a[i + 1] = str[i] - 0 ; while (n > 0 && a[n - 1] == 0) n--; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; const int MN = 100005, inf = 1000000005, mod = 1000000007; const long long INF = 1000000000000000005LL; const long double eps = (long double)1e-10; long long det(pair<int, int> x, pair<int, int> y) { return 1LL * x.first * y.second - 1LL * x.second * y.first; ... |
#include <bits/stdc++.h> using namespace std; const long long Llinf = LLONG_MAX; const int Inf = INT_MAX; const int Maxn = 400 + 10; const int Mod = 1e9 + 7; char* _c = new char[Maxn]; string GetString() { scanf( %s , _c); return string(_c); } int n; string s[Maxn]; string ns[Maxn]; unor... |
#include <bits/stdc++.h> using namespace std; int main() { int digit, base, pos, n; long long int sum = 0, sum_1 = 0, weight; cin >> digit >> base; pos = digit - 1; for (int i = 0; i < digit; i++, pos--) { cin >> n; weight = base; if (pos == 0) weight = 1; for (int j = 1;... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 200005; struct node { long long ab; long long cab; } a[maxn], b[maxn]; struct mon { long long x, y, z; } mo[maxn]; bool cmpab(struct node ab1, struct node ab2) { return ab1.ab < ab2.ab; } bool cmpm(struct mon mo1, struct mo... |
#include <bits/stdc++.h> using namespace std; int main() { long double m, n, c = 0, k = 0, a = 0, b = 0, d; cin >> m >> n >> c >> d; long double s1, s2, x, y; a = (3 * m) / 10; b = m - (m / 250) * c; x = (3 * n) / 10; y = n - (n / 250) * d; s1 = max(a, b); s2 = max(x, y); if ... |
#include <bits/stdc++.h> using namespace std; long long res; const long long mod = 1073741824; long long d(int a, int b, int c) { vector<int> q(102, 0); for (int i = 2; i <= a; i++) if (a % i == 0) { while (a % i == 0) { a /= i; q[i]++; } } for (int i ... |
#include <bits/stdc++.h> using namespace std; const int N = 5010; const int mod = 998244353; long long d[N][N]; long long p[N]; long long inv[N]; long long _inv[N]; long long f[N]; void init(int n) { d[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { d[i][... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; vector<pair<long long, long long> > g[N]; int n, m; stack<int> st; bool inStack[N]; int cmp[N], ind[N], low[N], cnt, cont; void dfs(int x) { ind[x] = low[x] = cnt++; st.push(x); inStack[x] = true; for (int i = 0; i < g[... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long ar[51]; vector<vector<long long>> price(5); long long currentBalance = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; } for (int i = 0; i < 5; i++) { price[i].assign(2, 0); cin >> ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long a = 0, b = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) b = -1; c = getchar(); } while (isdigit(c)) { a = a * 10 + c - 0 ; c = getchar(); } return a * b; } const l... |
#include <bits/stdc++.h> using namespace std; const int N = 4010; int n, m, a[N], rt, tot, L[N], siz[N], R[N], ls[N], rs[N]; long long val[N], dp[N][N]; inline void build(int &p, int l, int r) { if (l > r) return; p = ++tot; int pos = l; for (int i = l; i <= r; ++i) if (a[i] < a[pos]) po... |
#include <bits/stdc++.h> using namespace std; int n, m, w; int v[100010]; long long mark[100010]; bool test(long long x) { memset(mark, 0, sizeof mark); long long qnt = 0; long long sum = 0; for (int i = 0; i < n; ++i) { if (qnt > m) return false; sum -= mark[i]; long long va... |
#include <bits/stdc++.h> using namespace std; long long a[105][5]; int n, Ans, b[105]; bool check(int i) { for (int j = 1; j <= n; j++) for (int k = j + 1; k <= n; k++) if (i != j && i != k) { long long tmp = 0; for (int l = 1; l <= 5; l++) tmp += (a[j][l] - a[i... |
#include <bits/stdc++.h> using namespace std; void printReverseStack(stack<int> &ans) { int x = ans.top(); ans.pop(); if (!ans.empty()) printReverseStack(ans); cout << x << ; } int main() { int n, d, l, x; stack<int> ans; cin >> n >> d >> l; ans.push(d); while (ans.size() ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + (c & 15), c = getchar(); } const int P = 998244353; int n, m; char c[500001]; struct matrix { int n,... |
#include <bits/stdc++.h> const int32_t MAX_N = 1000; bool isInA[MAX_N + 5], isInB[MAX_N + 5], isVisited[MAX_N + 5]; std::vector<int32_t> v[MAX_N + 5]; int32_t Dfs(int32_t nd) { isVisited[nd] = true; if (isInA[nd]) { return nd; } int32_t ans = INT32_MAX; for (auto &x : v[nd]) { if... |
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000], n, i, x, y; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); for (i = 0; i < n; i++) { if (a[i] != b[i]) { x = i; break; } } for (... |
#include<bits/stdc++.h> #define ll long long int #define mk make_pair #define pb push_back #define INF (ll)1e18 #define pii pair<ll,ll> #define mod 1000000007 //998244353 #define f(i,a,b) for(ll i=a;i<b;i++) #define fb(i,a,b) for(ll i=a;i>b;i--) #define ff first #define ss second #define srt(v) i... |
#include <bits/stdc++.h> using namespace std; int k, n, a[101]; int main() { ios::sync_with_stdio(0); cin >> n >> k; for (int i = (0), _b = (n); i < _b; i++) cin >> a[i]; sort(a, a + n); cout << a[n - k]; return 0; } |
#include <bits/stdc++.h> using namespace std; vector<int> P; int m, n; void bs() { int lo = 1, hi = m, ans = 0; int cnt = 0; while (lo <= hi) { int mid = (lo + hi) / 2; cout << mid << endl; int t; cin >> t; if (P[cnt % n] == 0) { if (t == 0) { exit(0);... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) using namespace std; namespace ywy { char v[300][300]; long long dk1[300], dk2[300]; int dp[600]; typedef struct _p { long long h1, h2; _p() { h1 = 2333; h2 = 6663; } frie... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(0) * 2; const double EPS = 1e-8; const long long MOD = 1e9 + 7; const int MAXN = 1e5 + 5; const int oo = 1e9; const double foo = 1e30; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T ... |
#include <bits/stdc++.h> inline long long MAX2(long long a, long long int b) { return (a) > (b) ? (a) : (b); } inline long long MAX3(long long a, long long b, long long c) { return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c)); } inline long long MIN2(long long a, long long b) { re... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; typedef struct Cell { int i; int j; int t; } cell; int n, k; bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first < b.first) return true; else if (a.first == b.first && a.second < b.second) return... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; inline int read() { register int x = 0, w = 1, ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) w = -1; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 48; return w * x; } i... |
#include <bits/stdc++.h> using namespace std; int n, k; struct kni { int p, c, id; long long ans; } a[100005]; long long s[100005]; inline char nc() { static char buf[10001], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000, stdin), p1 == p2) ? E... |
#include <bits/stdc++.h> using namespace std; namespace TYC { const int N = 17, MX = (1 << 13) + 100, Q = 110; int n, m, q, edge[N][N], a[Q], b[Q], lca[Q], bin[N], from[N], to[N]; long long dp[N][MX]; bool intree(int tree, int node) { return tree & bin[node]; } long long dfs(int root, int tree) { long... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>;... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 100; long long a[N]; int ansL[N], ansR[N]; int st[N]; long long diff[N]; long long solve(int x, int y) { long long ans = 0; int r = 0; for (int i = x; i <= y - 1; i++) { while (r > 0 && diff[st[r - 1]] < diff[i]) r--;... |
#include <bits/stdc++.h> using namespace std; double r1, x, A, B, p1, p2, ans, t, y[5002], z[5002], r2; int n, m, k; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; r1 = (((r1) > (x)) ? (r1) : (x)); } cin >> m; for (int i = 1; i <= m; i++) cin >> y[i]; cin >> ... |
#include <bits/stdc++.h> using namespace std; const int64_t M = 1e2 + 5; int64_t n, t[M], w[M], dp[M][20005], totalW; int64_t solve(int64_t idx, int64_t wt) { if (idx > n) { if (wt >= 0) return 0; return 1e9; } if (dp[idx][1001 + wt] != -1) return dp[idx][1001 + wt]; int64_t ans = t[... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, pair<int, int> > k[n]; for (int i = 0; i < n; i++) { cin >> k[i].second.first >> k[i].second.second; k[i].first = abs(k[i].second.first) + abs(k[i].second.second); } sort(k, k + n); int j = ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200000; int n; string s1, s2; int main() { cin >> n >> s1 >> s2; int K = 7; long long H = 0, HH = 0, D = 1; n--; for (int(i) = (1); i < (n + 1); ++(i)) { int p = 0, pp = 0; if (s1[n - i] == N ) p = 1; if (s1[n... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int sum1 = (n * (n + 1)) / 2; if (sum1 % 2 == 0) { cout << 0 << endl; } else { cout << 1 << endl; } } |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long a[505], ar[505], num[505], b[505]; bool used[505]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t; cin >> t; whil... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) using namespace std; long long n, c[2005], dp[2005], ans[2005], pos = 0; vector<long long> v[2005]; void dfs1(long long nod) { for (auto it : v[nod]) { dfs1(it); dp[nod] += dp[it] + 1; } } void dfs2(lon... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; vector<int> level[MAXN]; vector<pair<int, int>> adj[MAXN]; vector<pair<int, pair<int, int>>> edges; int dp[MAXN], d[MAXN], prv[MAXN]; bool OnPath[MAXN]; int main() { int n, m, a, b, c, cnt = 0; scanf( %d%d , &n, &m); for ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, t, t1 = 0; cin >> n >> k; cin >> t1; for (int i = 2; i <= n; i++) { cin >> t; t1 += t + 1; } if (t1 == k) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; const int inf = 2147483647; template <typename T> inline T read() { T sum = 0, fl = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) fl = -1; for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - 0... |
#include <bits/stdc++.h> using namespace std; int main(void) { stack<int> tmpRes; string S; cin >> S; for (int i = 0; i < S.length(); i++) { if (S[i] == r ) printf( %d n , i + 1); else tmpRes.emplace(i + 1); } while (!tmpRes.empty()) { printf( %d n , tmpRes... |
#include <bits/stdc++.h> using namespace std; int main() { int hh, mm, i; while (~scanf( %d:%d , &hh, &mm)) { mm = mm - 1; for (i = 0;; i++) { mm++; if (mm >= 60) { mm = mm - 60; hh++; if (hh >= 24) hh = 0; } if (hh / 10 == mm % 10 &&... |
#include <bits/stdc++.h> using namespace std; void solve(); int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); } int const MAX = 1e6 + 7; int cnt[MAX]; void solve() { int n, k; cin >> n >> k; int val[n]; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; const int N = 1003, INF = 0x3f3f3f3f; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a; a = a * a; b >>= 1; } return ans; } int n, m, k; int a[N][N]; int ans = 0; void dfs(in... |
#include <bits/stdc++.h> template <typename T> T sqr(T x) { return x * x; } template <typename T> bool exmax(T &a, T b) { return (b > a) ? (a = b) || 1 : 0; } template <typename T> bool exmin(T &a, T b) { return (b < a) ? (a = b) || 1 : 0; } using namespace std; int a[510], b[510], l; ... |
#include <bits/stdc++.h> using namespace std; int main() { double x, y, z; cin >> x >> y >> z; double a[12] = {-200, -200, -200, -200, -200, -200, -200, -200, -200, -200, -200, -200}; string b[12] = { x^y^z , x^z^y , (x^y)^z , (x^z)^y , y^x^z , y^z^x , (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s1, s2; while (cin >> n) { vector<string> array(4); array[0] = |#.#.#.#.#.#.#.#.#.#.#.|D|) ; array[3] = |#.#.#.#.#.#.#.#.#.#.#.|.|) ; array[1] = |#.#.#.#.#.#.#.#.#.#.#.|.| ; array[2] = |#........................ |
#include <bits/stdc++.h> template <typename Tp> void in(Tp &x) { char ch = getchar(), f = 1; x = 0; while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) f = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); x *= f; } template ... |
#include <bits/stdc++.h> int main() { int n, i, j, c; int a[1000][1000]; int b[10000]; c = 0; scanf( %d , &n); for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) scanf( %d , &a[i][j]); for (i = 1; i <= n; i++) { int flag = 0; for (j = 1; j <= n; j++) { if (a[i][j] ... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 0; scanf( %d , &t); for (int qwe = 0; qwe < t; qwe++) { long long r = 0, l = 0, y = 0; scanf( %lld%lld , &l, &r); printf( %lld %lld n , l, l * 2); } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long i, j, k; int n; cin >> n; vector<long long> arr(n); long long sum = 0; for (i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } if (sum ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > numbersWithGrundy(1); int a[200001], grundyValues[200001]; bool isPrime[200001], isMoveValid[200001]; vector<string> players{ Alice , Bob }; void PreProcess(int n, int m) { vector<int> primes; for (int i = 2; i <= n; ++i) { is... |
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; using namespace std; int a[3030], b[3030]; int dp[3030]; int main() { int t; cin >> t; while (t--) { int n; memset(dp, 0, sizeof(dp)); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i]; ... |
#include <bits/stdc++.h> using namespace std; struct SNM { vector<SNM*> trgs; vector<SNM*> rv_trgs; int stype; bool asgn; bool used; void asgnN() { if (asgn) return; asgn = true; for (vector<SNM*>::iterator i = trgs.begin(); i != trgs.end(); i++) { (*i)->asgnN(); ... |
#include <bits/stdc++.h> using namespace std; string s; int main() { long long n, q, x, y; cin >> n >> q; for (long long i = 1; i <= q; i++) { cin >> x >> y; if ((x + y) % 2 == 0) { if (n % 2 == 0) { long long linie = n / 2; long long first = linie * (x - 1); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int num2 = {}, num3 = {}; while (n % 2 == 0) { n /= 2; num2++; } while (n % 3 == 0) { n /= 3... |
#include <bits/stdc++.h> using namespace std; bool valid(char str[]) { int now = 0; for (int i = 0; str[i]; i++) { if (str[i] > now + a ) return false; if (str[i] == now + a ) now++; } return true; } int main() { char in[550]; scanf( %s , in); int mx = 0; for (int i... |
#include <bits/stdc++.h> int main() { int n, m, k, p = 1; scanf( %d , &n); m = n; while (m != 0) { if (m % 10 == 1) { m = m / 10; continue; } if (m % 100 == 14) { m = m / 100; continue; } if (m % 1000 == 144) { m = m / 1000; ... |
#include <bits/stdc++.h> using namespace std; const int N = 105, A = 26; bool win[N][N][A], known[N][N][A]; char g[N][N]; int n; bool follow(int u, int v, char c) { if (known[u][v][c - a ]) return win[u][v][c - a ]; for (int i = 1; i <= n; ++i) if (g[u][i] >= c) win[u][v][c - a ] |= !follow... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; vector<long long> g[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { long long n; cin >> n; string s; cin >> s; long long i, j; long long ans = ... |
/* Author - Param Kothari Ah shit, here we go again */ #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define pb push_back #define mk make_pair typedef long long ll; typedef long double ld; void solve(){ ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s; scanf( %d , &n); s = n / 2; if (n % 2 == 0) { s--; } printf( %d n , s); } |
#include <bits/stdc++.h> using namespace std; long double dp[9000001] = {}; bool vis[9000001] = {}; long double solve(int inv) { if (inv == 0) return 0; if (inv == 1) return 1; if (vis[inv]) return dp[inv]; vis[inv] = 1; return dp[inv] = 4 + solve(inv - 2); } int main() { std::ios::s... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const double EPS = 1e-9; int ar[] = {1, -1, 0, 0, 1, 1, -1, -1}; int ac[] = {0, 0, 1, -1, 1, -1, 1, -1}; int p[200005]; int q[200005]; void solve1(int n) { int k = 1; if (n & 1) { cout << NO n ; return; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int MAX = 200002; int arr[MAX]; int cnt[MAX]; int main() { int n, wrong = 0; cin >> n; for (int i = (1); i <= (n); i++) { cin >> arr[i]; } string s; cin >> s; cnt[1] = s[0] - 0 ; for (int i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; vector<int> v[maxn]; vector<int> edge[maxn]; int flag[maxn], val[2][maxn]; bool bad[maxn]; int par[maxn][20]; inline int dfs(int x, int p) { par[x][0] = p; for (int i = 1; i < 20; i++) par[x][i] = par[par[x][i - 1]][i - 1];... |
#include <bits/stdc++.h> using namespace std; int s, n, b[7][7], a[49], used[49], n2; bool check() { for (int i = 0; i < (int)(n); i++) { int sr = 0; for (int j = 0; j < (int)(n); j++) sr += b[i][j]; if (sr != s) return false; sr = 0; for (int j = 0; j < (int)(n); j++) sr += b[j]... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } x *= f; } inline unsigne... |
#include <bits/stdc++.h> using namespace std; bool vt[202][202]; int cnt, n; int dfs(int x, int y) { int mx1 = 0, mx2 = 0, mx = 0; for (int i = 1; i <= n; i++) if (vt[x][i] && i != y) { mx = max(mx, dfs(i, x)); if (cnt > mx1) mx2 = mx1, mx1 = cnt; else if (cnt > m... |
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize( Ofast ) //#pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #define ms(s, n) memset(s, n, sizeof(s)) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORd(i, a, b) for (int i = (a) - 1; i >= (b)... |
#include <bits/stdc++.h> using namespace std; const long long nmax = 1e6 + 5; const unsigned long long oo = 1e18; const long long mod = 1e9 + 7; const long long ox[4] = {-1, 1, 0, 0}; const long long oy[4] = {0, 0, -1, 1}; const long long dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const long long dy[8] = {-1,... |
#include <bits/stdc++.h> using namespace std; const int N = 202020, P = 1e9 + 7; int n; int a[N], par[N], cnt[2][N], c[2][N]; long long ans; vector<int> g[N]; void upd(long long &a, long long b) { if (b < 0) b += P; a += b; if (a >= P) a -= P; } void dfs(int u, int fa) { cnt[0][u] = 1;... |
#include <bits/stdc++.h> using namespace std; #define Input(v, n) fr(i, n) cin >> v[i]; #define checkk(v, n) fr(i, n) cout << v[i] << << endl; #define sort(v) sort(v.begin(), v.end()); #define int long long int #define double long double #define fr(i, n) for (int i = 0; i < n; i++) #define frr(i, s,... |
#include <bits/stdc++.h> using namespace std; vector<string> numbers; unsigned n = 2; unsigned k = 5; int taken[100]; void print(unsigned i) { unsigned l; string str = ; for (l = 0; l <= i - 1; l++) str += (taken[l] + 1) + 0 ; numbers.push_back(str); } void variate(unsigned i) { u... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long INF = (long long)2e18; const int N = (int)1e6 + 77; int n; long long a[N]; long long solve(long long d) { long long ans = 0; long long cur = 0; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, finans = 0; int a[N], ans[N], sieve[N], countprime[N]; vector<int> primes[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n = 0; string s; long long int res = 0ll; cin >> n; cin >> s; res = (1ll * n * (n + 1)) / 2ll - 1ll * n; for (int i = 0; i + 1 < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } const int maxn = 1e6 + 5; vector<int> get(map<int, vector<int>> mp) { vector<int> res; for (auto p : mp) { for (auto x : p.second) { res.push_back(x); } }... |
#include <bits/stdc++.h> using namespace std; int read() { int X = 0, w = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) w = -1; c = getchar(); } while (c >= 0 && c <= 9 ) X = X * 10 + c - 0 , c = getchar(); return X * w; } const int N = 200000 + 10; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int mod = 1000000007; const double eps = 1e-6; const double PI = acos(-1); int tar, n, tot, a[N], hs[N], cnt[N], mx[N], now[N]; vector<int> vc; bool check(... |
#include <bits/stdc++.h> using namespace std; int n; long long x[2005], y[2005]; long long c[2005]; long long k[2005]; bool vis[2005]; long long dis[2005]; long long tower[2005]; long long diss[2005]; long long way[2005][2005]; long long townum = 0; long long add[2005][2]; long long addnum = 0... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000000000; const int MOD = 1000000007; const int base = 1000 * 1000 * 1000; int main() { int n, m; cin >> n >> m; int l = 1, r = n; string str, str1, str2, str3; int t; for (int i = 0; i < m;... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int X1[127], X2[128], Y1[111], Y2[105]; bool u[134][134]; vector<int> res; int check(int xx1, int yy1, int x2, int y2) { if (x2 < 0 || y2 < 0 || x2 >= n || y2 >= m || u[x2][y2]) return 0; if (xx1 > x2) swap(xx1, x2); if (yy1 > y2) swap(y... |
#include <bits/stdc++.h> using namespace std; const int maxn = 10005; int a[26][26][maxn]; char s[maxn]; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> s; n = strlen(s); for (int i = n; i < 2 * n - 1; ++i) { s[i] = s[i - n]; } ... |
#include <bits/stdc++.h> using namespace std; int a[1000005]; int main() { int n; while (cin >> n) { for (int i = n; i >= 0; i--) if (!a[i]) { int mm = (1 << ((int)(log2(i) + 1))) - 1; a[i] = mm ^ i; a[mm ^ i] = i; } long long int ans = 0; fo... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops , omit-frame-pointer , inline ) #pragma GCC option( arch=native , tune=native , no-zero-upper ) #pragma GCC target( avx2 ) using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typen... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int M = 1000005; int go[M][4], fa[M], sum[M], val[M], lzy[M], hsc[M], tsz; void pull(int x) { if (!x) return; sum[x] = val[x] + sum[go[x][0]] + sum[go[x][1]]; if (go[x][2]) sum[x] += min(sum[go[x][2]], sum[go[x][3]]); h... |
#include <bits/stdc++.h> using namespace std; const int N = 202; const int C = 6000; int dp[N][C]; int n, k; int a[N][2]; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) { long long x; scanf( %lld , &x); while (x % 5 == 0) { a[i][0]++; x /= 5; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int cnt = 0; int num; for (int i = 0; i != n; ++i) { scanf( %d , &num); if (num % 2 == 1) ++cnt; } if (cnt >= 1) printf( First n ); else printf( Second n ); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, maxx; vector<int> v, cnt; map<int, int> ma; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; maxx = min(2, n); v.resize(n + 1); cnt.resize(100001); for (int i = 1; i <= n; i++) { cin >> v[i]; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 200005; int n, m; int x[N], y[N]; int d[N]; queue<int> q[N]; int dist(int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); } int ans[N]... |
#include <bits/stdc++.h> using namespace std; long long calWhite(long long x1, long long y1, long long x2, long long y2) { if (x1 == 0 || y1 == 0 || x2 == 0 || y2 == 0) { return 0; } long long tmp = (abs(x1 - x2) + 1) * (abs(y1 - y2) + 1); long long res = tmp / 2; if (tmp % 2 == 1 && (x1 *... |
#include <bits/stdc++.h> using namespace std; const int P = 1000000007; const int N = 1010000; int fail[N]; int go[N][26], len[N], diff[N], anc[N], lst; int n; char str[N]; int p; int s[N]; int f[N], g[N]; void addChar(int c, int ww) { int x = lst; while (s[ww] != s[ww - len[x] - 1]) { ... |
#include <bits/stdc++.h> int main() { int n, i, c = 0; char s[500]; scanf( %d %s , &n, s); for (i = 0; i < n - 1; i++) { if (((s[i] == R ) && (s[i + 1] == U )) || ((s[i] == U ) && (s[i + 1] == R ))) { c++; i++; } } printf( %d n , n - c); return 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.