func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long labs(long long a) { return a < 0 ? (-a) : a; } long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } template <typename T> struct Point { T x, y; Point() {} Point... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - ) f = -1, c = getchar(); while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f * x; } const int... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int q, n, a[505]; int main() { cin >> q; while (q--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; bool pd = 1; for (int i = 1; i < n; i++) { int xx = a[i] + 1; if (xx > n) xx = 1; ... |
#include<bits/stdc++.h> #define ll long long int #define mod 1000000007 using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; int A[n]; for(int i=0;i<n;i++) { cin>>A[i]; } bool flag=tr... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n; cin >> k; if (n < k) { cout << -1; return 0; } if (k == 1) { if (n == 1) cout << a ; else cout << -1; return 0; } if (k == 2) { for (int i = 0; i < n >>... |
#include <iostream> #include<bits/stdc++.h> #include<vector> #define fo(i,n) for(long long i=0;i<n;i++) #define ll long long int #define inf 999999999999999999 #define pb push_back #define fi first #define se second #define vi vector<ll> #define vii vector<vector<ll>> #define pi pair<ll,ll> #def... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5; int n, can_win[MAXN + 5], can_lose[MAXN + 5]; struct game { long long s, e; } a[MAXN + 5]; bool get_win(long long s, long long e) { assert(s <= e); if (e % 2 == 1) { if (s % 2 == 1) return 0; else ret... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int maxN = 100000; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int n, m; cin >> n >> m; int ok = 1; for (int i = 0; i < n; i++) { for (int k = 0; k < m; k++) { char c; cin >> c; ... |
#include <bits/stdc++.h> using namespace std; struct READ { int d1, d2, d3; READ(int d1 = -1, int d2 = -1, int d3 = -1) : d1(d1), d2(d2), d3(d3) {} template <class T> operator T() { T tmp; this->read(tmp); return tmp; } template <class T> void read(T& t) { cin >> ... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( O0 ) #pragma GCC optimize( O1 ) template <typename T> void vec_SUN(vector<T> &Vec) { vector<T> X; X = Vec; sort(X.begin(), X.end()); X.resize(unique(X.begi... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rang( chrono::high_resolution_clock::now().time_since_epoch().count()); const int M = 1e9 + 7; long long power(long long x, long long y) { long long v = 1; while (y > 0) { if (y & 1) v = v * x; y = y >> 1; x = x * x; } ... |
#include <bits/stdc++.h> int main() { int a, b, x, y, ans; scanf( %d %d , &a, &b); ans = a; while (a >= b) { x = a / b; ans = ans + x; y = a % b; a = x + y; } printf( %d , ans); return 0; } |
#include <bits/stdc++.h> using namespace std; char str[102]; char miao[] = miao. ; char lala[] = lala. ; int check(char* a) { int res = 0; int k = strlen(a); if (k < 5) return 0; if (strncmp(a, miao, 5) == 0) res += 2; if (strncmp(a + k - 5, lala, 5) == 0) res += 1; return res; } ... |
#include <bits/stdc++.h> using namespace std; long double esp = 1e-11; const long double PI = acos((long double)-1); const long long int INF = 0x3f3f3f3fll; const int MOD = 1000000007ll; const int maxn = 200001; int inv[maxn], pin_inv[maxn], pin[maxn]; void initCab(int N) { inv[0] = pin[0] = pin_inv... |
#include <bits/stdc++.h> using namespace std; const long long int dx[] = {0, 1, -1, 0, 1, -1, -1, 1}; const long long int dy[] = {-1, 0, 0, 1, 1, 1, -1, -1}; long long int gcd(long long int x, long long int y) { return (y != 0 ? gcd(y, x % y) : x); } long long int lcm(long long int x, long long int y) {... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 512; const int INF = 0x3f3f3f3f; long long dis[MAXN][MAXN], a[MAXN], ans[MAXN]; bool in[MAXN]; int n; void Floyd() { for (int k = n; k >= 1; k--) { int t = a[k]; in[t] = 1; for (int i = 1; i <= n; i++) { for (int ... |
#include <bits/stdc++.h> using namespace std; long n, m; vector<int> a[1000000]; bool yt = 0; map<int, int> rt; string t; long ry = 0; string p[] = { 1869 , 6198 , 1896 , 9186 , 9168 , 6189 , 8691 }; void df(int k) { for (int i = 1; i <= rt[k]; ++i) { ry = (ry * 10 + k) % 7; cout... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200005; const int Maxl = 20; int table[Maxl][Maxn]; int tableor[Maxl][Maxn]; int numlog[Maxn]; int n, a[Maxn]; void buildTable() { numlog[1] = 0; for (int i = 2; i <= n; i++) { numlog[i] = numlog[i >> 1] + 1; } for (int... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; int n, in[100010], cnt, dyn[100010]; void check() { if (cnt < 2) { printf( %d n , cnt); exit(0); } } int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &in[i]); for (int i = n - 1; i >= ... |
#include <bits/stdc++.h> using namespace std; int ma[(300 + 10)][(300 + 10)], dp[(300 + 10)][(300 + 10)][(300 + 10) << 1]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> ma[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y, c = 0, d = 0; cin >> n; long long m = n; while (n--) { scanf( %lld %lld , &x, &y); if (x > 0) c++; if (x < 0) d++; } if (c == m - 1 || d == m - 1 || c == m || d == m) cout << YES << endl; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int M = 1e5 + 50; map<int, int> vis, cnt; int main() { int n; long long ans = 0; scanf( %lld , &n); for (int i = 0; i < n; i++) { int ch, tmp; scanf( %d , &ch); if (!vis[ch]) { vis[ch] = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a = 0, b, c, d, i, j; char s[116][116]; cin >> n >> m; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { cin >> s[i][j]; } } for (i = 1; i <= n && a == 0; i++) { for (j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5010; int f[MAXN]; string s; int l; int ans[MAXN]; int help[MAXN]; int nim[MAXN]; int start[MAXN]; void init() { f[0] = 0; f[1] = 1; for (int i = 2; i <= l; ++i) { memset(nim, 0, sizeof(nim)); nim[f[i - 2] ^ f[0]]... |
#include <bits/stdc++.h> using namespace std; long long int skip_classes[501][501], dp[501][501], N, M, K; vector<int> timings[501]; vector<string> grid(501); void preprocess() { for (long long int i = 1; i <= N; i++) { int total_classes_on_day_i = timings[i].size(); for (int skip = 0; skip <=... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> years; int curr = 1; for (int i = 1; i <= n; ++i) { int x; cin >> x; if (x == curr) { ++curr; years.push_back(2000 + i); } } cout << years.size() << endl; f... |
#include <bits/stdc++.h> using namespace std; int n, k, a[100005]; bool pos(int len) { set<pair<int, int> > ms; for (int i = 1; i <= n; i++) { ms.insert(make_pair(a[i], i)); if (i >= len) { auto it = ms.begin(); int mn = (*it).first; it = ms.end(); it--; ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int power(int a, int b, int m, int ans = 1) { for (; b; b >>= 1, a = 1LL * a *... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans = 0; cin >> n; string x; cin >> x; for (long long int i = 0; i < x.length(); i++) { if (x[i] == 0 || x[i] == 2 || x[i] == 4 || x[i] == 6 || x[i] == 8 ) { ans += (i + 1); } }... |
#include <bits/stdc++.h> using namespace std; int r, c, d[1020][1020], used[1020][1020]; string s[1020]; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; long long ans = 0; bool ok(int x, int y) { return x >= 0 && x < r && y >= 0 && y < c && s[x][y] != T ; } void bfs(int x, int y) { used[x... |
#include <iostream> using namespace std; typedef long long ll; int main() { int t; cin >> t; while (t--) { ll n, m, x; cin >> n >> m >> x; x--; ll j = x / n, i = x % n; cout << i * m + j + 1 << n ; } cin.ignore(2); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, mp[5][1000050]; int sta[20], cnt[20], tot; char s[1000050]; int f[1000050][20], ans; void init() { for (int i = 0; i < (1 << n); i++) { sta[++tot] = i; int u = i; while (u) { cnt[tot] += ((u % 2) ^ 0); u >>= 1; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long long INF = 1e9; const int MX = 2e5 + 10; const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; template <class T> using V = vector<T>; template <class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; ... |
#include <bits/stdc++.h> using namespace std; int i, j, k, m; int a[100010]; long long f[110][100010], n; long long dfs(int n, long long m) { if (!n) return m; if (m < 100010 && f[n][m] >= 0) return f[n][m]; long long A = dfs(n - 1, m) - dfs(n - 1, m / a[n]); if (m < 100010) f[n][m] = A; r... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s, t; cin >> s >> t; int sum1 = 0, sum2 = 0, sum3 = 0; for (int i = 0; i < 2 * n; i++) { if (s[i] == 1 && t[i] == 1 ) { sum3++; ... |
#include <bits/stdc++.h> using namespace std; int ni() { int a; scanf( %d , &a); return a; } double nf() { double a; scanf( %lf , &a); return a; } char sbuf[100005]; string ns() { scanf( %s , sbuf); return sbuf; } long long nll() { long long a; scanf( %lld , &a)... |
#include <bits/stdc++.h> using namespace std; const int MAX = 0x3f3f3f3f; const double EPS = 1e-6; const double PI = acos(-1.0); string second; int ch = 0; signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> second; for (int i = 0; second[i]; i++) { while (ch != second[i] + 1... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, a[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); if (a[n] >= a[n - 1] + a[n - 2]) cout << NO ; else { cout << YES n ; cout << a[n] << ; for (... |
#include <bits/stdc++.h> const int MAXN = 4e5 + 5, MAXLOG = 20, MAXS = MAXN * 50; template <typename _T> void read(_T &x) { x = 0; char s = getchar(); int f = 1; while (s > 9 || s < 0 ) { if (s == - ) f = -1; s = getchar(); } while (s >= 0 && s <= 9 ) { x = (x << 3... |
#include <bits/stdc++.h> using namespace std; int main() { int n, result = 0; { cin >> n; float init = sqrt(n); if (init == floor(init)) cout << init * 4 << endl; else { int init2 = floor(init); n = n - init2 * init2; result = init2 * 4; if (n ... |
#include <bits/stdc++.h> using namespace std; const long long FASTIO = []() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); return 0; }(); long long n; vector<vector<long long>> ans; long long ask(long long x1, long long y1, long long x2, long long y2) { cout << ? << x1 << << ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l[2005], r[2005], t, k; cin >> t; while (t) { int q = 0, next = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; if (i == 0) { next = l[i] + 1; cout << l[i] << ; ... |
#include <bits/stdc++.h> using namespace std; int n, a[500005], b[500005]; char s[500005]; int res = 1e9, xx, yy; int calc2(int x, int y) { if (x == 0 && y == 0) return 1000000000; int ans = 0; for (int i = 1; i <= n; i++) { if (x <= a[i] && y <= b[i]) ans = max(ans, max(a[i] - x, b[... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, num, l, r; string str, res; cin >> n; l = 1e9; l = l * (-2); r = 1e9; r = r * (2); while (n--) { cin >> str >> num >> res; if (str == > ) { if (res == Y ) l = max(l, num + 1); ... |
#include <bits/stdc++.h> using namespace std; bitset<1005> b[1005]; int n, m; bool ok2(int r, int c) { if (r + 2 > n || c + 2 > n) return false; for (int i = r; i < r + 3; i++) for (int j = c; j < c + 3; j++) { if (!b[i].test(j)) return false; } return true; } bool ok(int r, ... |
#include <bits/stdc++.h> using namespace std; int n, m, q; vector<int> colors[100013]; unordered_map<int, vector<int> > adj[100013]; unordered_map<int, int> p[100013]; unordered_map<int, int> h[100013]; pair<int, int> visited[100013]; unordered_map<int, int> precalc[100013]; int BIG = 200; int findS... |
#include <bits/stdc++.h> using namespace std; long long int n, a, b; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; cout << a + b << endl; } return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; w... |
#include <bits/stdc++.h> int main() { int n, i, j; int a[110][110]; long long ans[150]; while (scanf( %d , &n) != EOF) { for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) scanf( %d , &a[i][j]); memset(ans, 0, sizeof(ans)); for (i = 1; i <= n; i++) { for (j = 1; j <= n... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, i, sum = 0, k, l = 10000000000; cin >> n; for (i = 1; i <= n; i++) { cin >> a; sum += a; if (a % 2) l = min(l, a); } if (sum % 2 == 1) sum -= l; cout << sum << endl; } |
#include <bits/stdc++.h> using namespace std; long long q, t; bool f(long long x) { for (long long i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } int main() { ios::sync_with_stdio(false); cin >> q; while (q--) { long long ans = 0; cin >> t; { ... |
#include <bits/stdc++.h> const int maxn = 200005; int v[maxn], fa[maxn], ans[maxn], num[maxn]; int n, m; int findset(int x) { if (fa[x] != x) { fa[x] = findset(fa[x]); } return fa[x]; } void _union(int x, int y) { int p = findset(x); int q = findset(y); if (p != q) { fa[p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; bool f = 0; long last = -1, c = 0; long ans = 0; for (register int i = 0; i < s.length(); i++) { if (s[i] == F ) { if (last == -1) { last = i; ... |
#include <bits/stdc++.h> using namespace std; long long n, ara[100005], i, j, k, ind, mx, sum, ans, ans1; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> ara[i]; } for (i = 0; i < n; i++) { if (ara[i] >= k) { k = ara[i]; ind = i; } } for (i = 0; i ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); string s, t; cin >> s >> t; int64_t n = s.size(); int64_t m = t.size(); vector<vector<int64_t>> dp(n + 1, vector<int64_t>(n + 1, 0)); dp[0] = vector<int64_t>(n + 1, 1); for (in... |
#include <bits/stdc++.h> using namespace std; bool isprime(unsigned long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (unsigned long long i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return t... |
#include <bits/stdc++.h> using namespace std; map<string, int> m; int main() { int n, ans = 0; string str; scanf( %d , &n); for (int i = 0; i < n; i++) { cin >> str; m[str]++; ans = max(ans, m[str]); } cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m; struct pos { long long x, y; bool operator<(const pos &p) const { if (x != p.x) return x < p.x; return y < p.y; } } A[200005], stk[200005]; bool check(pos a, pos b, pos c) { return (c.y - a.y) * (b.x - c.x) <= (b.y - c.y) * (c... |
#include <bits/stdc++.h> using namespace std; struct fast_ios { fast_ios() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is... |
#include <bits/stdc++.h> using namespace std; int b[101]; int main() { int n, x; cin >> n >> x; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]]++; } int t = 0; for (int i = 0; i < x; i++) { if (b[i] == 0) { t++; } } if (b[x] == ... |
#include <bits/stdc++.h> using namespace std; int n, m, t; int data[105][3]; bitset<50> mark; set<pair<long long, long long> > ss; struct Node { pair<long long, long long> g; void reset() { g.first = g.second = 0; } void set(int x) { if (x < 50) g.first |= 1ll << x; else ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int z = N * 32; int n, a[N], f[N], rt; int pool[z], tp, cnt, ch[z][2]; long long ans; int fa(int x) { if (x == f[x]) return x; return f[x] = fa(f[x]); } void uni(int x, int y) { x = fa(x), y = fa(y); if (x == y) ... |
#include <bits/stdc++.h> using namespace std; int k, l; int main() { int i, n; scanf( %d , &n); getchar(); char ch[1000]; scanf( %s , ch); for (i = 0; i < n; ++i) { if (ch[i] == 0 ) k++; else l++; } if (n % 2 == 1 || k != l) { printf( 1 n%s n , ch... |
#include <bits/stdc++.h> using namespace std; long long n, m, A[300005], fix[300005], fix1[300005], B[300005], C[300005]; long long BITree[900005], BITree1[900005]; long long getSum(long long index) { long long sum = 0; index = index + 1; while (index > 0) { sum += BITree[index]; index -... |
#include <bits/stdc++.h> using namespace std; const int inv = numeric_limits<int>::max(); const int minv = numeric_limits<int>::min(); const int max_n = 500010; int n; int a[max_n]; int b[max_n] = {0}; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); int c = 0; ... |
#include <bits/stdc++.h> using namespace std; struct edge { long long from, to, w; edge(int from, int to, long long w) : from(from), to(to), w(w) {} bool operator<(const edge& e) const { return ((w > e.w)); } }; void O_o() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(... |
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; if (n % 7 == 0) cout << 2 * n / 7 << << 2 * n / 7; else { if (n % 7 == 1) cout << 2 * (n / 7) << << 2 * (n / 7) + 1; else if (n % 7 < 6) cout << 2 * (n / 7) << << 2 * (n / 7) + ... |
#include <bits/stdc++.h> using namespace std; long long mod = (long long)(1e13) + 7LL; long long osn = 137LL; long long getHash(string &s) { long long res = 0LL, curr = osn; for (int i = 0; i < s.size(); i++) { if (s[i] >= 65 && s[i] <= 90) s[i] += 32; if (s[i] == o ) s[i] = 0 ; if (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; vector<int> circuit; vector<int> e[MAXN]; void calc(int v) { stack<int> s; while (true) { if (((int)e[v].size()) == 0) { circuit.push_back(v); if (!((int)s.size())) { break; } v = s.... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 5050; long long a[maxn]; long long c[maxn]; long long tag[maxn]; long long number[maxn]; int main() { long long i, j, k, n, m; while (scanf( %lld%lld , &n, &k) != EOF) { memset(tag, 0, sizeof(tag)); for (i = 1; i <= n... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, piles[100000], q; cin >> n; cin >> q; piles[0] = q; for (int i = int(1); i < int(n); i++) { cin >> q; piles[i] = piles[i - 1] + q; } cin >> m; for (int i = int(0); i < int(m); i++) { cin >> q; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx ) using namespace std; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) { is >> x; } ... |
#include <bits/stdc++.h> using namespace std; void read_file(bool outToFile = true) {} int n, m; int A[1000 + 9][1000 + 9]; long long K, sum; int mrk = 0, to; int vis[1000 + 9][1000 + 9] = {0}; int di[] = {1, 0, -1, 0}; int dj[] = {0, 1, 0, -1}; set<int> usedAs[1000 + 9][1000 + 9]; bool valid(int ... |
#include <bits/stdc++.h> int a[100005]; inline int max(int x, int y) { return x > y ? x : y; } int main() { int ans = 0, n, Max, Min, Maxpos, Minpos; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int l = 1, r = 1; while (r <= n && a[r] == a[1]) r++; if (r == n + 1) retu... |
#include <bits/stdc++.h> using namespace std; long long int n, m, sol = 1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; if (n > m) swap(n, m); if (((n % 10) + 1 <= 2 && n % 10 >= 1 && m % 10 >= 5) || (abs(n - m) > 10)) return cout << 0, 0; else { ... |
#include <bits/stdc++.h> const int oo = 0x3f3f3f3f; const double PI = acos(-1.0); const double EPS = 1e-8; using namespace std; int read() { int d, f = 1; char c; while (!isdigit(c = getchar())) if (c == - ) f = -1; d = c ^ 0 ; while (isdigit(c = getchar())) d = (d * 10) + (c ^ 0 ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; inline int read() { char c = getchar(); int x = 0; bool f = 0; for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -x; return x; } i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const int M = 1000000007; int t; int n, k; string s; int dp[1001][1002][2]; int get(int it, int d, bool complete, bool zero) { if (it == 0) return complete; if (zero && dp[it][d][complete] != -1) return dp[i... |
#include <bits/stdc++.h> using namespace std; int aray[100002]; int main() { int i, j, k, a, b, x, n, y, p, q, len, mx = 0, s = 1; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &aray[i]); } p = 0; q = 0; s = 0; for (i = 1; i < n; i++) { a = aray[i] - aray[i - 1... |
#include <bits/stdc++.h> using namespace std; int a[30010], n; bool vis[30010]; void print(vector<int> v) { for (int i = 0; i < v.size(); i++) printf( %d , v[i]); printf( n ); } bool check(vector<int> v) { if (!v.size()) return false; if (v.size() == 1 || v.size() == 2) return true; in... |
#include <bits/stdc++.h> using namespace std; int n, w; long long ans; double a[100010], b[100010]; struct node { int f, x, v; double a, b; } sh[100010]; double m_abs(double x) { if (x < 0) return -x; else return x; } bool cmp(node x, node y) { return (x.a < y.a || (x.a == ... |
#include <bits/stdc++.h> using namespace std; const int nm = 100010; const long long inf = 1000000000000000ll; int n; long long a[nm], b[nm]; pair<long long, int> dau[nm], cuoi[nm]; int main() { scanf( %d , &n); long long x1, x2; scanf( %I64d%I64d , &x1, &x2); for (int i = 1; i <= n; ++i) ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T getint() { T x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ); if (ch == - ) p = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x * p; } mt1... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; bool inBound(int x) { return x >= 0 && x < 30001; } int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0); int n, d; cin >> n >> d; int mx = 30000; vector<int> gems(mx + 1, 0); fo... |
#include <bits/stdc++.h> using namespace std; char s[555555]; int t[555555]; int n, a, b, T; int getAns() { for (int i = 0; i + 1 < n - 1 - i; i++) { swap(t[i + 1], t[n - 1 - i]); } if (t[0] > T) { return 0; } int ct = t[0]; int ans = 1; for (int i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int n_ = 3010; long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); } long long power(long long a, long long n) { long long p = 1; while (n > 0) { if (n % 2) { p = p * a; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dp[1005][2005]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= max(m, n); i++) { for (int j = 0; j <= i; j++) { if (j == 1) { dp[i][j] = i; continue; }... |
#include <bits/stdc++.h> using namespace std; const long long N = 8e6 + 7, mod = 998244353, root = 3; long long x[N], n, m, i, j, ma, mb, inv, res, b[N], ans[N], L, R[N]; long long pow_mod(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = 1LL * x * res % mod; x = 1L... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool readInteger(T& x) { char c, r = 0, n = 0; x = 0; for (;;) { c = getchar(); if ((c < 0) && (!r)) return (0); else if ((c == - ) && (!r)) n = 1; else if ((c >= 0 ) && (c <= 9 )) x ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int k; cin >> n; cin >> k; int array[n]; for (int i = 0; i < n; i++) { cin >> array[i]; } int e; int s; int a = 0; for (int i = 0; i < k; i++) { e = 0; s = 0; for (int j = 0; j < n; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200 + 5; int a[maxn], b[maxn]; int n, m, k, x; int getloc(int x) { for (int i = 1; i <= k; i++) { if (a[i] == x) return i; } } void update(int x) { int pos = 0; for (int i = 1; i <= k; i++) { if (a[i] == x) pos = i;... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e6 + 3; long long quickpow(long long a, long long x) { long long ans = 1; while (x) { if (x & 1) ans = ans * a % mod; x >>= 1; a = a * a % mod; } return ans; } int main() { long long n, k, x = 0, m = 0; ci... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 * 1000 + 10; pair<int, long double> song[maxn]; int n; long double ans, sum; inline bool cmp(const pair<int, long double> &a, const pair<int, long double> &b) { return ((long double)1 - a.second) * b.second * b.first < ... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<long long, pair<long long, long long> > &a, const pair<long long, pair<long long, long long> > &b) { return (a.second.first < b.second.first); } bool sortbyth(const pair<long long, pair<long long, long long> > &a, ... |
#include <bits/stdc++.h> using namespace std; int sgn(long long v) { return v > 0 ? 1 : 0; } int main(void) { long long p, q, r, s; cin >> p >> q >> r >> s; int n; int res = 0; cin >> n; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; long long temp1 = (a *... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; void solve() { int n; cin >> n; string s; cin >> s; long long ans = 0; long long ca = 0, cab = 0, cabc = 0, slen = 1; for (char c : s) { if (c == a ) ca = (slen + ca) % mod; else if (c == ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int M = (1 << 7); const int mod = 1e9 + 7; long long dp[N][M]; struct node { int v, s[8]; } a[N]; bool cmp(node b, node d) { return b.v > d.v; } int n, p, k; int main() { scanf( %d%d%d , &n, &p, &k); int st = 1 <... |
#include <bits/stdc++.h> using namespace std; const int logsize = 18; int n, m, q, rt = 1, t, sc, vis[100005], dfn[100005], low[100005], sid[100005], sz[100005], dep[100005], pr[100005][logsize], w[100005], mod = 1e9 + 7; stack<int> s; vector<int> g[100005], ng[100005]; int inl... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; const long long int Mod = 998244353; vector<int> adj[maxn]; long long int dp[maxn], pd[maxn], alone[maxn]; int n; void dfs(int u, int p = -1) { dp[u] = pd[u] = 0; alone[u] = 1; for (auto v : adj[u]) if (v ^ p) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 11; const int MAXN = 1e5 + 5; const int LG = 20; const int INF = 1e9; using ll = long long int; using ull = unsigned long long int; const ll MOD2 = 998244353; const ll MOD1 = 1e9 + 7LL; vector<int> g[MAXN], cg[MAXN]; vector<int> ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.