func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int M = 1e6 + 6; const int inf = 0x3f3f3f3f; long long a[M], sum[M]; int main() { int t; scanf( %d , &t); while (t--) { int n, p, k; scanf( %d%d%d , &n, &p, &k); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); sort(a +... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; const string ALPHA = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ; string NAME[3] = { Kuro , Shiro , Katie }; int main() { ios::sync_with_stdio(... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, sum = 0; vector<long long> A; int n; cin >> n; A.resize(n); for (int i = 0; i < n; i++) { cin >> a; sum += a; A[i] = sum; } b = sum / 2 + (sum % 2); a = 0; while (A[a] < b) a++; c... |
#include <bits/stdc++.h> int main() { int n, c = 0, i, s = 0, j, k = 0; scanf( %d , &n); for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { s = s + j; if (s > n) { k = 1; break; } } c = c + 1; if (k == 1) { c--; break; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int awsl[maxn]; int main() { int n; scanf( %d , &n); string s; cin >> s; vector<int> sum(n); vector<int> m(n); for (int i = 0; i < n; ++i) { if (s[i] == ( ) awsl[i] = 1; else awsl[i]... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; int d[100005]; int pr[100005]; int cnt[100005]; int a[100005]; vector<int> g[100005]; int b[100005]; int main() { int n, i, j; scanf( %d , &n); for (i = 1; i <= n; ++i) { scanf( %d , &a[i]); ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int n, m, cnt, a[300002]; int32_t main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n - 1; i++) if (a[i] <= a[i + ... |
#include <bits/stdc++.h> using namespace std; long long inf = 1e18 + 42; const double eps = 1e-8; const int M = 1e9 + 7; const int MN = 1e9; int main() { vector<int> In; for (int i = 1; i <= 4; i++) { cout << ? << i << << i + 1 << endl; int x; cin >> x; In.push_back(x)... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long t = 1; cin >> t; while (t--) { long long n, i, j; string s, a, b; cin >> n >> s; a = b = ; bool flag = true; ; ... |
#include<bits/stdc++.h> #define rep(i,a,b) for(long long i=a;i<b;i++) #define pb push_back #define f first #define s second #define is insert #define vector_int vector<int> #define ll long long #define pqi priority_queue<int> #define all(x) x.begin(),x.end() #define mem(x,y) memset(x,y,sizeof(x)) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int arr[2 * n], maxi[2 * n], c = 1; vector<long long int> v; ... |
#include <bits/stdc++.h> using namespace std; struct proc { string name; string var[10]; }; struct vari { string name; string x; }; string s, t, name, varr[10]; proc a[1005]; vari b[1005]; int res, n, m, k, para[1005], p; bool check; int main() { if (0) { freopen( a.inp ,... |
#include <bits/stdc++.h> using namespace std; int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1}; const int N = 1e2 + 5, M = (1 << 17) + 5, inf = 1e7; int a[N], dp[N][M], bit[N], n; bool ip(int i) { for (int it = 2; it * it <= i; it++) { if (i % it == 0) return fals... |
#include <bits/stdc++.h> using namespace std; mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()); long long inf = 1e18, MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int ti = 1; while (ti--) { int n; cin >> n; vect... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 100; int f[N]; struct node { int u, v, w; bool operator<(const node& a) const { return w < a.w; } }; struct qq { int id, u, v, w; bool operator<(const qq& a) const { if (a.w == w) return id < a.id; return w < a.w; ... |
#include <bits/stdc++.h> using namespace std; int a[1000005], n; long long ans = 0; long long now = 0; long long solve(long long p) { ans = 0; now = 0; for (int i = 1; i <= n; i++) { now += a[i]; now %= p; ans += min(now, p - now); } return ans; } int main() { cin... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d %d , &n, &k); vector<long long int> v; vector<long long int>::iterator it; long long int a[k], i, j, c, t, x; for (i = 0; i < k; i++) scanf( %lld , &a[i]); for (i = 1; i <= n; i++) v.push_back(i); c = 0; ... |
#include <bits/stdc++.h> using namespace std; int c[5005], dp[5005][5005][2]; int n; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf( %d , &c[i]); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j) dp[i][j][0] = dp[i][j][1] = 0; else ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline string toString(T a) { ostringstream os( ); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <type... |
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> u, v; int n, ans = 0; long long a, b, c, p, q; scanf( %d%d%d%d , &u.first, &u.second, &v.first, &v.second); scanf( %d , &n); while (n--) { scanf( %lld%lld%lld , &a, &b, &c); p = a * u.first + b * u.second +... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i; cin >> n; long long int a[n], p, b[100000], sum = 0, r = 0, c[n]; for (i = 0; i < n; i = i + 1) { cin >> a[i]; p = a[i]; b[p] = 0; c[i] = 1; } for (i = 0; i < n; i = i + 1) { p = a[i]... |
#include <bits/stdc++.h> using namespace std; int dp, p[201000], tt[201000], pre[201000], l[201000], vis[201000]; int n, m, i, j, a[1010][1010], g[201000], now[201000], s, t, dis[201000], z[201000], ans; void link(int x, int y, int z) { dp++; pre[dp] = p[x]; p[x] = dp; tt[dp] = y; g[dp... |
#include <bits/stdc++.h> using namespace std; int n; string s; bool ok1 = 1, ok2 = 1; int a[220], b[220], l[110], r[110]; void qs(int u[], int L, int R) { int i = L; int j = R; int m = u[(L + R) >> 1]; while (i < j) { while (u[i] < m) i++; while (u[j] > m) j--; if (i <= j) ... |
#include <bits/stdc++.h> using namespace std; int n, k; int arr[1000008]; int l[1000008]; int mx[1000008 << 2], lazy[1000008 << 2]; void pushup(int rt) { mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]); } void build(int rt, int l, int r) { if (l > r) return; if (l == r) { mx[l] = arr[l]; re... |
#include <bits/stdc++.h> using namespace std; int c[100005], n, m; map<int, int> f; int lowbit(int x) { return x & (-x); } void add(int x, int j) { while (x < 100005) { c[x] += j; x += lowbit(x); } } int sum(int x) { int s = 0; while (x > 0) { s += c[x]; x -= lowbit... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, q; cin >> n >> q; deque<int> deq; for (int i = 0; i < n; i++) { int a; cin >> a; deq.push_back(a); } vector<pair<int, int>> ans; for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; struct BIT { int N; vector<int> B; BIT(int n = 0) { N = n; B.resize(n + 2, 0); } void add(int x, int v) { x++; while (x <= N) { B[x] += v; x += x & -x; } } int sum(int x) { int s = 0; ... |
#include <bits/stdc++.h> using namespace std; int const N = 70; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char s[N][N]; int vis[N][N]; int n, m; int dfs(int x, int y) { if (s[x][y] != # || vis[x][y]) return 0; vis[x][y] = 1; for (int i = 0; i < (4); i++) dfs(x + dx[i], y + dy[i])... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const long long mod = 1e6 + 3; const int INF = 1e9 + 1; const int N = 105; long long H[N], c, h, w; struct Matrix { long long arr[N][N]; Matrix() { memset(arr, 0, sizeof arr); } Matrix(int x) { memset(arr, 0, sizeof ... |
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e) { cout << e << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << << e2 ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int child[N], w[N]; long long dp[N][35][3], ans[N][2]; void pre(int n) { for (int i = 0; i < n; i++) { dp[i][0][0] = w[i]; dp[i][0][2] = w[i]; dp[i][0][1] = child[i]; } for (int j = 1; j < 35; j++) { for (i... |
#include <bits/stdc++.h> using namespace std; int is_prime[5000010 + 10], primes[5000010 + 10], firstp[5000010 + 10], prime_cnt; void get_primes() { memset(is_prime, -1, sizeof(is_prime)); for (int i = 2; i <= 5000010; i++) { if (is_prime[i]) { primes[prime_cnt++] = i; firstp[i... |
#include <bits/stdc++.h> int main() { int a; scanf( %d , &a); if (a == 5) printf( 1 n ); else printf( %d n , a % 3 + 1); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); cout.tie(NULL); ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { string s; cin >> s; int ans = 0; int one; bool turn = true; while (s.size() != 0) { one = ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; if (a > b || (b - a) % 2) { cout << -1; return 0; } if (a == b) { if (a == 0) cout << 0; else cout << 1 << n << a; } else if (((a + (b - a) / 2) ^ ((b - a) / 2... |
#include <bits/stdc++.h> using namespace std; int arr[100000]; int main() { int n, i, mi = 1e9 + 1, ans, last; cin >> n, ans = n; for (i = 0; i < n; i++) cin >> arr[i], mi = min(mi, arr[i]); for (last = 0; arr[last] != mi; last++) ; for (i = last + 1; i < n; i++) if (arr[i] == mi) ... |
#include <bits/stdc++.h> using namespace std; int stak1[200010], tot1, stak0[200010], tot0; int pre[200010], nex[200010]; char s[200010]; int a[200010]; int n, ans; int stak_ans[200010], tot_ans; int main() { int i, j, k; scanf( %s , s); n = strlen(s); for (i = 0; i < n; i++) a[i + 1] = ... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; for (long long i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; } int main() { ios_base::sync_with_stdio(0), cin.tie(0)... |
#include <bits/stdc++.h> using namespace std; int n, x, i; int reachable[1000000]; int need_to_convert[1000000]; int main(int argc, char **argv) { scanf( %d , &n); for (i = 0; i < n; ++i) { scanf( %d , &x); int trans_op_num = 0; while (x) { ++reachable[x]; need_to_con... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 0, y = 0, z = 0; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; x += a; y += b; c += z; } if (!x && !y && !z) cout << YES ; else cout << NO ; ... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; const int inf = 1e9; const int MOD = 1e9 + 7; const int nax = 1000000 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, s; cin >> n >> s; int a, b, c, d; cin >> a >> b; if (a * 60 ... |
#include <bits/stdc++.h> using namespace std; long long int ff[15][40000][15]; int maskk[15]; bool ok[15][40000][15]; int need[15], n; vector<int> forbit[15]; long long int f(int x, int mask, int pre) { if (ok[x][mask][pre]++) return ff[x][mask][pre]; long long int &ans = ff[x][mask][pre]; if ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int cnt, curk; int pos[N], fa[N]; struct Wall { int z, pos; int xmin, xmax, ymin, ymax; Wall() {} bool operator<(const Wall &x) const { return z < x.z; } } w[N]; struct Queries { int x, y; int pos; Queries() {... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int a[2020]; void solve() { int n, x, y; cin >> n >> x >> y; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); int c = 0; cout << a[x - 1] - a[x]; } int main() { ios::sync_with_st... |
#include <bits/stdc++.h> const int N = 100001, M = 998244353, mod = 1000000007; const long long MX = INT64_MAX, MN = INT64_MIN, oo = 1e18; using namespace std; vector<string> tokenizer(string str, char ch) { std::istringstream var((str)); vector<string> v; string t; while (getline((var), t, (ch)... |
#include <bits/stdc++.h> using namespace std; template <class T> void cmax(T &a, T b) { a = (a > b ? a : b); } template <class T> void cmin(T &a, T b) { a = (a > b ? b : a); } const long long maxn = 270000, base = 31, kcz = 1e9 + 7; long long inv; long long ksm(long long ds, long long zs = k... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 1000000000; const int N = 100005; struct Edge { int to, next, w, vis; }; struct Edge e[N << 1]; int head[N], E, f[N]; struct P { long long val; int idx; P(long long val, int idx) : val(val), idx(idx) {} bool operator... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; vector<long long> arr(2e5 + 2, 0); vector<long long> dp(2e5 + 2, 0); vector<long long> left1(2e5 + 2, 0); void solve() { int n, k; string s; cin >> n >> k >> s; for (int i = 0; i < n; i++) { arr[i] = (s[i] - 0 ) *... |
#include <bits/stdc++.h> using namespace std; int a[105]; bool judge(int x) { for(int i=1;i<=100;i++) { if(i*i==x) return true; } return false; } int main() { int t; cin>>t; while(t--) { int n; cin>>n; fo... |
#include <bits/stdc++.h> using namespace std; int main() { string s, provera; int p = -1, d = -1, brojac = 0; bool flag = false; cin >> s >> provera; for (int i = 0; i < provera.length(); ++i) { if (provera[i] == s[brojac]) { brojac++; } if (brojac == s.length()) { ... |
#include <bits/stdc++.h> using namespace std; int n, m; int lace[110][110]; int main() { int x, y, i, j; while (cin >> n >> m) { memset(lace, 0, sizeof(lace)); for (i = 1; i <= m; i++) { cin >> x >> y; lace[x][y] = lace[y][x] = 1; } int xx, ans = 0; while (1... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y) { long long res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res % 1000000007; } long long inv(long lo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e6 + 44; const int X[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int Y[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int mod = 998244353; const int INF = 1e9; ll ans[N], add[N]; vector<int> g[N]; vector<pair<int, int> > query[N];... |
#include <bits/stdc++.h> using namespace std; using LL = long long; int a[25]; LL dp[25][5], l, r; LL dfs(int pos, int cnt, bool zero, bool limit) { if (pos == -1) return 1; if (!limit && !zero && dp[pos][cnt] != -1) return dp[pos][cnt]; int up = limit ? a[pos] : 9; if (cnt == 3) up = 0; L... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(0.0) * 2.0; const long double eps = 1e-10; const int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}}; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } t... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int result = n / 2 + 1; cout << result; return 0; } |
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0); const int oo = 2e9; const int N = 205; const int AL = 26; vector<int> idx[AL]; vector<int> adj[N]; int clr[N]; bool dfs(int u, int c = 0); int main() { int n; scanf( %d , &(n)); string s(n, ); for (int i ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long int rev[N], fac[N], mod = 1e9 + 7; long long int wop(long long int x, long long int y) { if (y == 0) return 1; long long int ret = wop(x, y / 2); ret %= mod; ret *= ret; ret %= mod; if (y & 1) ret *= x; ret %=... |
#include <bits/stdc++.h> using namespace std; int euclid(int a, int b, int &x, int &y) { if (!a) { x = 0; y = 1; return b; } int _x, _y; int g = euclid(b % a, a, _x, _y); x = _y - b / a * _x; y = _x; return g; } void relax(int &obj, int C3, int C4, int C5, int _k3, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 505 * 505 * 4; int n; using vi = vector<int>; vi G[maxn]; int dfn[maxn]; int low[maxn]; int scc[maxn]; int scnt[maxn]; int ntime; int scc_cnt; int sta[maxn]; int sz; void tarjan(int u) { dfn[u] = low[u] = ++ntime; sta[sz+... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( tune=native ) using namespace std; const int MAX = 1e6 + 5; const long long MOD = 1000000007; const long long MOD2 = 2010405347; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmax(T& x, T y) { if (x < y) x = y; } template <typename T> void chkmin(T& x, T y) { if (x > y) x = y; } inline int read() { int x = 0; char c = getchar(); bool f = 0; while (c < 48) f |= c == - , c = get... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long dp[2001][2001]; long long dp1[2001][2001]; int main() { int N, K; string S; cin >> N >> K >> S; memset(dp, 0, sizeof(dp)); memset(dp1, 0, sizeof(dp1)); dp[0][0] = dp1[0][0] = 1; for (int n = 1; n <=... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int type[N], n, p[N], out[N]; int go(int u, bool print = false) { int res = p[u] == -1 || out[p[u]] > 1 ? 1 : go(p[u], print) + 1; if (print) cout << u + 1 << ; return res; } int main() { cin >> n; for (int i = 0; i < n;... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) const int MAXN = 1e5 + 5; using namespace std; struct node { int i; node *l, *r; }; node *newN(int i) { node *x = new node; x->i = i; x->r = x->l = NULL; return x; } node *insert(node *actual, int i, bool k) { if (!actual) r... |
#include <bits/stdc++.h> const double eps = 1e-10; const float epsf = 1e-6; using namespace std; inline long long int __gcd(long long int a, long long int b) { if (a == 0 || b == 0) { return max(a, b); } long long int tempa, tempb; while (1) { if (a % b == 0) return b; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100007; struct LinkCutTree { struct Node { int L, R, P, lazyFlip; int PP; }; Node LCT[MAXN]; void normalize(int u) { assert(u != -1); if (LCT[u].L != -1) LCT[LCT[u].L].P = u; if (LCT[u].R != -1) LCT[LCT[u]... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; long long arr[MAX], arr2[MAX]; int n, m; bool check(long long mid) { int prv = 0; for (int i = 0; i < n; ++i) { while (prv < m && arr2[prv] + mid < arr[i]) ++prv; if (prv == m || arr2[prv] - mid > arr[i]) return 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 2; int a[maxn << 1]; long long vis[maxn]; int main(void) { std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n, m; while (cin >> n >> m) { int k = 0; int t; vector<int> a(n + m + 1); vec... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; bool isprime[N] = {1, 1, 0}; int sum[N] = {}; void YesIcan() { for (int i = 2; i * i <= N; ++i) { for (int j = i * i; j <= N; j += i) isprime[j] = true; } } int main() { YesIcan(); int a, b, k; cin >> a >> b >> ... |
#include <bits/stdc++.h> using namespace std; int main() { #ifdef LOCAL freopen( ../IO/d.in , r , stdin); // freopen( ../IO/d.out , w , stdout); #else std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #endif int number_of_tests; cin >> number_of... |
#include <bits/stdc++.h> int gcd(int a, int b) { if (b == 0) return a; gcd(b, a % b); } using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q; cin >> q; while (q--) { int a, b; cin >> a >> b; if (gcd(a, b) != 1) ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16000000 ) using namespace std; const int Maxn = 1000005; const int Maxm = 4194304; const int Inf = 1000000000; int n, c; pair<int, int> lef[Maxn], rig[Maxn]; int me[Maxn]; int res[Maxn], rlen; int st[Maxm]; void Insert(int v, int l, int r, ... |
#include <bits/stdc++.h> using namespace std; const long long int sz = 7e5; long long int sum[sz]; long long int mi[sz]; long long int arr[sz]; void build(long long int node, long long int l, long long int r) { if (l == r) { sum[node] = arr[l]; } else { long long int mid = (l + r) / 2; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; const int inf = 0x3f3f3f3f; const long long INF = 1e18; template <typename T> void read(T &x) { x = 0; int s = 1, c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) s = -1; ... |
#include <bits/stdc++.h> const size_t max_vertices = 1 << 16; int degree[max_vertices], xor_sum[max_vertices]; std::queue<int> queue; std::vector<std::pair<int, int>> result; int main() { int vcount = 0; std::cin >> vcount; for (int i = 0; i < vcount; i++) { std::cin >> degree[i] >> xor_sum[... |
#include <bits/stdc++.h> using namespace std; long long isPrime(long long x) { long long i, flag = 1; if (x == 0 || x == 1) { flag = 0; } for (i = 2; i <= sqrt(x); i++) { if (x % i == 0) { flag = 0; break; } } return flag; } long long fact(long long n) {... |
#include <bits/stdc++.h> using namespace std; int n; int a[6], b[6], ord[6], c[6]; vector<pair<int, int> > v, nv; struct S { vector<pair<int, int> > v; int from; S(vector<pair<int, int> > v, int from) : v(v), from(from) {} S() {} }; vector<S> s; void pr(int a, int b) { if (a == 1) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const int inf = -INF; const int N = 100005; const int M = 2005; const int mod = 1000000007; const double pi = acos(-1.0); int mp1[N], mp2[N]; int main() { int n, m; int d, p; char s[2]; scanf( %d %d , &n, &m); ... |
#include <bits/stdc++.h> using namespace std; char arr[300001]; int main(void) { int N; scanf( %d , &N); scanf( %s , arr); int i; char _max = 0; int idx = -1; for (i = 0; i < N; i++) { if (_max < arr[i]) { _max = arr[i]; idx = i; } if (idx != -1 && _ma... |
#include <bits/stdc++.h> using namespace std; const int mo = 1000000007; const int Maxn = 1010; int f[110000], g[110000]; int a[Maxn * 2], b[Maxn * 2]; int sum[110000]; char st[Maxn]; int n, m, cnt; bool Check(int s) { for (int i = 0; i < n; ++i) if (a[s + i] != b[i]) return false; retur... |
#include <bits/stdc++.h> using namespace std; inline int read() { int w = 1, s = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = 0; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { s = (s << 1) + (s << 3) + ch - 0 ; ch = getchar(); } r... |
#include <bits/stdc++.h> using namespace std; int k[3]; long long t[200000]; long long c[200000]; int n; long long T[3]; long long nt[200000]; multiset<long long> s; int main(void) { for (int i = 0; i < 3; i++) scanf( %d , &k[i]); for (int i = 0; i < 3; i++) scanf( %I64d , &T[i]); scanf(... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print(T a) { for (auto x : a) cout << x << ; cout << n ; } void solve() { int n, m; cin >> n >> m; char a[n][m]; short down[n][m], up[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++)... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; const int p = 10000007; pair<long long, int> c[500005]; pair<long long, long long> sum[500005]; int id[500005]; long long a[500005], b[500005], ans[500005]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = (int)... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; string s; cin >> s; while (b--) { for (int i = 0; i < a - 1; i++) { if (s[i] == B && s[i + 1] == G ) { int t; t = s[i]; s[i] = s[i + 1]; s[i + 1] = t; ... |
#include <bits/stdc++.h> using namespace std; int abss(int n) { if (n < 0) return -n; else return n; } const int maxn = 3e5 + 10; int _min(int a, int b) { if (a < b) return a; else return b; } int _max(int a, int b) { if (a > b) return a; else re... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int a, b, c, d, m, v; cin >> a >> b >> c >> d; m = max((3 * a) / 10, a - (a / 250) * c); v = max((3 * b) / 10, b - (b / 250) * d); if (m > v) cout << Misha ; else if (v > m) cout << ... |
#include <bits/stdc++.h> using namespace std; int nn[2000000]; int ans[2000000]; string ss; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> nn[i]; int se = 0, en = n - 1; int noa = 0; ans[noa] = 0; while ((nn[se] > ans[noa] || nn[en] > ans[noa]) && en != se) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 355001; const int SQRTN = 320; const int LOGN = 20; const long double PI = acos(-1); const long double TAU = 2 * PI; int n, a[N], idx[N], last, m, an[N]; long long ans; signed main() { cin >> n >> m; for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; void propagate(int node, const map<int, set<int> >& idToChildren, set<int>& leaves) { map<int, set<int> >::const_iterator it = idToChildren.find(node); if (it == idToChildren.end()) { leaves.insert(node); return; } const set<... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i = 0; cin >> n; for (i = n + 1; i <= (2 * n); i++) cout << i << ; return (0); } |
#include <bits/stdc++.h> using namespace std; const int N = 600010, inf = N; int n, m; int head[N], cnt = 1; struct edge { int to, next; } e[N << 1]; void adde(int a, int b) { e[++cnt].to = b; e[cnt].next = head[a]; head[a] = cnt; } int nxt[N], st[N], vis[N], top, mn, mx, in[N]; void... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s1, s2; cin >> s1 >> s2; int a, b, c, d; a = s1[0] - 0 ; b = s1[1] - 0 ; c = s2[1] - 0 ; d = s2[0] - 0 ; vector<int> v1({a, b, c, d}); map<vector<int>, int> mp; mp[{a, b, c, d}] = 1... |
#include <bits/stdc++.h> using namespace std; int main() { string s; long long t, j = 0; cin >> t; cin >> s; for (long long i = 0; i < s.size(); i++) { if (s[i] == F ) if (s[i + 1] == S ) j--; if (s[i] == S ) if (s[i + 1] == F ) j++; } if (j <= 0) co... |
#include <bits/stdc++.h> using namespace std; char g[3010][3010]; long long dp[2][3010][3010]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 1; i < n + 1; i++) scanf( %s , g[i] + 1); if (g[1][2] == . ) dp[0][1][2] = 1; if (g[2][1] == . ) dp[1][2][1] = 1; for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; int mas[1010][1010]; int mas1[1001][1001]; bool check(int i, int j) { return mas[i][j] && mas[i + 1][j] && mas[i + 2][j] && mas[i + 2][j + 1] && mas[i + 2][j + 2] && mas[i + 1][j + 2] && mas[i][j + 2] && mas[i][j + 1]; } void draw(int i... |
#include <bits/stdc++.h> using namespace std; const int N = 2004; int pa[N]; int n, m, x, y, op, pos = 1, ans = 0; pair<int, int> p[N]; bool b[N]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n * 2; i++) { scanf( %d , &p[i].first); p[i].second = i; } for (int i = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> segs; int numNeg = 0; int curLen = 0; for (int i = 0; i < n; i++) { int a; scanf( %d , &a); if (a < 0) { if (numNeg == 2) { segs.push_back(curLen); cur... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000, INF = 2000000000; struct edge { int x; int y; int w; int o; }; vector<vector<edge> > G(MAXN + 1); int n, m, depth[MAXN + 1], low[MAXN + 1], s, t, previous[MAXN + 1], prevCost[MAXN + 1], cntEdges[MAXN + 1][MAXN + 1], c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.