func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; template <class F, class T> T convert(F a, int p = -1) { stringstream ss; if (p >= 0) ss << fixed << setprecision(p); ss << a; T b; ss >> b; return b; } template <class T> void print(T a, int p... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { int A, B; scanf( %d%d , &A, &B); int S = A + B; long long K = 0; while ((K + 1) * (K + 2) / 2 <= S) ++K; vector<int> a, b; for (int i = (K + 1) - 1; i >= (1); --i) { if (i <= A) { a.pus... |
#include <bits/stdc++.h> using namespace std; int p[200010], q, l[200010], c[200010], par[20][200010]; stack<int> st; int main() { int j, i, q, u, v, n; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d%d , &p[i], &l[i]); l[i] += p[i]; } scanf( %d , &q); memset(par, -1, si... |
#include <bits/stdc++.h> using namespace std; int N, K; int B[5]; vector<int> A[1 << 5]; int Q; int C, L, R; pair<int, int> mix(pair<int, int> a, pair<int, int> b) { return {max(a.first, b.first), min(a.second, b.second)}; } pair<int, int> Tree[1 << 5][4 * 200005]; void build(int b, int l = 0, i... |
#include<bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1; char ch = 0; while(!isdigit(ch)) {if(ch== - ) f=-1; ch = getchar();} while(isdigit(ch)) {x = x*10+ch- 0 ; ch = getchar();} return x*f; } typedef long long ll; const int maxn = 2e5+100; const double ... |
#include <bits/stdc++.h> using namespace std; int n, k; int mi = 0, ma = 25; bool exist[26]; char str[100005]; inline void init() { scanf( %d%d , &n, &k); memset(exist, false, sizeof(exist)); scanf( %s , str + 1); } inline void solve() { for (int i = 1; i <= n; i++) exist[str[i] - a ] =... |
#include <bits/stdc++.h> using namespace std; int main() { char c; int blackweight = 0; int whiteweight = 0; int i = 0; while (cin >> c) { i++; switch (c) { case Q : whiteweight += 9; break; case R : whiteweight += 5; break; ... |
#include <bits/stdc++.h> using namespace std; long long mult(long long a, long long b, long long p = 1000000007) { return ((a % p) * (b % p)) % p; } long long add(long long a, long long b, long long p = 1000000007) { return (a % p + b % p) % p; } long long fpow(long long n, long long k, long long p ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 5; const int INF = (int)1e9 + 7; const double EPS = 1e-9; const int hh[4] = {1, -1, 0, 0}; const int hc[4] = {0, 0, 1, -1}; void nhap(); void process(); int n; int res; int f[1000006]; int main() { int nTest = 1; fo... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, x, t, c; cin >> n >> t >> c; vector<int> sizes; int curr = 0; long long ans = 0; for (int i = 0; i < n; ++i) { cin >> x; if (x >... |
#include <bits/stdc++.h> using namespace std; int n, m, t; int tp, tu, td; int a[333][333], su[333][333], sd[333][333], sl[333][333], sr[333][333]; inline int get(int a, int b) { return a == b ? tp : a < b ? tu : td; } inline int get(int x1, int y1, int x2, int y2) { return sl[x1][y2] - sl[x1][y1] + sr[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e4 + 5; const int maxk = 505; int N, d; int dp[maxn][maxk], gem[maxn], vis[maxn][maxk]; int dfs(int pos, int prev) { int jj = prev - (d - 250); if (pos > 30000) return 0; if (vis[pos][jj]) return dp[pos][jj]; vis[pos][jj] = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, j = 0, oo = 1; cin >> n >> k; while (k != j) { oo *= 10; j++; } long long int prod = oo * n; while (oo != n) { if (oo > n) { oo %= n; if (oo == 0) oo = n; } else { n... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100100; long long n, m, k; vector<long long> g[maxn]; long long mark[maxn]; long long d[maxn]; vector<long long> q; bool check(long long x, bool print = false) { for (long long i = 0; i < n; i++) if (mark[i] != 1) mark[i] = 0... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) const double PI = acos(-1.0); using namespace std; const double EPS = 1e-9; const int N = 2e5 + 9; int a[N], n, p, k; long long sum[N], v[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; int arr[150]; int main() { int n, k, i, j, ans = 0, curr, temp; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &curr); arr[curr]++; } for (i = 1; i <= 100; i++) { ans += (arr[i] / 2); } ans /= 2; printf( %d n ,... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, b = 0, ans = 0, mid; cin >> n; for (int i = 0; i < n; i++) { cin >> mid; if (mid == 2) a++; else b++; } if (a > b) ans = b; else { ans = a; b = b - a; ans += b /... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 100; int k; long long a[20][maxn]; int nk[20]; map<long long, pair<int, int> > mp; long long sum = 0; bool _is[1 << 17]; long long tol[20]; bool _a[20][maxn]; vector<pair<int, int> > que; vector<vector<pair<int, int> > > dp[1 <... |
#include <bits/stdc++.h> using namespace std; int main() { int l; float p, q, t, res; cin >> l >> p >> q; t = l / (p + q); res = p * t; printf( %.4f , res); return 0; } |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 200005, M = 1000000007, K = 1000006; int ast(int x, int n) { int ans = 1; while (n) { if (n % 2 == 1) ans = (ans * 1LL * x) % M; x = (x * 1LL ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 505; const int mod = 1e9 + 7; long long int dp[1005][1005] = {0}; int main() { long long int n, m, k; cin >> n >> m >> k; if (2 * k > n - 1 || 2 * k > m - 1) cout << 0 << endl; else { dp[0][0] = 1; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; int weight[n + 1]; int stacked[m + 1]; for (int i = 1; i <= n; i++) { cin >> weight[i]; } for (int i = 1; i <= m; i++) { cin >> stacked[i]; } bool... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; inline long long sub(long long &a, long long b) { a -= b; if (a < 0) { a += MOD; } } inline long long mult(long long a, long long b) { return (a * 1ll * b) % MOD; } inline long long b_pow(long long a, long long p)... |
#include <bits/stdc++.h> using namespace std; struct superset { multiset<int> m; void insert(int x) { m.insert(x); } void erase(int x) { m.erase(m.find(x)); } int query() { return *m.begin(); } }; int n, m; int val[65536 * 4]; superset cl[65536 * 4]; vector<int> g[65536 * 4]; vector<int>... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n; while (scanf( %d , &n) != EOF) { if (n & 1) printf( black n ); else printf( white n1 2 n ); } return 0; } |
#include <bits/stdc++.h> const double Pi = acos(-1.0); using namespace std; const int maxN = 100005; const long long mod = 1000000009; int n, m; int par[maxN]; int findpar(int x) { if (par[x] != x) par[x] = findpar(par[x]); return par[x]; } int main(int argc, char** argv) { scanf( %d %d , ... |
#include <bits/stdc++.h> using namespace std; void BFS(vector<vector<long long> > &graph, long long n, vector<long long> &order) { vector<long long> vis(n + 1); set<long long> PQ; PQ.insert(1); while (!PQ.empty()) { long long x = *PQ.begin(); PQ.erase(PQ.begin()); order.... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int N = 10005; int f[N][2005]; int main() { int _; scanf( %d , &_); for (int j = 1; j <= 1000; j++) { f[0][j] = INF; } while (_--) { int n; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; int getint() { int res = 0, fh = 1; char ch = getchar(); while ((ch > 9 || ch < 0 ) && ch != - ) ch = getchar(); if (ch == - ) fh = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) res = res * 10 + ch - 0 , ch = getchar(); return fh * res... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long N = 5e6 + 3; long long dp[N]; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); string str; unsigned long long temp = 1, p = 0, q = 0; cin >> str; long long ans = 0; long long pp... |
#include <bits/stdc++.h> using namespace std; const int MN = 100005, inf = 1000000005, MOD = 1000000007; const long long INF = 1000000000000000005LL; int t[100]; int suma(int i) { int y = min(t[i], t[i + 2]), a = t[i + 1]; int res = (y + a) * (y + a) - a * a; int d = max(t[i], t[i + 2]) - y; r... |
#include<bits/stdc++.h> using namespace std; #define ll long long int #define endl n void solve() { int n,start=0; cin>>n; int end=n; int arr[n],pos[n+1]; for(int i=0 ; i<n;i++) { cin>>arr[i]; pos[arr[i]]=i; } for(int i=n;i>0;i--) { ... |
#include <bits/stdc++.h> using namespace std; template <typename... T> void read(T&... args) { ((cin >> args), ...); } template <typename... T> void write(T&&... args) { ((cout << args << ), ...); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ... |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6; int n, m, p, a[mxN]; long long s1[1 << 21]; vector<long long> s2[1 << 21]; void bld(int i = 1, int l = 0, int r = n - 1) { if (l == r) { s1[i] = a[l]; s2[i] = {p - a[l], 1ll << 60}; return; } int m = (l + r) / 2... |
#include <bits/stdc++.h> using namespace std; const int maxn = 405; double f[maxn], g[maxn], ans; int n, m, dis[maxn][maxn], q[maxn]; int main() { scanf( %d%d , &n, &m); memset(dis, 127 / 3, sizeof(dis)); for (int i = 1; i <= n; i++) { dis[i][i] = 0; } for (int i = 1; i <= m; i++) { ... |
#include <bits/stdc++.h> using namespace std; vector<long long> g[(long long)3e5], a((long long)3e5); long long i, n, x, y, r; void b(long long p, long long q, long long m) { a[p]++, r += m; for (auto j : g[p]) if (j != q) b(j, p, m ^ 1), a[p] += a[j]; } int main() { for (cin >> n, i = 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x7fffffffffffffff; const double eps = 1e-8; unsigned int seed = 19260817; const unsigned int _RAND_MAX_ = 4294967295u; __inline__ __attribute__((always_inline)) unsigned int Rand() { r... |
#include <bits/stdc++.h> using namespace std; int main() { int tests; cin >> tests; while (tests--) { int n, s, t; cin >> n >> s >> t; cout << min(max(s, t) + 1 - (s + t - n), n + (n - s - t) + 1) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; char s[200010]; int n, m, head[200010], o = 0, x[2], id[200010], sz[200010], cnt = 0, tree[800010], tag[800010]; bool isnt_rt[200010]; vector<vector<int> > w; struct edge { int to, link; } e[200010]; struct seg { int x, l, r... |
/* ``````````````````$$$$$ `````````````$$$$$$´´´´$$$$$$ ``````````$$$´´´´´´´´´´´´´´´´$$$ ````````$`$$´´´´´´´´´´´´´´´´´´´´$$ ```````$´$$$´´´´´´´´´´´´´´´´´´´´´$$$$ `````$´´$$$$´´´´´´´´´´´´´´´´´´´´´´´´´´$ ````$´´$$$$$´´´´´´´´´´$$$$$$$´´´´´´´´´$$ ```$´´´$$$$$$$´´´$$$$$$$$$$$$$$$$$´´´´´$$ ``$´´´´$$$$$$$$$... |
#include <bits/stdc++.h> using namespace std; int t, n, m, k, a[105][105], h, a1, a2, cnt, ans[105][105], pos, ch; char c[105][105]; string s; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> t; while (t--) { h = 0; pos = 0; cin >> n >> m >> k; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, f, h = 0, z = 0, x = 0; char a[100]; cin >> t; for (int i = 0; i < t; i++) { cin >> a[i]; } while (t > 0) { z++; t = t - z; } for (int y = 0; y < z; y++) { h = h + y; cout << a[h]; ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL ... |
#include <bits/stdc++.h> using namespace std; const int maxval = 2e6 + 6; int b[maxval]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int a; scanf( %d , &a); b[a] = a; } for (int i = 0; i < maxval; i++) if (!b[i]) b[i] = b[i - 1]; int ans = 0... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, i, m, j, x; cin >> n >> m; long long a[n][m], lowR[n][m], highR[n][m], lowC[n][m], highC[n][m]; for (i = 0; i < n; i++) { for... |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int mod[3]; int n; string s[maxn]; long long ha[maxn][3]; int prel[maxn]; int main() { ios::sync_with_stdio(false); mod[0] = 1e9 + 7; mod[1] = 1e9 + 9; mod[2] = 19260817; cin >> n; int ans = 0; for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, o = 0, h = 0, v = 0, d = 0; char r; char ar[3][3]; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { cin >> ar[i][j]; if (ar[i][j] == X ) x++; else if (ar[i][j] == 0 ) ... |
#include <bits/stdc++.h> using namespace std; long long n, m, v, x; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m >> v; if ((((n - 1) * (n - 2) / 2) + 1 < m) || (m < (n - 1))) return cout << -1 << n , 0; for (int i = 1; i <= n; i++) if (i != v) cout... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 6; struct Edge { int next, en; } edge[maxn]; int head[maxn], cnt; void init() { memset(head, -1, sizeof(head)); cnt = 0; } void add(int x, int y) { edge[cnt].en = y; edge[cnt].next = head[x]; head[x] = cnt++; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 152; const int MAX2 = 11300; const int INF = 1e9 + 10; int a[MAX]; int r[MAX][MAX2]; int t[MAX][MAX2]; int main() { int n, k, s; cin >> n >> k >> s; s = min(s, MAX2 - 1); for (int i = 1; i <= n; i++) { cin >> a[i]; }... |
#include <bits/stdc++.h> using namespace std; char s[1000010]; bool f[1000010]; int main() { int i, l, ans = 0, ans2 = 0, j, sta; scanf( %s , &s); l = strlen(s); sta = 0; while (s[sta] == s[(sta + 1) % l]) { sta = (sta + 1) % l; } ++sta; memset(f, false, sizeof(bool) * l); ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using ull = unsigned long long; using int2 = pair<ll, ll>; using int3 = tuple<ll, ll, ll>; template <typename A> string to_string(const A& v); string to_string(const string& s) { return + s + ; } strin... |
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; const int N_ = (int)2e6 + 2; long long n; char a[N_], b[N_]; double res; long long T; int main() { scanf( %lld , &n); scanf( %s , a + 1); scanf( %s , b + 1); for (char cur = A ; cur <= Z ; cur++) { long l... |
#include <bits/stdc++.h> using namespace std; struct pnt { int x, y; }; struct pr { int d, q; pr() {} pr(int d, int q) : d(d), q(q) {} friend bool operator<(pr a, pr b) { if (a.d != b.d) return a.d < b.d; return a.q < b.q; } }; const int N = 200000 + 20; bool ok[N]; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s[1001], d[1001], i, a, S; cin >> n; for (i = 1; i <= n; i++) { cin >> s[i] >> d[i]; } S = s[1]; for (i = 2; i <= n; i++) { if (s[i] <= S) { int x = ((S - s[i]) / d[i]) + 1; S = s[i] + d[i] * x; ... |
#include <bits/stdc++.h> using namespace std; void boost() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 1e6; const long long inf = 1e9; int n; vector<string> s; string ans, cur; vector<int> g[200]; bool was[N]; map<string, bool> wass; void dfs(int v) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 1e9 + 7; long long n, m, k, w; long long dp1[maxn]; long long dp2[maxn]; int d1[maxn]; int d2[maxn]; long long a, b; inline int low_bit(int x) { return x & (-x); } inline void upd1(int p, int x) { while (p ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 305; int a[maxn][maxn], b[maxn][maxn]; int main(int argc, char const *argv[]) { int t; scanf( %d , &t); while (t--) { int n, m; scanf( %d %d , &n, &m); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j)... |
#include <bits/stdc++.h> using namespace std; void JIZZ(string output = ) { cout << output; exit(0); } const long double PI = 3.14159265358979323846264338327950288; const long double eps = 1e-10; const long long mod = 1e9 + 7; void solve() { string s, t; cin >> s >> t; for (int st = ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 10; const long long INF = 1e18; const long double EPS = 1e-12; struct Point { long double x, y; Point() {} Point(long double x, long double y) : x(x), y(y) {} Point(const Point &p) : x(p.x), y(p.y) {} ... |
#include <bits/stdc++.h> using namespace std; using namespace std; const int mod = 1000000007; long long fastpow(long long a, long long b) { if (b == 0) return 1; else if (b % 2 == 0) return fastpow(a * a, b / 2); else if (b % 2 != 0) return a * fastpow(a * a, (b - 1) / 2); } c... |
#include <bits/stdc++.h> char map[55][55]; int cov[55][55]; int fx[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; int ok, sx, sy; int steps[55][55]; int n, m; int in(int x, int y) { if (x >= 1 && x <= n && y >= 1 && y <= m) return 1; return 0; } void dfs(int x, int y, int step) { steps[x][y] ... |
#include <bits/stdc++.h> using namespace std; bool check_lucky(long long num) { while (num) { if ((num % 10) == 8) return 1; num /= 10; } return 0; } int main() { long long num; cin >> num; int flag = 0, ans = 1, f2 = 0; if (num < 0) { flag = 1; num *= (-1); ... |
#include <bits/stdc++.h> using namespace std; long long n, ans, a[300123], maxx[300123], minx[300123], box[800123]; void dopart(long long l, long long r) { if (l == r) { ans++; return; } long long mid = (l + r) / 2; dopart(l, mid); dopart(mid + 1, r); maxx[mid] = a[mid], minx[m... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL ... |
#include <bits/stdc++.h> using namespace std; const int modu = 1e9 + 7; long long int mod(long long int n) { return (n % modu); } bool cmp(long long int a, long long int b) { return a > b; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int N, a, b, c, d, x ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n, q = 0, z = 0; cin >> a >> b >> n; for (int i = 0; n >= 0; ++i) { for (int j = a; j >= 1; --j) { if (a % j == 0 && n % j == 0) { q = n; n = n - j; break; } } if (n >= 0)... |
#include <bits/stdc++.h> using namespace std; const int N = 3077; int n, m, p, k, s[N], t[N], ls[N], nxt[N]; long long ans; vector<int> P[N]; int main() { scanf( %d%d%d%d , &n, &m, &p, &k); for (int i = 1; i <= p; i++) { int x, y; scanf( %d%d , &x, &y); P[x].push_back(y); } ... |
#include <bits/stdc++.h> const long long mod = 998244353; using namespace std; pair<long long, long long> dp[20][2][1 << 10]; int k; int s[20]; long long pw[20]; pair<long long, long long> solve(int i, bool U, int mask) { if (i < 0) return {0, 1}; pair<long long, long long> &ret = dp[i][U][mask]; ... |
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; long long cnt[3000005], pre[3000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ; long long n; scanf( %lld , &n); long long a; for (long long i = 0; i < n; i++) { scanf( %lld , &a); cnt[a... |
#include <bits/stdc++.h> using namespace std; vector<int> darmo; vector<pair<int, int> > tab; vector<bool> done; vector<int> wolne; int n, k; int main() { scanf( %d %d , &n, &k); darmo.resize(n); tab.resize(n); done.resize(k + 1, false); long long res = 0; for (int i = 0; i < n; i+... |
#include <bits/stdc++.h> using namespace std; int n, m, q, res[111][111]; pair<int, int> pos[111][111]; int type, r, c, x; int main() { scanf( %d %d %d , &n, &m, &q); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) pos[i][j] = pair<int, int>(i, j); while (q--) { scanf( %d , &... |
#include <bits/stdc++.h> using namespace std; const int N = 105; char mp[3][N], tmp[3][N], g[55][3][N]; bool vis[55][3][N]; int n, k; void getNext(int id) { memcpy(g[id], mp, sizeof(mp)); for (int i = int(0); i <= int((3) - 1); i++) for (int j = int(1); j <= int(n - 3); j++) tmp[i][j] = mp[i][... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; char num[maxn]; char num2[maxn]; vector<int> vec; queue<int> que; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } whi... |
#include <bits/stdc++.h> using namespace std; long long a[1000010]; long long l[1000010], r[1000010]; vector<pair<int, int>> g1[1000010], g2[1000010]; int n, q; long long ans[1000010]; const int N = 1000000; long long sum[N * 4]; long long flag[N * 4]; int cnt_v; void build(int n) { cnt_v = 1;... |
#include <bits/stdc++.h> using namespace std; const int N = 404040; int cnt, cnt2, cnt3, h, n, m; struct Node { int x, y, w, d, i; } a[N]; bool cmp(Node x, Node y) { return x.d < y.d; } vector<int> s[N]; vector<pair<int, int> > ss[N]; int dfn[N], low[N], viss[N], q[N], color[N], as[N]; map<int, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 100000, maxk = 2 * 100000, inf = 0x3f3f3f3f; int n, k, s, t; struct car { int c, v; } a[maxn + 10]; int d[maxk + 10]; int ans = inf; void init() { scanf( %d%d%d%d , &n, &k, &s, &t); for (int i = 1; i <= n; i++) scanf( %d%d , ... |
#include <bits/stdc++.h> using namespace std; int sol(const vector<long long>& a, int n, int m, long long t) { long long s = 0; for (int i = 0; i < m; i++) s += a[i]; int ans = 0; for (int i = 0; i <= n && s * i <= t; i++) { int cnt = (m + 1) * i; long long r = t - s * i; for (int ... |
#include <bits/stdc++.h> using namespace std; inline const int getint() { int r = 0, k = 1; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) k = -1; for (; c >= 0 && c <= 9 ; c = getchar()) r = r * 10 + c - 0 ; return k * r; } long long ans, a1, b1, a2, b... |
#include <bits/stdc++.h> using namespace std; const int M = 19, N = (1 << M); int a[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int id = -1; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == -1) id = i; } int rem = n - i... |
#include <bits/stdc++.h> using namespace std; int n, t; int main() { cin >> n >> t; long long z = pow(10, n - 2); if (n == 1 and t == 10) return cout << -1 << endl, 0; if (n == 1) return cout << t << endl, 0; if (t == 2 or t == 4 or t == 5 or t == 8 or t == 10) cout << 40; else if (t... |
#include <bits/stdc++.h> using namespace std; long long t, n, sum, t1, ans; string st; int main() { cin >> t; while (t--) { cin >> n; cin >> st; int a = 0, b = 0; for (int i = 0; i < n; i++) { if (st[i] == ( ) a++; if (st[i] == ) ) { if (a) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n, count = 1; cin >> n; while (n > 0) { if (count % 3 != 0 && count % 10 != 3) { count++; n--; } else { count++; } }... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 23; const int offset = (int)1e6; int st_sum[2 * N]; int st_ma[2 * N]; int getMax(int a, int b) { a += N + offset; b += N + offset; int ma = -1e9; int sum_a = 0; int ma_b = 0; for (; a < b; a /= 2, b /= 2) { if (a ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int h1[n + 1], h[n + 1]; for (int i = 1; i <= n; i++) cin >> h[i]; for (int i = 1; i <= n; i++) cin >> h1[i]; long long int dp[n + 1][2]; dp[1][0] = h[1]; dp[1][1] = h1[1]; dp[0][0] = ... |
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ull = uint64_t; using ld = long double; using uint = uint32_t; const double EPS = 1e-8; const int INF = 0x3F3F3F3F; const ll LINF = 4611686018427387903; const int MOD = 1e9 + 7; const int mod = 1e6 + 3; vector<vector<ll>> mat(... |
#include <bits/stdc++.h> char chars[200005]; int main() { int n; scanf( %d , &n); scanf( %s , chars); int sum = 0; for (int i = 0; i < n; i++) { if (chars[i] == < ) { sum++; } else { break; } } for (int i = n - 1; i >= 0 && sum < n; i--) { if (cha... |
#include <bits/stdc++.h> using namespace std; int q; char dirs[100000]; int l, r, u, d; int main() { cin >> q; for (int i = 0; i < q + 1; ++i) { char c; int ind = 0; l = r = u = d = 0; while ((c = getchar()) != n ) { dirs[ind] = c; ++ind; } for (in... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { int str[550][550], cnt[550], ans[550]; memset(str, 0, sizeof(str)); memset(cnt, 0, sizeof(cnt)); memset(ans, 0, sizeof(ans)); for (int i = 0; i < m; i++) { int u, v; cin... |
#include <bits/stdc++.h> using namespace std; vector<long long> f(21); long long fact(long long x) { return f[x]; } long long solve(long long k) { vector<long long> cnt(21), less(21); long long d = 1, den = 1, num = 1, den1 = 1, num1 = 0; while (k > 0) { d += 1; cnt[k % d] += 1; k ... |
// #pragma GCC optimize( Ofast ) #pragma GCC target ( sse4 ) #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <map> #include <queue> using namespace std; const int N = 2e5 + 10, M = N * 2, INT = 0x3f3f3f3f, mod = 1e9 + 7; //#define int long long #define p... |
#include <bits/stdc++.h> using namespace std; const int N = 400 + 5; const int INF = 1e9; int R, n, m; pair<int, int> H[N], T[N]; int vis[N][N]; vector<pair<int, int> > adj[N][N]; queue<pair<int, int> > Q; int dis[N][N]; int bfs(int h, int t) { memset(dis, 0x3c, sizeof dis); dis[h][t] = 0; ... |
#include <bits/stdc++.h> using namespace std; template <class T, class V> ostream &operator<<(ostream &s, pair<T, V> a) { s << a.first << << a.second; return s; } struct NTT { long long int MD, M = 1, R; vector<int> r; vector<long long int> w[2]; long long int bigmod(long long int ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; bool o00, o01, o10, o11; a = b = c = 0; string s; cin >> s; string::iterator its; its = s.begin(); for (; its != s.end(); ++its) { if (*its == 1 ) ++a; else if (*its == 0 ) ++b; ... |
#include <bits/stdc++.h> const int maxn = 10000050; using namespace std; char a[1005][6]; void solve() { memset(a, 0, sizeof(a)); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int flag = 0; for (int i = 0; i < n; i++) { if (a[i][0] == O && a[i][1] == O ) { a[... |
#include <bits/stdc++.h> using namespace std; long long Rev[35], C[35][35]; long long powmod(long long x, long long y = 998244353 - 2, long long p = 998244353) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % 998244353; x = x * x % 998244353; y >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; bool isIntersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { double t1 = (y3 - y4) * (x1 - x3) + (x4 - x3) * (y1 - y3); double t2 = (x4 - x3) * (y1 - y2) - (x1 - x2) * (y4 - y3); double r1 = t1 / t2; double f1 = (... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5; int n, x, k; int a[NMAX + 2]; long long ans; int ndiv(int f, int l) { return l / x - (f - 1) / x; } pair<int, int> bs(int arg) { pair<int, int> last; int st = arg, dr = n; last.first = last.second = -1; while (st <= dr) { ... |
#include <bits/stdc++.h> using namespace std; int n, a[500010], x, sz; long long ans; int main() { scanf( %d , &n); for (int step = 1; step <= n; step++) { scanf( %d , &x); while (a[sz - 1] >= a[sz] && a[sz] <= x && sz >= 2) { ans += min(a[sz - 1], x); sz--; } a[+... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, a, b, in[100], on[100], i = 0, r, y; cin >> n >> x; int t = n; while (t--) { cin >> a >> b; r = min(a, b); y = max(a, b); in[i] = r; on[i] = y; i++; } sort(in, in + n); sort(on, on + ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.