func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; typedef struct _lap { int p; int qu; } lap; bool cmp(const lap &a, const lap &b) { return a.p < b.p; } void remain() { int n; cin >> n; vector<lap> laps; for (int i = 0; i < n; ++i) { lap x; cin >> x.p >> x.qu; laps.push_b... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { char c; bool nega = 0; while ((!isdigit(c = getchar())) && (c != - )) ; if (c == - ) { nega = 1; c = getchar(); } x = c - 48; while (isdigit(c = getchar())) x = x * 10 + c -... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, i, flag = 0, j; cin >> n; long long int a[n]; set<int> s; for (i = 0; i < n; i++) { cin >> a[i]; s.insert(a[i]); } for (i = 1; i ... |
#include <bits/stdc++.h> int main(void) { unsigned short int m, n, c; scanf( %hu%hu , &m, &n); c = m * n; int i = 1; while (i) { if (c >= 2 * i) i++; else break; } printf( %d n , (i - 1)); return 0; } |
#include <bits/stdc++.h> using namespace std; long long c, hr, hb, wr, wb; int main() { cin >> c >> hr >> hb >> wr >> wb; long long i, mx = 0, mxi; for (i = 0; i <= c / wr; i += 1000) if (i * hr + ((c - i * wr) / wb) * hb > mx) { mx = i * hr + ((c - i * wr) / wb) * hb; mxi = i; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m; char str[N][N]; int use[N]; int ans[N], tot; int Ncnt, root; struct Node { vector<int> ch; int color; int leaf; int kind; Node(void){}; } tree[N * N * 2]; void fail() { puts( NO ); exit(0); } ... |
#include <bits/stdc++.h> long long int power(long long int a, long long int b) { long long int ans = 1; long long int k = a; while (b) { if (b % 2 == 1) ans *= k, ans %= 998244353; k *= k, k %= 998244353; b /= 2; } return ans; } int a, b, start; int z[40]; long long int a... |
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(0); cout.sync_with_stdio(0); int n, a, c, d, k = 0; cin >> n >> a; c = floorl(n * a / 180.l); if (c > n - 2) c = n - 2; if (c < 1) c = 1; d = ceill(n * a / 180.l); if (d > n - 2) d = n - 2; if (d <... |
#include <bits/stdc++.h> using namespace std; int z[(int)1e6 + 3]; string z_algo(string s) { int x = 0, y = 0; int T = 0, M = (int)1e6 + 3; for (int i = 1; i < s.size(); i++) { z[i] = max(0, min(z[i - x], y - i + 1)); while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) { x = i, y... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ii = pair<ll, ll>; using vi = vector<int>; using vii = vector<ii>; using graph = vector<vii>; const int INF = 0x3f3f3f3f; const ll INFL = 0x3f3f3f3f3f3f3f3f; const int MAXN = 2123; const ll mod = 998244353; int seen[MAXN... |
#include <bits/stdc++.h> using namespace std; int main() { int n, n1, k, k1, m, m1; cin >> n >> n1 >> k >> k1; if (n > n1) cout << First ; else cout << Second ; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; int maina() { int T; cin >> T; for (int _t = 0; _t < T; _t++) { } return 0; } int main() { ios::sync_with_stdio(false); long long N; cin >> N; vector<long long> in(N); for (int i = 0; i < N;... |
#include <bits/stdc++.h> constexpr unsigned primes[]{2672090437, 2569161337, 2414657393}; constexpr int np = sizeof(primes) / sizeof(*primes); std::vector<std::array<unsigned, np> > pow2; void setpow2(int maxp) { pow2.resize(maxp + 1); for (int i = 0; i < np; i++) pow2[0][i] = 1; for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; long long n, mod; long long expsq(long long base, long long exp) { if (exp == 0) return 1ll; if (exp == 1) return base; if (exp & 1) return (base * expsq((base % mod * base % mod) % mod, (exp - 1) / 2)) % mod; return expsq((base % mod * base % mo... |
#include <bits/stdc++.h> using namespace std; template <class t> t mag(t a) { return a > 0 ? a : -a; } template <class T, class U> T cdiv(T num, U den) { return (num / den) + ((num % den) > 0); } std::ifstream term( /dev/tty ); std::string tempstring; using ll = int_fast64_t; using ii = pa... |
#include <bits/stdc++.h> using namespace std; template <typename T> T Abs(T first) { return (first < 0 ? -first : first); } template <typename T> T Sqr(T first) { return (first * first); } string plural(string s) { return (int((s).size()) && s[int((s).size()) - 1] == x ? s + en ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long moves = 0; for (long long i = 0; i < n; i++) { if (a[i] < 1) { moves = moves + (i + 1) ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18 + 7; long long f[105]; long long g[105]; int main() { long long n; cin >> n; f[1] = 2, f[2] = 3; g[1] = 2, g[2] = 4; for (int h = 3; h <= 100; h++) { f[h] = f[h - 1] + f[h - 2]; g[h] = g[h - 1] + g[h - 1];... |
#include <bits/stdc++.h> using namespace std; void Fast_Read_Out() { ios_base::sync_with_stdio(0); cin.tie(), cout.tie(); } void Random() { unsigned int seed; asm( rdtsc : =A (seed)); srand(seed); } unsigned int Time() { unsigned int time = clock() / 1000.00; return time; } ... |
#include <bits/stdc++.h> using namespace std; long long int n, m; long long int arr[300000]; vector<long long int> ans; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long int TESTS, q, a, b, l, r, c, k, p, h, w, x, y, z, xs, ys, t, f; long double d; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int main(void) { long long n, k; cin >> n >> k; long long temp = 1; for (long long i = 1; i <= k; i++) temp *= 10; cout << n * temp / gcd(temp, n); } |
#include <bits/stdc++.h> using namespace std; int64_t mod = 1e9 + 7, inf = 4e18; map<vector<int64_t>, long double> seen; long double rec(vector<int64_t> &people, int64_t n, int64_t len) { if (len < 0) return -1; if (n == 0) return 0; if (seen[people]) return seen[people]; long double ans = 0; ... |
#include <bits/stdc++.h> using namespace std; int a[4000]; int main() { int n, ans1 = 0, ans2 = 0; cin >> n; for (int i = 1; i <= n / 2; ++i) cin >> a[i]; sort(a + 1, a + 1 + n / 2); for (int i = 1; i <= n / 2; ++i) { ans1 += abs((i * 2 - 1) - a[i]); ans2 += abs((i * 2) - a[i]); ... |
#include <bits/stdc++.h> using namespace std; template <class T> void chkmax(T& x, T y) { x = (x > y ? x : y); } template <class T> void chkmin(T& x, T y) { x = (x < y ? x : y); } int a[6], b[6]; int main() { for (int i = 0; i < (int)(4); ++i) scanf( %d%d , &a[i], &b[i]); for (int i = ... |
#include <bits/stdc++.h> using namespace std; priority_queue<long long> Q[3]; int K[4], T[5]; int n; void gao() { int i, j; for (i = 0; i < 3; ++i) { for (j = 0; j < K[i]; ++j) Q[i].push(-1); } long long ans = 0; while (n--) { int ti; scanf( %d , &ti); long long now... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long LINF = 2e16; const long long INF = 2e9; const long long magic = 348; const double eps = 1e-10; const double pi = acos(-1); inline long long getint() { char ch; long long res; bool f; while (!isdi... |
#include <bits/stdc++.h> int main() { long long count = 0; long long int n, a[100010], j, i; scanf( %lld , &n); for (i = 1; i <= n; i++) scanf( %lld , &a[i]); for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) if (a[i] != a[j]) break; count += ((j - i - 1) * (j - i)) / 2; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MAXN = 500005; struct seg { int typ; int s, e; bool operator<(const seg &x) const { return s < x.s; } bool operator!=(const seg &x) const { return typ != x.typ || s != x.s || e != x.e; } }; int n, a[MA... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100100; int a[MAX]; vector<int> ne[MAX]; int fabs(int x) { if (x < 0) x = -x; return x; } int main() { int n, m; int i, j; int tmp1, tmp2; long long sum1, sum2, maxdis; long long ans; while (scanf( %d %d , &n, &m... |
#include <bits/stdc++.h> using namespace std; long long fact[3000002], n, inv[3000002]; long long pw(long long b, long long e) { long long ans = 1; while (e) { if (e & 1) ans = (ans * b) % 1000000007; b = (b * b) % 1000000007; e >>= 1; } return ans; } int main() { ios_bas... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int F[MAXN] = {0}; int main() { int N, x, y; cin >> N; for (int I = 1; I <= N; I++) { cin >> x >> y; int ans = 0; for (int i = 1; i <= sqrt(x) + 1; i++) { if (x % i) continue; if (F[i] + y < I) a... |
#include <bits/stdc++.h> using namespace std; template <typename T> void LOG(T const& t) { std::cout << t << endl; } template <typename First, typename... Rest> void LOG(First const& first, Rest const&... rest) { std::cout << first << ; LOG(rest...); } void solve(); int main() { ios... |
#include <bits/stdc++.h> using namespace std; long long n, k, m, x[500010], y[500010], xx[500010], yy[500010], zz[500010]; const long long N = 2e6 + 10; struct link { long long top, fi[N], to[N], la[N], ne[N]; void clear() { top = 0, memset(fi, 0, sizeof fi), memset(la, 0, sizeof la), memset... |
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2, x3, y3, x4, y4; cin >> x1 >> y1 >> x2 >> y2; int x_diff = x1 - x2; int y_diff = y1 - y2; if (x_diff != 0 and y_diff != 0) { x3 = x1; y3 = y2; x4 = x2; y4 = y1; } else if (x_diff != 0) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; const int mod = 1e9 + 7; int n; long long p[N]; long long sz[N]; vector<pair<int, int> > v[N]; void dfs(int x, int pp) { sz[x] = 1; for (auto y : v[x]) { if (y.first != pp) { dfs(y.first, x); p[y.first] = ... |
#include <bits/stdc++.h> #pragma warning(disable : 4996 4018) using namespace std; int n, k, p, pep[1000], key[2000]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> k >> p; for (int i = 0; i < n; i++) cin >> pep[i]; for (int i = 0; i < k; i++) cin >> key[i]; int ans =... |
#include <bits/stdc++.h> using namespace std; int n; int ans[1 << 20]; void go(vector<int> Q) { if (Q.empty()) return; if (Q.size() == 1) { cout << Q[0] << ; return; } int hi = (int)Q.size() - 1; int p = 0; while ((1 << p) - 1 < hi) p++; if ((1 << p) - 1 > hi) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e6; char s[MAX_N + 1]; int len; vector<int> ans; void go(int i) { if (i == len) return; if (s[i] == l ) { go(i + 1); ans.push_back(i + 1); } else { ans.push_back(i + 1); go(i + 1); } } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; map<int, pair<char, int> > m; int main() { long long n, q; scanf( %lld%lld , &n, &q); m[0] = make_pair( U , 0); m[n + 1] = make_pair( L , 0); while (q--) { long long x, y; string s; scanf( %lld%lld , &x... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long int; const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; inline void assert_call(bool assertion, function<void()> f) { if (!assertion) { cerr << assertion fault: << en... |
#include <bits/stdc++.h> const int N = 200 + 10, MOD = 1000000007; int n; std::pair<int, int> poly[N]; long long sum[N]; inline long long Cross(const std::pair<int, int> &a, const std::pair<int, int> &b) { return (long long)a.first * b.second - (long long)a.second * b.first; } ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int nax = 2e6 + 7; long long n, x, l, r, db, m; long long temp[nax]; vector<pair<long long, long long> > v; long long calculate(long long n, long long db) { long long r = 1; for (int i = 1; i <= n; i++) { temp[i] = ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int INF = 0x7fffffff; const long long oo = 1e18; const int N = 106; const double pi = acos(-1.0); int n, ans = 1, now; char c; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) { scanf( %c , &c); ... |
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; vector<int> used(1000000, 0); vector<int> len(1000000, 5); queue<int> q; q.push(x); used[x] = 1; len[x] = 0; while (!q.empty()) { int v = q.front(), v1 = v; q.pop(); vector<int> res(6); ... |
#include <bits/stdc++.h> using namespace std; char buf[10001], buf2[1000001]; int tab[100001][26]; int main() { scanf( %s %s , buf, buf2); int len = strlen(buf), len2 = strlen(buf2); for (int i = 0; i < 26; i++) tab[len - 1][i] = -1; for (int ti = 2 * len - 2; ti >= 0; ti--) { int i = ti %... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, x; cin >> a >> b >> x; string s; if (x > 1) { for (int i = 0; i < x / 2; i++) { if (a > b) { s += 0 ; b--; s += 1 ; a--; } else { s += 1 ; a--; ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:16777216 ) using namespace std; const int INF = 1000000000; const int MAX = 1000006; const int MAX2 = 207; const int BASE = 1000000000; const int CNT = 500; const int MOD = 1000000007; vector<int> g[MAX]; int sz[MAX]; double ans[MAX]; void... |
#include <bits/stdc++.h> using namespace std; int main() { map<char, string> mp = {{ > , 1000 }, { < , 1001 }, { + , 1010 }, { - , 1011 }, { . , 1100 }, { , , 1101 }, { [ , 1110 }, { ] , 1111 }}; string in; cin >> in; string s; for ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) const int N = 205; int n; long long a[N]; map<long long, int> mp; vector<int> G[N], ans; bool vis[N]; bool dfs(int u, int step) { if (step == n) { ans.push_back(u); return true; } ... |
#include <cstdio> #include <iostream> using namespace std; const int M = 20005; const int N = 31; #define make make_pair #define pii pair<int,int> int read() { int x=0,f=1;char c; while((c=getchar())< 0 || c> 9 ) {if(c== - ) f=-1;} while(c>= 0 && c<= 9 ) {x=(x<<3)+(x<<1)+(c^48);c=getchar();} ... |
#include <bits/stdc++.h> using namespace std; int now[5 * 100010], after[5 * 100010], mx[5 * 100010]; int lft[5 * 100010], rgt[5 * 100010], vi[5 * 100010], timer = 0, comp = 0; long long Add[5 * 100010]; vector<int> g[5 * 100010]; stack<int> stk; inline void dfs(int c, int p) { vi[c] = 1; now[c] =... |
#include <bits/stdc++.h> using namespace std; int n, x, v[110]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 2; i <= n; i++) { if (v[i] == 1) { if (v[i - 1] == 1) cout << Infinite , exit(0); if (v[i - 1] == 2) x += 3; if (v[i - 1] == 3) x... |
#include <bits/stdc++.h> using namespace std; ifstream fin( in.in ); ofstream fout( out.out ); const int N = 1e5 + 10; int n, m, erased[N], cnt[N], rem[N]; vector<int> a[N], v[N]; deque<vector<int> > ind[N]; queue<int> q; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 1; if (a > b) { for (int i = b; i >= 1; i--) { ans *= i; } } else { for (int i = a; i >= 1; i--) { ans *= i; } } cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; long double add[3 * 100 * 1000]; const long double inf = 1e18; long double max(long double a, long double b, long double c, long double d) { return max(max(a, b), max(c, d)); } struct rmq { int l, r; long double pref, suf, all, best; rmq *left, *... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int mod = 998244353; const int inv2 = (mod + 1) / 2; int n, m, k; int row_one[N], row_zero[N], col_one[N], col_zero[N]; int all_one, all_zero; int zero_r, zero_c, mul_r, mul_c; map<pair<int, int>, int> Map; int rval(int x) {... |
#include <algorithm> #include <cassert> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <un... |
#include <bits/stdc++.h> using namespace std; const int MAX_SIZE = 10000; void solve() { int t; cin >> t; string str[2]; map<string, vector<string>> m; string tmp; for (int i = 0; i < t; i++) { cin >> str[0] >> tmp >> str[1]; m[str[0]].push_back(str[1]); } int a, b, c; ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1E-9; const int INF = 1000000000; const long long INF64 = (long long)1E18; const double PI = 3.1415926535897932384626433832795; long long gcd(long long a, long long b) { if (a < b) return gcd(b, a); if (b == 0) return a; return gcd... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const int maxm = 2005; struct detail { int c[maxm]; int len; int p; detail() { len = 0; } void add(int i) { c[len] = i; ++len; } } details[maxn]; int order[maxn]; int n, m; bool cmp(const int a, cons... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long a, b; cin >> a >> b; long long c = 1, i = 0; while (1) { if (i % 2 == 0 && a >= c) a -= c; else if (i & 1 && b >= c) ... |
#include <bits/stdc++.h> using namespace std; long long int n, N[5010], e, s, X[5010], A[5010], B[5010], C[5010], D[5010]; long long int total, t, selection; long long int Dis(long long int x, long long int y) { return labs(X[x] - X[y]) + (x > y ? C[x] + B[y] : D[x] + A[y]); } int main() { ios_base:... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; struct obj { int x, y, ind; obj(int x, int y, int ind) : x(x), y(y), ind(ind) {} obj() {} }; int main() { vector<obj> s; int n, x, y; scanf( %d , &n); for (int i = (1); i <= (n); ++i) { scanf( %d%d , &x, &y); s.push_back(obj(x... |
#include <bits/stdc++.h> void err() { std::cout << n ; } template <typename T, typename... Args> void err(T a, Args... args) { std::cout << a << ; err(args...); } void pt() { std::cout << n ; } template <typename T, typename... Args> void pt(T a, Args... args) { std::cout << a << ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e6; int a[N]; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; ++i) { int tmp; cin >> tmp; a[tmp]++; } int res = 0; for (int i = 0; i < N; ++i) { if (a[i] % ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); int even = 0, odd = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 0) { even++; } else { odd++; } } if (even > odd) { cout << odd << ... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> a; vector<long long> get_res(long long m) { vector<long long> res; for (long long i = 0; i < a.size(); ++i) { long long el = a[i].second; long long c = a[i].first; long long t = 0; while ((c / (t + 1))... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int a, b; cin >> a >> b; if (a == 9 and b == 1) { cout << 9 << << 10; } else if (a == b) { cout << a * 10 << << a * 10 + 1; } else if (b - a == 1) { cout << a * 10 + 9 << << b * 10 << endl; ... |
#include <bits/stdc++.h> using namespace std; const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1}; int h, w; string in[1000]; void put(int y1, int x1, int y2, int x2) { bool use[10] = {}; for (int d = 0; d < 4; d++) { int y = y1 + dy[d], x = x1 + dx[d]; if (y < 0 || x < 0 || y >= h || x >... |
#include <bits/stdc++.h> using namespace std; int a[105], b[105], n, k; bool f[105]; void dfs(int i) { f[i] = true; for (int k = 1; k <= n; k++) { if (f[k]) continue; if (a[i] > a[k] && a[i] < b[k]) dfs(k); else if (b[i] > a[k] && b[i] < b[k]) dfs(k); } } void s... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010, LOG = 20; long long n, m, k, u, v, x, ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000404; const long long MOD = 1000000007ll; const long double PI = acos(-1.0); const long double EPS = 1e-9; template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); } template <typename t1, typename t... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1010; string a[MAX]; int n, m; bool visit[MAX][MAX]; bool v[1000010]; int b[MAX][MAX]; int val[1000010]; void dfs(int x, int y, int cnt) { if (x < 0 || y < 0 || x >= n || y >= m) { return; } if (visit[x][y]) { return... |
#include <bits/stdc++.h> using namespace std; int n, cnt, a[220000]; long long sum; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int l = 1; l <= n; l++) { sum = a[l + 1]; for (int r = l + 2; r <= n; r++) { if (a[l] < a[r]) { sum +=... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int k = 1; int r = 0; int index1, index2; cin >> n; vector<pair<pair<int, int>, pair<int, int>>> s(n); vector<int> t(3); for (int i = 0; i < n; i++) { scanf( %i%i%i , &t[0], &t[1], &t[2]); sort(t.begin(), t... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const long long N = 210; 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 ) ... |
#include <bits/stdc++.h> using namespace std; long long a[5010], b[5010], n, dp[5010]; int main() { cin >> n; for (long long i = 1ll; i <= n; i++) scanf( %I64d , &a[i]), b[i] = a[i]; sort(b + 1ll, b + n + 1ll); dp[0ll] = (long long)1000000000000000007; for (long long i = 1ll; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1123; const int INF = 0x3f3f3f3f; const long long MOD = 1000000007; const double EPS = 1e-9; const double PI = acos(-1); inline int cmp(double x, double y = 0, double tol = EPS) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } st... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = (c & 15); while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15); x = v * f;... |
#include <bits/stdc++.h> using namespace std; int arr[100005]; int lfl[100005]; int rfl[100005]; int main() { int n; cin >> n; int i, j; for (i = 1; i <= n; i++) { cin >> arr[i]; } for (i = 1; i <= n; i++) { lfl[i] = min(lfl[i - 1] + 1, arr[i]); } long long ans = IN... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename T_container, typename T = typename enable_if< !is_same<... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; s += arr[i]; } int count = 0, k = 0; for (int i = 0; i < n - 1; i++) { k += arr[i]; if (k == (s - k)) count++; } cou... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); vector<int> lucky; for (int i = 1; i <= 9; i++) { for (int j = 0; j < (1 << i); j++) { int num = 0; for (int k = 0; k < i; k++) { if (j & (1 << k)) num ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; cin >> n >> x >> y; long long chis = y - n + 1; if (n - 1 + chis * chis >= x && chis > 0) { for (long long i = 0; i < n - 1; i++) cout << 1 << n ; cout << chis; } else cout << -1 ; return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; while (test--) { int a, b; cin >> a >> b; cout << (a ^ b) << endl; } return 0; } |
#include <bits/stdc++.h> class arr { bool* marked; int* nummarked; int markednumber; public: arr() { marked = new bool[1000000]; for (int i = 0; i < 1000000; i++) { marked[i] = false; } nummarked = new int[1000]; for (int i = 0; i < 1000; i++) { numm... |
#include <bits/stdc++.h> int main(void) { int n, w; int el[(4 * 100 * 1000)], be[(4 * 100 * 1000)]; int k[(4 * 100 * 1000)]; int i, j, z; scanf( %d %d , &n, &w); if (w == 1) { printf( %d n , n); return 0; } n--; for (i = 0; i <= n; i++) { if (i == 0) { sca... |
#include <bits/stdc++.h> using namespace std; ifstream fin( AAtest.in.txt ); long long n, p, t[4][ T ], su; string s; int main() { ios::sync_with_stdio(0); cin >> n; for (int(i) = (0); ((i)) < ((n)); ((i))++) { cin >> s; p = s.size(); p--; t[p][s[p]]++; su++; } ... |
#include <bits/stdc++.h> using namespace std; void solve(void) { int N; long int s = 0; cin >> N; for (int i = 2; i <= N; i++) s += i - 1; cout << s * 6 * 2 + 1 << endl; } int main(int argc, char const *argv[]) { solve(); return 0; } |
#include <bits/stdc++.h> using namespace std; int n; vector<string> v; set<string> st; map<string, int> mp; int main() { char t[11]; int c; scanf( %d , &n); for (int i = 0; i < n; i++) { memset(t, 0 , sizeof(t)); scanf( %s , t); if (st.count(t) == 0) { st.insert(t... |
#include <bits/stdc++.h> using namespace std; int n, m, k; long long cnt, sum, mx, ans = 0; bool flag, gov[1010], vis[1010]; vector<int> vec, edges[1010]; void dfs(int u) { vis[u] = 1; for (int v : edges[u]) if (!vis[v]) dfs(v); ++cnt; flag |= gov[u]; } int main() { int u, v, i... |
#include <bits/stdc++.h> using namespace std; const long long INF = 4e18; const long long MAX = 2e5 + 5; const long long MOD = 1e9 + 7; int n, m; void exgcd(int a, int b, long long &c, long long &d) { if (a == 0) { c = 0; d = 1; return; } exgcd(b % a, a, d, c); c -= b / a *... |
#include <bits/stdc++.h> using namespace std; const int N = 1010000; long long binpow(long long a, long long b, long long c) { long long res = 1; while (b) { if (b & 1) res = (res * a) % c; a = (a * a) % c; b >>= 1; } return res; } int gcd(int a, int b) { if (!b) return a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, len = 0, max = 0, flag = 1; cin >> n; string alpha = abcdefghijklmnopqrstuvwxyz ; vector<string> vs(n); for (int i = 0; i < n; i++) cin >> vs[i]; for (auto i : alpha) { for (auto j : alpha) { len = 0; fo... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[105]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int visited[105] = {0}; for (int i = 0; i < n; i++) { visited[arr[i]]++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; vector<pair<int, int> > v[N]; int n, m; int foo, bar, id; long long val[N]; long long wt[N]; int dep[N]; int dp[20][N]; int par[N]; int x1[N]; int x2[N]; void dfs(int node, int baap) { dep[node] = dep[baap] + 1; dp[0]... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long double P = 3.1415926536, a[110], n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] *= a[i]; a[i] *= P; } for (int i = 0; i < n; i++) for (int j = 0; j < n - 1;... |
#include <bits/stdc++.h> using namespace std; const int MN = 5e5 + 5; int N, i, j, pre = 1; long long ans, cur, acc; string s; stack<pair<int, int> > stk; int main() { cin >> N >> s; s.insert(s.begin(), ); for (i = 1; i <= N; i++) { if (s[i] == 1 ) { int len = i - pre + 1; ... |
#include <bits/stdc++.h> using namespace std; int p, n; char arr[1002], brr[1002]; int main() { scanf( %s , arr); n = strlen(arr); for (int i = 0; i < n; i++) { if (arr[i] == . ) { p = i; } } if (arr[p - 1] == 9 ) { printf( GOTO Vasilisa. n ); } else { i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.