func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <class T> void rd(T &x) { x = 0; int f = 1; char c; while (!isdigit(c = getchar())) if (c == - ) f = -1; do { x = (x << 1) + (x << 3) + (c ^ 48); } while (isdigit(c = getchar())); x *= f; } const int N = 3e5 + 5; ... |
#include <bits/stdc++.h> using namespace std; int p[2048]; vector<int> s[2048]; int main() { int n; int a; cin >> n; for (int i = 1; i <= n; i++) { cin >> a; p[i] = a; s[a].push_back(i); } int res = 0; bool fl = true; int k = 1; while (fl) { fl = false... |
#include <bits/stdc++.h> using namespace std; const int int_inf = 0x3f3f3f3f; const long long int ll_inf = 0x3f3f3f3f3f3f3f3f; const int max_n = 1e5 + 5; bool g[max_n]; int head[max_n], nxt[max_n << 2], to[max_n << 2], cnt; int dis[max_n]; int n, start, end1; struct nodes { int dis, v; bool op... |
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323843; void Time() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void print(int n) { if (n == 0) { return; } print(n - 1); cout << Hello world << endl; } long long arr[1000... |
#include <bits/stdc++.h> using namespace std; inline int add(int _a, int _b) { if (_a < 0) { _a += 1000000007; } if (_b < 0) { _b += 1000000007; } if (_a + _b >= 1000000007) { return _a + _b - 1000000007; } return _a + _b; } inline int mul(int _a, int _b) { if (... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int n, m; char s[5005]; long long state[5005]; long long dp[5005][5005]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { scanf( %s , s + 1); for (int j = 1; j <= n; j++) if (s[j] == ... |
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 7; int n, q; long long val[N]; struct edge { int to, nex; long long wei; } e[N << 1]; int fir[N], eid; int siz[N], dep[N], fa[N], son[N], ltp[N]; long long faw[N]; int dfn[N], inx; long long f[N], g[N]; long long bit[N]... |
#include <bits/stdc++.h> using namespace std; const int N = 1000001; int eu[N], ev[N]; vector<pair<int, int> > g[N]; bool vis[N]; bool be[N]; int dfn[N], low[N], vbel[N], ebel[N], dfc, ebcc; int sz[N]; int dfs_ebcc(int u, int f) { static int s[N], t; s[++t] = u; dfn[u] = low[u] = ++dfc; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int(_) = 0; (_) < (n); (_)++) { string S, T; cin >> S >> T; S.push_back( A ); T.push_back( A ); vector<pair<char, int> > sl, tl; char ns = S[0]; int cs = 1; for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; long long n, a[100001], b[100001], c[100001], k, x; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]] = i; } c[b[n]] = 0; for (long long i = n - 1; i >= 1; i--) { x = b[i]; for (long long j = (x - 1)... |
#include <bits/stdc++.h> using namespace std; int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1}; const double PI = acos(-1.0); const double EPS = 1e-6; const int MOD = (int)1e9 + 7; const int maxn = (int)3e5 + 10; const int LOGN = 20; struct Upd { int x, d; Upd(i... |
#include <bits/stdc++.h> using ld = long double; using ll = long long; using namespace std; int MOD = 998244353; void solve() { int n; cin >> n; vector<vector<int>> p(n + n, vector<int>(n)); for (int i = 0; i < 2 * n; i++) { for (int j = 0; j < n; j++) { cin >> p[i][j]; p[i][j]--; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, k = 1, cnt = 0, cnt1 = 0, q = 2; cin >> n; int ar[n + 5]; for (i = 0; i < n / 2; i++) { cin >> ar[i]; } sort(ar, ar + (n / 2)); for (i = 0; i < n / 2; i++) { cnt += abs(k - ar[i]); k += 2; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; while (N--) { int n; cin >> n; int mid = n / 2 + 1; for (int i = 0; i < n; i++) { if (i == 0) cout << mid << ; else if (i % 2) cout << mid - i / 2 - 1 << ; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 50, INF = 0, MOD = 0; long long n, m, a[N], tmp; vector<long long> v; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> m >> n; for (long long i = 0; i < n; i++) { cout << 1 << endl; fflush(std... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); long long A, B, n; cin >> A >> B >> n; for (int i = 0; i < n; ++i) { long long l, t, m; cin >> l >> t >> m; if (A + (l - 1) * B > t) { cout << -1 n ; } else { lo... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long n, long long m) { return n % m == 0 ? m : gcd(m, n % m); } const int Maxn = 2e3 + 10; bool enable[Maxn][Maxn]; string Number[10] = { 1110111 , 0010010 , 1011101 , 1011011 , 0111010 , 1101011 , 1101111 , 1... |
#include <vector> #include <algorithm> #include <queue> #include <iostream> #include <string> #include <stack> #include <map> #include <fstream> #include <random> #include <iomanip> #include <set> #include <cmath> #include <cassert> #include <unordered_set> #include <unordered_map> using ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; void solve() { int n; cin >> n; int a, b, c; cin >> a >> b >> c; string s; cin >> s; int ap = 0, bp = 0, cp = 0; for (auto i : s) { if (i == R ) ap++; else if (i == P ) bp++; ... |
#include <bits/stdc++.h> using namespace std; string w = RPS ; string s; int t[4], n, m, a[105], ans[105]; int main() { ios::sync_with_stdio(0); int Q; cin >> Q; while (Q--) { memset(ans, 0, sizeof(ans)); cin >> n >> t[1] >> t[2] >> t[3] >> s; m = (n + 1) / 2; for (in... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( fast-math ) using namespace std; const int INF = 1e9 + 9; const long long MAXN = 2... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.length(); int r = 0; vector<int> f(3, -1); f[0] = 0; vector<int> z(n + 1); for (int i = 1; i < (n + 1); ++i) { r = (r + s[i - 1] - 0 ) % 3; z[i] = z[i - 1]; if (f[r] != -1) z... |
#include <bits/stdc++.h> using namespace std; const int MAXA = 5e6; int m, n, k, s, x, l, r, si[MAXA], bo[MAXA], siz[MAXA], a[MAXA], tot; int check(int l, int r) { l -= (l - 1) % k; if (r - l + 1 > n + k) return 0; int ans = r - l + 1 - k; if (ans < 0) ans = 0; printf( %d n , ans); for (... |
#include <bits/stdc++.h> using namespace std; int arr[200005], arr2[200005], n, repeat = 1, maxi, mas; long double result[200005]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); } for (int i = 0; i < n; i++) { scanf( %d , &arr2[i]); if (arr[i]... |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-10; double EQ(double a, double b) { return abs(a - b) < EPS; } void fast_stream() { std::ios_base::sync_with_stdio(0); } int xs[4]; int ys[4]; int rs[4]; int Rs[4]; void solve() { for (int i = 0; i < 2; i++) { cin >> xs[i * 2] >> ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int arr[m]; for (int i = 0; i < m; i++) { int temp; cin >> temp; arr[i] = temp; } int middle = 1001; sort(arr, arr + m); for (int i = 0; i <= (m - n); i++) { middle = min(arr[i... |
#include <bits/stdc++.h> using namespace std; int n, ans = 0; long long int mn = int(1e9); vector<int> c, d; vector<vector<pair<int, int>>> g; void dfs(int u, int p = 1) { d[u] = 1; for (auto v : g[u]) if (v.first != p) { dfs(v.first, u); d[u] += d[v.first]; } return;... |
#include <bits/stdc++.h> using namespace std; const int _ = 1e2; const int maxn = 2e5 + _; struct node { int y, next; } a[2 * maxn]; int len, last[maxn]; void ins(int x, int y) { a[++len].y = y; a[len].next = last[x]; last[x] = len; } int c[maxn]; long long s[maxn]; bool v[maxn], t... |
#include <bits/stdc++.h> using namespace std; int n, a[60]; int abs(int x) { return x > 0 ? x : -x; } int f(int x) { int sum = 0; for (int i = 0; i < n / 2; ++i) sum += abs(i * 2 + x - a[i]); return sum; } int main() { scanf( %d , &n); for (int i = 0; i < n / 2; ++i) scanf( %d , a + i); ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const int MAXN = 10005; const int INF = 1111111111; struct Node { int id, val; bool operator<(const Node& a) const { if (a.val == val) return a.id < id; return a.val < val; } }; int du[100]; int n, p, tot, fg;... |
#include <bits/stdc++.h> using namespace std; bool matrix[5205][5205]; char inp[1305]; vector<int> divivi; int func(char c) { if (c >= 0 && c <= 9 ) return c - 0 ; else return c - A + 10; } bool check(int x, int n) { int i, j, r, c, ini; for (r = 0; r < n / x; r++) { ... |
#include <bits/stdc++.h> using namespace std; void _print(long long t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; char* c = new char[k]; for (int i = 0; i < k; i++) { c[i] = a + i; } for (int i = 0; i < n; i++) { cout << c[i % k]; } } |
#include <bits/stdc++.h> using namespace std; int x, cnt; vector<int> rj; bool good(int n) { bool t = false; for (int i = 20; i >= 0; i--) { if (n & (1 << i)) t = true; if (t && !(n & (1 << i))) return false; } return true; } int fix(int n) { bool t = false; for (int i = ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> St[5 * (int)(2e5 + 10)], arr[(int)(2e5 + 10)], A[(int)(2e5 + 10)]; int ans[(int)(2e5 + 10)], t[(int)(2e5 + 10)], b[(int)(2e5 + 10)]; int i, j, k, n, m, x, y, z; vector<pair<int, pair<int, int> > > v; vector<int> v2; map<int, int> H; pair... |
#include <bits/stdc++.h> using namespace std; pair<int, pair<int, int> > matrix[71][71][71]; int cost[71][71][71]; vector<string> colors; int n; void initialize() { colors.clear(); for (int i = 0; i < 71; i++) { for (int j = 0; j < 71; j++) { for (int k = 0; k < 71; k++) { ma... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; const int maxn = 20000000 + 20; long long dp[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, x, y; cin >> n >> x >> y; memset(dp, oo, sizeof dp); dp[1] = x; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int *tree; void buildTree(int node, int arr[], int start, int end) { if (start == end) { tree[node] = arr[start]; return; } int mid = (start + end) / 2; buildTree(2 * node + 1, arr, start, mid); buildTree(2... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int a[N]; int cnt[N]; int need[N]; int n, m; int getbit(int x, int i) { return (x >> i) & 1; } void add(int x, int val) { for (int mask = 0; mask < (1 << 6); mask++) if (getbit(mask, x)) cnt[mask] += val; } bool check() {... |
#include <bits/stdc++.h> using namespace std; const int N = 5005, K = 6, INF = 1000000000; int n; int t[N][3], pass[3], hack[3]; bool ch[N][3]; int nhack[K][3]; int calcs(int lv, int t) { if (t == 0) { return 0; } else { return 500 * (lv + 1) * (250 - t) / 250; } } const int L ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e9 + 5; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m, c, cost = 0; cin >> n >> m; for (long long i = 0; i < n; i++) { long long temp = N; for (long long j = 0; j < m; j... |
#include <bits/stdc++.h> using namespace std; const int MOD7 = 1e9 + 7; const int MOD9 = 1e9 + 9; const double EPS = 1e-9; long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } int toint(const string &s) { stringstream second; second << s; int x; se... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 9, M = 2e5 + 9, OO = 0x3f3f3f3f, mod = 1e9 + 7; long long n, aS, bS, aT, bT; string s, t; vector<long long> bMis, aMis; int main() { cin >> n >> s >> t; for (auto i : s) { aS += (i == a ); bS += (i == b ); } ... |
#include <bits/stdc++.h> using namespace std; bool isUpper(string s) { return std::all_of(s.begin(), s.end(), [](unsigned char c) { return std::isupper(c); }); } int main() { string s1, s2; cin >> s1 >> s2; transform(s1.begin(), s1.end(), s1.begin(), ::tolower); transf... |
#include <bits/stdc++.h> using namespace std; vector<string> pril, sush, glag; void Init() { pril.push_back( lios ); pril.push_back( liala ); sush.push_back( etr ); sush.push_back( etra ); glag.push_back( initis ); glag.push_back( inites ); } pair<int, bool> Check(string str) { pai... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 300005; long long n, e, idx[N], low[N], T, q[300005], ans = 0, ans2 = 1, scc[100005], mini[300005], cn, second[3000005]; vector<vector<long long> > g; vector<long lon... |
#include <bits/stdc++.h> using namespace std; vector<int> factor[500010]; int m, q; long long n; int p[10000], c[10000]; int divide(long long n) { int ans = 0; while (n % 5 == 0) n = n / 5 * 4, ans++; while (n % 3 == 0) n = n / 3 * 2, ans++; while (n % 2 == 0) n = n / 2, ans++; if (n > 1... |
#include <bits/stdc++.h> using namespace std; const int maxsize = 100; int n, m; bool visited[maxsize][maxsize]; string v, h; int go[][2] = {1, 0, -1, 0, 0, -1, 0, 1}; map<char, int> dir; int cnt; void dfs(int row, int col) { if (visited[row][col]) return; visited[row][col] = true; cnt++; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T nextInt() { T x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ); if (ch == - ) { p = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + (ch - 0 ); ch = g... |
#include <bits/stdc++.h> using namespace std; int n, m; long long k; int res[1000]; long long dp[205][205]; int p[105][105]; pair<int, int> a[10005]; long long calc(int i, int j) { if (j < 0) return 0; if (i == n + m - 1) { return (j == 0); } if (dp[i][j] != -1) return dp[i][j]; ... |
#include <bits/stdc++.h> #pragma comment(linker, ”/ STACK : 38777216“ using namespace std; const int N = 200005; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; int n, a[N]; set<int> q; set<int>::iterator it; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); ; cin.tie(0); cout.tie(0); int n, a, b, i; string s; cin >> n >> a >> b >> s; int tot = a + b, p = 0; for (i = 0; i < n; i++) { if (s[i] == * ) { p = 0; continue; ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; int add(int _a, int _b) { _a = (_a + 1000000007) % 1000000007; _b = (_b + 1000000007) % 1000000007; return (_a + _b) % 1000000007; } int mul(int _a, int _b) { _a = (_a + 1000000007) % 1000000007; _b = (_b + 1000000007) % 1000000007; return ((... |
#include <bits/stdc++.h> using namespace std; const int N = 100001; int main() { char c[3][3], cc[3][3]; char s[3][3]; int ind1, ind2; int ii = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { cin >> c[i][j]; cc[i][j] = c[i][j]; } for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<int> tree[maxn]; int n; bool flag[maxn]; double dfs(int deep, int at) { flag[at] = false; double ret = 0; for (int i = 0; i < tree[at].size(); i++) { int one = tree[at][i]; if (flag[one]) ret += dfs(deep ... |
#include <bits/stdc++.h> using namespace std; inline void prnt(bool ok) { cout << (ok ? YES : NO ); } const int ppr = 257; const long long INF = 2e18; const int inf = 2e9; const int mod = 1e9 + 7; const int N = 1e6 + 123; const long double pi = 3.141592653589793238462643; const int dx[] = {1, 0, -1... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MX = 2e5 + 1; bool sieve[MX], in_graph[MX], vstd[MX]; vector<int> pos[MX], adj[MX]; int mu[MX]; ll res[MX]; void init() { vector<int> primes; mu[1] = 1; for (int i = 2; i < MX; ++i) { if (!sieve[i]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; long long int arr[n]; vector<long long int> a, onsum, offsum; for (long long int i = 0; i < n; i++) { cin >> arr[i]; } a.push_back(arr[0]); for (long long int i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 100; int bitRow[maxn][maxn], bitCol[maxn][maxn], n, m; bool a[maxn][maxn]; void addRow(int fi, int idx, int val) { while (idx <= 1000) { bitRow[fi][idx] += val; idx += idx & (-idx); } } void addCol(int fi, int idx, i... |
#include <bits/stdc++.h> using namespace std; struct Poi { int x, y; Poi() { x = y = 0; } Poi(int _x, int _y) : x(_x), y(_y) {} } q[200000], po[500]; int n, vX, vY, sX, sY, cX, cY, minX, minY, maxX, maxY, up, dw, lf, rt; int pre[500][500], li[200000], len, qi[200000]; bool tree[500][500]; int ... |
#include <bits/stdc++.h> const int INF = 1e9; using namespace std; inline string gtStr() { char st[200]; scanf( %s , st); return st; } long long sum[1001]; int cnt[11]; int main() { int n, m, f; cin >> n >> m; for (int i = 0; i < n; i++) { scanf( %d , &f); cnt[f]++; ... |
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); typedef long long ll; typedef long double ld; typedef vector<ll> vll; typedef pair<ll,ll> pll; #define F first #define S second #define PB push_back #define MP make_pair #define all(x) x.begi... |
#include <bits/stdc++.h> using namespace std; using lint = long long; int a[111][111]; void solve(istream& cin, ostream& cout) { int n, m; cin >> n >> m; bool sw = n > m; for (int i = (0); i < int(n); ++i) { for (int j = (0); j < int(m); ++j) { if (sw) { cin >> a[j][i]; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; long long powmod(long long a, long long b) { long long res = 1; for (; b; b >>= 1) { if (b & 1) (res *= a) %= mod; (a *= a) %= mod; } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0);... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int T = 1; while (T--) { string s1, s2; cin >> s1 >> s2; long long int ans = 0; long long int i, j, k; i = j = k = 0; long long int n = s2.si... |
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(15); } int dx[] = {1, -1, 0, 0, 0, 0}; int dy[] = {0, 0, 1, -1, 0, 0}; int dz[] = {0, 0, 0, 0, 1, -1}; int k, n, m; int ANS = 0; string x[10][10]; in... |
#include <bits/stdc++.h> using namespace std; class MinCostMaxFlowLongLong { public: class MinCostMaxFlowEdge { private: int destination_; long long capacity_; long long cost_; long long flow_; public: MinCostMaxFlowEdge(int destination, long long capacity, long lon... |
#include <bits/stdc++.h> using namespace std; char qur[8]; int cnte, cntt, cntf; bool chke[256], chkt[256], chkf[256]; char e[256][111], t[256][111], f[256][111]; vector<int> ve, vt, vf; char tmp[111]; char ans[256][111]; int main() { int n, num; strcpy(f[15], x ); vf.push_back(15); c... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k; cin >> n >> m >> k; vector<long long> v; v.push_back(0); for (int i = 0; i < m; i++) { long long a; cin >> a; v.push_back(a); } int i = 1, j = 1, ans = 0; while (i <= m) { while ((v[... |
#include <bits/stdc++.h> using namespace std; long long modulo = 1e9 + 7; template <class X> void printarr(X arr[], int n) { for (int i = 0; i < n; ++i) cout << arr[i] << ; cout << endl; } long long fpow(long long a, long long n) { long long ans = 1; while (n) { if (n & 1) ans = (an... |
#include <bits/stdc++.h> using namespace std; string S; vector<int> V; int rev(int x) { long long sum = 0; for (int i = 0; i < 8; i++) { int temp = x % 2; sum = sum * 2 + temp; x /= 2; } return sum; } int main() { ios::sync_with_stdio(false); getline(cin, S); in... |
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t>0){ t--; int n; cin >> n; vector<int> a(n); map<int,int> mp; for(int i=0;i<n;i++){ cin >> a[i]; if(i%2){mp[a[... |
#include <bits/stdc++.h> using namespace std; char s[1005][11][11]; int d[1005][1005], vis[1005], fa[1005], t[1005][2]; int n, m, c; vector<int> V[1005]; struct Edge { int a, b, w; } p[500005]; int cmp(Edge x, Edge y) { return x.w < y.w; } int cal(int a, int b) { int ans = 0, i, j; for (i ... |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 1000... |
#include <bits/stdc++.h> using namespace std; const long int z = 1000000007; long long int h[1000009], a[1000009]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); vector<pair<string, string> > p; std::set<int> myset; std::set<int>::iterator it; long long int... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; ; long long max(long long a, long long b) { if (a > b) return a; else return b; } long long min(long long a, long long b) { if (a > b) return b; else ret... |
#include <bits/stdc++.h> using namespace std; long long a[110000], b[110000], dp[110000][5]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, i, j, k; vector<long long> v; cin >> n; for (i = 1; i < n; i++) { cin >> a[i]; } for (i ... |
#include <bits/stdc++.h> using namespace std; int findd(string s1, string s2) { long long h1 = 0, h2 = 0, x = 1; int i, n = (int)s1.size(), m = (int)s2.size(); if (n < m) return -1; for (i = 0; i < m; i++) h2 = h2 * 33 + s2[i] - a + 1; for (i = 0; i < n; i++) { if (i < m) { h1 = ... |
#include <bits/stdc++.h> using namespace std; pair<pair<string, string>, string> solve(int n) { if (n == 1) { return {{ a , }, a }; } if (n == 2) { return {{ a , a }, a }; } int k = n - 1 >> 1; auto res = solve(k); string c = ; c += res.second[res.second.size() - 1... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int t; cin >> t; while (t--) { long long int n; cin >> n; string ans; string v; string p; for (int i = 0; i < n - 2; i++) { cin >> v; if (v[0] == p[1] && i != 0) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m; bool check(int mid) { ll cnt = m * 1ll * mid, C = 1, ret = 1; for (int i = 1; i <= min(m, mid) && cnt; i++) { C = C * (mid - i + 1) / i; if (cnt >= C * i) cnt -= C * i, ret += C; else { ret +=... |
#include <bits/stdc++.h> using namespace std; inline void pisz(int n) { printf( %d n , n); } const int MAX_N = 200010; int n; char a[MAX_N]; char b[MAX_N]; double s1[26][MAX_N]; double s2[26][MAX_N]; void precompute() { s1[b[1] - A ][1] = 1UL; for (int(i) = (2); (i) <= (n); ++i) { for (... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long int> a; long long int n; cin >> n; long long int sum = 0, m, ans = 0, count = 0; ; for (long long int i = 0; i < n; i++) { long long int x; cin >> x; sum = sum + x; a.push_back(x); } m... |
#include <bits/stdc++.h> using namespace std; int ile(long long int a) { int ans = 0; while (a) { if (a % 2 == 1) ans++; a /= 2; } return ans; } int main() { int n; cin >> n; long long int* a; a = new long long int[n]; for (int i = 0; i < n; i++) { cin >> a[... |
#include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #include<map> #include<queue> #include<sstream> #include<stack> #include<set> #include<bitset> #include<vector> #define ll long long #define ull unsigned long long #define up_b upper_... |
#include <bits/stdc++.h> using namespace std; const int64_t Nmax = 2e5 + 10; const int64_t mod = 1000000007; vector<int64_t> prime; int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); } int64_t isperfectsquare(int64_t a) { double b = sqrt(a); return (b - ceil(b) == 0); } int64_t p... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 2000005; int pref[N], suf[N]; int lB[N], lW[N]; int arr[N]; int S[N][4]; int n, k; char s[N]; int pw[N]; int value[N]; int summary; int mPow(int x, int n, int mod) { if (n == 0) return 1; if (n % 2)... |
#include <bits/stdc++.h> using namespace std; const int NUM = 2e5 + 5; const int mod = 998244353; int INF = 1e6; pair<int, int> pinf = {INF, INF}; long long bin_pow(int n) { if (n == 0) return 1; if (n % 2 == 0) return bin_pow(n / 2) * bin_pow(n / 2) % mod; return 2 * bin_pow(n - 1) % mod; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e6 + 666; struct palindromic_tree { int len[MAXN], link[MAXN], cnt[MAXN]; char s[MAXN]; vector<pair<char, int>> to[MAXN]; int n, last, sz; void clear() { fill(to, to + MAXN, vector<pair<char, int>>()); memset(len, 0, s... |
#include <bits/stdc++.h> using namespace std; const int MxN = (int)15e4 + 9; int n, Q; int parent[MxN + 9]; vector<int> adj[MxN + 9]; int height[MxN + 9]; char label[MxN + 9]; const string YES = Shi ; const string NO = Fou ; int parent2[MxN + 9]; vector<int> adj2[MxN + 9]; array<int, 26> label... |
#include <bits/stdc++.h> 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)); } pair<int, int> rev[1000005]; int h[1000005]; int d[1000005]; vector<int> g[1000005]; int N, K; void pre_d... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 100 + 10; int par[N], n, m, c; unordered_map<int, int> adj[N]; unordered_set<int> adj1[N]; int getPar(int root) { return par[root] == par[par[root]] ? par[root] : par[root] = getPar(par[root]); } ... |
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using dbl = double; using ii = pair<int, int>; const ll MOD = 998244353; ll z1[2000005], z2[2000005], dp[1000005], psum[1000005]; void solveZ(string s, ll z[]) { z[0] = 0; ll L = 0, R = ... |
#include <bits/stdc++.h> using namespace std; string st; int dp[10005][4]; int n; set<string> st_set; int rec(int pos, int len) { if (pos == 4 || pos == 5) { return 1; } if (pos < 4) return 0; int &ret = dp[pos][len]; if (ret != -1) return ret; ret = 0; if (len == 0) { ... |
#include <bits/stdc++.h> using namespace std; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr; inline void flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }... |
#include <bits/stdc++.h> using namespace std; bool cmp1(vector<int> a, vector<int> b) { int q = a[4] + a[1] + a[2] + a[3] - a[0]; int p = b[4] + b[1] + b[2] + b[3] - b[0]; return q < p; } bool cmp2(vector<int> a, vector<int> b) { int q = a[0] + a[4] + a[2] + a[3] - a[1]; int p = b[0] + b[4] ... |
#include <bits/stdc++.h> int i, j, k, n, m, p[2001], a[2001], x[1002001][26], y[2001][26], dp[2000][2002], dp2[2000][2002]; char t[1002001], s[2001]; int main() { for (i = 0; i < 2000; i++) for (j = 0; j < 2002; j++) dp[i][j] = 1e9; scanf( %d , &n); p[0] = 0; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long freq[100001]; int dp[101]; int main() { int h, a, p; cin >> h >> a >> p; int mh, ma; cin >> mh >> ma; vector<int> s; while (h - ma > 0 || mh <= a) { h -= ma; mh -= a; s.push_back(1); if (mh <= 0) break; }... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.