func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int a[105]; int n, k; char s[105]; int main(void) { int i, j, x, y, z; scanf( %d %d , &n, &k); scanf( %s , s); x = 0; for (i = 0; i < s[i]; i++) { a[x++] = s[i] - a + 1; } sort(a, a + n); x = 1; y = a[0]; z = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k = 0, k1 = 0, kol1 = 0, kol2 = 0; cin >> n >> m; int a[n + 10], b[m + 10]; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] % 2 == 1) k++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, a, b, x, y, flag = 0; cin >> n >> a >> x >> b >> y; int in = 0; for (int i = 0; i < n; i++) { a = a % n + 1; b = b - 1; if (b == 0) b = n; if (a == b) { ... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[301]; int l[301], r[301]; void INPUT() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> l[i] >> r[i]; } void SOLVE() { int res = 0; int ans[301], tam[301]; int sl = 0; in... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500010; bool f[MAXN]; int main() { int n, d; scanf( %d %d , &n, &d); f[0] = 1; for (int i = 0; i < n; i++) { int x; scanf( %d , &x); for (int j = MAXN - 1 - x; j >= 0; --j) f[j + x] |= f[j]; } int r = 1, sum... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 7; long long a[N]; long long l[N]; long long r[N]; int32_t main() { long long ans = 0, n, i; for (i = 1, scanf( %I64d , &n); i <= n; scanf( %I64d , &a[i++])) ; for (i = 1; i <= n; l[i] = r[i] = i, i++) ; for ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, inv2 = (mod + 1) / 2; const int N = (1 << 24); int n, m, X, Y, Z, mu, v1, v2, v3, v4, inv; vector<int> a, b, c, ans; inline int add(const int &x, const int &y) { return x + y < mod ? x + y : x + y - mod; } inline int sub(const ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; int fans = 1; long long getnum(long long x) { long long fx, fy; if (x >= (n - k + 1)) { fx = (n - k + 1 + 1) * (n - k + 1) / 2 + (x - (n - k + 1)) * (n - k + 1); } else { fx = (x - 1 + 1) * (x - 1) / 2 + (n - k + 1); } ... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { char ch[106][106]; scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> ch[i][j]; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (ch[i][j] == C || ch[i][j] == M... |
#include <bits/stdc++.h> using namespace std; int n, m; int cnt[2][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; cnt[0][x % 2]++; } for (int i = 1; i <= m; i++) { int x; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 10; int ans[maxn]; bool build(int l, int r, int base, int top, int sum) { if (l > r) return true; int len = r - l + 1; int tmp = len * base; if (tmp > sum) return false; if (tmp == sum) { for (int i = l; i <= r; ++i)... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 2000000000000000000; long long int MOD(long long int a, long long int b) { if (a > b) return a - b; else return b - a; } long long int max3(long long int a, long long int b, long long int c) { return max(c, max(a, ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const long long mod = 1e9 + 7; const int inf = 1 << 30; const int maxn = 900500; const double EPS = 1e-7; struct da { int x, ty; double p; bool operator<(const da& ot) const { return (make_pair(x, make_pair(ty, p)) < ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int t; cin >> t; while (t--) { int len; cin >> len; string s1, s2; cin >> s1 >> s2; int cnt1 = 0, cnt2 = 0; if (s1[0] > 2 ) { cnt1++; if (s2[0] <= 2 ) { puts( ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const long long N = 3e5 + 7; const long long MOD = 1e9 + 7; long long pw(long long b, long long p) { b %= MOD; long long res = 1; while (p > 0) { if (p & 1) res = res * b % MOD; b = b * b % MOD; p >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> struct number_iterator : iterator<random_access_iterator_tag, T> { T v; number_iterator(T _v) : v(_v) {} operator T &() { return v; } T operator*() const { return v; } }; template <typename T> struct number_range { T b, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int k; cin >> k; int n = 2000; k += n; int arr[n]; arr[0] = -1; for (int i = 1; i < 2000; i++) { if (k >= 1000000) arr[i]... |
#include <bits/stdc++.h> int ___read_tmp; using namespace std; int fwt[1010000]; int query(int sz) { int sum = 0; sz++; while (sz > 0) { sum += fwt[sz]; sz -= sz & (-sz); } return sum; } void upd(int id, int add) { id++; for (; id < 1010000; id += (id & (-id))) { ... |
#include <bits/stdc++.h> long long mod = 1000000007; using namespace std; int n; int b1[200005]; struct node { int x, y; }; bool cmp(node a, node b) { return a.y - a.x > b.y - b.x; } node a1[200005]; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b ... |
#include <bits/stdc++.h> using namespace std; int f[100010], r[2][100010]; vector<int> mat[2][100010]; void DFS(int a, int x) { r[x][a] = 1; if (x == 1 && f[a] == 1) return; for (int i = 0; i < mat[x][a].size(); i++) { int b = mat[x][a][i]; if (!r[x][b]) DFS(b, x); } } int main()... |
#include <bits/stdc++.h> using namespace std; long long good[3000]; long long fact[20]; int q = 0; void gen(long long sum, int left) { if (!left) { good[q++] = sum; } else { if (!sum) { gen(sum, left - 1); } gen(sum * 10 + 4, left - 1); gen(sum * 10 + 7, left - 1)... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; long long int ans = 0; long long int t = 1; long long int x = 2; while (n - (t * (t + 1) / 2) >= 0) { long long int val = t * (t + 1) / 2; n -= val; t += x; x *= 2; ans++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, M = 1e5 + 5, P = 105; int n, m, p; long long d[N]; int h[M], t[M]; long long a[M], s[M]; long long f[P][M]; int q[M]; long long Y(int j, int k) { return f[j - 1][k] + s[k]; } int32_t main() { cin >> n >> m >> p; for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, count[8] = {0}; cin >> n; for (int i = 0; i < n; i++) { cin >> x; count[x] = count[x] + 1; } if ((count[5] == 0) && (count[7] == 0) && (count[2] >= count[4]) && (count[1] == count[4] + count[6]) && (... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int grid[n][n]; int nro = 1; for (int i = 0; i < n; i++) { if (!(i & 1)) for (int j = 0; j < n; j++) grid[j][i] = nro++; else for (int j = 0; j < n; j++) grid[n - 1 - j][i] = nro++; } ... |
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3; const double eps = 1e-8; int n; struct point { double x, y, z; } p[maxn], pp; double dis(point a, point b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z); } double get(dou... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9, I = 1e18; const int mxn = 1e5; int t, n; string s, pr, ans; bool fl; void solve() { fl = 0; ans = ; cin >> n; cin >> pr; ans = pr; for (int i = 1; i < n - 2; i++) { cin >> s; if (pr[1] != s[0]) { ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:64000000 ) template <class T> inline T sqr(T x) { return x * x; } int n, k; int a[1 << 17]; map<int, int> d; set<pair<int, int> > s; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; ++i) scanf( %d , &... |
#include <bits/stdc++.h> using namespace std; namespace IO { static char buf[1 << 20], *fs, *ft; inline char gc() { if (fs == ft) { ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin); if (fs == ft) return EOF; } return *fs++; } inline int read() { int x = 0, f = 1; char s = getc... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200010; const long long MOD = (int)1e9 + 7; const int INF = 1e9; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const long double EPS = 1e-8; int r, g, h, total; inline int add(int a, int b) { return (a + b) % MOD; } int32_t main() { ios_b... |
#include <bits/stdc++.h> using namespace std; bool check(int x1, int y1, int r1, int x2, int y2, int r2, int R2) { int l = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); int rr1 = (r1 - r2) * (r1 - r2); int rr2 = (r1 + r2) * (r1 + r2); int RR1 = (r1 - R2) * (r1 - R2); int RR2 = (r1 + R2) * (r1 +... |
#include <bits/stdc++.h> int ex[] = {1, -1, 0, 0}; int wye[] = {0, 0, 1, -1}; using namespace std; vector<int> vt[10005]; bool visit[10005]; int n, x, y, an; void dfs(int node) { if (visit[node]) return; visit[node] = true; int siz = vt[node].size(); int tmp; for (int i = 0; i < siz; i... |
#include <bits/stdc++.h> using namespace std; constexpr long long inf = 1e9 + 7, base = 541; constexpr long long mod = 1e9 + 7, N = 1e6 + 7; struct piii { long long sm = 0, an = 0, cn = 0; }; long long n; long long v[N]; long long sum[4 * N], ans[4 * N]; piii calc(piii x, piii y) { x.an += y.a... |
#include <bits/stdc++.h> using namespace std; int a[1000006], n, v[1000006], t[1000006]; void uma(int x) { int i; for (i = 0; i < n; i++) v[i] = i; for (; x; x >>= 1) { if (x & 1) { for (i = 0; i < n; i++) v[i] = a[v[i]]; } for (i = 0; i < n; i++) t[i] = a[a[i]]; for (i... |
#include <bits/stdc++.h> using namespace std; long long dp[31][31]; long long solve(int n, int r) { if (n == r || r == 0) return 1; if (n < r) return 0; if (dp[n][r] != -1) { return dp[n][r]; } return dp[n][r] = solve(n - 1, r - 1) + solve(n - 1, r); } int main() { int t = 1; ... |
#include <bits/stdc++.h> using namespace std; long long r = 1000000009; int main() { long long m, n, k; cin >> n >> m >> k; long long d = n % k; d += (n / k) * (k - 1); if (m <= d) { cout << m % r; return 0; } int s = m - d; long long sc = (m - s * k) % r; long long... |
#include<bits/stdc++.h> using namespace std; const int maxn=1e2+5; int t,n,m; int f[maxn<<1]; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cin>>t; while(t--){ memset(f,0,sizeof(f)); cin>>n>>m; for(int i=1;i<=n;++i){ for(in... |
#include <bits/stdc++.h> using namespace std; int n, m, q, dfn[200005], low[200005], ibcc[200005], dfncnt, bcccnt; vector<pair<int, int>> g[200005]; vector<int> ng[200005]; int st[200005], stcnt; void getbcc(int x, int pe) { dfn[x] = low[x] = ++dfncnt; st[stcnt++] = x; for (pair<int, int> &e : g... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int otg = 1 << 30, i; for (i = 0; i < m; i++) { int l, r; cin >> l >> r; if (r - l + 1 < otg) otg = r - l + 1; } cout << otg << endl; for (i = 0; i < n; i++) cout << i % otg << ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 300005, mod = 998244353; int qp(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = 1ll * ans * a % mod; a = 1ll * a * a % mod; b >>= 1; } return ans; } int rv[N], w[N]; void ntt(vector<int> &a, int f) { ... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 2e5 + 13, mod = 1e9 + 7; long long r, g, odp[maxN], ans; bool can(long long x) { if (x * (x + 1) / 2 <= r + g) return 1; return 0; } int32_t main() { cin >> r >> g; long long lf = 0, rg = max(r, g) + 1; while (rg - lf >... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2>& p) { out << { << p.first << , << p.second << } ; return out; } template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& p) { in >> p.... |
#include <bits/stdc++.h> using namespace std; const long long Mod = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; a %= Mod; for (; b; b >>= 1) { if (b & 1) res = res * a % Mod; a = a * a % Mod; } return res; } long long gcd(long long a, long long b) {... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, d, l1, r1, l2, r2, k; while (cin >> l1 >> r1 >> l2 >> r2 >> k) { if (l2 > r1) cout << 0 << endl; else if (l1 > r2) cout << 0 << endl; else { long long int ans = 0; if (l2 >= l1... |
#include <bits/stdc++.h> using namespace std; bool ok(double a, double b) { if (a - b >= 0) return true; else return false; } double a, b; double calc(double x) { int l = 1; int r = 1000000000; while (l < r) { int m = (l + r) / 2 + 1; if (ok(x / ((double)m * 2.0), b... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long TESTS = 1; while (TESTS--) { long long n, x, y; cin >> n >> x >> y; string s; cin >> s; long long cnt = 0; char c = s[0]; f... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; int a[1005][505]; vector<int> pos[505][505]; bool removed[505]; void remove1(int x, int n, int layerNum = 0){ if(removed[x]){return;} removed[x] = true; vector<int> toRemove; for(int j = 1; j <... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 400010; const long long mod = 1000000007; const long double eps = 1e-9; const long long inf = ((1ll << 31ll) - 1ll); const long long INF = 2000000000000000000ll; const long double pi = acos(-1); long long qpow(long long b, long long e)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { vector<int> a(3); cin >> a[0] >> a[1] >> a[2]; sort(a.begin(), a.end()); int v = a[0]; int d = min(v, a[2] - a[1]); int ans = d; a[0] -= d; a[2] -= d; d = a[0] ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int cases; cin >> cases; while (cases--) { int length, target; cin >> length >> target; vector<vector<int>> BGR(3, vector<int>(length, 0)); string inp; cin >> inp; for (size_t i = 0... |
#include <bits/stdc++.h> using namespace std; const int INFint = 2147483647; const long long INF = 9223372036854775807ll; const long long MOD = 1000000007ll; char f[2020][2020]; int n, m; bool c(int x, int y, int d, int cnt) { int cur = 0; cerr << x << << y << endl; if (x > 0 && y > 0 && x... |
#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 count1 = 0; for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; j < n; j++) { if (i == j) { continue; ... |
#include <bits/stdc++.h> using namespace std; int sgn(double x) { return (x > 1e-8) - (x < -1e-8); } int count_bit(int x) { return x == 0 ? 0 : count_bit(x >> 1) + (x & 1); } template <class T> inline void ckmin(T& a, const T b) { if (b < a) a = b; } template <class T> inline void ckmax(T& a, const ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int c1 = 0, c2 = 0; for (int i = 0; i < n; ++i) { int aux; cin >> aux; c1 += aux == 1; c2 += aux == -1; } for (int i = 0; i < m; ++i) { ... |
#include <bits/stdc++.h> int main() { char s[15]; char a; int len; scanf( %s , s); len = strlen(s); a = a - 1; for (int i = 0; i < len; i++) { if (a <= s[i]) { a = s[i]; } } for (int i = 0; i < len; i++) { if (s[i] == a) printf( %c , s[i]); } ret... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 239; const int inf = (int)1e9 + 1; const long long big = (long long)1e18 + 1; const int P = 31; const int MOD = (int)1e9 + 7; const int MOD1 = (int)1e9 + 9; const double eps = 1e-9; const double pi = atan2(0, -1); int a[N]; vect... |
//#pragma GCC target ( avx2 ) //#pragma GCC optimization ( O3 ) //#pragma GCC optimization ( unroll-loops ) #include<bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; #define eps 1e-8 #define eq(x,y) (fabs((x)-(y)) < eps) usi... |
#include <bits/stdc++.h> using namespace std; long long mysqrt(long long x) { long long l = 0; long long r = 1; while (r * r <= x) r *= 2; while (r - l > 1) { long long m = (l + r) / 2; if (m * m <= x) l = m; else r = m; } return l; } int main() { lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, mx = 0, i, j, value; cin >> n; vector<int> v(n + 1, 0); for (i = 1; i <= n; i++) { cin >> v[i]; v[i] += v[i - 1]; } for (i = 1; i <= n; i++) { for (j = 0; j < i; j++) { if ((v[i] - v[j]) > (100 * (i -... |
#include <bits/stdc++.h> using namespace std; void solve(); string conc(long long int a, long long int b) { return to_string(a) + | + to_string(b); } long long int rev(long long int x) { long long int ans = 0; while (x != 0) { ans = ans * 10 + (x % 10); x /= 10; } return ans;... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; pair<int, int> calc(int a, int b) { if (a <= b) return {a, 0}; int r = a / b; if (a % b == 0) return {b, r - 1}; return {a / (r + 1), r}; } vector<pair<int, int>> compact(const vector<pair<int, int>>& V) { vector<pair... |
#include<bits/stdc++.h> #define maxn 1000005 #define inf 9999999999999999 #define mod 100003 typedef long long LL; using namespace std; LL a[maxn]; int main() { ios::sync_with_stdio(false); //freopen( bwxnQAQin.txt , r ,stdin); LL T; cin>>T; while(T--) { LL ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long 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(); } r... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int f[N]; void init() { for (int i = 1; i <= N; i++) { f[i] = f[i - 1] + i * 2 + (i - 1); if (f[i] >= 1e9) { break; } } } int Find(int x) { int l = 0, r = 25820; while (l < r) { int mid = (l ... |
#include <bits/stdc++.h> using namespace std; const int inf = ~0ull / 2; const int maxn = 100100; int seen[maxn]; int ind[maxn]; int par[maxn][22]; int bd[maxn]; int h[maxn]; vector<int> adj[maxn]; vector<int> adlist[maxn]; vector<int> tree[maxn]; vector<pair<int, int> > edges; void dfs1(int r... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; double dp[maxn], p[maxn]; int main() { int n; scanf( %d , &n); double ans = 0, d; for (int i = 1; i <= n; i++) { scanf( %lf , &p[i]); ans += p[i]; } for (int i = 2; i <= n; i++) { dp[i] = (dp[i - 1]... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char c = getchar(); bool p = 1; for (; !isdigit(c); c = getchar()) if (c == - ) p = 0; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return p ? x : -x; } const int N = 1000105; s... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; long long a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; long long v, x, add = 0, y, q; int t; w... |
#include <bits/stdc++.h> using namespace std; double areaa(int x1, int x2, int x3, int y1, int y2, int y3); int gcd(int x, int y); int lcm(int x, int y); int egcd(int a, int b, int& x, int& y); vector<int> prime_possible_factors(int n); vector<int> primes_included(int n, int m); map<int, int> factor(int... |
#include <bits/stdc++.h> using namespace std; string s, t, tmp1, tmp2; vector<int> ans; int cnt, n; int main() { cin >> n; cin >> s >> t; tmp1 = s, tmp2 = t; sort(tmp1.begin(), tmp1.end()); sort(tmp2.begin(), tmp2.end()); if (tmp1 != tmp2) return cout << -1, 0; if (s[0] == t[n - 1]... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; int a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < (int)n; i++) cin >> a[i], b[i + 1] += b[i] + a[i]; int t = 0; for (int i = 0; i < (int)n; ... |
#include <bits/stdc++.h> using namespace std; int MIN(int a, int b) { return a < b ? a : b; }; int MAX(int a, int b) { return a > b ? a : b; }; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int n, m, q; int h; int a[20] = {2, 4, 3, 9, 5, 25, 7, 49, ... |
#include <bits/stdc++.h> using namespace std; int n, m; struct edge { int from; int to; int next; } E[500005 << 1]; int head[100005]; int deg[100005]; int tmp[500005]; int used[500005 << 1]; int size = 1; void add_edge(int u, int v) { size++; E[size].from = u; E[size].to = v;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1123456; const int MAXINT = 2147483098; const long long MAXLL = 9223372036854775258LL; set<pair<int, int> > s; int ans[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d, pos = 0, mx = 0; cin >> n >> m >>... |
#include <bits/stdc++.h> char s[200005]; using namespace std; int main() { int n, k; cin >> n >> k; getchar(); cin >> s; int maxn1 = 0; for (int i = 0; i < 26; i++) { char t = a + i; int sum1 = 0; int maxn = 0; for (int j = 0; j < n; j++) { if (s[j] == t &... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; vector<int> G[maxn]; int n, k; int u, v; int siz[maxn], dep[maxn]; int val[maxn], fa[maxn]; void dfs(int x, int d) { dep[x] = d; siz[x] = 1; for (int i = 0; i < G[x].size(); ++i) { int to = G[x][i]; if (to == ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; pair<long long, long long> a[n]; for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n); queue<long long> q; set<long long> s; bool turn = true;... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; vector<pair<string, int>> a(n); int c = 1; for (auto &t : a) { cin >> t.first; t.second = c++; } for (auto &t : a) { for (int i = 1; i < m; i += 2) { t.first[i] = z - t.first... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; double dfs(int i, int ult) { double ans = 0; int c = g[i].size() - (i != 1); for (int j = 0; j < g[i].size(); j++) { if (g[i][j] != ult) { ans += (dfs(g[i][j], i) + 1.0) / c; } } return ans; } int main... |
#include <bits/stdc++.h> using namespace std; const long long MXN = 2e5 + 10; const long long LOG = 21; const long long MXM = (1LL << LOG); const long long INF = 1e9; int n, m, ans; int dp[MXN], ps[MXN], Best[LOG][MXM]; string S[MXN]; int Cost(int i, int j) { for (int x = m; x; x--) { if (S[... |
#include <bits/stdc++.h> using namespace std; vector<int> idb[100002]; int dp[301]; int main() { int n, m, s, e; cin >> n >> m >> s >> e; vector<int> a(n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 0; i < m; i++) { int b; scanf( %d , &b); idb[b].push_back... |
#include <bits/stdc++.h> using namespace std; int n, K, a[100100], f[30030][205][4][2]; bool vis[30030][205][4][2]; void work() { memset(f, -127, sizeof(f)); for (int i = 1; i <= n; i++) { f[i][1][0][0] = -a[i]; f[i][1][2][0] = a[i]; vis[i][1][0][0] = 1; vis[i][1][2][0] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5; int T, n, m, k, f[N + 5], ans[N + 5]; struct People { int a, r, d, u, id; } p[N + 5]; struct Info { int opt, l, r; Info() {} Info(int opt, int l, int r) : opt(opt), l(l), r(r) {} }; template <int MAX> struct BIT { sta... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); if ((n / 2) % 2 == 0) { for (int i = 1; i <= n; ++i) { if (i <= n / 2 && i % 2 == 1) { printf( %d , i + 1); } else if (i <= n / 2 && i % 2 == 0) { printf( %d , n - i + 2); ... |
#include <bits/stdc++.h> using namespace std; int n, K, m; set<pair<int, int> > Set; set<int> SS; int O[524288]; struct Tree { int K[524288 + 524288], M[524288 + 524288]; void UDT(int nd) { M[nd] = max(M[nd * 2], M[nd * 2 + 1]); } void init(int nd, int b, int e) { K[nd] = 0; if (b ==... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a[maxn], b[maxn]; bool v[maxn]; int main() { int n; cin >> n; a[0] = -1; for (int i = 1; i <= n; ++i) { cin >> a[i]; v[a[i]] = 1; if (a[i] > a[i - 1]) b[i] = a[i - 1]; else b[i] ... |
#include <bits/stdc++.h> using namespace std; int isTandom(string s, int n) { if (n > s.size() / 2) return 0; for (int i = 0; i < n; i++) if (s[i + n] != && s[i] != s[i + n]) return 0; return 1; } int main() { string s; int k; cin >> s >> k; int len = s.size(); for (int... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, x, y; cin >> n; long long a[n], b[n - 1], c[n - 2]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n - 1; i++) cin >> b[i]; sort(b, b + (n - 1)); for (i = 0; i < n - 2; i++) cin >> c[i]; so... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, x, c, d, ch = 0, caser = 0, lol = 0, sum = 0, rating = -1, upper = 1e9, lower = -1e9; cin >> n; for (int i = 0; i < n; i++) { cin >> c >> d; if (i == 0) { if (d == 1) lower = 1900; ... |
#include <bits/stdc++.h> using namespace std; long long f[6][10010], b = 1; int main() { for (int i = 1; i <= 5; ++i) for (int j = 1; j <= (i == 5 ? 1 : 10000); ++j) { long long now = f[i - 1][j]; for (int k = 1; k <= j; ++k) now += f[i - 1][min(now + j + 1, 10000ll)] + 1; ... |
#include <bits/stdc++.h> using namespace std; bool kjg[100002]; int isi[100002]; long long dp[100002]; vector<int> adlis[100002], radlis[100002]; int rut, nvert, u, v; void ruted(int x) { kjg[x] = 1; for (int i = 0; i < adlis[x].size(); i++) { if (!kjg[adlis[x][i]]) { radlis[x].push_... |
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if ((n % 2) == 0) cout << home ; else cout << contest ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 7, M = 1e9 + 7; vector<int> primes; bool isp[N]; void sieve() { fill(isp, isp + N, 1); isp[0] = isp[1] = 0; for (int i = 2; i * i < N; i++) if (isp[i]) for (int j = i * i; j < N; j += i) isp[j] = 0; for (int i = 2;... |
#include <bits/stdc++.h> using namespace std; vector<int> v[26]; int A[26], m; void solve() { string s; cin >> s; for (int i = 0; i < s.length(); i++) v[s[i] - a ].push_back(i); for (int i = 0; i < 26; i++) { if (s.find(i + a ) != string::npos) { m = v[i][0] + 1; for (int... |
#include <bits/stdc++.h> using namespace std; const int N = 5010, mod = 1LL * 1000 * 1000 * 1000 + 7; long long dp[N][N], inv_fact[N], fact[N], n, k; long long Pow(long long a, long long b) { return b ? (b & 1 ? a : 1) % mod * Pow(a * a % mod, b >> 1) % mod : 1; } int C(int r, int n) { if (r > n) re... |
#include <bits/stdc++.h> using namespace std; int n, k; int haha[105]; int ans = 0; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , &haha[i]); if (haha[i] == 0) break; else if (i < k) ans++; else if (haha[i] == haha[k - 1]) ... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<long long int, int> > pq; vector<pair<int, int> > vp; map<long long int, int> mp, m; const int N = 1e5 + 6; long long int ans[N]; vector<int> v, v1; set<long long int> s, s1; int visit[N]; struct domingo { int val, left, right; ... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long N = 1e5 + 10; const long long INF = 1e9 + 7; vector<long long> fact(N), ifact(N); long long gcd(long long x, long long y) { if (y % x == 0) return x; return gcd(y % x, x); } long long inv(long long x) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.