func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n; int s[100005], num[100005]; bool cmp(int a, int b) { return a < b; } int main() { while (scanf( %d , &n) != EOF) { int i; for (i = 0; i < n; i++) scanf( %d , &s[i]); sort(s, s + n, cmp); bool flag = true; for (i = 1; i < n ... |
#include <bits/stdc++.h> using namespace std; char a[100005]; int main() { int n; scanf( %d , &n); scanf( %s , &a); int x = 0, f = 0, sum = n, y = 0; for (int i = 1; i < n; i++) { if (a[i] != a[i - 1]) { sum -= x; x = 0; if (i - 2 >= 0 && i + 1 < n && a[i - 2] == ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5010; const int INF = 1e5; static int N, val[MAXN], dp[MAXN][MAXN][2]; int main() { scanf( %d , &N); for (int i = 1; i <= N; i++) scanf( %d , &val[i]); val[0] = -INF; memset(dp, 0x3f, sizeof dp); dp[0][0][0] = dp[1][0][0] = dp[... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, sum = 0; string s; cin >> x; while (x--) { cin >> s; if (s[0] == T ) sum += 4; if (s[0] == C ) sum += 6; if (s[0] == O ) sum += 8; if (s[0] == D ) sum += 12; if (s[0] == I ) sum += 20; ... |
#include <bits/stdc++.h> using namespace std; string Levelcheck(vector<vector<int> > vec) { int n; n = vec.size(); if (vec[0][0] < vec[0][1]) { return NO ; } for (int i = 1; i < n; i++) { if (vec[i][0] < vec[i][1]) { return NO ; } if (vec[i][0] < vec[i - 1][0]) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n{0}; cin >> n; bool flag = false; bool flag1 = false; long long int i{0}, x{0}, rem{0}; for (i = 1; i <= 1000000; i++) { if (n >= 4 * i && n <= 7 * i) { x = 4 * i; rem = n - x; if ((rem % ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int r, c, ans = 0; cin >> r >> c; vector<vector<long long int> > A(r + 2, vector<long long int>(c + 2)); for (long long int i = 1; i <= r; i++) for (long long int j = 1; j <= c; j++) cin >> A[i][j]; vector<vector<long lon... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int k = s.size(); for (string::iterator i = s.begin() + 1; i != s.end(); i++) if (*i == 1 ) { k++; break; } printf( %d n , k / 2); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, a; scanf( %d%d , &n, &a); if (a & 1) printf( %d , (a + 1) / 2); else printf( %d , (n - a) / 2 + 1); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 100, inf = 1e15; long long dis[N][N][6], clr[6][6], ans = inf; queue<pair<int, int> > q[3]; char a[N][N]; bool mark[N][N][6]; pair<int, int> k; int ki, kj, n, m, x, y; int xx[] = {0, 1, 0, -1}, yy[] = {1, 0, -1, 0}; bool is_vall... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const long long llINF = 9223372036854775807; const int INF = 2147483647; const int maxn = 1e3 + 7; const int maxm = 1e5 + 7; const int mod = 1e9 + 7; int n, m; int c[maxn], a[maxn]; int main(int argc, char const *argv[]) { sca... |
#include <bits/stdc++.h> const int N = 100000 + 10; long long A[N], B[N], L[N]; int n, m, a, b; std::set<std::pair<long long, int> > dic; double ans = 1e100; int ansx, ansy; double sqr(long long x) { return (double)x * x; } void Cal(int idx) { double dis; long long x = B[idx] * a / b; std::s... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, sum[3] = {0}, j, yo; cin >> n; for (i = 0; i < 3; ++i) for (j = 0; j < n - i; ++j) { cin >> yo; sum[i] += yo; } cout << sum[0] - sum[1] << endl; cout << sum[1] - sum[2]; return 0; } |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1000001; bool vis[NMAX]; int p[NMAX]; int go(int u) { vis[u] = true; if (vis[p[u]]) return 1; return 1 + go(p[u]); } int sizes[NMAX]; int cap[NMAX]; bitset<NMAX> knp; int main() { vector<int> v; int n, k; scanf( %... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 205; const int MAXM = 55; struct Point { int x, y; double k; Point(int _x = 0, int _y = 0) { x = _x, y = _y; } Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); } bool operator<(const Point &b) const { retur... |
#include <bits/stdc++.h> using namespace std; int INF = 1000 * 1000 * 1000; vector<vector<pair<int, int>>> adj; int mem[80][80][80][80]; int dp(int cur, int closestLeft, int closestRight, int remainingMoves) { if (remainingMoves == 0) return 0; if (mem[cur][closestLeft][closestRight][remainingMoves] !... |
#include <bits/stdc++.h> using namespace std; void DFS(long long n, long long p, long long d, vector<pair<long long, long long>> &D, vector<long long> &Pa, vector<vector<long long>> &G) { for (long long nn : G[n]) { if (nn == p) continue; D.emplace_back(d + 1, nn); Pa[nn]... |
#include <bits/stdc++.h> using namespace std; int m1[200010] = {0}, m2[200010] = {0}; map<int, int> pp; bool d[200010]; int e[100000]; int main() { int n; cin >> n; long long x; int p = 2; int tt = 0; for (int i = 2; i <= 200005; i++) { m1[i] = m2[i] = 1000000000; } for... |
#include <bits/stdc++.h> using namespace std; const int N = 2410; int n, l, r, a[N]; vector<int> p; tuple<int, int, int> tmp[2]; vector<tuple<int, int, int>> ans; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 1, x; i <= 3 * n; i++) cin >> x, a[x] = 1; ... |
#include <bits/stdc++.h> using namespace std; int N, M, D; const int NMax = 100005; vector<int> G[NMax]; int Arb[4 * NMax], Lazy[4 * NMax]; int Point[NMax], Left[NMax], Right[NMax]; bool V[NMax]; int Level[NMax], cnt; const int INF = -10000000; int Max[NMax], Max2[NMax]; void Read() { scanf( %... |
#include <bits/stdc++.h> using namespace std; int p[200005], q[200005]; int fa[200005], top[200005], sz[200005], dep[200005]; vector<int> E[200005]; void dfs1(int root); void dfs2(int root, int toproot); int lca(int node1, int node2); int dis(int node1, int node2); pair<int, int> merge(int node1, int ... |
#include <bits/stdc++.h> using namespace std; string s; bool atted, dotted, goned; int cntu, cnth = -1, cntr = -1, cntd = -1; int main() { cin >> s; for (int i = 0; i < ((int)(s).size()); i++) { if (!atted && s[i] == @ ) atted = 1; else if (atted && !goned && s[i] == . && s[i - ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long dd[200000], h[200000]; int a, b; int aaa[100000], bbb[100000]; long long d[200000]; long long mmin[200000][18], mmax[200000][18]; long long xxx(int x) { return h[x] - d[x]; } long long yyy(int y) { return h[y] + d[y]; } long long xval... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int main() { int n, k, m, t, i, c[N]; scanf( %d%d , &n, &k); int ans = 0; while (k--) { scanf( %d , &m); for (i = 0; i < m; i++) { scanf( %d , &c[i]); } if (c[0] == 1) { for (i = 0; i < m; i... |
#include <bits/stdc++.h> using namespace std; long long res, n, k, d = 0, f, s, moy, mx; long long t[300003]; bool b = true; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (long long i = 0; i < n; i++) cin >> t[i]; reverse(t, t + n); f = k - 1; while (d <... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 200000 + 10; int n, m, k, nv; vector<pair<int, pair<int, int> > > edge; vector<pair<int, int> > e[maxn]; int f[maxn]; bool vis[maxn]; long long dis[maxn]; vector<long long> q; void print(int a[], int n, int ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(const T& x) { return x * x; } template <class T> inline void updMin(T& a, const T& b) { if (b < a) a = b; } template <class T> inline void updMax(T& a, const T& b) { if (b > a) a = b; } vector<string> a; in... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, c0, c1, h, cc0 = 0, cc1 = 0; cin >> t; cout << endl; for (int i = 0; i < t; i++) { cin >> n >> c0 >> c1 >> h; cout << endl; string ali; cin >> ali; bitset<1001> ss(ali); cc1 = ss.count(); c... |
#include <bits/stdc++.h> using namespace std; typedef long double ld; const long long inf = 1100000000000000000; #define maxn 200050 #define mod 1000000007 //998244353 #define int long long #define PB push_back #define F first #define S second #define vi vector<int> #define rep(i,a,b) for( ... |
#include <bits/stdc++.h> struct V { int a, b; int wybor; }; std::vector<int> v[507]; V prev[507][507][2]; int odl[507][507][2]; bool odw[507][507][2]; std::queue<V> Q; int wynik[1000007][2]; int main() { int N, M; scanf( %d%d , &N, &M); int a, b; for (int i = 0; i < M; i++) { ... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long INFll = 1e18; const int INFint = 1e9; const long long MOD = 1e9 + 7; void needForSpeed() { ios_base::sync_with_stdio(0); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ans; scanf( %d %d , &a, &b); for (ans = 0; a > 0 && b > 0; ans++) { if (a > b) swap(a, b); if (b == 1) break; a++, b -= 2; } printf( %d n , ans); return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int add(int a, int b) { long long x = a + b; if (x >= 998244353) x -= 998244353; if (x < 0) x += 998244353; return x; } long long mul(long long a, long long b) { return (a * b) % 998244353; } long long pw(long long a, l... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 + 2; int main() { int n, m; cin >> n >> m; int ind = 0; int x[3], y[3]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char s; cin >> s; if (s == * ) { x[ind] = i; ... |
#include <bits/stdc++.h> using namespace std; string s; int main() { long long n, x, y, br = 0, k = 0; cin >> n >> x >> y; cin >> s; for (long i = 0; i < n; i++) { if (s[i] == 0 ) { if (i == 0) { br++; } else if (s[i - 1] != 0 ) { br++; } }... |
#include <bits/stdc++.h> using namespace std; int n, m, a, b, v[2100][2100]; int k, d[2100][2100], x, y; bool solve(int x, int y, int k) { int l = max(1, x - k), r = min(x + k, n), t; for (int i = l; i <= r; i++) { t = k - abs(i - x); if (y - t > 0 && !v[i][y - t]) { a = i; b... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 1) + (x << 3) + c - 0 ; c = getchar(); } return x ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long int num, ans = INT_MAX, temp, multi1 = INT_MAX, multi2 = INT_MAX; cin >> num; for (long long int i = 1; i <= sqrt(num); i++) { if (num % i == 0) { temp = num ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) constexpr auto INF = 9223372036854775807; using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int d[n]; d[0] = a[0]; map<int, int> even, odd; even[d[0]]++; odd[0]++; long long int c = 0; for (int i = 1; i < n; i++) { d[i] = a[i] ^ d[... |
#include <bits/stdc++.h> using namespace std; int main() { double n; cin >> n; double sum = 0, y; for (int i = 0; i < n; i++) { cin >> y >> y; sum += y; } sum = sum / n; cout << sum + 5 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int i, t, m, n; cin >> t; int arr[t]; for (i = 0; i < t; i++) { int sum = 0, k = 0; cin >> n >> m; int arr1[n]; for (int j = 0; j < n; j++) { cin >> arr1[j]; if (j != 0) sum += arr1[j]; } k... |
#include <bits/stdc++.h> using namespace std; vector<long long int> small; vector<long long int> large; long long int largest(long long int digits, long long int sum) { long long int i; if (digits == 0) return sum; for (i = 9; i >= 0; i--) { if (sum >= i) { large.push_back(i); ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, m, k; long long mpow(long long b, long long e) { if (e == 0) return 1; if (e == 1) return b % MOD; long long tmp = mpow(b, e / 2) % MOD; tmp = tmp * tmp % MOD; if (e % 2) tmp = tmp * (b % MOD) % MOD; ... |
#include <bits/stdc++.h> using namespace std; int segtree[4 * ((24 * 3600) + 100)], lazy[4 * ((24 * 3600) + 100)]; void propagate(int root, int l, int r) { segtree[root] += lazy[root]; if (l != r) { lazy[2 * root + 1] += lazy[root]; lazy[2 * root + 2] += lazy[root]; } lazy[root] = 0; ... |
#include <bits/stdc++.h> using namespace std; void Read(int &x) { char c; while (c = getchar(), c != EOF) if (c >= 0 && c <= 9 ) { x = c - 0 ; while (c = getchar(), c >= 0 && c <= 9 ) x = x * 10 + c - 0 ; ungetc(c, stdin); return; } } int m, n, a[10000... |
#include <bits/stdc++.h> using namespace std; bool isp[300005]; void sv() { long long i, j; memset(isp, true, sizeof(isp)); isp[1] = false; for (i = 2; i * i < 300005; i++) { if (isp[i]) { for (j = i * i; j < 300005; j += i) isp[j] = false; } } } long long powr(long lon... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 1e6 + 5; const int K = (1 << 17) + 10; const long long int INF = 2e18 + 500; const int inf = 0x7fffffff; const int SQRT = 500; const int lgN = 20; int main(int argc, char const *argv[]) { cin.sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; long long a[31]; int main() { long long t, n; long long q = 0; cin >> t; for (int i = 0; i <= 29; i++) { a[i] = pow(2, i); } for (int i = 1; i <= t; i++) { cin >> n; if (n % 2 == 0) { q = (n + 1) * (n / 2); } els... |
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void solve() { long long int n; cin >> n; vector<long long int> v(n); vector<long long int> cnt(2 * n + 1, 0); for (long long int i = 0; i < (n); i++) { cin >> v[i]; cnt[v[i]]++; } vector<long long i... |
#include <bits/stdc++.h> const int N = 1 << 20; int n, m, lim; char s[22][100005]; int64_t a[N], b[N]; void fwt(int64_t* a, int f) { for (int i = 1; i < lim; i <<= 1) for (int j = 0; j < lim; j += i << 1) for (int k = 0; k < i; ++k) { int64_t x = a[j + k], y = a[j + k + i]; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n; int a[maxn]; int p; double dp[maxn][maxn]; double release(int x) { double res = 1; for (register double i = x + 1; i <= n; i++) { res *= (i - x); res /= i; } return res; } signed main() { scanf( ... |
#include <bits/stdc++.h> using namespace std; struct node { int l, r, id; bool operator<(const node& nd) const { return l == nd.l ? r > nd.r : l < nd.l; } } a[300010]; int main() { int n; scanf( %d , &n); for (int i = (0); i < (n); ++i) { scanf( %d%d , &a[i].l, &a[i].r); ... |
#include <bits/stdc++.h> int perm[100010 + 1]; using namespace std; int main() { int n; cin >> n; int s = 1; int e = n; while (e - s > 0) { perm[s] = s + 1; perm[s + 1] = e; perm[e] = e - 1; perm[e - 1] = s; s += 2; e -= 2; } if (s == e) perm[s] = s;... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, cnt, head[N], vis[N], in[N], u, v, ans, op[N]; int idx, dfn[N], g[N], f[N]; struct edge { int v, nxt; } e[N]; void add(int u, int v) { e[++cnt] = (edge){v, head[u]}; head[u] = cnt; } int dfs(int u) { vis[u] ... |
#include <bits/stdc++.h> using namespace std; const int N = 122; string s[N]; bool eq[N]; vector<int> g[30]; int used[N]; string ans; void dfs(int x) { used[x] = 1; for (int to : g[x]) { if (!used[to]) { dfs(to); } else if (used[to] == 1) { puts( Impossible ); ... |
#include <bits/stdc++.h> using namespace std; int p1, p2, p3, p4, a, b; int fun(int x) { return x % p1 % p2 % p3 % p4; } int main() { while (~scanf( %d%d%d%d%d%d , &p1, &p2, &p3, &p4, &a, &b)) { int cnt = 0; for (int i = a; i <= b; i++) { if (fun(i) == i) cnt++; } printf( %d ... |
#include <bits/stdc++.h> using namespace std; void main2() { long long int n, m, sum = 0, t = INT_MAX, temp, r = 0; cin >> n >> m; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < m; j++) { cin >> temp; if (temp < 0) r++; sum += abs(temp); t = m... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; if ((n - 2) % 3 == 0) { cout << 1 << << 2 << << n - 3 << endl; } else { cout << 1 << << 1 << << n - 2 << endl; ... |
#include <bits/stdc++.h> using namespace std; vector<long long int> lucky; long long int l, r; void gen(long long int a) { if (a <= 1e11) lucky.push_back(a); if (a * 10 + 4 <= 1e11) gen(a * 10 + 4); if (a * 10 + 7 <= 1e11) gen(a * 10 + 7); } void solve() { cin >> l >> r; gen(4); gen(... |
#include <bits/stdc++.h> using namespace std; int N, S, M, K; int A[2020], B[2020]; int L[2020], R[2020]; vector<int> V; int MR[2020]; int dp[1600][1600]; int ok(int v) { int i, j; for (i = 0; i < (N); i++) B[i + 1] = B[i] + (A[i] <= v); memset(dp, 0, sizeof(dp)); for (i = 0; i < (N); i+... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x7fffffff; const int maxn = 2e5 + 5; int bit[2][maxn], num[maxn]; int n, k, a, b, q; void update(int id, int x, int v) { while (x <= n) { bit[id][x] += v; x += (x & -x); } } int sum(int id, int x) { int ans = 0; w... |
#include <bits/stdc++.h> using namespace std; long long a[100005], c[100005]; int main() { long long n; cin >> n; for (long long i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { c[i] = c[i - 1] + 20; long long x = upper_bound(a + 1, a + 1 + n, a[i] - 90) - ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7; int n; char s[N][10]; int val[N]; int l[N], r[N]; set<int> st[N]; void go(int u, int v) { if (st[v].size() > st[u].size()) { st[u].swap(st[v]); } for (int x : st[v]) st[u].insert(x); ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool smin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const long long N = 3e5 + 10; long long n, bad[N], m; vector<long ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int arr[maxn]; int main() { int n; scanf( %d , &n); int pos = n; cout << 1 << endl; for (int i = 1; i <= n; i++) { int tmp; scanf( %d , &tmp); arr[tmp] = 1; while (arr[pos]) pos--; printf( ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long pw(long long a, long long b, long long p) { if (b == 0) return 1; long long t = pw(a, b / 2, p); if (b % 2) return ((a * t * t) % p); else... |
#include <bits/stdc++.h> using namespace std; int t, n, k; char a[5][500]; bool vis[5][500], check; bool valid(int x, int y) { if (x < 0 || x > 2 || vis[x][y]) return 0; return 1; } void dfs(int x, int y, int tm) { if (!valid(x, y) || check) return; if (a[x][y + 2 * tm] != . ) return; ... |
#include <bits/stdc++.h> #pragma hdrstop using namespace std; void rot(int n, int *x, int *y, int rx, int ry); int xy2d(int n, int x, int y) { int rx, ry, s, d = 0; for (s = n / 2; s > 0; s /= 2) { rx = (x & s) > 0; ry = (y & s) > 0; d += s * s * ((3 * rx) ^ ry); rot(s, &x, &y, r... |
#include <bits/stdc++.h> using namespace std; void Read(int &p) { p = 0; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) ; for (; c >= 0 && c <= 9 ; c = getchar()) p = p * 10 + c - 0 ; } int n, k; struct Node { long long siz; int mxx[12], mnn[12]; bool opera... |
#include <bits/stdc++.h> using namespace std; int n, ind, mini(1000000000); int t[11]; string ans = ; char chr(int x) { return char( 0 + x); } int main() { cin >> n; for (int i = 1; i < 10; i++) { cin >> t[i]; if (t[i] <= mini) { mini = t[i]; ind = i; } } ... |
#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 = 500000 + 10; int arr[nax], color[nax]; vector<int> graph[nax]; map<int, set<int> > map1; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m... |
#include <bits/stdc++.h> using namespace std; const int M = 200001; const long long int MOD = 1000000007; long long int N = 1, c[M], i, j, N2, m; bool flag; int main() { cin >> m; fill(c, c + M, 1); while (m--) { int p; cin >> p; c[p]++; N *= p, N %= MOD; } for (i... |
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> mp; int x[2005], y[2005]; int main() { int n, ans = 0; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d %d , x + i, y + i); for (int j = 0; j < i; j++) ans += mp[{x[i] + x[j], y[i] + y[j]}]++; } printf... |
#include <bits/stdc++.h> using namespace std; int n, m, T, fa[500005], top, st[500005 << 2], d[500005], a[500005]; struct E { int x, y, l, r; } e[500005]; int Getfa(int x) { while (fa[x] != x) x = fa[x]; return x; } int col(int x) { int now = 0; while (fa[x] != x) now ^= a[x], x = fa[x... |
#include <bits/stdc++.h> using namespace std; int n, m; char s[100010]; int main() { cin >> n >> m; scanf( %s , s + 1); while (m--) { int l, r; cin >> l >> r; char a[2], b[2]; scanf( %s%s , a, b); for (int i = l; i <= r; i++) if (s[i] == a[0]) s[i] = b[0]; }... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; bool vis[N][N]; int n, ai, aj; bool can(int i, int j) { if (ai == i || aj == j || i + j == ai + aj || i - j == ai - aj) return 0; return (i <= n && i >= 1 && j <= n && j >= 1); } int bi, bj, ci, cj; int di[] = {0, 0, 1, 1, 1, -1, ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long int> v; long long int n, num, max_ind = 0, max_num = -1; cin >> n; for (long long int i = 0; i < n; i++) { cin >> num; v.push_back(num); if (num > max_num) { max_num = num; max_ind = i; ... |
#include <bits/stdc++.h> using namespace std; template <class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os << ( << v.first << , << v.second << ) ; } template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { os << [ ; for (int i = int(0); i ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:536870912 ) #pragma warning(disable : 4996) using namespace std; const int N = 305; int dp[N * 2][N][N], ar[N][N]; int n; pair<int, int> getC(int t, int i) { return t <= n - 1 ? make_pair(t - i, i) : make_pair(n - 1 - i, t - n + 1 + i); } in... |
#include <bits/stdc++.h> struct node { int* children; node() { children = new int[2]; children[0] = children[1] = -1; } int& operator[](int i) { return children[i]; } }; struct trie { std::vector<node> nodes; int root; trie() { nodes.push_back(node()); root = 0;... |
#include <bits/stdc++.h> using namespace std; multiset<int> maxH, maxV; set<pair<int, int> > vH, vV; int main() { int w, h, n, x; std::set<pair<int, int> >::iterator it, itL, itR; char ch; cin >> w >> h >> n; vH.insert(make_pair(0, h)); vH.insert(make_pair(h, 0)); vV.insert(make_pair... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, t; cin >> n >> k >> t; if (t <= k) cout << t << endl; else if (t > k && t <= n) cout << k << endl; else cout << k - (t - n) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; const int MAXN = 900; const int MAXM = 1900000; int N, edges; int last[MAXN], preve[MAXM], head[MAXM]; int Cap[MAXM], Flow[MAXM]; int dist[MAXN]; int nextEdge[MAXN]; queue<int> Q; void init(int N) { edges = 0; memset(last, ... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 100500; int n, x, y, a, b, T... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> add_pair(pair<long long, long long> a, pair<long long, long long> b) { return make_pair(a.first + b.first, a.second + b.second); } long long power(long long a, long long b) { long long res = 1;... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int add(int a, int b) { long long x = a + b; if (x >= 1000000009) x -= 1000000009; if (x < 0) x += 1000000009; return x; } long long mul(long long a, long long b) { return (a * b) % 1000000009; } long long pw(long long ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x; cin >> n; long long b = n, i(0), c(0); for (int i = n + 1;; i++) { b = i; if (b < 0) b *= -1; while (b != 0) { x = b % 10; if (x == 8) { c = 1; break; } b ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e10; long long s[300005]; int main() { int T; long long n, k; scanf( %d , &T); while (T--) { scanf( %lld %lld , &n, &k); for (long long i = 1; i <= n; i++) scanf( %lld n , &s[i]); long long ans = inf, v; ... |
#include <bits/stdc++.h> using namespace std; long long deal(long long x, long long y) { int a = x + y; return (x + 1) * x * (y + 1) / 2 + y * (y + 1) / 2 * (x + 1); } long long max(long long a, long long b) { return a > b ? a : b; } int main() { long long m, b; long long ans = -1; scanf( ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; template <typename T> bool chmax(T &x, const T &y) { return (x < y) ? (x = y, true) : false; } template <typename T> b... |
#include <bits/stdc++.h> using namespace std; const int N = 101; int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}; const int sz = sizeof(prime) / sizeof(int), V = 58; int pos[V + 1], dp[N][1 << sz], n, A[N], minPrime[V + 1], trace[N][1 << sz]; void prepare() { for (int i = 2; i... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 3; struct node { int nonzero, val; void merge(node &n1, node &n2, int range) { if (val) nonzero = range; else nonzero = n1.nonzero + n2.nonzero; } void update(int x) { val += x; } } tree[7 * MAX]; v... |
#include <bits/stdc++.h> using namespace std; int pri[100003], top, n; bool ntp[100002]; struct node { int a, b; bool operator<(const node &rhs) const { return b > rhs.b; } }; void euler() { for (int i = 2; i <= 100000; ++i) { if (!ntp[i]) pri[top++] = i; for (int j = 0; j < top && p... |
#include <bits/stdc++.h> using namespace std; template <typename T> using min_queue = priority_queue<T, vector<T>, greater<T>>; const long long MOD = 1e9 + 7; vector<int> g[1010]; long long edg[1010][1010]; map<pair<int, int>, long long> res; int leaf[1010]; int N; void dfs(int v, int p) { leaf[... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 150010; const int INF = 2147483600... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int N = 505; int sign(double x) { return (x > eps) - (x < -eps); } int n; struct P { double x, y; P(double a = 0., double b = 0.) : x(a), y(b) {} P operator+(const P& a) const { return P(x + a.x, y + a.y); } P opera... |
#include <bits/stdc++.h> using namespace std; int arr[10][10]; bool CheckArr(const string& s) { const int n = s.length(); for (int a = 0; a < (10); ++a) { if (arr[a][0] == 0) continue; char c = s[arr[a][0] - 1]; for (int i = 0; i < (10); ++i) { if (arr[a][i] == 0) break; ... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, i = 1, s, p, q; cin >> x >> y; s = x % 10; q = s; p = s; while (p % 10 != 0 || p != y) { if (p % 10 == 0 || p == y) { break; } i++; q = q + s; p = q % 10; } cout << i; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long SIZE = 100000; const int INF = 0x3f3f3f3f; const long long ll_INF = 0x3f3f3f3f3f3f3f3f; const long double PI = acos(-1); const long long MAXN = numeric_limits<long long>::max(); const long long MAX = 2000000; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.