func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, i, j; int l = 0, t = 0, m = 0, max = 0; cin >> n; cin >> i >> j; l = j; while (t < n) { t++; cin >> x >> y; m = j - x + y; if (m > max) { max = m; } j = m; } if (max ==... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, t, a, x, cur = 0, sum = 0, sz = 1; cin >> n; vector<long long> arr(n + 20), ch(n + 20); for (int i = 0; i < n; i++) { cin >> t; if (t == 1) { cin >> a >> x; ch[a - 1] += x; sum += a * x; ... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 1; const int MAXN = (int)5001; int solve(vector<pair<int, int> > sg, int pos) { sg.erase(sg.begin() + pos); int mx = sg[0].first, mn = sg[0].second; for (int i = (1); i < (int)(sg.size()); i++) { if (sg[i].first > mn || s... |
#include <bits/stdc++.h> using namespace std; int n, m; string s; set<string> st; int main() { ios_base::sync_with_stdio(0); cin.tie(0); while (cin >> s) { st.clear(); for (int i = 0; i < s.size(); i++) { string s1 = ; for (int j = 0; j < s.size(); j++) s1 += s[(i + j... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> moves = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; bool isValid(int a, int b, int x, int y) { return (a >= 0 && a < x) && (b >= 0 && b < y); } bool isPath(int n, int m, vector<string>& mat) { bool isPossible = false; int cnt = 0; for (... |
#include <bits/stdc++.h> using namespace std; int t = 0; int d[300000]; int par[300000]; int t1[300000]; int t2[300000]; void dfs(int s, vector<vector<int> > &ed, int y) { d[s] = y; t1[s] = t++; for (int i = 0; i < ed[s].size(); i++) { if (ed[s][i] != par[s]) { par[ed[s][i]] = s;... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; int q(int l, int r){ cout << ? << l << << r << endl; int idx; cin >> idx; return idx; } void solve(){ int n; cin >> n; int idx = q(1, n); int L = -1, R = -1; if(1 < idx) L = q(1, idx... |
#include <bits/stdc++.h> using namespace std; long long int a[10000010]; int main() { long long int n; long long ans = 0; cin >> n; for (long long int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); ans = a[n - 1] * n; long long int c = n; for (long long int i = n - 2; i >= 0; i--)... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; int a[1100][1100], pt[1100], b[] = {25, 18, 15, 12, 10, 8, 6, 4, 2, 1}, ef, n; map<string, int> m; string st[1100]; int f(int aa, int bb) { if (pt[aa] != pt[bb]) return pt[aa] > pt[bb]; else { for (i... |
#include <bits/stdc++.h> using namespace std; int main() { char st[500]; cin >> st; int n = strlen(st); int left = 0, right = 0, i = 0; for (; i < n; ++i) { if (st[i] == | ) break; else left++; } right = n - 1 - i; char a[500]; cin >> a; int x = s... |
#include <bits/stdc++.h> using namespace std; string inc[6] = { 011112 , 103231 , 110121 , 121011 , ,112101 , 211110 }; string near[6] = { 1234 , 0254 , 0153 , 4520 , 3510 , 4321 }; int opp[6] = {5, 3, 4, 1, 2, 0}; char t[7], s[7]; string t_p; bool seen[6]; set<string> se; void dfs(int x, in... |
#include <bits/stdc++.h> using namespace std; long long mo(const long long input, const long long ceil) { return input >= ceil ? input % ceil : input; } const long long maxn = 5e5 + 10; long long cnt, cnta, cntb; long long vis[maxn]; vector<long long> e[maxn]; void dfs(long long k, long long t) { ... |
#include <bits/stdc++.h> using namespace std; int ans[10]; int main() { memset(ans, 0, sizeof(ans)); int n; char c; scanf( %d , &n); while (n--) { scanf( %c , &c); if (c == 9 ) { ans[7]++; ans[3] += 2; ans[2]++; } if (c == 8 ) { ans[7]... |
#include <bits/stdc++.h> using namespace std; inline long long int __gcd(long long int a, long long int b); void pdash(int n = 1); int bitcount(long long int u); long long int power(long long int x, long long int y); long long int power(long long int x, long long int y, long long int z); long long int mod... |
#include <bits/stdc++.h> using namespace std; const double INF = 1000000000; struct point { long long x, y; point() {} point(long long x, long long y) : x(x), y(y) {} point operator-(point P) { return point(x - P.x, y - P.y); } }; double abs(point P) { return sqrt(P.x * P.x + P.y * P.y); } d... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int _inf = 0xc0c0c0c0; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long _INF = 0xc0c0c0c0c0c0c0c0; const long long mod = (int)1e9 + 7; const int Z = 100; const int N = Z * Z; const int M = Z * Z * Z; int px[N], ... |
#include <bits/stdc++.h> using namespace std; int main() { int odd_a = 0, odd_b = 0, even_a = 0, even_b = 0; int a, b, c; cin >> a >> b; for (int i = 0; i < a; i++) { cin >> c; c % 2 ? odd_a++ : even_a++; } for (int i = 0; i < b; i++) { cin >> c; c % 2 ? odd_b++ : eve... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int const N = 1e5 + 86; int const M = 1e9 + 7; int a[N], f[111][N]; ll ext_gcd(ll a, ll b, ll &x, ll &y) { if (!b) { x = 1, y = 0; return a; } ll ret = ext_gcd(b, a % b, x, y); ll t = x; x = y, y = t - a / b ... |
#include <bits/stdc++.h> int main(void) { int n, i, j; scanf( %d , &n); int a[n][2], b[n + 1]; for (i = 0; i < n + 1; i++) { b[i] = 0; } for (i = 0; i < n; i++) a[i][1] = 0; for (i = 0; i < n; i++) { scanf( %d , &a[i][0]); if (a[i][0] <= n && a[i][0] >= 1) { if (b... |
#include <bits/stdc++.h> using namespace std; long long int a1[200005]; long long int a2[29]; vector<long long int> v, v1; bool p[100000008]; void seive() { long long int i, j; for (i = 1; i * i <= 100; i++) { if (p[i] == false) { for (j = i * i; j <= 100; j += i) { p[j] = tr... |
#include <bits/stdc++.h> using namespace std; long long read() { long long r = 0, t = 1, c = getchar(); while (c < 0 || c > 9 ) { t = c == - ? -1 : 1; c = getchar(); } while (c >= 0 && c <= 9 ) { r = r * 10 + c - 48; c = getchar(); } return r * t; } const ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; const int mod = 1e9 + 7; const long long inf = 1e18; const double PI = acos(-1); const double eps = 1e-8; long long qkmod(long long base, long long cnt) { long long res = 1; while (cnt) { if (cnt & 1) res = res * base % ... |
#include <bits/stdc++.h> int main() { int t = 0, i, n; char str[60]; scanf( %d , &n); scanf( %s , &str); for (i = 1; t < n; i = i + 1) { printf( %c , str[t]); t += i; } return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; vector<int> edge[1005]; pair<int, int> ans[1005]; set<int> eQQ; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, a, b; cin >> n; for (int i = 1; i < n; ++i) { cin >> a >> b; if (b != ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[100 * 100 + 5]; pair<int, int> as[100 * 10000 + 5]; pair<int, int> ass[100 * 1000 * 7 + 5]; int p = 0; int badbakhti(int l, int r) { if (r - l < 2) { return 1; } int h = -10000 * 100000, e = (r + l) / 2; h = a[e].first; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000100; const int M = 1001000; const int P = 1000000007; int fac[M], phi[M]; vector<int> prime; long long val[M], sum[M], res[M]; long long ans[M], vec[M], rec[M]; void init_() { fac[1] = 1; for (int i = 2; i <= N; i++) { if (!... |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 3; int nxt[mxN], vis[mxN]; void get(string s) { nxt[0] = -1; int i = 0, k = -1, len = s.size(); while (i < len) { if (k == -1 or s[i] == s[k]) nxt[++i] = ++k; else k = nxt[k]; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; long long a[10] = {}; int fac[13] = {1}; inline void p(vector<int> q, vector<int> w, int cnt, long long pr) { if (q.size() == 0) { a[cnt] += pr; return; } int qq = q[q.size() - 1], ww = w[w.size() - 1]; q.pop_back(); w.pop_back(); ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { string s; cin >> s; long long n = s.length(); map<char, long long> m; m[ B ] = 1; m[ u ] = 1; m[ l ] = 1; m[ b ] = 1; m[ a ] = 1; m[ s ] = 1; m[ r ] = 1; for (long long i = 0; i < n; i++) { if (m[s[i... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int a[N]; struct Block { int len, st, ed, num; Block(const int len = 0, const int st = 0, const int ed = 0, const int num = 0) : len(len), st(st), ed(ed), num(num){}; }; vector<Block> v; bool islucky(int a) { ... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, pair<long long, long long>>> v; long long a, b, w, cnt; long long parent[100005], sz[100005]; void init(long long n) { for (long long i = 1; i <= n; i++) parent[i] = i, sz[i] = 1; } long long root(long long x) { if (parent[x] == ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000001; int n; int l[MAXN]; int r[MAXN]; int num[MAXN]; int izq[MAXN]; int der[MAXN]; long long int ans[MAXN]; long long int bit[2][MAXN]; vector<pair<int, int> > L[MAXN]; vector<pair<int, int> > R[MAXN]; void update(int id, int a... |
#include<bits/stdc++.h> #define LL long long #define SZ(x) (int)x.size()-1 #define F(i,a,b) for (int i=a;i<=b;++i) #define DF(i,a,b) for (int i=a;i>=b;--i) #define pb push_back #define ms(a,b) memset(a,b,sizeof a) using namespace std; int read(){ char ch=getchar(); int w=1,c=0; for (;!isdigi... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e8 + 5e4 + 1; const double error = 1e-7; const double PI = acos(-1); mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); inline long long int MOD(long long int x, long long int m = mod) { long long int y = x % m; ret... |
#include <bits/stdc++.h> using namespace std; int N; vector<int> arr; int main() { cin >> N; for (int i = 0; i < N; i++) { int num; cin >> num; arr.push_back(num); } vector<int> cur(1000, 0); int toto = 0; for (int i = 0; i < N; i++) { int zoto = toto; for (... |
#include <bits/stdc++.h> using namespace std; int he[100005], np; int n; long long v[100005], f2[100005], fl[100005], ms[100005]; long long h[100005], g[100005]; int read() { int x = 0; char ch; ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) {... |
#include <bits/stdc++.h> using namespace std; const long long N = 400010; inline long long read() { long long s = 0, w = 1; register char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s <... |
#include <bits/stdc++.h> using namespace std; int main() { long long b, d, s, x, y, z, m, t; x = y = z = 0; cin >> b >> d >> s; long long a[3] = {b, d, s}; sort(a, a + 3); if (a[0] == a[2]) { cout << 0; } else if (a[1] == a[2]) { cout << a[2] - a[0] - 1; } else { co... |
#include <bits/stdc++.h> using namespace std; int main() { long long l, r; cin >> l >> r; while (l % 2) l++; if (l + 2 > r) cout << -1 << endl; else cout << l << << l + 1 << << l + 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; int n, k; vector<vector<long long> > mul(vector<vector<long long> > &A, vector<vector<long long> > &B) { vector<vector<long long> > C(1, vector<long long>(n)); for (int i = 0; i < n; ++i) { for... |
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int n, m, u, f[3100][3100], sum[3100][3100], C[3100][3100], inv[3100], g[3100]; int edgenum, vet[210000], Next[210000], Head[110000]; void addedge(int u, int v) { vet[++edgenum] = v; Next[edgenum] = Head[u]; Head[u] = edgenum; ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long N = mod; long long quick_mod(long long a, long long b) { long long ans = 1; a %= N; while (b) { if (b % 2 != 0) { ans = ans * a % N; b--; } b /= 2; a = a * a % N; } ret... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <int modd> struct modint { static const int mod = modd; int v; explicit operator int() const { return v; } modint() : v(0) {} modint(long long x) : v(int(x % mod)) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<int> v; int temp = 0; for (int i = 0; i < n; i++) { cin >> temp; v.push_back(temp); } int dem0 = 0; if (n == 1) { if (v[0] == 1) cout << YES ; else co... |
#include <bits/stdc++.h> using namespace std; const int N = 3E6 + 5; const int M = 3E6 + 5; struct map { int l, r; } Q[M]; int n, m, k, len, tr[N * 4], u, x, P[N], tot; char s[N], ans[N], ch; void add(int p, int l, int r, int x) { if (x < l || x > r) return; tr[p]++; if (l == r) return; ... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long double EPS = 1e-9; long long binpow(long long b, long long p, long long mod) { long long ans = 1; b %= mod; for (; p; p >>= 1) { if (p & 1) ans = ans * b % mod; b = b * b % mod; } return ans; } voi... |
#include<bits/stdc++.h> #define ll long long using namespace std; void solve(int tc) { int n; cin >> n; string s; cin >> s; vector<int> pos; for (int i = 0 ; i < n ; i++) { char ch = s[i]; if (ch == * ) pos.push_back(i); } int sz = (int)pos.size(); if (sz == 0) { cou... |
#include<bits/stdc++.h> #define ld long double #define ll long long using namespace std; template<class T> void read(T& x) { T res = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - )f = -1; c = getchar(); } while (isdigit(c)) { res = (res << 3) + (res << 1) + c - 0 ; ... |
#include <bits/stdc++.h> using namespace std; void inp(long long &n, long long &m, vector<long long> &v, vector<pair<signed, signed> > &rope) { cin >> n >> m; v.resize(n + 1); rope.resize(m + 1); for (long long i = 1; i <= n; ++i) { cin >> v[i]; } for (long long i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; bool agm(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) { if (a.second > b.second) return true; else return false; } else if (a.first < b.first) return true; else return false; } void solve(vector<in... |
#include <bits/stdc++.h> using namespace std; int main() { cout << INTERCAL ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = -1; const long long INF = 1e9 + 19; int main() { int n, m, x; scanf( %d%d%d , &n, &m, &x); x--; auto f = [&](int y) { int nn = n - y * 2; int mm = m - y * 2; if (nn <= 0 || mm <= 0) { return 0; } re... |
#include <bits/stdc++.h> using namespace std; int N, K; long long F[510][510], P[510 * 510]; int main() { scanf( %d%d , &N, &K); P[0] = 1; for (int i = 1; i <= N * N; i++) P[i] = (P[i - 1] << 1) % 1000000007; memset(F, 0, sizeof(F)); F[0][0] = 1; for (int i = 1; i <= N; i++) { F[i]... |
#include <bits/stdc++.h> using namespace std; int lft[100005], rght[100005], up[100005], dwn[100005]; int end() { cin.get(); cin.get(); return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int d, n, m, x1[100005], x2[100005], y1[100005], y2[100005], c... |
#include <bits/stdc++.h> using namespace std; const int OO = 1e9; const double EPS = 1e-9; template <class T> void _db(const char* dbStr, T e) { cout << dbStr << = << e << endl; } template <class T, class... L> void _db(const char* dbStr, T e, L... r) { while (*dbStr != , ) cout << *dbStr++... |
#include <bits/stdc++.h> using namespace std; double dp[105][105][105][3] = {{{{0}}}}; bool used[105][105][105] = {{{0}}}; void f(int a, int b, int c) { if (used[a][b][c]) return; ; used[a][b][c] = 1; if (a == 0) dp[a][b][c][1] = 1; else if (b == 0) dp[a][b][c][2] = 1; else i... |
#include <bits/stdc++.h> using namespace std; string solve(int n) { if (n == 1) { return -1 ; } else { return 2 + string(n - 1, 3 ); } } int main() { ios::sync_with_stdio(0), cin.tie(0); int T; cin >> T; while (T--) { int n; cin >> n; cout << solve(n... |
#include <bits/stdc++.h> using namespace std; int main() { int rj = 1000000000; int n, m, a, b; scanf( %d %d %d %d , &n, &m, &a, &b); for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) { if (i + j * m < n) continue; rj = min(rj, a * i + b * j); } printf( %d n ,... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double Pi = acos(-1); namespace { template <typename T> inline void read(T &x) { x = 0; T f = 1; char s = getchar(); for (; !isdigit(s); s = getchar()) if (s == - ) f = -1; for (; isdigit(s); s = getch... |
#include <bits/stdc++.h> using namespace std; struct point { double x, y; point(){}; point(double _x, double _y) { x = _x, y = _y; } }; point s, e; double det(double a, double b, double c, double d) { return (a * d - b * c); } point perpotongan(point p1, point p2, point p3, point p4) { point... |
#include <bits/stdc++.h> using namespace std; int n, a[301][301], dp[301][301][301]; int solve(int i, int j, int k) { if (i == n && j == n && k == 0) return a[n][n]; int x = i + k, y = j - k; if (x < 1 || y < 1 || x > n || y > n || i < 1 || j < 1 || i > n || j > n || k < 0) return -1e9; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; for (int i = 0; i < n; ++i) for (int interval = 1; interval <= n; ++interval) { int cnt = 0, cur = i; while (cur < n && s[cur] == * ) ++cnt, cur = cur + interval; if (cnt >= 5) g... |
#include <bits/stdc++.h> using namespace std; string s = What are you doing at the end of the world? Are you busy? Will you save us? ; string s1 = What are you doing while sending ; string s2 = ? Are you busy? Will you send ; string s3 = ? ; const int MAX_N = 1e5 + 10; const long ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); string a, s; cin >> a >> s; vector<int> v(10, 0); for (int i = 0; i < s.size(); i++) v[s[i] - 48]++; int j = 9; for (int i = 0; i < a.size(); i++) { while (v[j] == 0... |
#include <bits/stdc++.h> using namespace std; int n, m; char cmd[(100000 + 10)]; int vis[510][510], path[(100000 + 10)]; const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; int convert(char ch) { if (ch == R ) return 0; else if (ch == L ) return 1; else if (ch == D ) retur... |
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int n; scanf( %d , &n); int cnt = 0; int aa[1000]; for (int i = 1; i <= n; i++) { scanf( %d , &aa[i]); } sort(aa + 1, aa + 1 + n); int flag = 1; ... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, y; }; istream &operator>>(istream &in, point &p) { in >> p.x >> p.y; return in; } ostream &operator<<(ostream &out, point &p) { out << p.x << << p.y; return out; } double len(struct point a, struct point b)... |
#include <bits/stdc++.h> using namespace std; map<string, long long> m; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); vector<pair<long long, long long> > v = { make_pair(1989, 1998), make_pair(1999, 2098), make_pair(2099, 3098), make_pair(3099, 13098... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, res; scanf( %lld %lld , &n, &k); if (k <= n) { if (k % 2 == 0) res = (k - 1) / 2; else if (k % 2 == 1) res = k / 2; } else if (k > n) { if (k - n <= n) res = (n - (k - n) + 1) / 2; ... |
#include <bits/stdc++.h> using namespace std; int n, a[100005], p[100005]; long long cost; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i] >> p[i]; } int mn = p[0]; for (int i = 0; i < n; ++i) mn = min(p[i], mn), cost += mn * 1LL *... |
#include <bits/stdc++.h> using namespace std; const int N = 210; int n, k, m; long long a[N]; int b[N]; int f[N][6010]; int ans = 0; int c[N], d[N]; int main() { scanf( %d%d , &n, &m); for (int i(1); i <= (n); ++i) scanf( %lld , a + i); for (int i(1); i <= (n); ++i) { for (; a[i] % 2... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d, sum = 0, ans = 0; cin >> n >> d; string *s = new string[d]; for (int i = 0; i < d; i++) cin >> s[i]; for (int i = 0; i < d; i++) { int flag = 0; for (int k = 0; k < n; k++) { if (s[i][k] == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 5; const long long mod = 1e9 + 7; long long fact[MAXN]; long long invfact[MAXN]; bool sieve[MAXN]; long long powe(long long x, long long y, long long mod) { long long res = 1; while (y > 0) { if (y & 1) res = (res * x... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int count = 0; int a[n + 1][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cin >> a[i][j]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[... |
#include <bits/stdc++.h> using namespace std; char mat[100][100]; int main(void) { int minyX = (1 << 30), minyY = (1 << 30), maxyX = 0, maxyY = 0; int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %s , mat[i]); for (int j = 0; j < m; ++j) { if (mat[i][j] !=... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; char s[N]; int m, n; void sol() { int b[26] = {0}; scanf( %d %d , &n, &m); int a[N] = {0}; scanf( %s , s); int t; for (int i = 0; i < m; i++) { scanf( %d , &t); a[t - 1]++; } a[n - 1] = 1; for ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 201; const int logn = 20; struct matrix { double a[maxn][maxn]; int n; bool is_vec; matrix() {} void init(int n) { this->n = n; is_vec = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> a; int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int T; cin >> T; while (T--) { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int n, c1, c2; int dp[505][505], fact[1000005], inv[1000005]; int po(int a, int b) { int c = 1, d = a; while (b) { if (b & 1) c = 1LL * c * d % 1000000007; d = 1LL * d * d % 1000000007; b >>= 1; } return c; } int ncr(int N, int ... |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; typedef pair <int, int> pii; struct UF { int fa[3010]; void clear(int n) { for (int i = 1; i <= n; i++) { fa[i] = i; } } int find(int x) { if (fa[x] == x) return x; re... |
#include <bits/stdc++.h> using namespace std; const int A = 1e6 + 5; const int N = 5e4 + 5; const int M = 5005; int dp[A], a[N], l[M], r[M], b[N], ans[M]; int32_t main() { for (int i = 1; i < A; i++) dp[i] = dp[i - 1] ^ i; int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) scanf( %d , a +... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; int de = 0, in = 0; for (int i = 0; i < n; i++) { if (x[i] > y[i]) de = de + x[i] - y[i]; if (y[i] > x... |
#include <bits/stdc++.h> using namespace std; int main() { long long cnt1, cnt2, x, y; cin >> cnt1 >> cnt2 >> x >> y; long long low = 1, high = 4000000000LL; if (x == y) { while (low < high) { long long mid = low + (high - low) / 2; if (mid - mid / x >= cnt1 + cnt2) h... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long a, b; cin >> a >> b; int maxa = sqrt(a); int maxb = maxa * (maxa + 1); if (b >= maxb) cout << Vladik ; else cout << Valera ; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) { cout << 0 << endl; } else { n -= 1; cout << n / 2 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, pair<int, int> > tab; int main() { int n, v[3]; pair<int, int> ans; int maior = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d%d , &v[0], &v[1], &v[2]); sort(v, v + 3); for (int j = 0; j < 3; j+... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int a[N]; int main() { int t; cin >> t; while (t--) { int n, x; cin >> n >> x; int ok = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == x) { ok = 1; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, i, j; cin >> a >> b >> c; long long s = min(a / 3, min(b / 2, c / 2)); a -= s * 3; b -= s * 2; c -= s * 2; set<long long> sett; for (i = 1; i <= 7; i++) { long long cnt = 0; long long x = a, y =... |
#include <bits/stdc++.h> using namespace std; template <class t> vector<t> sort(vector<t> &a) { return sort(a.begin(), a.end()); } const int N = 200200; int a[N], b[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) ci... |
#include <bits/stdc++.h> using namespace std; int n, m; string str[110]; int rev[110]; bool counted[110]; stack<int> st; queue<int> q; int length; bool isRev(string s, string t) { for (int i = 0; i < m; i++) if (s[i] != t[m - i - 1]) return false; return true; } bool same(string s) {... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; vector<vector<int> > tims; vector<int> part; vector<int> conf; int n; int e; int T = 0; void build_part() { bool ok = false; while (!ok) { for (int(i) = (1); (i) < (T + 1); ++(i)) { part[i] = rand() % 2; ... |
#include <bits/stdc++.h> int main(void) { int stack[100000 + 1], sp = 0, c; stack[0] = 0 ; while (c = getchar(), c != n ) { if (c == stack[sp]) --sp; else stack[++sp] = c; } printf( %s n , sp == 0 ? Yes : No ); exit(EXIT_SUCCESS); } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int> > A(n, vector<int>(m)), B(n, vector<int>(m)); for (int x = 0; x < n; x++) for (int y = 0; y < m; y++) cin >> A[x][y]; for (int x = 0;... |
#include <bits/stdc++.h> const int maxi = 2000000000; const int maxq = 1000000000; const double eps = 1e-10; const double pi = 3.1415926535897932; const double inf = 1e+18; const int mo = 1000000007; const int maxn = 500000; using namespace std; int n; string s[555]; vector<char> v; int le[555][... |
#include <bits/stdc++.h> using namespace std; struct Vec2 { int x, y; bool left, right, top, bottom; Vec2() : x(0), y(0), left(false), right(false), top(false), bottom(false) {} }; int main() { int n; Vec2 points[200]; int ans = 0; cin >> n; for (int i = 0; i < n; ++i) cin >> poi... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, x, y; cin >> n >> x >> y; long long val; for (int i = n - 1; i >= 1; i--) { if (abs(y - x) % i == 0) { val = (y - x) / i; break; } ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; int v[1024]; int vv[1024]; int N; int try_it(int last) { for (int i = (0); i < (N); i++) vv[i] = v[i]; for (int i = (last); i < (N); i++) vv[i] = max(0, vv[i] - 1); vv[N] = 0; int NN = N; while (NN > 0 && vv[NN - 1] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int i, j, k, n, m = 1e10, f = 1; cin >> n; vector<long long int> a(n), b(n), in, val; for (i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const int maxn = 5555; int s[maxn]; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) { int t; cin >> t; s[i] = s[i - 1] + t; ... |
#include <bits/stdc++.h> using namespace std; int a, b, c[101], d, e, f, g; int main() { cin >> a >> b; for (; d < a; d++) { cin >> e; c[e]++; f = max(f, c[e]); if (c[e] == 1) { g++; } } f = (f % b) ? (f / b + 1) * b : f; cout << f * g - a; return 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.