func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int res; int tox[] = {0, 0, 1, -1}; int toy[] = {1, -1, 0, 0}; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); string s; cin >> s; while (s.back() == 0 ) s.erase(s.size() - 1, 1), res++; while (s != 1 )... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); deque<long long int> b, g; long long int n; cin >> n; for (long long int i = 0; i < n; i++) { long long int temp; cin >> temp; b.push_back(temp); } cin >> n; for (long long int ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; bool comp(pair<long long, long long> p1, pair<long long, long long> p2) { if (p1.first != p2.first) { return p1.first < p2.first; } else return p2.second < p1.second; } int32_t main() { ios_base::sync_with_stdio(fal... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 9223372036854775807; const long long int mod = 998244353; 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 ... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int Q = 1e9 + 7; struct Point { int x, y; Point(int _x = 0, int _y = 0) : x(_x), y(_y) {} const int sign() const { return y < 0 || y == 0 && x < 0; } Point operator-(const Point &R) { return Point(x - R.x, y - R.y); } lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, r, sall, sk; cin >> n >> k >> l >> r >> sall >> sk; int el[n]; int div, mod, m, sm; m = n - k; sm = sall - sk; if (k > 0) { div = sk / k; mod = sk % k; for (int i = 0; i < k; i++) { el[i] = ... |
#include <bits/stdc++.h> using namespace std; long long ar[100005]; long long N; int main() { cin >> N; for (long long i = 0; i < N; i++) cin >> ar[i]; long long ans = 0ll; for (long long i = 0; i < N; i++) { long long lft = (i == 0 ? 0 : ar[i - 1]); if (ar[i] < lft) ans += (ar[i]) *... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, m; cin >> n >> m; for (long long int i = 0; i < n; i += 1) { long long int s, f, t; cin >> s >> f >> t; long long int q = t / (m - 1); ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; long long add[N << 2], sum[N << 2], color[N << 2]; int n, m; void down(int rt, int len) { if (add[rt]) { add[(rt << 1)] += add[rt]; add[(rt << 1 | 1)] += add[rt]; sum[(rt << 1)] += add[rt] * (len - (len >> 1)); ... |
#include <bits/stdc++.h> using namespace std; bool f[9000000]; int a[30]; bool check(int sta, int i) { if (sta & (1 << (i - 1))) ; else return false; for (int j = 0; j < i; j++) if (sta & (1 << j)) for (int k = j; k < i; k++) if (sta & (1 << k)) if (a[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 1; int a[maxn], n; bool check(int r) { for (int i = 1; i <= n; i++) if (a[i] % r > 0 && r - 1 - a[i] % r > a[i] / r) return 0; return 1; } long long calc(int r) { long long res = 0; for (int i = 1; i <= n; i++) res +=... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1005; int n, m, k; long long s[Maxn][Maxn], sl[Maxn][Maxn], sr[Maxn][Maxn]; inline int get() { char ch; while (!isdigit(ch = getchar())) ; int v = ch - 48; while (isdigit(ch = getchar())) v = v * 10 + ch - 48; return v; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum[3] = {0}; cin >> n; int *x = new int[n], *y = new int[n], *z = new int[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> z[i]; sum[0] += x[i]; sum[1] += y[i]; sum[2] += z[i]; } if (sum[0] == ... |
#include <bits/stdc++.h> using namespace std; struct man { long long int m, s, I; }; man a[131072]; bool cmp(man a, man b) { if (a.m < b.m) return true; if (a.m > b.m) return false; if (a.I > b.I) return true; if (a.I < b.I) return false; } int main() { queue<man> x; long long ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long INF = 1000000000; struct wie { int il_50, il_100, str; }; int main() { ios_base::sync_with_stdio(0); int n, k; cin >> n >> k; int p = 0, s = 0; for (int i = 0; i < n; ++i) { int x; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1000 + 10, M = 998244353; int t; int n, m, q; bool locked[N][N]; long long num[N][N][2]; long long ans = 0; int calc(int i, int j, int t) { if (i > n || j > m) return 0; if (num[i][j][t] != 0) return num[i][j][t]; num[i][j][t]... |
#include <bits/stdc++.h> using namespace std; int n; int values[400][400]; int mem[400][400][2]; void read() { cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> values[i][j]; mem[i][j][0] = 0; mem[i][j][1] = 0; } } } void add(int x... |
#include <bits/stdc++.h> using namespace std; long long int modulo = 1e9 + 7; int n; const int limite = 100001; long long int cuantoshasta[limite], sumahasta[limite], valor[limite], prodhasta[limite]; long long int cuatros[limite][10], sietes[limite][10], diezala[limite], dosala[limite], sumahas... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, z; long long x1, y1, z1; vector<long long> a(6); long long sum = 0; cin >> x >> y >> z; cin >> x1 >> y1 >> z1; for (int i = 0; i < 6; ++i) { long long b; cin >> b; a[i] = b; } if (x < 0) ... |
#include <bits/stdc++.h> struct node { double x, y, z; } p[5005]; double d[5005]; double getlen(node a, node b) { double len; len = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z); return sqrt(len); } int main() { int n, i, j, a, b, c; whil... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); if (n == 2) { printf( -1 n ); return 0; } printf( 6 n10 n15 n ); for (int i = 4; i <= n; i++) { printf( 6 ); for (int zero = 1; zero <= i - 4 + 1; zero++) printf( 0 ); printf( n ); } return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int x; cin >> x; int a[s.length()]; for (int i = 0; i < s.length(); i++) { a[i] = 1; } for (int i = 0; i < s.length(); i++) { if (... |
#include <bits/stdc++.h> using namespace std; long long n, m, a, b, c, d, e, R, B, P, ans; char s; inline long long read() { long long sum = 0, x = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) x = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, x, y; cin >> n >> x >> y; long long a1 = y - n + 1; if (a1 <= 0 or a1 * a1 + n - 1 < x) return cout <... |
#include <bits/stdc++.h> using namespace std; int T; priority_queue<int, vector<int>, greater<int> > q; vector<int> g[1000005]; int main() { scanf( %d , &T); int n; long long int ans; while (T--) { ans = 0; scanf( %d , &n); int x, y; for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> const double EPS = 1e-24; const long long int MOD = 1000000007ll; const long long int MOD1 = 1000000009ll; const long long int MOD2 = 1100000009ll; const double PI = 3.14159265359; int INF = 2147483645; long long int INFINF = 9223372036854775807; template <class T> T Max2(T a,... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; int l1, l, r, count = 0; cin >> s; l1 = s.size(); int arr[l1]; memset(arr, 0, sizeof(arr)); int last = -1; for (int i = 0; i < l1;) { if (s[i] == s[i + ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int maxn = 1100; const int maxk = 2 * maxn; long long dp[maxn][maxk][4]; long long st[4][4] = {{0, 1, 1, 1}, {1, 0, 1, 1}, {0, 0, 0, 2}, {0, 0, 2, 0}}; int main() { int n, k; scanf( %d%d , &n, &k); dp[1][1][0]... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int>> a; vector<pair<long long int, long long int>> b; vector<long long int> c; long long int n, m, T; bool solve(long long int d) { priority_queue<long long int, vector<long long int>, greater<long long int>> s; ... |
#include <bits/stdc++.h> using namespace std; const int N = 6e1; map<string, int> mp; int n; int answer = 1; string To(string a) { for (int i = 0; i < a.size(); i++) if (a[i] > Z ) a[i] = a[i] - 32; return a; } int main() { mp[ POLYCARP ] = 1; cin >> n; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; struct Node { long long l, r; } dict[maxn]; long long N, s; inline bool check(long long mid) { long long cnt = 0, cost = 0; priority_queue<long long, vector<long long>, greater<long long>> q; for (int i = 1; i <= N; ++i... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t = 1, n, k = 0, flag = -1, b = 0; while (t--) { scanf( %lld , &n); k = 0; while (n != flag) { if (n / 10 == 0 && b == 0) { flag = n; b = 1; } k++; n++; whil... |
#include <bits/stdc++.h> using namespace std; int t[40008]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, k, l, p; cin >> n; string s; map<string, string> ex; map<string, int> kol; map<string, int> wh; for (int u = 1; u <= n; u++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int mid = (m + 1) / 2; int cnt = 0; int ans[m + 1]; if (m % 2) { int i = 1; int cnt = 1; int k = 1; ans[k++] = mid; while (true) { if (cnt > m) break; ans[k++] = ... |
#include <bits/stdc++.h> using namespace std; int n, m, d[105]; char x[205]; int main() { scanf( %d%d%s , &n, &m, x); d[0] = 1; for (int i = 0; i < n; i++) if (x[i] == 1 && d[i]) for (int j = 1; j <= m; j++) if (x[i + j] == 1 && (!d[i + j] || d[i + j] > d[i] + 1)) ... |
#include <bits/stdc++.h> using namespace std; int main(){ int t,n,d; int a[110],b[110]; scanf( %d ,&t); while(t--){ scanf( %d%d ,&n,&d); int fir=200,sec=200; int fid,sid; int x[110]; int xid[110]; int c=0; for(int i=1;i<=n;i++){ scanf( %d ,&a[i]); if... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &first, T2 second) { if (first > second) first = second; } template <typename T1, typename T2> inline void chkmax(T1 &first, T2 second) { if (first < second) first = second; } const string Fil... |
#include <bits/stdc++.h> using namespace std; int n, k, a[400010]; map<int, int> m; set<pair<int, int> > s; long long ans = 0; int main() { cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> a[i]; a[0] = 0; for (int l = 1, r = 0; l <= n; ++l) { s.erase(make_pair(-m[a[l - 1]], a[l - 1])... |
#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); } int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; vector<long long> v; for (long long i =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int fa[maxn], cnt[maxn], vis[maxn], arr[maxn]; int fi(int x) { return x == fa[x] ? x : fa[x] = fi(fa[x]); } int main(int argc, char const *argv[]) { int n, m; scanf( %d %d , &n, &m); for (int i = 1; i <= n; ++i) fa[i] = i, cn... |
#include <bits/stdc++.h> using namespace std; int n; void input() { cin >> n; } void solve() { int cnt = 0; for (int i = 1; i <= n; ++i) { if (cnt == n) { break; } printf( %d 1 n , i); ++cnt; if (cnt == n) { break; } if ((i % 2) == 0) { p... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); cout << 4 << endl; cout << R << l - 1 << endl; cout << L << 2 << endl; cout << L << l + 1 << endl; cout << L << 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; int n, k; string s; int main() { cin >> n >> k; cin >> s; int sum = 0; for (int i = 0; i < n; i++) { if (s[i] == # ) sum++; if (sum >= k)... |
#include <bits/stdc++.h> using namespace std; int b[65], p = 1e9 + 7; long long pow_(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % p; b >>= 1, a = a * a % p; } return res % p; } void solve(int n, int x) { int t = 0; long long ans = 0;... |
#include <bits/stdc++.h> using namespace std; const int N = 5000 + 10; const int BASE = 1e9 + 7; int n; int memo[N][N], _memo[N][N]; string s; int _solve(int pos_1, int pos_2) { if (pos_1 > n || pos_2 > n) return 0; if (_memo[pos_1][pos_2] != -1) return _memo[pos_1][pos_2]; int cur = 0; if... |
#include <bits/stdc++.h> using namespace std; int parent[100005]; int coun[100005]; bool isLucky(int a) { while (a) { int x = a % 10; if (x == 4 || x == 7) { } else return false; a = a / 10; } return true; } int findp(int a) { if (parent[a] == a) { retur... |
#include <bits/stdc++.h> using namespace std; void fscpp() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fscpp(); long long n; cin >> n; long long ct = 0; long long xm, ym; long long x, y; cin >> xm >> ym; vector<long long> vx(n), vy(n); ... |
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; const double pi = 3.14159265358979323; const double eps = 1e-8; int n, k, a[100100]; set<long long> vis; int main() { scanf( %d%d , &n, &k); for (int i = (0); i < (n); i++) scanf( %d , &a[i]); sort(a, a + n); int an... |
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int t = 0; while (str[t]) { if (str[t] == . ) { cout << 0; t++; } else if (str[t] == - && str[t + 1] == . ) { cout << 1; t += 2; } else if (str[t] == - && str[t ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100 + 10; const int MAX_V = 200 + 10; const int MAX_S = 1 << 7; const int INF = 1000000; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; int N, M, K, S; int w[MAX_N][MAX_N]; int f[MAX_N][MAX_N][MAX_S]; int pre[MAX_N][M... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 3; i * i <= n; i = i + 2) { if (n % i == 0) return false; } return true; } int main() { int w, h, k; cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, r, s; cin >> n; if (n % 2 == 1) { if (n == 1) { cout << -1 ; } else { r = (n * n - 1) / 2; s = (n * n + 1) / 2; cout << r << << s; } } else { if (n == 2) { cou... |
#include <bits/stdc++.h> const double eps = 1e-11; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; using namespace std; const int maxn = 1005; int n; typedef struct node_ { int x, y; } N; N node[maxn]; pair<int, pair<int, int> > ans[100005]; int cnt; void deal(int t, int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << min(a + a + b + b, min(a + b + c, min(a + a + c + c, b + b + c + c))) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 6; namespace AC { int tot, tr[N][26]; int fail[N]; int cnt[N]; int sid[N]; int next[N]; bool vis[N]; int isend[N]; int in[N]; int val[N]; int victim[N]; queue<int> q; void init() { memset(fail, 0, sizeof(fail)); mems... |
#include <bits/stdc++.h> using namespace std; vector<int> a; vector<pair<int, int> > s; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; a.push_back(x); } for (int i = 0; i < n; i++) { for (int j = 0; j < n ... |
#include <bits/stdc++.h> using namespace std; int main() { short n, before, after; cin >> n; string a; bool flag = false; for (short i = 0; i < n; i++) { cin >> a; cin >> before; cin >> after; if (after >= 2400 && before >= 2400 && after - before > 0) flag = true; } ... |
#include<bits/stdc++.h> #define pb push_back #define int long long using namespace std; int p=998244353,tt,n,m,fac[25]; void prepare(){ fac[0]=1; for(int i=1;i<25;i++){ fac[i]=(fac[i-1]*i)%p; } } int inv(int z){ int s=p-2,t=z,ans=1; while(s>0){ if(s%2)ans=(ans*t)%p; t=(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e4 + 10, mod = 1e9 + 9, maxa = 1e6 + 100; long long sta = 0; const long long inf = 2e18 + 13; long long max(long long x, long long y) { return (x > y ? x : y); } long long min(long long x, long long y) { return (x < y ? x : y); } long long pw... |
#include <bits/stdc++.h> using namespace std; int n, tx, ty; vector<pair<int, int> > ar; int vis[100010]; bool check(int first, int second, int x1, int y1, int x2, int y2) { if ((1LL * x2 - 1LL * x1) * 1LL * (1LL * second - 1LL * y1) == (1LL * y2 - 1LL * y1) * 1LL * (1LL * first - 1LL * x1)) ... |
#include <bits/stdc++.h> using namespace std; long long K, B, N, T; int main() { cin >> K >> B >> N >> T; if (K == 1 && 1 + N * B >= T) { cout << (int)ceil((1 + N * B - T) / (1.0 * B)) << endl; return 0; } if (K == 1) { cout << 0 << endl; return 0; } long long C = 1... |
#include <bits/stdc++.h> using namespace std; char buff[100000], *pb; int readInt() { int num = 0; while (*pb && isdigit(*pb)) { num = num * 10 + (*pb - 0 ); ++pb; } return num; } int nextChar() { int c = 0 ; if (*pb) { c = *pb; pb++; } return c; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, c, d; cin >> a >> b >> c >> d; if (min(a, b) + min(c, d) == max(a, b) && max(a, b) == max(c, d)) { cout << YES n ; } else { cout << NO n ; } } } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); ; long long int t; cin >> t; while (t--) { string s; cin >> s; long long int a[26] = {0}; long long int cnt = 0; char c; int i = 0; while (i < s.len... |
#include <bits/stdc++.h> using namespace std; int check(string st) { int s1 = 0, s2 = 0; for (int i = 1; i < st.length(); i++) { if (st[i] == 1 && i % 2 == 1) s1++; if (st[i] == 1 && i % 2 == 0) s2++; if (s1 - s2 > 5 - i / 2 || (i % 2 == 1 && s2 - s1 >= 5 - i / 2) || (i % 2 =... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << ( << v.first << , << v.second ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k, t; cin >> n >> m >> k >> t; vector<pii> waste(k); for (int i = 0; i < k; ++i)... |
#include <bits/stdc++.h> using namespace std; vector<int> ad[100009]; vector<int> idx; deque<int> vec; int cnt[100009]; int ans[100009]; vector<pair<int, int> > arr, arr2; int val[100009]; set<int> s; int main() { int a, b, c, d, e, i, j, k, l, n, m, x, y, t, p, X; scanf( %d , &t); for (... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int nums[n]; for (int i = 0; i < n; i++) { cin >> nums[i]; } for (int i = 0; i < n - 1; i++) { if (nums[i] < 0) { cout << NO ; return 0; ... |
#include <bits/stdc++.h> void rd(int &x) { x = 0; int f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 0 , ch = getchar(); x *= f; } void lrd(long long &x) { x = 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int dr8[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dc8[] = {1, -1, 0, 0, -1, 1, -1, 1}; int dr4[] = {0, 1, -1, 0}; int dc4[] = {1, 0, 0, -1}; int n; int a[N]; set<pair<int, int> > s; set<int> end_idx; int sz[N]; int main() { ios_b... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (107); const int inf = (int)1e9 + 42; struct aho_corasick { int is_end[MAXN], link[MAXN], psz; map<char, int> to[MAXN]; void clear() { for (int i = 0; i < psz; i++) is_end[i] = 0, link[i] = 0, to[i].clear(); psz = 1; is... |
#include <bits/stdc++.h> char s[100][100]; int main() { int n, m, ans = 0; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1); for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { int f = 0, g = 0; for (int k = 1; k <= m; k++) if (s[... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, d; cin >> n >> d; if (n >= d) cout << YES << endl; else { double i = 1, cnt = 0; while (i <= n) { int y = ceil(d / (i + 1)) + i; if... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); bool flag = 1; for (int i = 1; i < n; i++) { if (arr[i] - arr[i - 1] > 1... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100, PI = 3.14159265359, M = 1e9 + 7; long long a[N], ans = 1; int main() { long long n; cin >> n; long long x = 0, y = 0; for (int i = 0; i < n; i++) { long long a, b; cin >> a >> b; long long t1 = a - x, t2 = b... |
#include <bits/stdc++.h> using namespace std; const int maxN = 40; int a[maxN][maxN]; int b[maxN][maxN]; int flips[maxN][maxN]; int n, x; int check(int mask) { memset(flips, 0, sizeof(flips)); for (int i = 0; i < x; ++i) { if (mask & (1 << i)) { flips[x - 1][i] = 1; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int str, in, ex, z; cin >> str >> in >> ex; if (str + ex - in <= 0) { cout << 0 << endl; } else { if (ex + in < str) { z = ex + 1; } else { ... |
#include <bits/stdc++.h> using namespace std; long long n, k; long long S[1000000] = {}; int main() { cin >> n >> k; for (long long i = 0; i < n; i++) { string s; cin >> s; S[s.size()]++; } string s; cin >> s; long long pass = s.size(); long long sum1 = 1, sum2 = 0;... |
#include <bits/stdc++.h> using namespace std; long long exp(long long x, long long y, long long p) { long long res = 1; while (y) { if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res; } long long exp(long long x, long long y) { long long res = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 500010; int A[N]; const int S = 250; int sum[S][S]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int Q; cin >> Q; while (Q--) { int t, x, y; cin >> t >> x >> y; if (t == 1) { A[x] += ... |
#include <bits/stdc++.h> using namespace std; struct Point { public: int x, y; bool operator<(const Point &a) const { if (x != a.x) return x < a.x; return y < a.y; } } tem; set<Point> p; set<int> xSet; set<int> ySet; bool f() { if (xSet.size() != 3 || ySet.size() != 3 || p.s... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(n); string aans = string(n / 2, 1 ) + string((n + 1) / 2, 0 ); string bans = string(n / 2, 1 ) + string((n + 1) / 2, 0 ); for (int i = 0; i < n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { string str; int c1, c2, c3; c1 = c2 = c3 = 0; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == + ) { str.erase(i, 1); i--; } } for (int i = 0; i < str.length(); i++) { if (str[... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1}, dy[8] = {1, 0, -1, 0, -1, 1, -1, 1}; int a[100005]; int cnt = 0; int n, m, k; vector<int> vt[100005], vt2[2]; stack<int> st; int dfn[100005], color[100005]; void... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; struct Edge { int to, cap, flow; }; struct Graph { int n; vector<vector<int> > e; vector<Edge> edges; vector<int> d, c; Graph() {} Graph(int _n) { n = _n; e.resize(n); } void addEdge(int from, in... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; while (n--) { int p, q; cin >> p >> q; if ((q - p) >= 2) cnt++; } cout << cnt << n ; } |
#include <bits/stdc++.h> using namespace std; char s[4005], t[4005], ax[4005]; int main() { scanf( %s%s , s, t); int n = strlen(s), m = strlen(t), ret = m; for (int i = n - 1; i >= 0; i--) s[i + m] = s[i], s[i] = 0; n += m; for (int i = 0; i < n; i++) { int ct = 0; for (int j = 0; ... |
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; const long double PI = acos(-1); const long long INF = 2e18; template <typename T, typename T1> void amax(T &a, T1 b) { if (b > a) a = b; } template <typename T, typename T1> void amin(T &a, T1 b) {... |
#include <bits/stdc++.h> using namespace std; long long bit[65], f[65][120][2]; inline long long dp(long long s, int tot, int h1, int h2) { memset(f, 0, sizeof f); f[0][0][0] = 1; int ed = log2(s); for (int i = 1; i <= ed; ++i) { long long d = (s >> i) & 1; int ed = i * 2 - 2; fo... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y; point() : x(0), y(0) {} point(int x, int y) : x(x), y(y) {} point operator-(const point& p) const { return point(x - p.x, y - p.y); } int dot(const point& p) const { return x * p.x + y * p.y; } int cross(const point& p) c... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; int flag = 0, f = 0; cin >> s1 >> s2; int l = s1.length(); for (int i = 0; i < l; i++) { if (s1[i] < a ) { s1[i] += 32; } if (s2[i] < a ) s2[i] += 32; if (s1[i] != s2[i]) { f = i; ... |
#include <bits/stdc++.h> using namespace std; int n, k, f[33]; double ans = 0; vector<int> v[33]; string s; template <class T> ostream& operator<<(ostream& out, vector<T> v) { out << v.size() << n ; for (auto e : v) out << e << ; return out; } double check(int k) { double ans = 0,... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_str... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, i, e, f, g, n, m, k, l, A[500005], B[500005], fix[500005], root, ans, C[500005]; vector<long long> v[500005]; void dfs(long long x, long long y) { for (long long i = 0; i < v[x].size(); i++) { if (v[x][i] == y) continue; d... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 101; int n, m; struct price { int p; int au; bool operator<(const price &rhs) const { if (au == rhs.au) return p > rhs.p; return au < rhs.au; } } price[MAX_N]; int main() { scanf( %d%d , &n, &m); for (int i =... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int N = 2e5 + 6; int cnt[666], dp[777][777]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int _, n; cin >> _; while (_--) { cin >> n; for (int i = 0; i <= n - 1; i++) c... |
#include <bits/stdc++.h> using namespace std; bool calculate_digits(int a) { int sum = 0; while (a > 0) { sum += (a % 10); a = a / 10; } if (sum % 4 == 0) { return true; } else { return false; } } int main() { int a; cin >> a; for (int i = a; i <= a + ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, res = 0; cin >> n >> k; vector<int> arrAB; vector<int> arrA; vector<int> arrB; for (int i = 0; i < n; i++) { int time, a, b; cin >> time >> a >> b; if (a == 1 && b == 1) { arrAB.push_back(time); ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 100000; int n, k; char s[max_n + 5]; void solve(void); int main(void) { int t; scanf( %d , &t); while (t--) solve(); return 0; } void solve(void) { scanf( %d%d , &n, &k); scanf( %s , s); int i, j, t, ans = 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.