func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <class T> void read(vector<T> &a, long long n) { T x; a.clear(); for (long long i = 0; i < n; i++) { cin >> x; a.push_back(x); } } template <class T> void write(vector<T> &a) { for (T x : a) cout << x << ; cout << ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 1e9 + 7; long long minv[1 << 16]; long long numx[15], numy[15]; long long n, a[maxn], x, y, A, B, facy[15000], ans; inline long long read() { char ch = getchar(); long long u = 0, f = 1; while (!isdigit(ch)... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n; cin >> n; long long a[n], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum % 2 == 1 || n == 1) { cout << NO ; ... |
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c; while (cin >> a >> b >> c) { double m = a * c; cout << ceil(m / b) - c << endl; } } |
#include <bits/stdc++.h> using namespace std; using namespace rel_ops; using ll = int64_t; using Pii = pair<int, int>; using ull = uint64_t; using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); run(); return 0; } ... |
#include <bits/stdc++.h> using namespace std; ifstream input; ofstream output; int main(int argc, char *argv[]) { input.sync_with_stdio(false); output.sync_with_stdio(false); int n, tmp, tmp2; priority_queue<int> y; set<int> used; cin >> n; for (int i = 0; i < n; i++) { cin >> ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = INT_MAX; const int MAX = 4e6 + 5; const int N = 1e5 + 5; long long dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; long long dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; char dir[] = { U , R , D , L }; long long power(long long a, lo... |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() {} Point(double _x, double _y) : x(_x), y(_y) {} }; struct Point p0, p1, p2; double dist(Point a, Point b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } double check(Point s, Point e... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; if (2 * c < d || 2 * d < c || d >= b) cout << -1 ; else { cout << 2 * a << endl << 2 * b << endl; if (c > d) cout << c; else cout << d; } return 0; }... |
#include <bits/stdc++.h> using namespace std; struct _ { _() { ios_base::sync_with_stdio(0); } } _; template <class A, class B> ostream &operator<<(ostream &o, pair<A, B> t) { o << ( << t.first << , << t.second << ) ; return o; } template <class T> string tostring(T first, int len = 0,... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> a; vector<int> r; vector<vector<pair<int, int>>> pre, suf; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; a = vector<vector<int>>(n, vecto... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; int sp = -1, rmv = 0, ans = 0; stack<int> st; while (n--) { int t; cin >> t; if (t == 1) { int x; cin >> x; sp = x; } else if (t == 3) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, a, counter = 0, ar[100000]; map<char, int> mp; mp[ 6 ] = 1, mp[ 7 ] = 2, mp[ 8 ] = 3, mp[ 9 ] = 4, mp[ T ] = 5; mp[ J ] = 6, mp[ Q ] = 7, mp[ K ] = 8, mp[ A ] = 9; string str1, str2; char trump; cin >> trump; cin... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef string str; #define pb push_back #define ppp pop_back #define pii pair<int,int> #define fi first #define se second #define stie std::tie #define vec vector #define forn(i, l, r) for (int i=l; i... |
#include <bits/stdc++.h> using namespace std; bool y[200005]; long long n, m, k, j, i, p[2000005], q[2000005], haj[2000005], s, sum; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; p[1] = 0; sum = n * (n + 1) / 2; for (i = 1; i < n; i++) { haj[... |
#include <bits/stdc++.h> using namespace std; ; const double eps = 1e-8; const int mod = 1000000007; const int maxn = 1e5 + 7; const double pi = acos(-1); const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f; int n; long long p; struct node { long long a, b; } num[maxn]; bool... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-11; int countbit(int n) { return (n == 0) ? 0 : 1 + countbit(n & (n - 1)); } int lowbit(int n) { return n & (n ^ (n - 1)); } string toString(long long v) { ostringstream sout; sout << v; return sout... |
#include <bits/stdc++.h> int main() { int N, Q; scanf( %d%d , &N, &Q); int et[N + 1]; memset(et, -1, sizeof(et)); while (Q-- > 0) { int t, k, d; scanf( %d%d%d , &t, &k, &d); int ans = -1; int as = 0; for (int i = 1; i <= N; i++) { if (t > et[i]) et[i] = -1; ... |
#include <bits/stdc++.h> using namespace std; long long mod = 0; const int N = 100005; vector<array<int, 2>> v[N]; vector<set<int>> g(N); vector<int> depth(N, 0); vector<vector<int>> p(N, vector<int>(17, 0)); vector<long long> up(N, 0); vector<long long> down(N, 0); vector<int> sz(N, 0); vector<in... |
#include <bits/stdc++.h> using namespace std; int seq[100]; void display(const int n) { for (int i = 0; i < n; ++i) printf( %d , seq[i]); putchar( n ); } int compute_sum(const int n) { int sum = 0; for (int i = 0; i < n; ++i) { int x = seq[i]; for (int j = i; j < n; ++j) { ... |
#include <bits/stdc++.h> const int inf = 1039074182; using namespace std; int n, r, c; string word[1000005]; int len[1000005]; int nxt[1000005]; pair<int, int> st[1000005][22]; int sum[1000005]; int calc(int start) { int res = 0; for (int i = 0; i < 22; i++) { if ((1 << i) & r) { ... |
#include <bits/stdc++.h> using namespace std; int n, m; string a, b, c, d, e; vector<vector<int> > vals; vector<vector<int> > forms(1); map<string, int> getind; int doop(int left, int right, int op) { if (op == 2) return left ^ right; if (op == 3) return left & right; else return l... |
#include <bits/stdc++.h> using namespace std; int r, c; int main() { int n; scanf( %d , &n); while (n--) { scanf( %d %d , &r, &c); for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) if (i == r - 1 && j == c - 1) printf( W ); else p... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2 * (100000) + 5; int a[MAXN], b[MAXN]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; int res = 0; int j = 0; for (int i = 0; i < n && j < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; long long w[400005], sum[400005][21], f[400005][21], mx[400005][21]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(sum, 0x3f, sizeof(sum)); int q; cin >> q; long long last = 0; int tot = 1; f[1][0] = 1, sum[1... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long n, long long m) { long long x, y; if (n > m) { y = n; x = m; } else { y = m; x = n; } if (y % x == 0) return x; else { return gcd(x, y % x); } } int main() { long long n; ... |
#include <bits/stdc++.h> int q, n; int main() { scanf( %d , &q); while (q--) { scanf( %d , &n); int b = sqrt(2 * n + 4); while ((b + 1) * (b + 2) / 2 > n) b--; int a = n - (b + 1) * (b + 2) / 2; printf( 133 ); for (int i = 1; i <= a; i++) printf( 7 ); for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e; int ar[200100]; int ar1[200100]; int main() { vector<int> arr(200100); string s, s1; cin >> s; cin >> s1; a = min(s.length(), s1.length()); b = a; c = 1; while ((c <= a) && (s[s.length() - c] == s1[s1.length() - c... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long t[n + 1], c[n + 1]; for (int i = 1; i <= n; i++) { cin >> t[i] >> c[i]; t[i]++; if (t[i] > n) { t[i] = n;... |
#include <bits/stdc++.h> using namespace std; const int N = 505; const int mod = 998244353; long long n, k, ans; long long dp[N][N], dp2[N]; signed main() { cin >> n >> k; dp[0][0] = 1; for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= i; j++) { for (long long l = i -... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; bool t = false; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) t = true, ch = getchar(); while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 48, ch = getchar(); retu... |
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <bitset> #include <vector> #include <unordered_map> using namespace std; const int N = 100007, M = 500007, INF = 0x3f3f3f3f; typedef long long ll; typedef int itn; int n, m, t, x; i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5, inf = 1e9; int a[maxn]; struct segtree { int lb, rb; int mn = 0; segtree *l, *r; segtree(int _lb, int _rb) { lb = _lb, rb = _rb; if (lb == rb) mn = a[lb]; else { int t = (lb + rb) / 2; l... |
#include <bits/stdc++.h> using namespace std; int main() { vector<string> v; map<char, int> m; int k; cin >> k; string q; cin >> q; int l = q.size(); int flag = 1; int cnt = 0; string s; if (l < k) { cout << NO ; return 0; } else { cnt = 1; s ... |
#include <bits/stdc++.h> using namespace std; int main() { double h, l; scanf( %lf %lf , &h, &l); printf( %lf n , (l * l - h * h) / (2 * h * 1.0)); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MAX_N = 5000; const long long MAX_Q = 10000; struct Node { vector<long long> val; vector<int> nex; }; long long cnt = 1, cur = 0, pows[5] = { 1LL, (MAX_Q + 1LL), (MAX_Q + 1LL) * (MAX_Q + 1LL), (... |
#include <bits/stdc++.h> void initialize(int *arr, int length) { for (int i = 0; i < length; i++) arr[i] = 0; } int teams(int *arr, int length) { for (int i = 1; i < length; i++) { if (arr[i - 1] == 1 && arr[i] == 1) return 2; } return 1; } int main() { int queries, len, curr, sieve[... |
#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() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int T; cin >> T; while (T--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int i; bool poss = 1; ... |
#include <bits/stdc++.h> using namespace std; long long mod = 998244353; int main() { ios_base::sync_with_stdio(false); long long r, s, p; cin >> r >> s >> p; double dp[r + 1][s + 1][p + 1]; int visited[r + 1][s + 1][p + 1]; for (int i = 0; i < r + 1; i++) { for (int j = 0; j < s + 1... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int a[4]{0}; int i, j, k, ans, min1 = 0, min2 = 0; for (i = 0; i < s.size(); i++) { if (s[i] == L ) a[0]++; if (s[i] == R ) a[1]++; if (s[... |
#include <bits/stdc++.h> using namespace std; int e, s, n, m; vector<int> comp; vector<pair<int, int> > has; vector<int> all, butR, onlyS; int query[200013]; int id(int x) { return lower_bound(comp.begin(), comp.end(), x) - comp.begin(); } vector<int> cover(int use) { vector<int> res(comp.size... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int found; string s = +------------------------+ ; string r1 = |#.#.#.#.#.#.#.#.#.#.#.|D|) ; string r2 = |#.#.#.#.#.#.#.#.#.#.#.|.| ; string r3 = |#.......................| ; string r4 = |#.#.#.#.#.#.#.#... |
#include <bits/stdc++.h> const int N = 22; const int M = (1 << 22); const int INF = 0x3f3f3f3f; bool dp[M] = {0}; int neib[N] = {0}, ex[M] = {0}; int main() { int m, n, u, v; scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { neib[i] = (1 << i); dp[1 << i] = true; } for (in... |
#include <bits/stdc++.h> using namespace std; int n, m; set<int> s[100001]; int a[100001]; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; s[x].insert(y); s[y].insert(x); } srand(time(0)); for (int op = 1; op <= 200; op++) { ... |
// BY : VIDIT BHARDWAJ #include<bits/stdc++.h> using namespace std; #define int long long int #define ff first #define ss second #define pb push_back #define popb pop_back #define lb lower_bound #defi... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; long long a[N]; struct t { int lval, rval, mval; } tr[N * 4]; int sign(long long x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } inline void cal(int cur, int l, int r) { int m = (l + r) / 2; int dcur... |
#include <bits/stdc++.h> using namespace std; long long f[5005][5005]; long long mod = 1000000007, ans = 0; char s1[5005], s2[5005]; int main() { scanf( %s n %s , s1 + 1, s2 + 1); int len1 = strlen(s1 + 1); int len2 = strlen(s2 + 1); for (int i = 1; i <= len1; ++i) for (int j = 1; j <= ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int good = 0; int bad = 0; cin >> s; for (int i = 0; i < s.length(); i++) { if (s.at(i) == a ) good++; else bad++; } if (good > bad) cout << s.length(); else cout << s.length... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x[3]; cin >> x[0] >> x[1] >> x[2]; sort(x, x + 3); cout << (x[1] - x[0]) + (x[2] - x[1]) << n ; ; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long llINF = 9223372036854775807; const int INF = 2147483647; const int maxn = 2e5 + 7; const int maxm = 5e4 + 7; const long long mod = 1e9 + 7; const double pi = acos(-1.0); const double eps = 1e-12; int n; int fa[2][maxn]; int a[maxn], b[m... |
#include <bits/stdc++.h> using namespace std; using point = complex<double>; const int T = 1 << 16; point root[T]; void fft(vector<point>& a) { int n = a.size(); vector<int> reverse(n); for (int i = 0; i < n; ++i) { reverse[i] = (reverse[i / 2] + (i % 2) * n) / 2; if (i < reverse[i]) {... |
#include <bits/stdc++.h> using namespace std; bool prime[1007]; int n; void sieve() { for (int i = 4; i <= 1005; i += 2) prime[i] = false, prime[i - 1] = true; prime[2] = true; for (int i = 3; i <= 1000; i += 2) { if (prime[i]) { for (int j = i * i; j <= 1005; j += i * 2) prime[j] = fa... |
#include <bits/stdc++.h> using namespace std; int main() { long long q, x; cin >> q >> x; long long n = q; long long a[n]; map<long long, long long> m; long long min = 0; map<long long, long long> f; for (long long i = 0; i < n; i++) { cin >> a[i]; long long mod = a[i] % ... |
#include <bits/stdc++.h> int read() { static int c, x; while ((c = getchar()) < 48) { } x = c & 15; while ((c = getchar()) >= 48) x = x * 10 + (c & 15); return x; } struct edge { int next, to; } e[100010 << 1]; int ans = 0; int head[100010], deg[100010], f0[100010], f1[100010]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int t; cin >> t; while (t--) { int n; cin >> n; int nroot = floor(sqrt(n)); if (nroot * nroot >= n) { cout << 2 * nroot - 2 << n ; } else if ((nroot + 1) * nroot >= n) { ... |
#include <bits/stdc++.h> const int maxn = 100000; struct point { int x, y; }; point p[maxn + 10]; int n, used[maxn + 10]; inline int one_line(int a, int b, int c) { if ((a == 0) || (b == 0) || (c == 0)) { return 1; } return 1ll * (p[c].x - p[a].x) * (p[b].y - p[a].y) == 1ll ... |
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf( %d , &T); while (T--) { int x, n, m; scanf( %d%d%d , &x, &n, &m); while (n-- && x >= 20) x = floor(1.0 * x / 2) + 10; while (m--) x -= 10; printf(x <= 0 ? YES n : NO n ); } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 200100; const int INF = 1000 * 1000 * 100; string s[N]; char ch[30]; int d[1000 * 3000 + 10], l[30], r[30]; int lcps(int x) { int sz = s[x].size(); for (int i = sz - 1; i >= 0; i--) r[i] = r[i + 1] + ((s[x][i] - 0 ) << (sz - i - 1)... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int n, m; vector<int> liga[200100]; vector<int> adj[200100]; int state[200100]; int id[200100], sz[200100]; int vis[200200]; vector<int> top; int find(int x) { if (id[x] == x) return x; retur... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { int tmp = 0, mid = (m + 1) / 2, res = mid; while (n--) { if (tmp % 2 == m % 2) res -= tmp; else res += tmp; if (tmp == m) tmp = 0, res = mid; cout << r... |
#include <bits/stdc++.h> using namespace std; int v[100010]; int j[100010]; string ss; bool haha; int m; void jump(int n) { if (n < 0 || n >= m) { haha = true; return; } else if (j[n] == 1) { haha = false; return; } else { int p; if (ss[n] == < ) p ... |
#include <bits/stdc++.h> using namespace std; int Search[1001][1001], Target1[1001], Target2[1001], Attack = 0; int main() { int Data1, Data2; cin >> Data1 >> Data2; for (int i = 0; i < Data1; i++) { for (int i2 = 0; i2 < Data2; i2++) { char Test; cin >> Test; if (Test ==... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; long long mulmod(long long a, long long b, long long MOD) { if (b == 0) return 0; long long res = mulmod(a, b >> 1, MOD); res += res; res %= MOD; return (b & 1) ? (a + res) % MOD : res; } int gcd(int ... |
#include <bits/stdc++.h> namespace IO { template <typename Tp> inline Tp input() { Tp x = 0, y = 1; char c = getchar(); while ((c < 0 || 9 < c) && c != EOF) { if (c == - ) y = -1; c = getchar(); } if (c == EOF) return 0; while ( 0 <= c && c <= 9 ) x = x * 10 + c - 0 , c... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000000 + 9; long long pow(long long a, int n, long long mod) { long long res = 1; while (n) { if (n % 2) { res *= a; res %= mod; --n; } else { a *= a; a %= mod; n /= 2; ... |
#include <bits/stdc++.h> using namespace std; const int N = 105; const int oo = 1000000000; long long n, k; long long a[N], b[N], c[N]; long long module = 1000000007; void print(vector<vector<long long> > mat) { for (int j = 0; j < mat.size(); j++) { for (int k = 0; k < mat[j].size(); k++) cout ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int com(const void* a, const void* b) { return *(int*)a - *(int*)b; } int main(void) { int n, k, i; cin >> n >> k; if (n / 2 > k) cout << -1; else if (n == 1 && k != 0) cout << -1; else { ... |
#include <bits/stdc++.h> using namespace std; int a[200001]; int b[600001]; int n, L; bool chk(int d) { if (d * 2 >= L) return true; int l = 0, r = 3 * n - 1; while (b[l] < a[0] - d) l++; while (b[r] > a[0] + d) r--; for (int i = 1; i < n; i++) { l++; r++; while (b[l] < a... |
#include <bits/stdc++.h> using namespace std; int A[2006]; int B[2005]; map<int, int> mp; int main() { int a, b, n, x; while (cin >> n) { mp.clear(); int t = 1, x1, y1; for (int i = 0; i < n; i++) { scanf( %d , &A[i]); if (mp.count(A[i]) == 0) mp[A[i]] = t++; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, a[MAXN * 3], u[MAXN * 3], v[MAXN * 3], front, rear; int main() { int Q; long long x; scanf( %d%d , &n, &Q); front = 1; rear = n; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= 2 * n -... |
#include <bits/stdc++.h> const long long INF = (long long)1e18 + 123; const int inf = (int)2e9 + 123; const int mod = 1e9 + 7; using namespace std; int n, m, d[8000011], a[1000011], b[1000011]; void upd(int id, int x, int v = 1, int tl = 1, int tr = 1000000) { if (tl > id || tr < id) return; if (tl ... |
#include <bits/stdc++.h> namespace IO { template <typename T> inline void read(T &x) { x = 0; int f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = (x << 3) + (x << 1) + ch - 0 , ch = ge... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; long long a[n]; map<long long, long long> m; for (long long i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; } long long ctr = 0, mx = 1; for (auto i : m) { ctr++; if (i.second > ... |
#include <bits/stdc++.h> using namespace std; const int N = 65; const int M = 5e4 + 10; int n, m, a[N], b[N], q, trans[M], ans; vector<int> p[N * N]; template <class T> void chkMax(T &x, T y) { if (x < y) x = y; } int Do(int x, int y) { int i = 0, j = 0, ret = 0, szx = p[x].size(), szy = p[y].... |
#include <bits/stdc++.h> using namespace std; int piles = 1, heavy = 0, num; int a[110], n; void solve(int x) { if (num == 0) { return; } if (heavy <= a[x]) { a[x] = -1; heavy++; num--; solve(x + 1); } else if (x < n) { solve(x + 1); } else { for (in... |
#include <bits/stdc++.h> using namespace std; int n, m, nxt[100010], pre[100010]; pair<int, int> b[100010]; struct Frog { int p, a, id; } a[100010]; set<pair<int, int> > s; inline bool operator<(Frog a, Frog b) { return a.p < b.p; } inline int cal(int i, int j) { if (i == j) return 0x7fffffff; ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c; map<char, char> mp; mp.clear(); int s = 0; cin >> a; cin >> b; cin >> c; s = c.size(); for (int i = 0; i < 26; i++) { mp[a[i]] = b[i]; } for (int i = 0; i < s; i++) { if (c[i] < 97 && c... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5; const long long mod = 1e9 + 7; const long double PI = acos(-1); long long n, k; pair<long long, long long> a[N]; long long ans[N]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { scanf( %lld , &a[i].first)... |
#include <bits/stdc++.h> using namespace std; int occ[26]; int main() { string s, p; cin >> s >> p; int err = 0; if (s.size() < p.size()) { cout << 0 << endl; return 0; } for (int i = 0; i < p.size(); i++) { occ[p[i] - a ]++; } for (int i = 0; i < p.size(); i++) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int g[maxn][maxn]; int vis[maxn][maxn]; int cnt[maxn][maxn]; struct node { int x, y; } que[maxn * maxn]; int dx[10] = {0, 1, 0, -1, 0}; int dy[10] = {0, 0, 1, 0, -1}; map<char, int> p; void init() { p[ U ] = 2; p[ D ]... |
#include <bits/stdc++.h> using namespace std; map<long long, int> mark; int32_t main() { int n; scanf( %d , &n); set<long long> s; for (int i = 0; i < n; i++) { int x; scanf( %d , &x); mark[x]++; s.insert(x); } int p = 0; long long MX = 0; while (s.size()) {... |
#include <bits/stdc++.h> using namespace std; int n; int c[5005]; int r[5005]; int p[5005]; int main() { memset(p, -1, sizeof p); cin >> n; for (int i = 0; i < n; ++i) { cin >> c[i]; if (p[c[i]] == -1) { p[c[i]] = i; } } for (int i = 0; i < n; ++i) { int o... |
#include <bits/stdc++.h> using namespace std; const int buffer_size = 1e5 + 5; char buf[buffer_size], *S, *T; bool flag_EOF; inline char read_char() { if (S == T) T = (S = buf) + fread(buf, 1, buffer_size, stdin); return S != T ? *(S++) : EOF; } inline int read_int() { bool flag = false; c... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x60000000; const int MINF = -1000000000; const int mod = 99999997; const long long cons = 100000; const double pi = 3.141592653589793; int lim; int p[100005][20]; int depth[100005]; pair<int, int> dmax[100005][3]; int up[100005][20]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0, pos = 0; string s; cin >> s; for (int i = 0; i < s.length(); i++) sum += min(abs(pos - (s[i] - a )), 26 - abs(pos - (s[i] - a ))), pos = s[i] - a ; cout << sum; return 0; } |
#include <bits/stdc++.h> using namespace std; int a[30], col[100100] = {}; int main() { string s; cin >> s; for (int i = 0; i < 26; i++) a[i] = -1; for (int i = 0; i < s.size(); i++) a[s[i] - a ] = i; int p = 25; for (int i = 0;;) { while (p >= 0 && a[p] < i) p--; if (p < 0) b... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int n, c = 0, fl, i, a, b; int deg[100005] = {0}; vector<int> v; cin >> n; for (i = 0; i < n - 1; i++) { cin >> a >> b; deg[a]++; deg[b]++; } for (i = 1; i < n + 1; i++) { ... |
#include <bits/stdc++.h> const long long INF = 1e18; const long long N = 2e5 + 50; const long long MOD = 1e9 + 7; using namespace std; vector<long long> prime, graph[N]; long long n, k, a[N], m, z; long long POWER(long long base, long long expo) { long long ret = 1; while (expo) { if (expo &... |
#include <bits/stdc++.h> int main() { long long int tcase, nc, np, o, connectable, done; std::vector<long long int> O; std::cin >> tcase; for (int i = 0; i < tcase; i++) { connectable = 1; done = 1; o = 0; std::cin >> nc >> np; while (nc > done) { o++; don... |
#include <bits/stdc++.h> using namespace std; const int N = 150005; int n, m; int a, b; vector<int> g[N]; bool pos[N]; vector<int> dsu; bool rez; bool proveri() { for (int u = 0; u < dsu.size(); u++) if (g[dsu[u]].size() != dsu.size() - 1) return false; return true; } void dfs(int cv... |
#include <bits/stdc++.h> using namespace std; int INP() { int n, flag; char c; n = 0; flag = 1; c = getchar(); while (c < 33) { c = getchar(); } if (c == - ) { flag = -1; c = getchar(); } while (c > 32) { n = n * 10 + c - 0 ; c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> struct LazySegTree { int n; vector<T> dat; vector<U> lazy; T e; U upe; static void biop_assign(T &u, const T &a, const T &b) { int m = a[0].size(); for (int i = (int)(0); i < (int)(2); i++) { for ... |
#include <bits/stdc++.h> using namespace std; int main() { map<pair<long long, long long>, long long> m; vector<long long> p1, p2; long long n, s, i, j, k, a, u, v, w, l, k1, k2; cin >> n; while (n--) { cin >> a; if (a == 1) { cin >> u >> v >> w; j = u; k1 = 0... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; vector<long long> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; long long k; cin >> k; long long x; for (int i = 1; i <= n; i++) if (k >= a[i] && k <= b[i]) { x =... |
#include <bits/stdc++.h> using namespace std; const int INF = 100 * 30; int main() { string A, B; cin >> A >> B; vector<vector<int> > v(26, vector<int>(26, INF)); for (int i = 0; i < 26; ++i) v[i][i] = 0; int N; cin >> N; while (N--) { char a, b; int cost; cin >> a >>... |
#include <bits/stdc++.h> using namespace std; int sti(const string &s) { int x; stringstream ss(s); ss >> x; return x; } string its(const int &x) { string s; stringstream ss(s); ss << x; s = ss.str(); } void sscan(string &str) { str = ; char str_c; scanf( %c , &... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 7; set<int, greater<int> > s; int main() { int q; scanf( %d , &q); while (q--) { s.clear(); int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); s.insert(x);... |
#include <bits/stdc++.h> using namespace std; long long n; bool h[100100][40], u[100100][40]; bool big(long long a, long long b) { long long ans = 1; for (long long i = 0; i < b; ++i) { ans *= a; if (ans >= n) return 1; } return 0; } bool win(long long a, long long b) { if (b... |
#include <iostream> #include <cstring> using namespace std; const int MAXN = 100 + 10; int cnt[MAXN]; int main() { int t; cin >> t; while (t--) { int n, input, ans = 0; cin >> n; memset(cnt, 0, sizeof(cnt)); for (int i = 0; i < n; ++i) { cin >> input; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.