func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int x; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> x; if (x == 3) { cout << 5 << endl; return 0; } for (int i = 1; i <= 199; i += 2) { int temp = i * i + 1; temp /= 2; ... |
#include <bits/stdc++.h> using namespace std; bool able[105], prime[105], left[105], flag = 0; int least = 1; string tp; bool isPrime(int i) { int to = int(sqrt(double(i) + 1.0)); if (i == 1 || i == 2 || i == 5) return 1; for (int j = 2; j <= to; j++) if (i % j == 0) return 0; return 1; ... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << n ; err(++it, args...); } long long powMod(long long x, long long y) { long lon... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) long long cntx, cnty; int vx[(1000000 + 10)], vy[(1000000 + 10)]; int main() { int n, m; scanf( %d%d , &n, &m); long long ans = (long long)n * n; cntx = n, cnty = n; for (int i = 0; i < m; +... |
#include <bits/stdc++.h> using namespace std; vector<unsigned int> vc; unsigned long long n, T; void LIS(unsigned int ll, unsigned int hh, unsigned long long &len, unsigned long long &offset) { vector<unsigned int> dp_nn; vector<unsigned int> dp_nn_plus_n; dp_nn.resize(ll); dp_nn_plus... |
#include <bits/stdc++.h> using namespace std; vector<int> fail(string s) { int n = s.size(); vector<int> z(n); int l = 0, r = 0; for (int i = 1; i < n; ++i) { if (i <= r) z[i] = min(z[i - l], r - i + 1); while (z[i] + i < n && s[z[i] + i] == s[z[i]]) ++z[i]; if (z[i] + i - 1 > r) {... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); function<long long(long long, long long)> power = [&](long long x, long long y) { if (y == 0) { return 1LL; } else ... |
#include <bits/stdc++.h> using namespace std; char buf[1000][1005]; int main() { int N; scanf( %d , &N); int T[N]; pair<int, int> T2[N]; for (int i = 0; i < (N); i++) { scanf( %d , &T[i]); T2[i].first = T[i]; T2[i].second = i; } sort(T2, T2 + N); if (T2[0].first =... |
#include <bits/stdc++.h> using namespace std; struct ii { int a, b; bool operator<(ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); } }; struct iii { int a, b, c; bool operator<(iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); } }; int TC, N, M, K... |
#include <bits/stdc++.h> using namespace std; int key[300]; int main() { int n, k, x, i; scanf( %d%d , &n, &k); memset(key, -1, sizeof key); while (n--) { scanf( %d , &x); if (key[x] == -1) { for (i = x - 1; i >= 0 && key[i] == -1 && x - i < k; i--) ; if (i >=... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clo... |
#include <bits/stdc++.h> using namespace std; int n; int a[210000]; void work() { int cnt[33]; memset((cnt), (0), sizeof(cnt)); int xorsum = 0; cin >> n; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); xorsum ^= a[i]; for (int j = 0; j <= 30; j++) cnt[j] += (a[i] >> j) & ... |
#include <bits/stdc++.h> using namespace std; const int maxl = 2e5 + 10; int n, m, cnt, tot, cas, ans; int a[maxl], b[maxl], num[maxl * 32]; int ind[maxl * 32], sz[maxl * 32], tr[maxl * 32][2]; bool vis[maxl], pr[maxl]; char s[maxl]; vector<int> e[maxl]; inline void prework() { scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long power(long long n, long long k) { long long ans = 1; while (k) { if (k & 1) ans = (ans * n) % mod; k /= 2; n = (n * n) % mod; } return ans; } int main() { ios_base::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n; cin >> n; vector<long double> probs(n); for (i = 0; i < n; i++) { cin >> probs[i]; } sort(probs.begin(), probs.end()); reverse(probs.begin(), probs.end()); long double prob0 = 1; long double prob1 = ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long inf = 10000000; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline bool isLeapYear(long long year) { return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); } inline void normal(l... |
#include <bits/stdc++.h> using namespace std; long long val; int visid; const int mod = 1e9 + 7; long long dp[60][10005]; long long Inv[100]; int vis[60][10005]; long long fp(long long b, long long p) { if (p == 0) return 1; long long tmp = fp(b, p / 2); if (p % 2) return (((tmp * tmp) % mod... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline T1 max(T1 a, T2 b) { return a < b ? b : a; } template <typename T1, typename T2> inline T1 min(T1 a, T2 b) { return a < b ? a : b; } const char lf = n ; namespace ae86 { const int bufl = 1 << 15; cha... |
#include <bits/stdc++.h> using namespace std; long long dp[114514][16]; int N, M; char s[114514]; long long res; int main() { scanf( %d%d , &N, &M); scanf( %s , &s); dp[0][2] = 1; for (int(i) = 0; (i) < (N); (i)++) for (int(b) = (1); (b) < (16); (b)++) if (dp[i][b]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; char c; bool ch = false; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> c; if (c == C || c == M || c == Y ) { ch = true; break; } }... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { bool flag = false; int sum = 0; while (n) { if (n % 10 == 4 || n % 10 == 7) n /= 10, sum++; else n /= 10; } if ((sum == 4 || sum == 7)) cout <<... |
#include <bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } const long long int N = 100010; long long int cnt[N], f[N]; int main() { fastio(); long long int n, temp; cin >> n; long long int ar[n]; memset(cnt, 0, s... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; bool a[n][n], fin[n][n], line[n]; for (long long i = (0); i < (n); i++) { string s; cin >> s; for (long long j = (0); j < (n); j++) a[i][j] = s[j] == 0 ? 0 : 1; } for (long long i = (0); i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; string s, t; cin >> n; cin >> s >> t; vector<int> vect; for (int i = 0; i < n; i++) { if (s[i] == t[i]) continue; else { int flag = -1; for (int j = i + 1; j < n; j++) { if ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; const int N = 207; const int K = 1007; const long long mod = 1e9 + 7; long long dp[2][N][K]; long long a[N]; int n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) scanf... |
#include <bits/stdc++.h> using namespace std; int arr[3000]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> arr[i]; } int minn = 99999; int maxx = -999; for (int i = 0; i < n - 1; i++) { minn = min(minn, arr[i]); if (arr[i] <= arr[i + 1]) ... |
#include <bits/stdc++.h> using namespace std; int n, k; int d[188]; int par[188]; vector<int> g[188]; int dp[188][188]; int pos[188]; int ans[188]; void build(int x, int pre) { par[x] = pre; for (int i = (0); i < (g[x].size()); ++i) { int to = g[x][i]; if (to == pre) { g[x]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5000 + 10; int main() { int n, k; int a[maxn]; scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int sum = 0; int maxs = 0; double maxa = 0; for (int i = k; i <= n; i++) { for (int j = 0; j < ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else { return (gcd(b, (a % b))); } } int main() { int t; long long n; scanf( %d , &t); for (int i = 1; i <= t; i++) { cin >> n; long long a = (long lo... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int maxn = 100010; int n, m, k, t, t1, t2, t3, t4; struct node { int x, y; int xd, xx, yd, yx; } a[maxn]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); for (int i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; void solve() { pair<int, int> A[50007]; int n; cin >> n; for (int i = 0; i < (n); i++) cin >> A[i].first >> A[i].second; sort(A, A + n); int r1 = A[0].first, r2 = A[0].second; int r3, r4; for (int i = 1; i < n; i++) { if (A[i].first... |
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; if (x % 4 == 0) { cout << 1 A ; } else if (x % 4 == 1) { cout << 0 A ; } else if (x % 4 == 2) { cout << 1 B ; } else if (x % 4 == 3) { cout << 2 A ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long INFLL = 1e18 + 1; const int MAX = 200001; const long long MOD = 1000000007; const int SZ = 300100; const double PI = 3.14159265358979323846264338327; long long inq(long long k, long long q, long long mod) { if (q == 0... |
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f; } ... |
#include <bits/stdc++.h> using namespace std; void setIo(string nom) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((nom + .in ).c_str(), r , stdin); freopen((nom + .out ).c_str(), w , stdout); } struct Reine { int x, y, id; vector<int> tris; int indTri; void init(int i)... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int maxN = 131079; inline int pls(int x, int y) { return (x + y) % mod; } inline int mns(int x, int y) { return pls(x, mod - y); } inline int mul(int x, int y) { return 1LL * x * y % mod; } inline void Add(int &x, int y) { x = ... |
#include <bits/stdc++.h> using namespace std; int n; double a[21][21]; double f[1100000]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %lf , &a[i][j]); f[1] = 1; for (int i = 2; i < (1 << n); i++) { for (int j = 0; j < n; j++) { ... |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int mx = 2e5 + 9; int game[2][mx]; int f_occ[2][mx]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); x--; game[x][i]++; } memset(f_occ, -1, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long n, k, t; cin >> n; string s; cin >> s; int a1 = 0, a2 = 0; int flag1 = 0; int flag2 = 0; while (1) { flag1 = 0; flag2 = 0; for (int i = 0; i < n; i++) { if ... |
#include <bits/stdc++.h> using namespace std; int n, k, p[111], c[111], l[111], bottleneck[111], par[111], cost[111][111]; bitset<200005> prime; vector<vector<int> > vert; int edmondskarp(int s, int t) { int mf = 0; while (1) { memset(bottleneck, 0, sizeof(bottleneck)); bottleneck[s] = 1e9... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int M = 1e7 + 5; int x[N]; int cnt[M]; bool vis[M + 5]; int f[M + 5]; int sum[M + 5]; void erato() { for (int i = 2; i <= M; i++) vis[i] = true; for (int i = 2; i <= M; i++) { if (vis[i]) { f[i] += cnt[i];... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 5005; vector<long long> arr(MAX); long long solve(long long l, long long r, long long cur) { if (l > r) return 0; long long mn = arr[l], idx = l; for (int i = l; i <= r; i++) { if (arr[i] < mn) { mn = arr[i]; i... |
#include <bits/stdc++.h> using namespace std; int main() { int t_; cin >> t_; while (t_--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int turns = 0; int alice = 0; int bob = n - 1; int alice_candies = 0;... |
#include <bits/stdc++.h> using namespace std; struct ee { int x, y, w; }; vector<int> ke[300010], kq; int n, m, s, c[300010] = {0}, p[300010], b[300010]; ee e[300010]; priority_queue<pair<long long, int> > Q; long long d[300010]; void enter() { scanf( %d%d , &n, &m); for (int i = 1; i <= m... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e3 + 10, INF = 1e9 + 10; long long dp[N][2], a[N], n, k; inline bool check(long long x) { for (long long i = 1; i <= n; i++) dp[i][0] = i - 1; for (long long i = 1; i <= n; i++) for (long long j = i - 1; j; --j) { if (a[i] ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; cout << n << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; x *= f; } int mx[40][110][110]; int a[40][... |
#include <bits/stdc++.h> using namespace std; int N, A[100001], BIT[100001], res[100001]; vector<int> v; map<int, int> m; int main() { scanf( %d , &N); for (int i = 1; i <= N; ++i) scanf( %d , &A[i]), v.push_back(A[i]); sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin())... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, m; cin >> n >> k >> m; map<string, int> mp; vector<int> cost(n); for (int i = 0; i < n; ++i) { string str; cin >> str; mp[str] = i; } for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i, j, k, mini = INT_MAX, maxi = 0; cin >> t; while (t--) { mini = INT_MAX; maxi = 0; cin >> n >> k; int a[n]; for (i = 0; i < n; i++) { scanf( %d , &a[i]); mini = min(mini, a[i]); m... |
#include <bits/stdc++.h> using namespace std; struct re { long long x[300300]; long long up[300300]; bool f[300300]; }; int o; re rmq; void f_read() { int i, n, a[100100]; cin >> n; for (i = 0; i < n; ++i) cin >> a[i]; o = 1; memset(rmq.x, 0, sizeof(rmq.x)); memset(rmq.up... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const long long MOD = 1e9 + 7; long long n, x[N], ans, pw[N], dp[N], num[N]; inline long long add(long long a, long long b) { a += b; while (a >= MOD) a -= MOD; return a; } int main() { ios_base::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; char ss[8][5] = { 1869 , 6198 , 1896 , 1689 , 1986 , 1968 , 1698 }; string s; int x, cnt, vis[1000010]; int main() { cin >> s; int len = s.length(); for (register int i = 0; i < len; i++) { if (s[i] == 0 ) cnt++; else if (!vi... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read1() { T t = 0; char k = getchar(); bool flag = 0; while ( 0 > k || k > 9 ) { if (k == - ) flag = 1; k = getchar(); } while ( 0 <= k && k <= 9 ) t = (t << 3) + (t << 1) + (k ^ 48), k = ge... |
#include <bits/stdc++.h> using namespace std; template <class A, class B> A cvt(B x) { stringstream ss; ss << x; A y; ss >> y; return y; } typedef struct { string name; int c; int p[3]; int size; int room; } item; typedef struct { string name; int c; int... |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5, M = 1e9 + 7, I3 = 333333336; int n, m, eu[mxN], ev[mxN], ew[mxN], c2, px[mxN]; vector<int> adj[mxN], c; long long ans = 1, ans2, ca; bool vis[mxN], vis2[mxN]; void dfs(int u, int p) { vis[u] = 1; for (int e : adj[u]) { int v ... |
#include <bits/stdc++.h> using namespace std; struct arr { int l, r, add, cnt, sum[50]; } a[110005 * 4]; int data[110005], i, n, m, opt, L, R; const int P = 95542721; inline int calc(int x) { while (x > 47) x -= 48; return x; } inline void down(int k) { if (!a[k].cnt || a[k].l == a[k].r)... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int _inf = 0xc0c0c0c0; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long _INF = 0xc0c0c0c0c0c0c0c0; const long long mod = (int)1e9 + 7; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long l... |
#include <bits/stdc++.h> using namespace std; const string str = VC ; const int maxn = 300; char s[2]; int l, n, m; char buf[maxn]; int alpha[26]; vector<int> G[maxn * 2]; bool mark[maxn * 2]; int stk[maxn * 2], top; bool dfs(int u) { if (s[u & 1] == 0) return false; if (mark[u ^ 1]) retu... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int n, k, x, sum, a[24], BadPoint[2], dp[(1 << 24)]; int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cin >> k; for (int i = 0; i < k; i++) cin >> ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; int a = 2, b = 3, c = 5, d = 7; int ab = 6, ac = 10, ad = 14, bc = 15, bd = 21, cd = 35; int abc = 30, bcd = 105, abd = 42, acd = 70; int abcd = 210; cout << n - (n / a + n / b + n / c + n / d) + ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> ar[110]; set<int> se; int findstart(int k) { while (ar[k].first != 0) k = ar[k].first; return k; } int findend(int k) { while (ar[k].second != 0) k = ar[k].second; return k; } void addalltoend(int i) { se.insert(ar[i].secon... |
#include <bits/stdc++.h> using namespace std; void calc(int n, int p) { int j = 1, k = 1; int cnt = 0; int here = 1; for (int i = 0; i < 2 * n + p; i++) { cout << j << ; j += k; if (j > n) j -= n; cout << j << endl; cnt++; int tmp = j + k; if (tmp > n) tm... |
#include <bits/stdc++.h> using namespace std; char a[1001][1001]; int vis[1001][1001]; int n, m; void dfs(int x, int y) { vis[x][y] = 1; if (x - 1 >= 0 && !vis[x - 1][y] && a[x - 1][y] == # ) { dfs(x - 1, y); } if (x + 1 < n && !vis[x + 1][y] && a[x + 1][y] == # ) { dfs(x + 1, y)... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; set<long long> s; for (long long i = 0; i < n; i++) { cin >> a[i]; s.insert(a[i]); } cout << s.size() << ... |
#include <bits/stdc++.h> using namespace std; int_fast64_t viz[100001], ans; vector<int_fast64_t> v(100001); void dfs(int_fast64_t node) { ans++; viz[node] = 1; if (!viz[v[node]]) dfs(v[node]); } void solve() { int_fast64_t n; cin >> n; for (int_fast64_t i = 1; i <= n; i++) cin >> v[... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; void solve() { int n; cin >> n; set<int> s; for (int i = 0; i < n; i++) { int a; cin >> a; s.insert(a); } for (int cnt = 1; cnt <= 1023; cnt++) { bool vis[1025]; memset(vis, 0, sizeof(vis... |
#include <bits/stdc++.h> using namespace std; ifstream fin( A.in ); ofstream fout( A.out ); int n, m, a, b, v[100001], viz[100001]; vector<int> G[100001]; long long sum; struct sor { int x, i; } s[100001]; bool cmp(sor a, sor b) { return a.x > b.x; } int main() { cin >> n >> m; for (int ... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INF = 1000000000; const long long LINF = 1000000000000000000; const long long MOD = 1000000007; const double PI = acos(-1.0); const double EPS = 1e-10; ... |
#include <bits/stdc++.h> using namespace std; template <typename... As> struct tpl : public std::tuple<As...> { using std::tuple<As...>::tuple; tpl() {} tpl(std::tuple<As...> const& b) { std::tuple<As...>::operator=(b); } template <typename T = tuple<As...> > typename tuple_element<0, T>::type... |
#include <bits/stdc++.h> using namespace std; typedef int matrix[130][130]; long long n; vector<int> v[130]; int k, q[30], d, f[30], h[130], len[30], r[30], ans; matrix a, b, t; char c; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void mul(matrix a, matrix b) { for (int i = 0; i < len[0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; int n; int cnt; int sum; int head[maxn]; int size[maxn]; int T[maxn]; int top; int temp[2]; struct edge { int u, v, w, next; } e[maxn * 2]; void addedge(int u, int v, int w) { e[cnt].u = u; e[cnt].v = v; e[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 10; int a[maxn][maxn]; vector<int> G[maxn], R[maxn], topo; bool v[maxn]; void rdfs(int now) { v[now] = true; for (int u : R[now]) if (!v[u]) rdfs(u); topo.push_back(now); } void dfs(int now) { v[now] = true; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; int n; int arr[8005]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { cin >> n; multiset<int> ms; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[2]; long long get(long long a, long long b) { return (a + b != 0); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; string s; long long ans, x, y, a, b, c, d; long long minx, ma... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 1020; int n, m, d, tmp; int h[maxn], dis1[maxn], dis2[maxn]; bool mark[maxn], isaffected[maxn]; vector<int> adj[maxn]; pair<int, int> temp; void dfsa(int v) { for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i]; ... |
#include <bits/stdc++.h> using namespace std; int c, v0, v1, a, l; int main() { scanf( %d %d %d %d %d , &c, &v0, &v1, &a, &l); int s = 0, d = v0 - a; for (int i = 1;; i++) { d += a; if (d >= v1) d = v1; if (i == 1) s += d; else s += d - l; if (s >= c) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); const long long ZERO = 0LL; const long long INF64 ... |
#include <bits/stdc++.h> using namespace std; vector<long long> adj[500005]; vector<pair<long long, long long>> vc[500005]; string s; bool ans[500005], hv[500005]; long long level[500005], sz[500005], heavy[500005], cnt[500005], col[500005]; void dfs(long long u, long long p, long long l = 1) { sz[u] ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using llu = unsigned long long; using ld = long double; const double PI = acos(-1.0), g = 9.80665; const int unseen = -1; const ll inf = 1e18 + 505, ninf = -1e18 - 505; const int MOD = 1000000007; void solve(void) { int n, p; ... |
#include <bits/stdc++.h> using namespace std; void read(int &x) { x = 0; int f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -f; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; x *= f; } void print(int x) { if (x < 0) putchar( - ),... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:640000000 ) using namespace std; const long long INF = (1e15) + 4; const int N = 1e6 + 5; const int K = 26; int a[N]; int t[N]; int n; int nxt[N]; int c[N]; int sum(int r) { int result = 0; for (; r >= 0; r = (r & (r + 1)) - 1) resul... |
#include <bits/stdc++.h> using namespace std; namespace Flandle_Scarlet { int n; int a[51][51]; char tmp[51]; int s[51][51]; void Input() { cin >> n; for (int i = 1; i <= n; ++i) { scanf( %s , tmp); for (int j = 1; j <= n; ++j) { if (tmp[j - 1] == # ) a[i][j] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2005; const long long inf = 1e18 + 5; long long n, m, x; long long a[maxn], b[maxn]; long long ma[maxn * maxn], mb[maxn * maxn]; void input() { cin >> n >> m; for (long long i = 1; i <= n; ++i) { cin >> a[i]; a[i] += a[i - ... |
#include <bits/stdc++.h> const int mod = 1000000007; const int inf = 1000000009; const long long INF = 1000000000000000009; const long long big = 1000000000000000; const long double eps = 1e-9; using namespace std; struct odcinek { int l, x, r, nr; }; int suma = 1; odcinek T[100005]; int D[110... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int c = 0; int a[2 * m]; for (int i = 0; i < n; i++) { for (int j = 0; j < 2 * m; j++) cin >> a[j]; for (int j = 0; j < 2 * m - 1; j += 2) { if (a[j] == 1 || a[j + 1] == 1) c++; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n = 0, ans = 0, mod = 1000000009LL; scanf( %I64d , &n); if (n >= 5) { vector<long long> lev(n + 1, 0); if (n >= 3) lev[3] = 1; if (n >= 4) lev[4] = 1; if (n >= 5) lev[5] = 5; for (int i = 6; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long b, long long y) { return b > 0 ? gcd(y % b, b) : y; } long long lcm(long long b, long long y) { return b * y / gcd(b, y); } double dis(double x1, double x2, double y1, double y2) { double ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2... |
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string first; while (getline(ss, first, c)) v.emplace_back(first); return move(v); } void err(vector<string>::iterator it) {} template <typename T, typename..... |
#include <bits/stdc++.h> using namespace std; int main() { long long a[6]; set<long long> s; for (int i = 0; i < 6; i++) { cin >> a[i]; } sort(a, a + 6); if ((a[0] == a[1] && a[0] == a[2] && a[0] == a[3] && a[4] == a[5]) || (a[1] == a[4] && a[1] == a[2] && a[1] == a[3] && a[0] ... |
#include <bits/stdc++.h> using namespace std; long long solve(long long h, long long n, bool left) { if (h == 1) return left ? n : 3 - n; long long p = 1ll << (h - 1); if (left) { if (n > p) return ((long long)1 << h) + solve(h - 1, n - p, left); else return 1 + solve(h - 1, ... |
#include <bits/stdc++.h> using namespace std; struct edge_t { int u, dist; }; struct firstk_sum_t { multiset<long long> left, right; long long left_sum = 0LL; void insert(long long value) { if (!left.empty() && value <= *left.rbegin()) { left.insert(value); left_sum += valu... |
#include <bits/stdc++.h> using namespace std; const int N = 233; int a[N][N]; int main() { ios::sync_with_stdio(false); int m, n, q, p, x, y, b; cin >> n >> m; for (int i = 0; i < n; ++i) cin >> a[i][0]; p = a[0][0]; for (int i = 0; i < m; ++i) cin >> a[0][i]; q = a[0][0]; x = y ... |
#include <bits/stdc++.h> void Letter() { char str[100000 + 1]; int Left[100000 + 1], Right[100000 + 1]; int i, j; int Len; scanf( %s , str); Len = strlen(str); Left[0] = Right[Len - 1] = 0; for (i = 1; i < Len; i++) if (str[i - 1] <= z && str[i - 1] >= a ) Left[i] = Le... |
#include <bits/stdc++.h> using namespace std; int n, cnt; int po[999994], cr[14]; map<int, int> mert; void calc(int L) { int x = 0; for (int i = 1; i <= L; i++) x = x * 10 + cr[i]; if (x == 0) return; else if (!mert.count(x)) { mert[x] = 1; po[++cnt] = x; } } void dfs... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, count(0); cin >> n >> m; for (int a = 0; a * a <= n; a++) { for (int b = 0; b * b <= m; b++) { if (a * a + b == n && a + b * b == m) count++; } } cout << count << endl; return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) using namespace std; const int N = 405; const int MOD = 1000000007; int T, lim, n, k, l, p, cnt, id[N]; long long C[N][N], a[N], dp[N][N], fac[N] = {1}; vector<int> G[N]; bool Judge(long long x) { long long k = s... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); ; long long t; cin >> t; while (t--) { long long n; cin >> n; vector<set<long long>> lol(n - 1); long long cnt = 0; long long x; for (... |
#include <bits/stdc++.h> using namespace std; long long const lim = 1e5 + 5; long long const mod = 1000000007; vector<long long> adj[lim + 5]; long long vis[lim + 5], n; vector<long long> count_edge; long long child[lim + 5]; void all_clear() { count_edge.clear(); for (long long i = 1; i <= lim;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, c, d, cnt1, cnt2; cin >> n; pair<int, int> date[n]; for (i = 0; i < n; i++) { cin >> date[i].first >> date[i].second; } sort(date, date + n); c = date[0].first; d = date[0].second; if (c <= d) cnt1 =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.