func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; using longInt = long long; const int maxL = 204; int r[maxL], g[maxL], b[maxL], l[3]; longInt f[maxL][maxL][maxL]; void get_array(int *a, int n) { for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1, [](int x, int y) -> bool { return x > y; }... |
#include <bits/stdc++.h> using namespace std; int gr[5000][5], n, m; string s[5000]; bool isOK(int x, int y) { if (x >= 0 && x < n && y >= 0 && y < m) return true; return false; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; map<char, int> mp; mp[ U ] = 0; ... |
#include <bits/stdc++.h> using namespace std; long long n, k; const long long Lim = 1e14; const long long M = 1e7; int flag[M], f[M]; int b[15]; vector<pair<int, int> > Q[15][2]; inline int calc(int x, int flag, long long now, long long &k) { if (now >= M) return -1; int st = lower_bound(Q[x][fl... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; int a, b; for (int i = 0; i < n; i++) { int x; cin >> x; if (x == 1) a = i; if (x == n) b = i; } cout << max(max(a, b), max(n - 1 - a, n - 1 - b)) << endl; } |
#include <bits/stdc++.h> using namespace std; int n, rt, c[200005], col[200005]; vector<int> son[200005], b; long long a[200005][5]; void dfs(int x, int fa) { b.push_back(x); for (int i = 0; i < son[x].size(); i++) { if (son[x][i] == fa) continue; dfs(son[x][i], x); } } int main() ... |
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 55, INF = 5e5 + 55; const double Eps = 1e-5; long long n, m, k, Fa[N], Vis[N], flag; struct Node { long long first, second, Num; double val; Node() { first = second = val = 0; } bool operator<(const Node &X) const { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:536870912 ) const int MOD = 1000000007; const int INF = 1000000001; const int MAXN = 17; const long double EPS = 1e-6; const int HASH_POW = 29; const long double PI = acos(-1.0); using namespace std; void my_return(int code) { exit(code); } in... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1, i = 0, j = 0, k = 0; cin >> t; while (t--) { long long int n; cin >> n; long long int l[n], r[n]; for (i = 0; i < n; ++i) cin >> l[i] >> r... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, x; cin >> t; for (int i = 0; i < t; i++) { string s; cin >> s >> x; bool possible = true; for (int j = 0; j < s.size(); j++) { if (s[j] == 1 ) { ... |
#include <bits/stdc++.h> using namespace std; const int mac = 2e3 + 10; int a[mac], vis[mac]; int ask(int pos) { printf( ? %d n , pos + 1); fflush(stdout); char s[5]; scanf( %s , s); if (s[0] == Y ) return 1; return 0; } int main(int argc, char const *argv[]) { int n, m; sca... |
#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 & 1) { vector<int> v1, v2; bool flag = true; for (int i = 1; i <= 2 * n; i++) { if (flag) { v1.push_back(i); ... |
#include <bits/stdc++.h> using namespace std; struct Node { int data; Node* next; }; Node* head = NULL; void insert_ll(int data) { Node* temp = new (Node); temp->data = data; temp->next = NULL; if (head == NULL) { head = temp; return; } else { Node* temp2 = head; ... |
#include <bits/stdc++.h> using namespace std; int a[110]; int main() { int n, k; cin >> n >> k; vector<int> v; for (int i = 0; i < k; i++) cin >> a[i]; for (int i = 1; i <= n; i++) v.push_back(i); int lea = 0; for (int i = 0; i < k && v.size() > 0; i++) { lea %= v.size(); i... |
#include <bits/stdc++.h> using namespace std; int N; int main() { cin >> N; long long int A[N + 1]; A[1] = 1; long long int currentFact = 1; for (int i = 2; i <= N; i++) { currentFact *= i; currentFact %= 998244353; A[i] = ((A[i - 1] * i) % 998244353 - i + currentFact) % 9982... |
#include <bits/stdc++.h> using namespace std; int t, n; char s[505050]; int a[1 << 20], b[1 << 20]; const int L = 20, FN = (1 << L); int rev[FN]; const long double pi = 3.1415926535897932384626433832795028841971l; const long double two_pi = pi * 2; struct cp { long double x, y; cp() {} cp(... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[100005]; int tr[100005]; int lb(int x) { return x & (-x); } void add(int x, int v) { while (x <= 100000) { tr[x] = max(tr[x], v); x += lb(x); } } int get(int x) { int ans = 0; while (x > 0) { ans = max(ans, t... |
#include <bits/stdc++.h> int n; int a[1000]; int main() { int maxx = 0; scanf( %d , &n); int i; for (i = 1; i <= n; i++) { scanf( %d , &a[i]); maxx = (maxx > a[i]) ? maxx : a[i]; } int s = 0; for (i = 1; i <= n; i++) { s += (maxx - a[i]); } printf( %d , s); ... |
#include <bits/stdc++.h> using namespace std; int w, b; int main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { char s; cin >> s; if (s == Q ) { w += 9; } if (s == R ) { w += 5; } if (s == B ) { w +... |
#include <bits/stdc++.h> using namespace std; int n, m; char s[5001], t[5001]; int dp[5001][5001]; int main() { while (cin >> n >> m) { for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < m; i++) { cin >> t[i]; } for (int i = 0; i < m + 1; i++) { ... |
#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; const int N = 105; int answer[N][4]; int main() { int n, m; cin >> n >> m; int k = 0; for (int i = 1; i <= n; ++i) { if (k == m) break; answer[i][0] = ++k; if (k == m) break; answer[i][3] = ++k; } for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; int a[33]; int b[33]; int k[33]; int p[33]; int n = 0; int u = 0; int r = 0; long long ans = -0x7FFFFFFFFFFFFFFFLL; int updateAns() { long long tans = 0; for (int i = 1; i <= n; i++) tans += (long long)a[i] * k[i]; if (tans > ans) ans = tans;... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 5; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long r; cin >> r; for (long long i = 1; i * i <= r; i++) { long long y = r - i * i - i - 1; if (y > 0 && y %... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> qucv[3], v; void quc() { cout << ? OC n ; cout.flush(); int k; cin >> k; if (k == -1) exit(0); while (k--) { int x; cin >> x; qucv[0].push_back(x); } cout << ? HC n ; cout.flush(); cin >>... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int SIZE = 1e6 + 5; const long long INF = 1LL << 55; const double eps = 1e-10; long long expo(long long a, long long b) { if (b == 0) return 1; long long h = expo(a, b / 2); h = (h * h) % MOD; if (b % 2) h = (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 1; int f[MAXN]; int s[MAXN]; int e[MAXN]; int main() { string S; cin >> S; int maxi = 0; int len = 0; int start = 0; stack<int> st; f[0] = 1; s[0] = -1; e[0] = -1; for (int i = 0; i < S.length(); i++... |
#include <bits/stdc++.h> using namespace std; const int N = 100, yzh = 1e9 + 7; void read(int &x) { char ch; bool flag = 0; for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == - )) || 1); ch = getchar()) ; for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar()... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int mod = (int)1e9 + 7; int sum(int a, int b) { int s = a + b; if (s >= mod) s -= mod; return s; } int mult(int a, int b) { return (1LL * a * b) % mod; } int pw(int a, int b) { if (b == 0) return 1; if (b & ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const long long LINF = (long long)INF * INF; const int MAX = 2e5; const double EPS = 1e-9; const double PI = acos(-1.); int n, m, k; vector<pair<int, long long> > g[300005]; set<pair<pair<int, int>, int> > elist; set<i... |
#include <bits/stdc++.h> using namespace std; inline long long read() { char ch = getchar(); long long p = 1, data = 0; while (ch < 0 || ch > 9 ) { if (ch == - ) p = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { data = data * 10 + (ch ^ 48); ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; struct edge { int to, next, v; } e[2005 * 105]; int head[2005], tot, n; void add(int x, int y, int v) { e[++tot] = (edge){y, head[x], v}; head[x] = tot; } struct Graph { int S, sz; bool vis[2005]; long long dis[2005], b[2005]; void ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int a, b, i, cnt, x; cin >> a >> b; if (a < b) { cout << 0 n ; return 0; } if (a == b) { cout << infinity n ; return 0; } a = a - b; cnt = 0; for (i = 1; i <= sq... |
#include <bits/stdc++.h> using namespace std; long long ansp[200001]; int main() { long long k; memset(ansp, 0, sizeof(ansp)); scanf( %lld , &k); char s[200001], t[200001], ans[200001]; scanf( %s %s , s, t); long long add = 0, dec = 0, again = 0; long long i, j; for (i = 0; i < k; ... |
#include <bits/stdc++.h> using namespace std; int bit(int mask, int n) { return mask & (1 << n) ? 1 : 0; } int rev(int a) { int res = 0; for (int i = 0; i < 8; ++i) res = res | ((1 << (7 - i)) * bit(a, i)); return res; } int main() { string s; int prev = 0; getline(cin, s); for (in... |
#include <bits/stdc++.h> using namespace std; int a[101][101], c[101], D[101], d[101], size[101], n, m, i, j, k, l, x, y, h, t, tot, Tot; long long jc[101], Jc[101], f[101][101], g[101], F[101][101]; bool bz[101], Bz[101], bz2[101], bz3[101], bz4[101]; long long qpower(long long a, int b) { long lon... |
#include <bits/stdc++.h> using namespace std; int n, m; long long a[100010], ans; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } inline long long cal(long long a) { if (a % 2 == 0) return 0; long long tmp = 0; for (int i = 0; (a << i) < m; i++) { tmp += m - (a... |
#include <bits/stdc++.h> using namespace std; const int INF = 2000000000; struct Edge { int from, to, cap, flow, index; Edge(int from, int to, int cap, int flow, int index) : from(from), to(to), cap(cap), flow(flow), index(index) {} }; struct Dinic { int N; vector<vector<Edge> > G; ... |
#include <bits/stdc++.h> using namespace std; bool comp(int x, int y) { return x > y; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int t = 1; cin >> t; long long m, n, k; string a, b; while (t--) { cin >> n; vector<long long> vec(n); ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c, d; cin >> a >> b >> c >> d; long long ans = 0, fl = 0; if (a != c && b != d) ans = abs(a - c) + abs(b - d) + 2; else ans = abs(a - c) + abs(b - d); cout << ans << n ; } int main() { ios_base... |
#include <bits/stdc++.h> using namespace std; template <class T> void rd(T &ret) { ret = 0; bool ok = 0, u = 0; for (;;) { int c = getchar(); if (c >= 0 && c <= 9 ) ret = (ret << 3) + (ret << 1) + c - 0 , ok = 1; else if (c == - ) u = 1; else if (ok) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; int arr[N], grr[100006] = {0}, fre[100005] = {0}, x, ma = 0, ans = 0; for (int i = 0; i < N; i++) { bool ok = false; cin >> x; grr[fre[x]]--; fre[x]++;... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int SIZE = 2e6 + 10; int a[SIZE]; int num[SIZE], nxt[SIZE]; int main() { int n, q; scanf( %d%d , &n, &q); long long sum = 0; for (int i = 0; i < (n); ++i) { scanf( %d , &(a[i])); sum += a[i]; a[i +... |
#include <bits/stdc++.h> using namespace std; long long mul(long long a, long long b) { return ((a % 1000000007) * (b % 1000000007)) % 1000000007; } long long power(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a; long long temp = power(a, b / 2); if (b % 2 == 0) ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[105]; int dp[105][55]; int f[55]; int n, k; void dfs(int u, int fa) { dp[u][0] = 1; dp[u][k + 1] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (v == fa) continue; dfs(v, u); memset(f, 0, sizeof... |
#include <bits/stdc++.h> using namespace std; int n, cnt; char c[11]; int main() { scanf( %d %s , &n, c + 1); if (n == 6) printf( espeon n ); else if (n == 8) printf( vaporeon n ); else if (c[1] == j || c[2] == o || c[4] == t ) printf( jolteon n ); else if (c[1] == u ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; const int n = s.length() + 5; int arr[n]; memset(arr, 0, sizeof arr); int m, l, r; for (int i = 0; i < s.length(); i++) { if (s[i] == s[i + 1]) { arr[i + 2]++; } arr[i + 1] += arr[i];... |
#include <bits/stdc++.h> using namespace std; int dp[110][10100]; bool f[110][10100] = {false}; int main() { int m, n, x, y, i, j, k, a[1111]; pair<int, int> pii[101]; cin >> n; for (i = 0; i < n; i++) cin >> pii[i].second >> pii[i].first; sort(pii, pii + n); for (i = 0; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; const int maxl = 2 * 1000 * 100 + 5; const int maxlg = 22; vector<pair<int, int> > adj[maxl]; vector<int> tree[maxl]; int n, m, q; int mark[maxl], depth[maxl]; bool cut[maxl]; int dsu[maxl]; int arr[maxl]; int lca[maxl][maxlg]; int psum1[maxl], psum2... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } long long add(long long a, long long b) { long long ret = a + b; if (ret >= 1000000007) ret -= 1000000007; return ret; } long long subtract(long long a, lon... |
#include <bits/stdc++.h> using namespace std; int64_t dp[2004], nx[2004]; struct pt { int64_t v, c; }; int main() { ios::sync_with_stdio(false); int n, m, q; cin >> n >> m >> q; vector<vector<pair<int, int>>> G(n + 1); vector<int> val(n + 1, 0); vector<int64_t> cost(n + 1, 0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int A[3] = {0}; int num; cin >> num; long ip; while (num--) { cin >> ip; if (ip % 3 == 0) A[0]++; else if (ip % 3 == 1) A[1]++; else if (ip % 3 == 2) A[2]++; } cout << A[0] / 2 + mi... |
#include <bits/stdc++.h> using namespace std; int n, ret, f[26]; vector<pair<pair<int, int>, int> > ss; int call(char c) { return int(c) - int( a ); } int main() { cin >> n; string s; for (int i = 1; i <= n; i++) { cin >> s; ss.push_back(make_pair(make_pair(call(s[0]), call(s[long(s.le... |
#include <bits/stdc++.h> using namespace std; int n, x, m, t, cnt, r[105]; int main() { scanf( %d , &n); for (int i = (0); i <= (n); i++) { ++cnt; if (i < n) scanf( %d , &x); if (x < 0) ++t; if (t == 3 || i == n) { r[m++] = cnt - 1; cnt = t = 1; } } pr... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 0; string a, b; vector<pair<string, string> > vec; cin >> n; while (n--) { cin >> a >> b; vec.push_back(make_pair(a, b)); } n = 0; sort(vec.begin(), vec.end()); while (i < vec.size()) { n++; ... |
#include <bits/stdc++.h> using namespace std; int m, n; int main() { cin >> n >> m; if (m * n % 2 || ((min(m, n) == 1) && max(m, n) > 2)) { cout << 1 << n ; cout << n << << m << << 1 << << 1 << n ; for (int i = 1; i <= m; ++i) { if (i % 2) { for (int j =... |
#include <bits/stdc++.h> using namespace std; int vowel(char a) { if (a == a || a == i || a == e || a == u || a == o ) { return 1; } return 0; } int main() { char s[1005]; char t[1005]; int i; scanf( %s , s); scanf( %s , t); if (strlen(s) != strlen(t)) { ... |
#include <bits/stdc++.h> using namespace std; int A[50][50]; int main() { long long int T; cin >> T; while (T--) { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < n; j++) { A[i][j] = s[j] - 0 ; } ... |
#include <bits/stdc++.h> using namespace std; long long n, m, p[500500], pp[500500], t = 1; vector<long long> s, f; int fd(long long x) { if (x == pp[x]) { return x; } return pp[x] = fd(pp[x]); } int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { p[i] = i; pp[i]... |
#include <bits/stdc++.h> using namespace std; long long t, n, a[100010], b[100010], c[100], w, e; long long ans = 0; void init() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= 90; i++) c[i] = 0; sort(a + 1, a + n + 1); w = 1; for (int i = 1; i <= n; i++) { ... |
#include<bits/stdc++.h> using namespace std; const int N=10,M=405,mod=998244353; int n,m,k,t,v[M],id[M][M],ch[M][30],l[N]; char s[N][N]; struct mat{int a[M][M];}; mat operator*(mat x,mat y) { mat z; for(int i=1;i<=t;i++) { for(int j=1;j<=t;j++) { z.a[i][j]=0; for(int k=1;k<=t;k+... |
#include <bits/stdc++.h> using namespace std; long long int a[4005]; long long int dp[4005][4005]; int m; int dfs(int l, int r) { if (l > r) return 0; long long int mi = 1e18; long long int root = -1; for (int i = l; i <= r; i++) { if (a[i] < mi) { mi = a[i]; root = i; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5010; const int mod = 1e9 + 7; const int INF = 0x3f3f3f3f; const double pi = acos(-1.0); const double eps = 1e-4; int main() { double d, l, v1, v2; cin >> d >> l >> v1 >> v2; printf( %.6lf n , (l - d) / (v1 + v2)); return 0; ... |
#include <bits/stdc++.h> using namespace std; template <class S, class T> ostream& operator<<(ostream& o, const pair<S, T>& p) { return o << ( << p.first << , << p.second << ) ; } template <class T> ostream& operator<<(ostream& o, const vector<T>& vc) { o << sz = << vc.size() << endl << [ ;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n; cin >> n; long long d = 0; vector<long long> v; vector<long long> a; long long val = 0; map<long long, long long> m; long long start = 0, end = -1, c... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long ar[n + 1]; for (long long i = 1; i <= n; i++) { cin >> ar[i]; } ar[0] = 0; long long ans = 0; for (long long i = 0; i < n; i++) { l... |
#include <iostream> #include <vector> #include <algorithm> #include <math.h> using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define mk make_pair #define tests int t; cin >> t; while(t--) #define forn(i, ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y >= 1) { if (y % 2) res = (res * x) % p; x = ((x % p) * (x % p)) % p; y /= 2; } return res; } void solve() { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int m = max(3 * a / 10, a - a / 250 * c); int v = max(3 * b / 10, b - b / 250 * d); if (m == v) cout << Tie ; else if (m > v) cout << Misha ; else cout << Vasya ; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 6; long long int arr[2000005], brr[2000005], crr[2000005]; void solve(int n, long long int arr[]) { int cnt = n + arr[0]; for (int i = 1; i < n; i++) { cnt += abs(arr[i] - arr[i - 1]) + 1; } cout << cnt; return; } ... |
#include <bits/stdc++.h> using namespace std; const int INFTY = 20000000; const int MAX = 500100; const int MOD = 10000000; void coutTab(int* tab, int n) { for (int i = 0; i < n; i++) { cout << tab[i] << ; } cout << n ; } string create(int a, int b, int x, int start) { if (start... |
#include <bits/stdc++.h> using namespace std; struct NODE { int to, next; } node[200000 + 10]; long long dp[100000 + 10], k[100000 + 10]; int n, tol; int head[100000 + 10]; void addedge(int from, int to) { node[tol].to = to; node[tol].next = head[from]; head[from] = tol++; } void tree_... |
#include <bits/stdc++.h> using namespace std; const int N = 200004, M = 19; vector<int> g[N]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int d[N], fa[N][M], n; long long w[N][M], a[N], mod = 1000000007; void bfs() { d[1] = 1; for (int i = 0; i < M; i++) w[1][i] = a[1... |
#include <bits/stdc++.h> using namespace std; int main() { int mera[100001]; int snct[100001]; string s; cin >> s; int len = s.length(); stack<int> st; if (s[0] == [ ) { snct[0] = 1; } else { snct[0] = 0; } for (int i = 1; i < len; i++) { snct[i] = snct[i -... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; int a[n], g[n]; int sa = 0, sg = 0; char ans[n]; for (int i = 0; i < n; ++i) { cin >> a[i] >> g[i]; } for (int i = 0; i < n; ++i) { sa += a[i]; if (sa <... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = MOD; vector<int> a[200]; int cnt = 0; bool used[200]; void dfs(int v) { used[v] = true; for (int i = 0; i < a[v].size(); i++) if (!used[a[v][i]]) dfs(a[v][i]); } bool flag = false; vector<pair<int... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; vector<long long> cnt(26); long long posl = 1e9, posr = 0; for (auto c : s) { cnt[c - a ]++; posl = min(posl, (long long)(c - a )); posr = max(posr, (long long)(c - a )); } for (long lon... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e6 + 5; long long solve() { long long n; cin >> n; map<long long, long long> mp; vector<long long> v(n); for (long long &x : v) { cin >> x; mp[x]++; } long long ans = 0; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const double EPS = 1e-9; int n, m, t[210][210], d[210][210]; bool active[210]; vector<pair<int, int> > x_sorted; double calc(int x, int y) { double ans = INF; vector<pair<int, int> > s; multiset<int> up; int down = -... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i < n + 1; i++) { for (int j = 1; j < m + 1; j++) { if (i % 4 == 2) { if (j == m) { cout << # ; } else ... |
/** try <3 **/ #include<bits/stdc++.h> using namespace std; #define task sol #define lb lower_bound #define ub upper_bound #define fi first #define se second #define pb push_back #define mp make_pair #define zs(v) ((int)(v).size()) #define BIT(x, i) (((x) >> (i)) & 1) #define CNTBIT _... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a[60], b[60]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cin >> m; for (int i = 0; i < m; i++) cin >> b[i]; int BG = -1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (!(b[j] % a[i... |
#include <bits/stdc++.h> int main(void) { int t, h, m; scanf( %d , &t); while (t--) { scanf( %d%d , &h, &m); printf( %d n , (23 - h) * 60 + (60 - m)); } return 0; } |
#include <bits/stdc++.h> using namespace std; const int Max = 1000000100; vector<long long> s; void dfs(long long temp) { if (temp > Max) { return; } long long x = temp * 10 + 4; if (temp > Max) { return; } s.push_back(x); dfs(x); long long y = temp * 10 + 7; if (... |
#include <bits/stdc++.h> using namespace std; long long fact[1000001], power[1000001]; long long powerr(long long x, long long y); long long mpower(long long x, long long y, long long p); long long gcdExtended(long long a, long long b); bool isPrime(long long n); long long func(long long n) { long lon... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e5 + 5; const long long int M = 1e3; const long long int mod = 1e7 + 7; const long long int m1 = 1e9 + 7; const long long int m2 = 1e9 + 9; const long long int p1 = 402653189; const long long int p2 = 1610612741; const int LN = 32;... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { int temp; temp = a; a = b; b = temp; } while (a % b) { int r = a % b; a = b; b = r; r = a % b; } return b; } int fun(int a, int n) { int sum = 0; for (;;... |
#include <bits/stdc++.h> using namespace std; class Point { public: int x; int y; Point(int x = 0, int y = 0) : x(x), y(y) {} friend Point operator-(Point a, Point b) { return Point(b.x - a.x, b.y - a.y); } }; int getBit(int mask, int num) { return ((mask & (1 << num)) ? 1 : 0); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { vector<int> f(n); vector<int> v[100005]; vector<int> b(m); vector<int> a(m); vector<int> used(100005, 0); for (int i = 0; i < n; i++) { cin >> f[i]; v[f[i]].push_b... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string A, B; cin >> A >> B; int ans = 0; for (int x = 0; x < N - 1 - x; x++) { vector<char> v; v = {A[x], A[N - 1 - x], B[x], B[N - 1 - x]}; sort(v.begin(), v.end()); if (v[0] == v[1] && v[2] ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int n, c1, c2; int a[10]; long long f[501]; long long c[501][501]; long long dp[501][501]; long long gao(int a, int b) { if (a == 0 && b == 0) { return 1; } if (dp[a][b] == -1) { long long& cur = dp[a][b] =... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int N = 10e6 + 6; int p[N]; int nx[N]; int n; priority_queue<int> r; bool vis[N]; int main(void) { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i]; nx[p[i] - 1] = i... |
#include <bits/stdc++.h> const int S = 103; int n, m, a[S], b[S]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { if (2 * n + 2 * (i - 1) + 1 <= m) printf( %d , 2 * n + 2 * (i - 1) + 1); if (2 * i - 1 <= m) printf( %d , 2 * i - 1); if (2 * (n + i) <= m) printf( %d ,... |
#include <bits/stdc++.h> using namespace std; inline long long Getint() { char ch = getchar(); long long x = 0, fh = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { (x *= 10) += ch ^ 48; ch = getchar(); } ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) #pragma warning(disable : 4786) using namespace std; int MIN(int a, int b) { return a < b ? a : b; } int MAX(int a, int b) { return a > b ? a : b; } int GCD(int a, int b) { while (b) b ^= a ^= b ^= a %= b; return a; } int LCM(in... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 555; int n, m; int a[maxn], b[maxn]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , a + i); for (int i = 1; i <= m; i++) scanf( %d , b + i); int i1 = 1, i2 = 1; int res = 0; while (i1 <= ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int q, r, g, b, w; cin >> q; while (q--) { vector<int> a(4); int odd = 0, even = 0; for (int i = 0; i < 4; i++) { cin >> a[i]; if (a[i] % 2) odd +=... |
#include <bits/stdc++.h> using namespace std; int X, Y, Z, N, M, K; int L[3], R[3]; int OK[101010][3], NG[101010][3], Q[101010][3]; int ret[101010]; vector<pair<int, int>> query[8]; void solve() { int i, j, k, l, r, x, y; string s; scanf( %d%d%d%d%d%d , &X, &Y, &Z, &N, &M, &K); R[0] = R[1]... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, etime, cnt[2], f[2]; int main() { int t; scanf( %d , &t); while (t--) { scanf( %d%d%d%d , &n, &etime, f, f + 1); vector<int> v = {etime}; vector<pair<int, bool> > p(n); cnt[0] = cnt[1] = 0; for ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n = 0; long long k = 0; long long wynik = 0; long long wynik2 = 0; long long wynik3 = 0; cin >> n >> k; if (k == 1) { cout << 1 ; return 0; } if (k == 2) { wynik = n * (n - 1) / 2 + 1; c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.