func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; string to_string(string s) { return + s + ; } string to_string(char s) { return string(1, s); } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } templat... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 != 0) cout << -1 << endl; else { for (int i = 1; i <= n; i++) { if (i % 2 == 0) cout << i - 1 << ; else cout << i + 1 << ; } } return 0; } |
#include <bits/stdc++.h> using namespace std; int N; int arr[51][51]; bool checkSum(int num, int row, int col) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (arr[row][i] + (long long int)arr[j][col] == num) { return true; } } } return false; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; double e[100010], r[100010], p[100010]; int main() { int n; { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %lf , &p[i]); } e[0] = p[0]; r[0] = p[0]; for (int i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<char, int> &a, pair<char, int> &b) { return a.second < b.second; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s[3]; int i; bool imp = false; unordered_map<char, int> m; vector<pair<char,... |
#include <bits/stdc++.h> using namespace std; void _dbg(string) { cout << endl; } template <class H, class... T> void _dbg(string s, H h, T... t) { int l = s.find( , ); cout << s.substr(0, l) << = << h << , ; _dbg(s.substr(l + 1), t...); } template <class T, class U> ostream &operator<<(... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int main() { double s, f, r, v; int n; scanf( %d%lf%lf , &n, &r, &v); while (n--) { scanf( %lf%lf , &s, &f); double ans = 0, d = f - s; int cnt = (int)floor(d / (2 * pi * r)); ans += cnt * 2 * pi * ... |
#include <bits/stdc++.h> using namespace std; long long d1[] = {0, 2, 3, 1}; long long fn1(long long start, long long pos, long long len) { long long zzz = len / 4; if (len == 1) return start; for (long long i = 0; i < 4; i++) { long long l = i * zzz; long long r = l + (zzz - 1); if ... |
#include <bits/stdc++.h> using namespace std; vector<long long> g[100009], df; long long n, v[100009]; long long used[100009], x, sum, plu[100009], minu[100009], br; void dfs(int node) { used[node] = 1; long long mxpl = 0, mxmi = 0; for (int i = 0; i < g[node].size(); i++) { if (used[g[node]... |
#include <bits/stdc++.h> using namespace std; long long num[100500]; long long d1[15], d2[15]; int main() { long long n; long long ans = 0; scanf( %lld , &n); for (int i = 1; i <= n; i++) { scanf( %lld , &num[i]); } for (int i = 1; i <= n; i++) { long long digit = 0; lo... |
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x > 0 ? x : -x; } int cur = 0; string get_next() { string ans = ; if (cur >= 26) { ans = B ; } else { ans = A ; } ans +... |
#include <bits/stdc++.h> using namespace std; int N, M; long long ans, add[400009], sum[400009]; set<pair<int, pair<int, int> > > segm; int mod(int x) { if (x < 0) return -x; return x; } void split(int nod, int l1, int l2) { if (add[nod] == 0) return; int f1 = nod << 1, f2 = (nod << 1) + 1... |
#include <bits/stdc++.h> using namespace std; set<int> q; const int maxn = 360; int main() { int t, n; scanf( %d , &t); while (t--) { scanf( %d , &n); int num = 360 / (180 - n); int ans = 0; if (num * (180 - n) != 360) num++; for (int i = num; i <= 360; i++) { i... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const double INF = 1e12, EPS = 1e-9; const int B = 2000; const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1}; int h, w, q; int qs[100000][4]; char in[100010][12], dir[256]; int dp[100010 * 12], vis[100010][12]; inline int to(in... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 350; const long long PHI = (long long)998244352; const long long INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const long long MOD = (long long)998244353; const long long OVER_FLOW = 0x7fffffff; const long long LOVER_FLO... |
#include <bits/stdc++.h> long long k, L, R, a[2222222], b[2222222], ans, sum[2222222]; int n, r; long long min(long long a, long long b) { return a < b ? a : b; } long long max(long long a, long long b) { return a > b ? a : b; } bool check(long long x) { long long ans = 0, now = 0; memset(b, 0, sizeof... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<long long> a(n); vector<int> nx(n); for (int i = 0; i < n; i++) { cin >> a[i]; } map<long long, int> mp; long long sig = 0; for (int i =... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, t; cin >> n >> t; long long int A[n]; for (long long int i = 0; i < n; i++) { cin >> A[i]; } long long int cnt = 0; long long int sum = 0; long long int i = 0; long long int j = 0; for (i = 0; i... |
#include <bits/stdc++.h> using namespace std; int nnext[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); } int main() { int n, m, k, idx, x, y, now, have, array[350][350]; cin >> n >> m >> k, x = y = 1, idx = now = have = 0; vector<... |
#include <bits/stdc++.h> using namespace std; const long long BINF = 9e18, LINF = 2e9, mod = 998244353, P = 179, Q = 1791791791; const long long MAXN = 1e4 + 7; long long a[MAXN], b[MAXN], c[MAXN]; vector<pair<long long, long long>> g[MAXN]; bool cmp(vector<pair<long long, long long>> &a, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 202000; int n, m; struct edge { int u, v, w; } edges[maxn]; int pre[maxn]; vector<edge> vec; int found(int x) { int rx = x; while (pre[rx] != rx) rx = pre[rx]; while (pre[x] != rx) { int tmp = pre[x]; pre[x] = rx;... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 18) + 100; const int maxnode = maxn << 2; int n, ai[maxn + 5]; int ls[maxnode + 5], rs[maxnode + 5]; int re[maxnode + 5], sp[maxnode + 5]; long long sum[maxnode + 5]; void Build(int x, int l, int r) { re[x] = sp[x] = 0; ls[x] =... |
#include <bits/stdc++.h> using namespace std; struct deal { long num_person; long num_shoue; vector<deal> *d; public: deal(long _p, long _s, vector<deal> *_d) { num_person = _p; num_shoue = _s; d = _d; } deal(long _p, long _s) { num_person = _p; num_shoue ... |
#include <bits/stdc++.h> using namespace std; inline int ckmax(int &a, int b) { return a < b ? a = b, 1 : 0; } inline int ckmin(int &a, int b) { return a > b ? a = b, 1 : 0; } struct matrix { double x[128][128]; double *operator[](int a) { return x[a]; } void clear() { memset(x, 0, sizeof(x)); } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; int n, value; char str[200]; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> str; if (strcmp(str, add ) == 0) { cin >> value; v.insert... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while ((~c && c < 0 ) || c > 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; set<pair<long long, long long> > st; int resp[maxn]; struct island { long long ini, fim; } isl[maxn]; struct event { long long type, val, ini; event() { type = 0, val = 0, ini = 0; } event(long long a, long long b, long... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[10000], i, sum = 0; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } int maxv = a[0]; int minv = a[0]; for (i = 1; i < n; ++i) { if (maxv < a[i]) { maxv = a[i]; sum++; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; int s[505][505]; int main() { scanf( %d%d , &n, &m); char c = getchar(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { c = getchar(); if (c == S ) s[i][j] = 0; else if (c == W ) ... |
#include <bits/stdc++.h> int main() { int n, i, j, c = 0, p, q, f = 0; scanf( %d , &n); scanf( %d , &p); int a[p]; for (i = 0; i < p; i++) scanf( %d , &a[i]); scanf( %d , &q); int b[q]; for (i = 0; i < q; i++) scanf( %d , &b[i]); for (i = 1; i <= n; i++) { f = 0; for (j... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000018; char str[2][510000], text[1010000]; int n, ans[1010000], num_node, fail[1010000], nxt[1010000], len[1010000], to[1010000][26], path[1010000], pa[1010000]; int dl[1010000], last, save[1010000], ie[1010000]; void init() { num_nod... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double INF = 1e6; const double PI = atan2(0, -1); const int maxn = 550; inline int sgn(double x) { if (fabs(x) < EPS) return 0; return x < 0 ? -1 : 1; } inline int iseq(double x, double y) { return sgn(x - y) == 0; } ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; vector<long long> arr(n); for (long long i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end()); if (arr[n ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { if (y == 0) return 1; if (y & 1) return (x * power(x, y - 1)) % 1000000007; long long int t = power(x, y / 2); return (t * t) % 1000000007; } int main() { ios_base::sync_with_stdio(false); ... |
#include <bits/stdc++.h> const int N = 1000010; const int inf = 0x3f3f3f3f; using namespace std; int n, m; int c[N]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int a, b; scanf( %d%d , &a, &b); c[a]++; c[b]++; } if (n < 3) return puts( 0 ), 0; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using dd = double; using pii = pair<int, int>; using pll = pair<ll, ll>; ll INFLL = (ll)2e18, MOD = 1e9 + 7; const int INF = 0x6f6f6f6f; vector<vector<ll>> adj; vector<int> vis; int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, int> > H[1000007]; long long n, val[1000005], ans, cnt[1000005]; int S[1000005]; int m, up[1000005], p[1000005], len, b[1000005], mp[1000005]; void prepare() { int i, j; b[1] = 1; for (i = 2; i < 1000005; i++) { if (!b[i]... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); long long n, i, j, k, l, m, arr[100010], arr1[100010], x, y; double a, b, c, d, p, t; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); reve... |
#include <bits/stdc++.h> using namespace std; int in() { int n; scanf( %d , &n); return n; } long long Lin() { long long n; scanf( %lld , &n); return n; } double Din() { double n; scanf( %lf , &n); return n; } const long long inf = (long long)1e17; const long long m... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, k; cin >> n >> k; int r[257] = {}; for (int i = 0; i < 257; i++) { r[i] = -1; } int p; for (int i = 0; i < n; i++) { cin >> p; if (r[p] == -1) { for (int j = (p - k + 1 >= 0) ? p - k + 1 : 0; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int i = n / 2 - 1, j = n / 2; sort(arr, arr + n); int x = 0; int ans[n]; if (n % 2) ans[0] = arr[n / 2], x++, j++; for (; i >= 0 && j < n; i--,... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); void test_case() { int n; cin >> n; cout << fixed << setprecision(10) << (1 / tan(PI / (2 * n))) << n ; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tc; cin >> tc; for (int tt = 1; t... |
#include <bits/stdc++.h> struct node { char a; struct node *left; struct node *right; }; int main() { int t, len; char ch[205]; struct node *p, *q, *r[26]; scanf( %d , &t); getchar(); while (t--) { int flag = 0; scanf( %s , ch); len = strlen(ch); for (in... |
#include <bits/stdc++.h> using namespace std; const int N = int(2e6); int n; bool used[N + 7]; int main() { cin >> n; for (int i = 2; i * i <= N; ++i) { if (!used[i]) { for (int z = i * i; z <= N; z = z + i) used[z] = true; } } int cnt = 0; for (int i = 2; i <= N; ++i) ... |
#include <bits/stdc++.h> using namespace std; long long const M = 2e5 + 10, M2 = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long tmp = 1; for (long long i = 1;; i++) { if (tmp - 1 >= n) r... |
#include<bits/stdc++.h> using namespace std; #define pi acos(-1) #define printfl printf( %f n ,f) #define printd printf( %lf n ,d) #define printi printf( %d n ,p) #define printl printf( %ld n ,l) #define printll printf( %lld n ,ll) #define case cout<< Case <<TEST<< : #define forcase for... |
#include <bits/stdc++.h> using namespace std; long long mod_factorial[100005]; long long mod_inv_factorial[100005]; long long binpow(long long a, long long b) { long long res = 1LL; while (b) { if (b & 1) { res = (res * a); } a = (a * a); b >>= 1; } return res; ... |
#include <bits/stdc++.h> using namespace std; int main() { bool discount_flag = true; int num_of_session; cin >> num_of_session; vector<int> num_of_teams(200001); for (int i = 0; i < num_of_session; i++) cin >> num_of_teams[i]; for (int i = 0; i < num_of_session; i++) if (num_of_teams[... |
#include <bits/stdc++.h> using namespace std; int fact(vector<int> x, long long t) { if (t == 1) return 1; vector<long long> num(x.begin(), x.end()); stringstream s; string tmp; s << t; s >> tmp; int count = 0; for (int i = 0; i < num.size(); i++) { stringstream ss; strin... |
#include <bits/stdc++.h> using namespace std; void optimise() { ios_base::sync_with_stdio(false); cin.tie(NULL); } long long int mod = 998244353; long long int inf = 1e18 + 6; void normalize(long long int &a) { a = (a + mod) % mod; } long long int modmul(long long int a, long long int b) { a =... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; long long int a[n + 2]; vector<long long int> pre(n + 2); for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { pre[i] = pre[i - 1] + a[i]; ... |
#include <bits/stdc++.h> int main() { int t, a, b, i, temp; scanf( %d , &t); for (i = 1; i <= t; i++) { scanf( %d %d , &a, &b); if (b > a) { temp = a; a = b; b = temp; } while ((a * a) < 2 * a * b) { a++; } printf( %d n , a * a); } ... |
#include <bits/stdc++.h> using namespace std; long long a[222222], b[222222], c[222222], d[222222]; set<long long> st; set<long long>::iterator it; map<long long, long long> sp2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, k, x, s, i; cin >> n ... |
#include <bits/stdc++.h> using namespace std; const int INF32 = 0x3f3f3f3f; const double EPS = 1.0e-8; const double PI = acos(-1.0); struct Point { double x, y; Point(double _x = 0, double _y = 0) { x = _x; y = _y; } friend Point operator+(const Point &a, const Point &b) { re... |
#include <bits/stdc++.h> using namespace std; int n; vector<array<int, 2>> v, good; long long f(int x, int y) { return abs(v[x][0] - v[y][0]) + abs(v[x][1] - v[y][1]); } int main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n; v.resize(n); long long ans = 0; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; const long long base = 7; const long long maxn = 1e6 + 9; const long long inf = 1e9 + 7; queue<long long> l[30], r[30], l1, r1, lf, rf; vector<pair<long long, long long> > res; long long n, i; string a, b; int main() { ios_base::sync_with_stdio(false);... |
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(false); int ans, cnt, k; string str; while (cin >> str >> k) { ans = 0; cnt = 0; int len = str.length(); for (int i = len - 1; i >= 0; i--) { if (str[i] == 0 ) { ans++; }... |
#include <bits/stdc++.h> using namespace std; int b, d, ans, l, h; char a[105], c[105]; bool letter[30]; int lena, lenc; int ll[105], yy[105]; char aa[105 * 105]; inline int ok() { memset(letter, 0, sizeof(letter)); for (char *p = a; *p; ++p) letter[*p - a ] = 1; for (char *p = c; *p; ++p) ... |
#include<bits/stdc++.h> #define pb push_back #define mk make_pair #define ll long long #define ss second #define ff first #define pll pair<ll,ll> #define vll vector<ll> #define mll map<ll,ll> #define mod 1000000007 #define w(x) ll x; cin>>x; while(x--) #define ps(x,y) fixed<<setprecision(y)<<x; ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int MAXV = 100010; const int MAXT = 333; int a[MAXN], n; int b[MAXN], m; int s, e; vector<int> ind[MAXV]; int p[MAXN][MAXT]; int main() { scanf( %d%d%d%d , &n, &m, &s, &e); for (int i = int(0); i <= int((MAXV)-1); +... |
#include <bits/stdc++.h> using namespace std; struct rec { int x, y; } p; char a[2][100010]; queue<rec> q; int d[2][100010], n, k; bool bfs() { memset(d, -1, sizeof(d)); q.push((rec){0, 1}); d[0][1] = 0; while (q.size()) { p = q.front(); q.pop(); if (p.y + k > n) retu... |
#include <bits/stdc++.h> using namespace std; struct node { int Tea; int Index; friend bool operator<(const node& a, const node& b) { return a.Tea > b.Tea; } } D[105]; int main() { int i, n, w, Ans[105]; scanf( %d%d , &n, &w); for (i = 0; i < n; i++) { scanf( %d , &D[i].Tea); ... |
#include <bits/stdc++.h> int main() { int n, s, k = 0; scanf( %d %d , &n, &s); while (s > 0) { s -= n; k++; } printf( %d , k); return 0; } |
#include <bits/stdc++.h> using namespace std; #define y1 temp_y1 #define all(x) x.begin(), x.end() const int N = 3e5 + 5; int n; int lst[N]; int fa[N]; vector<int> g[N]; int min_leaf = -1; int ext_cnt = 0; bool ok = true; void dfs1(int u, int k) { for (auto v : g[u]) ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<int, int>> flowers; vector<int> first_flowers; vector<long long> pref_sum; long long answer; void In() { flowers.clear(); pref_sum.clear(); first_flowers.clear(); answer = LLONG_MIN; cin >> n >> m; flowers.resize(m... |
#include <bits/stdc++.h> using namespace std; int digit(long long int n) { if (n > 0) return (digit(n / 10) + 1); return 0; } int main() { long long int l, h; long long int a[] = {0, 4, 49, 499, 4999, 49999, 499999, 4999999, 49999999, 49999999... |
#include <bits/stdc++.h> using namespace std; const int mo = 1e9 + 7; int main() { long long a, b, n; while (cin >> a >> b) { n = b - 1; long long ans = 0; for (int k = 1; k <= a; ++k) { ans = (ans + (((((k * b) % mo) * ((n * (n + 1) / 2) % mo)) % mo + (n *... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T BM(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; ... |
#include <bits/stdc++.h> using namespace std; const int N = 110; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int al, ar, bl, br; cin >> al >> ar >> bl >> br; if ((al * 2 + 3 > br && br >= al - 1) || (ar * 2 + 3 > bl && bl >= ar - 1)) cout << YES << endl; ... |
#include <bits/stdc++.h> using namespace std; long long int c = 0; void bfs(map<long long int, vector<long long int> > &map, vector<bool> &visited, long long int x) { queue<long long int> q; q.push(x); visited[x] = true; while (!q.empty()) { long long int y = q.front(); q.po... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = (int)2e5 + 100; const int M = (int)2e6 + 100; const int inf = (int)1e9 + 100; int a[N]; int b[N]; int t[4 * N]; map<int, int> m[4 * N]; void add(int x, int L, int R, int pos, int val) { t[x] = min(t[x], val); ... |
#include <bits/stdc++.h> using namespace std; bool custom(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) { return a.second < b.second; } return a.first < b.first; } bool c1(string a) { int dec = 0; for (int i = 0; i < a.size() - 1; i++) { if (a[i] >= a[i + 1]) { ... |
#include <bits/stdc++.h> using namespace std; int n, a, b; vector<vector<int> > adj; vector<int> col; queue<int> x, y; void colorear(int u, int c) { col[u] = c; for (int v : adj[u]) if (col[v] == -1) colorear(v, 1 - c); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); c... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[100000]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int go; cin >> go; a[i].first = go; a[i].second = i; } sort(a, a + n); int an = 0; for (int i = 0; i < n; i++) { k -... |
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include library/debug.cpp #else #define debug(...) #endif template <long long mod> struct modular { long long value; modular(long long x = 0) { value = x % mod; if (value < 0) value += mod; } modu... |
#include <bits/stdc++.h> using namespace std; const int Day = 86400; const long long INF = 1e18; const int N = 4004; long long dp[N][N], t[N], d[N]; int main() { int n, k; scanf( %d%d , &n, &k); for (int(i) = 0; (i) < (n); (i)++) scanf( %d%d , &t[i], &d[i]), t[i]--; if (n == k) return printf... |
#include <bits/stdc++.h> using namespace std; const int limN = 1e5 + 5; vector<pair<long long, int> > adj[limN]; bool usd[limN]; long long minP[limN]; int main() { int ans = 0; int N, E1, E2; priority_queue<tuple<long long, int, int> > Q; scanf( %d%d%d , &N, &E1, &E2); for (int a, b, c; ... |
#include <bits/stdc++.h> using namespace std; int n, m; int p[30]; char A[30], ch[205]; int d[405][405]; int now[205], minv[205], minc[205]; int fan(int x) { return (x > n) ? (x - n) : (x + n); } int main() { scanf( %s , A); int tot = strlen(A); for (int i = 0; i < tot; ++i) { p[i] = A... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.size(); bool flag = false; for (int i = 0; i < len - 1; i++) { if ((s[i] != a && s[i] != e && s[i] != i && s[i] != o && s[i] != u )) { if (s[i] == n ) continue;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1007; bool ans[MAXN]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int n = s.size(); int l = 0; for (int i = 0; i < n; ++i) { if (s[i] == a && (i == n - 1 || s[i + 1] == b )) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX_MEM = (int)1e8; int mpos = 0; char mem[MAX_MEM]; inline void *operator new(size_t n) { char *res = mem + mpos; mpos += n; return (void *)res; } inline void operator delete(void *) {} struct __io_dev { __io_dev(const bool &__fast... |
#include <bits/stdc++.h> using namespace std; int t, n, p[100002]; bool id[100002]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); for (int i = 1; i <= n; i++) { int a; scanf( %d , &a); p[a] = i; id[i] = true; } id[n + 1] = 0; b... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1e9 + 7; void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } unsigned long long int POW(unsigned long long int p, int b) { unsigned long long int ans = 1LL; while (b > 0) { if (b & 1) { ans =... |
#include <bits/stdc++.h> using namespace std; long long q, dp[105][100005], a[555555], b[555555], k, l, m, n, o, p; map<long long, long long> mp; vector<long long> adj[555555]; const long long mod = 1e9 + 7; void solve() { cin >> n; for (long long i = 1; i <= n; i++) { string s = ; cin... |
#include <bits/stdc++.h> using namespace std; const bool debug = false; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s[8]; for (int i = 0; i < 8; i++) { cin >> s[i]; } int r = 0, col = 0; for (int i = 0; i < 8; i++) { int c = 0; for (int j =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; const int mod = 1000000007; long long dp[maxn][maxn]; long long s[maxn][maxn], ss[maxn][maxn]; void upd(long long &t, long long k) { t += k; t %= mod; } int main() { int n, i, j, m; long long t; cin >> n >> m; f... |
#include <bits/stdc++.h> using namespace std; long long a, b, w, x, c, ans; int main() { cin >> a >> b >> w >> x >> c; if (c <= a) { cout << 0 << endl; } else { ans = ceil(1.0 * (x * (c - a) - b) / (w - x)); cout << ans + c - a << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, d, b, l, r, need, ans1, ans2; long long a[500011], n1[500011], n2[500011]; int main() { scanf( %lld%lld%lld , &n, &d, &b); long long re = (n >> 1) * b; for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, ans; cin >> s; ans = s; s += s; for (int k = 0; k < 10; k++) { for (int i = 0; i < s.length(); i++) { s[i]++; if (s[i] > 9 ) s[i] = 0 ; } for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; str[0] = toupper(str[0]); cout << str; } |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int inf = 1e9; int mod = 1e9 + 7; const int M = 20; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int n = (int)s.length(); int dp[(1 << M)]; memset(dp, 0, sizeof(d... |
#include <bits/stdc++.h> using namespace std; const int maxm = 2e6 + 5; struct task { int t, k, d; } tasks[maxm]; int times[110]; int main() { for (int i = 0; i < 110; ++i) { times[i] = 0; } int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < m; ++i) { scanf( %d%d%d , &t... |
#include <bits/stdc++.h> using namespace std; const int N = 510; int t, n, m, a, b, c; vector<pair<int, int> > g[N]; int dp[N][N], inDegree[N][N], source, ans[N][N]; bool vis[N]; void dfs(int u) { if (vis[u]) return; vis[u] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i].fir... |
#include <bits/stdc++.h> using namespace std; int a[200005]; bool got[200004], gave[200004]; queue<int> q; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; got[a[i]] = 1; if (a[i] != 0) { gave[i] = 1; } } for (int i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) bool check(string pattern, string text) { int j = 0; int i = 0; while (i < text.size()) { if (pattern[j] == text[i]) { j++; } i... |
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); } void err(vector<string>::iterator it) {} template <typename T, typename... Args> vo... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int k; cin >> k; int sum = (1 << 18) - 1; cout << 3 3 n ; cout << sum << << (1 << 17) << << 0 << n ; cout << k << << sum << << 0 << n... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n + 1]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int i = n - 1; i >= 0; i--) { if (k % arr[i] == 0) { cout << (k / arr[i]) << endl; break; } ... |
#include <bits/stdc++.h> using namespace std; int a[200000]; int b[200001]; int br[200001]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; int minimum = 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.