func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; string s; cin >> s; int x = 0; for (int i = 0; i < a - 1; i++) { if (s[i] > s[i + 1]) { cout << YES << endl; cout << i + 1 << << i + 2; return 0; } } cout << NO ; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, p, q, r; cin >> n >> p >> q >> r; long long int a[n], ans = LLONG_MIN; for (long long int i = 0; i < n; i++) cin >> a[i]; long long int prefixMax[n], suffixMax[n]; prefixMax[0] = p * a[0]; suffixMax[n - 1] = r * ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double PI = 3.141592653589793; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } struct Pt { double x, y; Pt(double a = 0, double b = 0) : x(a), y(b) {} bool operator==(const Pt& p) const { re... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; while (cin >> a >> b >> c >> d) { cout << (((a ^ b) & (c | d)) ^ ((b & c) | (a ^ d))) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; void exgcd(int a, int b, int *x, int *y) { if (b) { exgcd(b, a % b, y, x); (*y) = (*y) - (a / b) * (*x); } else *x = 1, *y = 0; } int main() { std::ios::sync_with_stdio(false); double r1, r2, c1, c2, d1, d2; cin >> r1 >> r2 >> c... |
#include <bits/stdc++.h> using namespace std; struct Node { int x, y, id; }; bool operator<(const Node &s, const Node &t) { if (s.x != t.x) return s.x < t.x; else return s.y < t.y; } int main() { int n, m; scanf( %d%d , &n, &m); vector<Node> vn; vector<int> ans; s... |
#include <bits/stdc++.h> 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; } n >>= 1; a *= a; } return p; } long long power(long long a, ... |
#include <bits/stdc++.h> using namespace std; string str1, str2; int main() { cin >> str1 >> str2; if (str1 == str2) cout << str1; else puts( 1 ); return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = unsigned long long; ll a[5], b[5], c[5], d[5], fl, k, cnt, vis[10]; set<pair<ll, ll> > st; map<pair<ll, ll>, ll> mp; vector<ll> G[10]; set<ll> stt; void dfs(ll u = 1, ll par = -1) { vis[u] = 1; cnt++; for (ll v : G[u]) { if (par ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int d, n, c, ans, m; string arr[105]; cin >> n >> d; ans = 0; m = 0; for (int i = 0; i < d; i++) { cin >> arr[i]; c = 0; for (int j = 0; j < n; j++) { if (arr[i][j] == 1 ) c++; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int get_inv(int x) { return (x == 1) ? 1 : (mod - (long long)(mod / x) * get_inv(mod % x) % mod); } const int MaxN = 200010, MaxT = 1 << 19; struct tree_node { int k, sum; int lazy; tree_node() { k = lazy = 1; } } T[... |
#include <bits/stdc++.h> using namespace std; char str[500005], cmd[500005]; int baam[500005], daan[500005], jora[500005]; int n, m, pos; long long bit[500005]; void update(int l, int r) { bit[l] += 1; bit[r + 1] -= 1; } void moveLeft() { if (baam[pos] > 0 && baam[pos] <= n) pos = baam[pos];... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 2e5 + 10; int n; int d[maxn]; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) { int u, v; scanf( %d%d , &u, &v); d[u]++; d[v]++; } for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<long long int> v; unordered_map<long long int, long long int> mapy; v.push_back(0); v.push_back(2); mapy[2] = 1; for (long long int i = 2; i <= 100000; i++) { v.push_back(((3 * (i * (i + 1))) / 2... |
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1); const int _ML = 500; const char _inpf[] = ; const char _outf[] = ; template <typename T, typename U> inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) { _out << _p.x << << _p.y; return _out; } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n == 1) { cout << 1 n0 1 n0 n1 ; return 0; } vector<long long> p1, p2; p1.push_back(1); p1.push_back(0); p2.push_back(1); for (long long i = 1; i < n; i++) { vector<long long>... |
#include <bits/stdc++.h> using namespace std; int main() { long n, d, a[100000], diff; long sum = 0; cin >> n >> d; for (long i = 0; i < n; i++) cin >> a[i]; for (long i = 1; i < n; i++) { if (a[i - 1] >= a[i]) { diff = a[i - 1] - a[i]; a[i] = a[i] + (diff / d + 1) * d; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 55, p = 1e9 + 7; int n, m; long long inv[Maxn], f[Maxn][Maxn], g[Maxn][Maxn], sum[Maxn][Maxn]; long long get_inv(int x) { return x <= 1 ? 1 : (p - p / x) * get_inv(p % x) % p; } int main() { scanf( %d%d , &n, &m); for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; int m, n; long long mas[300007]; long long ex[300007]; vector<long long> s; int main() { scanf( %d %d , &m, &n); for (int i = 0; i < m; i++) { scanf( %I64d , &mas[i]); } for (int i = 0; i < n; i++) { scanf( %I64d , &ex[i]); } ... |
#include <bits/stdc++.h> using namespace std; const int M = 1500 + 10; int n, x, y; struct node { int xx, yy, id; bool operator<(const node &a) const { if (xx - x >= 0 && a.xx - x <= 0) return 1; if (xx - x <= 0 && a.xx - x >= 0) return 0; return (yy - y) * (long long)(a.xx - x) < (a.y... |
#include <bits/stdc++.h> using namespace std; long long n, m; pair<long long, long long> a[3005]; long long v[3005]; vector<long long> vec[3005]; priority_queue<long long, vector<long long>, greater<long long> > mc; bool compare(pair<long long, long long> a, pair<long long, long long> b) { return a > ... |
#include <bits/stdc++.h> using namespace std; long long int res[100005]; int main() { long long int n; scanf( %lld , &n); if (n % 4 == 2 || n % 4 == 3) { printf( -1 ); exit(0); } long long int c = 2; for (long long int i = 0; i < n / 2; i += 2) { res[i] = c; res[i +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 7; const int maxm = 1e5 + 7; struct Que { int l, r, rt, id; }; struct Data { int sum; int id; bool operator<(const Data& a) const { return (sum == a.sum) ? (id < a.id) : (sum > a.sum); } }; struct Edge { i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5000; int p[MAXN], size[MAXN], n, m; int find_set(int v) { return v == p[v] ? v : p[v] = find_set(p[v]); } void union_set(int x, int y) { x = find_set(x); y = find_set(y); if (x != y) { if (size[x] < size[y]) swap(x, y); p[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int MOD = 1000000009; int parent[N]; int Rank[N]; int Find(int x) { if (parent[x] != x) { parent[x] = Find(parent[x]); } return parent[x]; } bool Union(int x, int y) { x = Find(x); y = Find(y); if (x... |
#include <bits/stdc++.h> using namespace std; int n, m, a[100005], b[2005], d[100005], z[100005], L[100005]; inline void upd(int &a, int b) { if (a < b) a = b; } int main(void) { while (cin >> n >> m) { for (int i = int(1); i <= int(n); i++) cin >> a[i]; for (int i = int(1); i <= int(m); i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, r[200005], cnt = 0; bool valid[200005]; pair<int, int> p; pair<int, pair<int, int> > u; vector<int> v; vector<pair<int, pair<int, int> > > event; priority_queue<pair<int, int> > pq; scanf( %d %d , &n, &k); fo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; struct Splay { struct node { node *fa, *ch[2]; int num, key, mx, mn, tg; } pl[2 * MAXN + 5], *root, *NIL; Splay() { root = NIL = &pl[0]; NIL->ch[0] = NIL->ch[1] = NIL->fa = NIL; NIL->mx = -MAXN, NIL->m... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 23, MAXM = 2e4 + 10, LIM = (1 << MAXN), mod = 998244353; int n, f[1 << MAXN], g[1 << MAXN], F[1 << MAXN]; long long ans; int pcnt[1 << MAXN], psum[1 << MAXN], tag[1 << MAXN]; char s[MAXN][MAXM]; int cnt[MAXN][26]; int main() { for (int i... |
#include <bits/stdc++.h> using namespace std; struct input { int a; int b; }; int myfunc(input x, input y) { if (x.a > y.a) { return false; } else if (x.a < y.a) { return true; } else { if (x.b > y.b) { return false; } else { return true; } }... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { int n, x; cin >> n >> x; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> ... |
#include <bits/stdc++.h> using namespace std; int tc = 1; const int M = 1e9 + 7; const long long Inf = (long long)2e18 + 5; const int N = 2e5 + 5; std::vector<long long> a[N]; int solve() { int a; cin >> a; int z = 0; int bg = 0; int xx = 0; int mx = 0; long long ans = 0LL; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x1, x2, y1, y2; cin >> n >> m >> x1 >> y1 >> x2 >> y2; int dx = abs(x2 - x1); int dy = abs(y2 - y1); if (dx <= 4 && dy <= 2 || dy <= 4 && dx <= 2 || dx == 3 && dy == 3) { cout << First ; } else { cout << Secon... |
#include <bits/stdc++.h> using namespace std; int n, a, b, c; int main() { ios_base::sync_with_stdio(false); cin >> n >> a >> b >> c; if (n == 1) cout << 0 << endl; else if (c >= min(a, b)) cout << (n - 1) * min(a, b) << endl; else cout << min(a, b) + (n - 2) * c << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, m; cin >> n >> m; long long s = 0; for (long long i = 0; i < n; i++) { long long a; cin >> a; s += 2 * a; } if (n == m && n > 2) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); if ((s[l - 1] - 48) % 2 == 0) { int temp = s[l - 2] * 10 + s[l - 1]; if (temp % 4 == 0) { cout << 4 << endl; } else { cout << 0 << endl; } } else { cou... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (n == 1 && m == 2) { cout << 0 << endl; cout << 1 << << 1 << endl; cout << 1 << << 2 << endl; cout << 1 << << 1 << endl; return 0; } if (n == 2 && m == 1) { cout... |
#include <bits/stdc++.h> using namespace std; int n, m; int c[100010]; int x[100010], y[100010]; vector<int> t[100010]; int f[100010]; int find(int x) { return (f[x] == -1 ? x : f[x] = find(f[x])); } int fa[100010], dep[100010]; int dfn[100010], rnk[100010], totn = 0; int siz[100010], son[100010], t... |
#include <bits/stdc++.h> #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( O3 ) #pragma GCC optimize( fast-math ) using namespace std; const int INF = 1e9; const long long INFll = 2e18; const int BASE1 = 179; const int BASE2 = 653; const long long MOD = 1e9 + 7; const int MAXN = 2e5; cons... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 10; long long n, m; long long res[N], sum[N], a[N]; long long len; struct Node { int x, p, id; } Q[N]; inline long long read() { long long x = 0, f = 0; char ch; while (((ch = getchar()) < 0 || ch > 9 ) && (ch != ... |
#include <bits/stdc++.h> using namespace std; long long readi() { long long input = 0; char c = ; while (c < - ) { c = getchar(); } bool negative = false; if (c == - ) { negative = true; c = getchar(); } while (c >= 0 ) { input = 10 * input + (c - 0 ); ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 200010; char str[MAXN + 1], S[MAXN... |
#include <bits/stdc++.h> using namespace std; int N, M; int main() { cin >> N >> M; int putere = 1; for (int i = 1; i <= M; i++) { putere <<= 1; if (putere >= 1000000009) putere -= 1000000009; } int val = 1; for (int i = putere - 1; i >= putere - N; i--) val = (1LL * val ... |
#include <bits/stdc++.h> using namespace std; const long long M = 4e5 + 10; long long t, n, k, p, a[M], dp[M], s[M], ans; long long bs(long long r, long long rem) { long long l = 0, mid; r++; while (r - l > 1) { mid = (r + l) / 2; if (s[mid] > rem) r = mid; else l =... |
#include <bits/stdc++.h> using namespace std; long long a[100001]; long long n, k; int main() { long long p = 0, no = 0; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); p = 0; for (int i = 0; i < n; i++) { if (p != a[i]) { no++; cout << a[i] ... |
#include <bits/stdc++.h> using namespace std; int n, a[1001], m, cnt[1001]; set<int> S; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i]; cnt[a[i]]++; } cout << *min_element(cnt + 1, cnt + n + 1); } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int q; cin >> q; vector<int> ta(n, -1); vector<int> payouts(q, 0); for (int i = 0; i < q; i++) { int k, p, x; cin >> k;... |
#include <bits/stdc++.h> using namespace std; const unsigned long long maxn = 200005; unsigned long long n, m, vis[maxn]; unsigned long long sum, A, B, C, he[maxn]; struct node { unsigned long long x, y; bool operator<(const node &a) const { return x == a.x ? x < a.x : y < a.y; } } chongtu[maxn]; ... |
#include <bits/stdc++.h> using namespace std; int arr[300005], key[300005]; struct node { int cnt; struct node *zero, *one; node() { cnt = 0; zero = NULL, one = NULL; } } * root; void Insert(int pat) { struct node *curr = root; int on = 1; for (int i = 30; i >= 0; i--) ... |
#include <bits/stdc++.h> int main() { int i, j, k, l, p, q, m = 1, a = 0, b = 0, c = 0; char s[50001]; scanf( %s , s); l = strlen(s); i = 0; if (s[i] == a && l > 1) { for (j = i + 1; j < l; j++) { if (s[j] != a ) { if (s[j] == b ) { for (p = j + 1; p < l... |
#include <bits/stdc++.h> using namespace std; int F[30030]; int n; int mod; int a[30030], id[30030]; int nxt[30030]; bool cmp(int i, int j) { return a[i] < a[j]; } int m; struct pnt { int l, r, i; pnt(int l = 0, int r = 0, int i = 0) : l(l), r(r), i(i){}; } q[30030]; bool operator<(pnt a, ... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define ld long double #define ff first #define ss second #define io ios_base::sync_with_stdio(false); cin.tie(NULL); #define yes cout<< YES #define no ... |
#include <bits/stdc++.h> using namespace std; unsigned long long min(unsigned long long x, unsigned long long y) { if (x < y) return x; return y; } unsigned long long max(unsigned long long x, unsigned long long y) { if (x < y) return y; return x; } long long min(long long x, long long y) { ... |
#include <bits/stdc++.h> const int maxn = 200000; using namespace std; int a[maxn], b[maxn]; int l[maxn], r[maxn]; int main() { int n, q; scanf( %d%d , &n, &q); a[0] = 0; for (int i = 1; i <= n; i++) scanf( %d , &a[i]), b[i - 1] = abs(a[i] - a[i - 1]); for (int i = 1; i <= q; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; vector<long long> a(n); long long mn = 1e5; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] < mn) { mn = a[i]; ... |
#include <bits/stdc++.h> using namespace std; const string roman[] = { M , CM , D , CD , C , XC , L , XL , X , IX , V , IV , I }; const int roman_num[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; int a; string b, c; string ans; long long toint(strin... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main(void) { int n, x, k; scanf( %d %d %d , &n, &x, &k); for (int i = 0; i < n; i++) { scanf( %d , a + i); } sort(a, a + n); long long sum = 0; for (int i = 0; i < n; i++) { long long p = (long long)ceil(a[i] ... |
#include <bits/stdc++.h> using namespace std; long long int min_answer; long long int max_answer = -1; void test_this_order(long long int a, long long int b, long long int c) { long long int new_n = (a + 1) * (b + 2) * (c + 2) - a * b * c; min_answer = std::min(min_answer, new_n); max_answer = std::... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int level = 20; vector<int> adj[N]; bool checked[N]; int parent[N]; int sz[N]; int centroid; int sparse[N][level]; int depth[N]; void subtree(int cur, int prev) { sz[cur] = 1; for (auto &child : adj[cur]) { i... |
#include <bits/stdc++.h> using namespace std; const int MX = 2000 + 1; const int M = 1e9 + 7; vector<pair<int, int>> adj[MX]; int dp[MX][MX]; int add(int a, int b) { return (a += b) < M ? a : a - M; } int mul(int a, int b) { return 1LL * a * b % M; } int floor_div(int a, int b) { return a / b - ((a ^ b)... |
#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); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; long long read() { long long s = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { s = s * 10 + ch - 0 ; ch = getchar(... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long inf = 1e18; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, b; cin >> n >> b; long long i = 2; long long ans = inf; while (i <= b) { if (i * i ... |
#include <bits/stdc++.h> using namespace std; const int ss = 1000; int n, k, ans, x; bool flag1, flag2; bool a[5000][5000]; int b[1002], tot; int main() { scanf( %d%d , &n, &k); memset(a, false, sizeof(a)); memset(b, false, sizeof(b)); flag1 = flag2 = false; n += ss; for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int q; cin >> q; while (q--) { long long n, a, b; cin >> n >> a >> b; if (n == 1) { cout << a << endl; continue; } if (n % 2 == 0) { long long... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double i = n / 3.0; int in = i; if (i - in > 0.6) in += 1; int f = in / 12; cout << f << << in - f * 12 << n ; } |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int pwr(int a, long long b) { int res = 1; for (; b; b >>= 1) { if (b & 1) res = 1LL * res * a % MOD; a = 1LL * a * a % MOD; } return res; } int T, n; int main() { ios_base::sync_with_stdio(false); cin... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long t = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { c = getchar(); } while (c >= 0 && c <= 9 ) t = t * 10 + c - 48, c = getchar(); return t * f; } char s[10000001]; long long len, hsh[... |
#include <bits/stdc++.h> using namespace std; int main() { string s, c; int n, t = 0; cin >> n; cin >> s >> c; for (int i = 0; i < n; i++) { int p = s[i], k = c[i]; if (p <= k) t += min(abs(p - k), (p + 1) + (9 - k)); else t += min((9 - p) + (k + 1), abs(p - k))... |
#include <bits/stdc++.h> using namespace std; const int MAX_BUF_SIZE = 16384; char BUFOR[MAX_BUF_SIZE]; int BUF_SIZE, BUF_POS; char ZZZ; const int MXN = 100010; const int C = 262144; const int INF = 1000000001; string a[MXN]; int aa; int typ[MXN], gender[MXN]; string fem[3] = { liala , etra , ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e5; class union_find { int n, no_of_comp; vector<int> par, sz; public: union_find(int nv) { n = no_of_comp = nv; par = sz = vector<int>(n + 1, 1); for (int i = 1; i <= n; i++) par[i] = i; ... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); int s = 0; s = n * (n + 1) / 2; if (s % 2 == 0) { printf( 0 ); } else { printf( 1 ); } return 0; } |
#include <bits/stdc++.h> using namespace std; vector<long long> com; vector<long long> all; long long c, a, n, k, mm; void solve() { long long s = 0, e = (long long)1e9 * 2 + 5; long long mid = 0; long long sum = 0; while (s <= e) { mid = (s + e) / 2; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; inline bool equal(double _x, double _y) { return _x > _y - 1e-9 && _x < _y + 1e-9; } int l[105], r[105], t[105], c[105], ans, mx, id; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) scanf( %d%d%d%d , &l[i], &r[i], &t[i], &... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1, typename Arg2> ostream& operator<<(ostream& out, const pair<Arg1, Arg2>& x) { return out << ( << x.first << , << x.second << ) ; } template <typename Arg1> ostream& operator<<(ostream& out, const vector<Arg1>& a) { out << [... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int mod = (int)1e+9 + 7; const double pi = acos(-1.); const int maxn = 100100; int x[maxn]; int z[10 * maxn]; int a, b; void fill(int u) { int lpos = (u - b % u) % u; for (; lpos <= a - b; lpos += u) { z[lpos] =... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int MOD = 1000000007; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; int n, m; char grid[65][65]; bool row(int row, char c) { for (int i = 0; i < m; i++) if (grid[row][i... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int main() { ios_base::sync_with_stdio(0); string s, t; cin >> s >> t; int n = s.size(), m = t.size(); vector<vector<int> > f(n + 1); vector<vector<int> > what(n + 1); vector<vector<pair<int, int> > > from(n ... |
#include <bits/stdc++.h> using namespace std; const long long int m = pow(10, 9) + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s, t; cin >> s >> t; int j = 0, l = -1, r = -1; for (int i = 0; i < t.length(); i++) { if (s[j] == t[i]) j++; if (j == s.le... |
#include <bits/stdc++.h> bool local = false; using namespace std; template <class T> string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> void print(T v) { cout << ((int)(v).size()) << n ; for (auto x : v) cout << x << ; cout << n ; ... |
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for (int (i) = 0; (i) < (n); (i)++) #define FORI(i, a, b) for (int (i) = (a); (i) < (b); (i)++) #define ll long long #define mp(m, n) make_pair((m), (n)) // #define DEBUG #ifdef DEBUG template<typename T> void _debug(string s, T x... |
#include <bits/stdc++.h> using namespace std; inline unsigned RD() { unsigned intmp(0); char rdch(getchar()); while (rdch < 0 || rdch > 9 ) rdch = getchar(); while (rdch >= 0 && rdch <= 9 ) { intmp = (intmp << 3) + (intmp << 1) + rdch - 0 ; rdch = getchar(); } return intmp... |
#include <bits/stdc++.h> using namespace std; const long long BIG = 1000000000000000000LL; void solve(); signed main() { ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } const long long borne = 3 * (long long)(1e5) + 5; long long tab[borne]; long long som[borne]; long long... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, x; cin >> a >> b >> c; if (a * c % 100 == 0) x = (a * c) / 100; else x = (a * c) / 100 + 1; if (x < b) cout << 0 << endl; else cout << x - b << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; struct node { char name[20]; int id; int num; } a[100005]; bool cmp(node x, node y) { if (x.id == y.id) return x.num > y.num; return x.id < y.id; } int main() { int n, m; while (cin >> n >> m) { for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int maxn = 4e2 + 5, maxk = 4e2 + 5, inf = 1e9 + 69, delta = 1e9 + 7, max_sum = 10000 + 5; inline vo... |
#include <bits/stdc++.h> using namespace std; int k; string n, m; int a[1001], b[1001], ns, ms; int fs, ss; int lcm(int, int); int gcd(int, int); int main() { cin >> k >> n >> m; ns = n.size(); ms = m.size(); for (int i = 0; i < ns; i++) { a[i] = (n[i] == R ? 0 : (n[i] == P ? 1... |
#include <bits/stdc++.h> using namespace std; int rd() { int x = 0, flg = 1; char c = getchar(); for (; (c < 48 || c > 57) && c != - ; c = getchar()) ; if (c == - ) flg = -1, c = getchar(); for (; c > 47 && c < 58; x = x * 10 + c - 48, c = getchar()) ; return flg * x; } con... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 21], *p1 = buf, *p2 = buf; template <class T> void read(T &x) { x = 0; int c = getchar(); int flag = 0; while (c < 0 || c > 9 ) flag |= (c == - ), c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ ... |
#include <bits/stdc++.h> using namespace std; double dist(double x1, double y1, double x2, double y2) { double dx = x1 - x2; double dy = y1 - y2; return sqrt(dx * dx + dy * dy); } double catet(double a, int b) { double z = a * a - b * b; if (z < 1e-12) z = 0; return sqrt(z); } int ma... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; const int N = 2 * 5e5 + 5; int n, m, q; int par[N], sub[N]; int p[N]; struct edge { int l, r, tag = 0; } elist[N]; vi g[N]; int dp[19][500005]; const int lg = 19; int po... |
#include <bits/stdc++.h> using namespace std; long long n, q; long long f(long long md) { return n - md + min(n - md, md * (md - 1) / 2); } signed main() { cin >> q; while (q--) { cin >> n; long long lo = 1, hi = n; while (lo + 1 < hi) { long long md = (lo + hi) >> 1; i... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100005; int n, q, tree_ct, k[Maxn], r[Maxn], ord[Maxn], Head[Maxn]; struct Tree { int lson, rson; long long k, b; } tree[24 * Maxn]; void build_first(int root, int lt, int rt) { if (lt + 1 == rt) tree[root].k = k[lt], tree[root... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100005; long long n, x[maxn], y[maxn]; bool flag; inline long long nxt(long long id) { return (id + 1) % n; } inline bool check(long long i, long long j) { return (x[i] + x[j] == x[nxt(i)] + x[nxt(j)]) && (y[i] + y[j] == y[n... |
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { while (b) { a %= b; swap(a, b); } return a; } int main() { int n, k, i; long double x, y, xant, yant; scanf( %d%d , &n, &k); double sol = 0; for (i = 0; i < n; i++) { cin >> ... |
#include <bits/stdc++.h> inline int A(int x, int y) { return x && y; } inline int O(int x, int y) { return x ^ y; } inline int X(int x, int y) { return x || y; } int main() { int t1, t2, t3, t4; scanf( %d%d%d%d , &t1, &t2, &t3, &t4); int a1 = O(t1, t2); int a2 = X(t3, t4); int a3 = A(t2, t3)... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int t, n, m; string x, y; int main() { cin >> t; while (t--) { cin >> x; cin >> y; n = (int)(x.length()); m = (int)(y.length()); reverse(x.begin(), x.end()); revers... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int w[MAXN]; map<int, int> f; long long Calc(long long Res, long long Mod) { if (Res > Mod) return Res % Mod + Mod; return Res; } long long power(long long a, long long n, long long Mod) { long long Res = 1; while (n) ... |
#include <bits/stdc++.h> using namespace std; int n, m; int check(int x) { int sum = 0; if (n <= ceil(x / 2)) sum++; if (m <= ceil(x / 3)) sum++; if ((n + m <= ceil(x / 2) + ceil(x / 3) - ceil(x / 6))) sum++; if (sum == 3) return 1; return 0; } int main() { cin >> n >> m; int x... |
#include <bits/stdc++.h> using namespace std; char a[60][60]; int ch(int r, int c) { int i, j, f = 0; for (i = 0; i < c; i++) { if (a[0][i] == P ) f = 1; } if (f == 0) return 0; f = 0; for (i = 0; i < c; i++) { if (a[r - 1][i] == P ) f = 1; } if (f == 0) return 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.