func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m; const int MAX_N = 100005; long long cost[MAX_N]; int r[MAX_N]; struct dish { int idx, cnt; long long c; bool operator<(const dish &d) const { if (c != d.c) return c < d.c; return idx < d.idx; } }; int main() { cin >>... |
/* -> Written by <- ----------- |K_A_Z_A_M_A| |___________| | ___ | | (^_^) | | /( | ) | |____|_|____| H O A N G */ #include <bits/stdc++.h> #define Task running #define F first #define S second #define pb ... |
#include <bits/stdc++.h> int main(void) { int m, n; char a[100001], b[100001]; scanf( %s , a); scanf( %s , b); n = strlen(a); m = strlen(b); if (n == m) { if (strcmp(a, b) == 0) printf( -1 ); else printf( %d , m); } else if (n > m) { printf( %d , n); ... |
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> m; int sum = 0, a; for (int i = 0; i < 5; i++) { cin >> a; m[a]++; sum += a; } int temp = 0; for (auto i : m) { if (i.second == 2) temp = max(temp, i.first * 2); if (i.second >= 3) temp = m... |
#include <bits/stdc++.h> using namespace std; const int max_n = 5005, inf = 1011111111; int n, p[max_n], b[max_n]; int pos[max_n]; vector<pair<vector<int>, pair<vector<int>, vector<int>>>> all; vector<pair<vector<int>, pair<vector<int>, vector<int>>>> my_all; void find_b() { for (int i = 0; i < n; ++i... |
#include<bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll t,i,maxi,sumi,mini; cin>>t; while(t--) { ll n; cin>>n; ll a[n]; for(i=0;i<n;i++) cin>>a[i]; maxi=-1; mini=a[0]; sumi=0; ... |
#include <bits/stdc++.h> using namespace std; long long PosMod(long long a) { return a >= 0 ? a : a + 998244353; } long long AddMod(long long a, long long b) { return PosMod((a + b) % 998244353); } long long MultMod(long long a, long long b) { return PosMod((a * b) % 998244353); } long long powll(... |
#include <bits/stdc++.h> using namespace std; const int lcd = 2 * 2 * 2 * 3 * 3 * 5 * 7 * 11 * 13; long long a, b, k, d[lcd], y = 0, l, i; int main() { cin >> a >> b >> k; while (a > b) { for (i = 2, l = 1; i <= k; i++) if (a % i > l && a - a % i >= b) l = a % i; y++; a -= l; ... |
#include <bits/stdc++.h> using namespace std; int cla[110]; int main() { int n; cin >> n; int cnt = 0; int c; int cnt0, cnt1; int flag = 0; for (int i = 0; i < n; i++) { cin >> c; if (c == 1) { if (cnt0 == 1 && flag == 1) cnt++; flag = 1; cnt0 = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int O = 0, E = 0; scanf( %d%d , &N, &K); for (int i = 0; i < N; i++) { int t; scanf( %d , &t); if (t % 2 == 0) E++; else O++; } if (N == K) { if (O % 2) puts( Stannis );... |
#include <bits/stdc++.h> using namespace std; int v[1000001]; int main() { int n; cin >> n; for (int i = 2; i * i <= 1000000; i++) if (v[i] == 0) for (int j = i * i; j <= 1000000; j += i) v[j] = 1; if (n > 2) cout << 2 << endl; else cout << 1 << endl; for (int i... |
#include <bits/stdc++.h> using ll = long long; using namespace std; const long double PI = acos(-1); const long long M = 998244353; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline long long mod(long long n, long long m = M) { long long ret = n % m; if (ret < 0) ret += m; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)5e6 + 100; const int maxm = (int)1e6 + 100; const int mod = (int)1e9 + 7; const int P = (int)1e6 + 7; const double pi = acos(-1.0); int n, t[2][maxn], id = 1; long long dp[2][30]; vector<int> g[maxn]; void add(int x, int pos) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int x[n], x1[m], x2[m], y[m]; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); vector<int> v; for (int i = 0; i < m; i++) { cin >> x1[i] >> ... |
#include <bits/stdc++.h> int main() { int n, result, count = 0, i; scanf( %d , &n); char arr[n]; for (i = 0; i < n; i++) { scanf( n%c , &arr[i]); } i = 0; for (i = 0; i < n; i++) { if (arr[i] != arr[i - 1]) { count++; } } if (count + 2 < n) { result... |
#include <bits/stdc++.h> using namespace std; typedef struct x { int cor; int power; bool operator<(x T) const { return cor < T.cor; } } beacon; beacon arr[2000009]; vector<int> tmp; int dp[2000009]; int main() { int n, m, k; scanf( %d , &n); for (int i = 0; i < n; i++) { sca... |
#include <bits/stdc++.h> using namespace std; template <class X = int> inline X min(X a, X b, X c) { return min(min(a, b), c); } template <class X = int> inline X min(X a, X b, X c, X d) { return min(min(a, b, c), d); } template <class X = int> inline X max(X a, X b, X c) { return max(max(... |
#include <bits/stdc++.h> using namespace std; int main() { char s1[50], s2[50]; cin >> s1 >> s2; long long left = 0, right = 0, mid = 0, l; l = strlen(s1); for (long long i = 0; i < l; i++) if (s1[i] == | ) { mid = i; break; } left = mid; right = l - (mid + 1... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, x, y, z, ans = 0; cin >> n >> x >> y >> z; for (long long i = 0; i <= x / 2; i++) { for (long long j = 0; j <= y; j++) { if ((n - (i + j)) % 2 == 0 && (n - (i + j)) / 2 <= z && (n - (i + j)) / 2 >= 0) ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, a, b, k, p[N]; int main() { cin >> n >> a >> b >> k; int sum = a + b; for (int i = 1; i <= n; i++) { cin >> p[i]; if (p[i] % sum == 0) p[i] = sum; else p[i] %= sum; p[i] -= a; } ... |
#include <bits/stdc++.h> using namespace std; const int64_t maxn = 1e3 + 42; vector<int64_t> g[maxn]; int64_t par[maxn], sz[maxn]; basic_string<int64_t> leaves[maxn]; void dfs(int64_t v) { sz[v] = 1; for (auto u : g[v]) { if (u != par[v]) { par[u] = v; dfs(u); sz[v] += ... |
#include <bits/stdc++.h> using namespace std; int n, d, h, i, j; int main() { cin >> n >> d >> h; if (d > h * 2) { cout << -1 << endl; return 0; } if (d == 1 && h == 1 && n > 2) { cout << -1 << endl; return 0; } for (i = 1; i <= h; i++) cout << i << << i + 1 << ... |
#include <bits/stdc++.h> using namespace std; int dp[1000001]; int a[1000001]; vector<int> v[1000001]; vector<int> an; int main() { memset((dp), (0), sizeof(dp)); memset((a), (0), sizeof(a)); int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { int x; scanf( %d , &x... |
#include <bits/stdc++.h> using namespace std; long long int n, k, pres[300005], cont[300005]; vector<long long int> fcts[300005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; long long int tot = 0; pres[1] = 1; for (long long int i = 1; i <= n; ++i) for (int... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); struct Point { double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} }; Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); } Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y... |
#include <bits/stdc++.h> using namespace std; int qtd[200007]; int vogal(char ch) { return ch == a || ch == e || ch == i || ch == o || ch == u || ch == A || ch == E || ch == I || ch == O || ch == U ; } map<int, int> prim; int main() { string s; cin >> s; int res... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 1e18; const long double pie = acos((long double)-1); int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; unordered_map<int, vector<int>> mp; int indegree[1001]; void addedge(int x, int y) { mp[x].pus... |
#include <bits/stdc++.h> using namespace std; const int maxm = 1.5e7; const int maxn = 1e5 + 5; int lson[maxm], rson[maxm]; long long sum[maxm]; int T[maxn]; int clk, n; void modity(int &rt, int L, int R, int pos, int val) { if (!rt) rt = ++clk; if (L == R) { sum[rt] += val; } else { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long maxn = 1e5 + 10; vector<long long> a[maxn]; long long lo[maxn], hi[maxn]; const long long inf = 1e15; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; int a[maxn], ans[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, c; cin >> n >> m >> c; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) { int ... |
#include <bits/stdc++.h> using namespace std; int i, j, k, l, n, m, s, tot, ss, t; const int pp = 1000000007; long long a[100010], an; void dfs(int x, bitset<120> y, long long s) { if (x > m / 2) { an = (an + s) % pp; return; } dfs(x + 1, y, s); if ((a[x]) && (!y[x])) dfs(x +... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; vector<set<long long int>> v(k); for (long long int i = 0; i < n; ++i) { cha... |
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; int n, k; while (t--) { char a[3] = { a , b , c }; cin >> n >> k; int temp = k; ... |
#include <bits/stdc++.h> using namespace std; bool check(long long mid, vector<long long> &d, vector<long long> &prep) { long long n = d.size(); long long m = prep.size() - 1; vector<long long> pos(m + 1, -1); for (long long i = 0; i <= mid; i++) pos[d[i]] = i; for (long long i = 1; i <= m; i++)... |
#include <bits/stdc++.h> using namespace std; template <typename T> int sz(const T &a) { return (int)a.size(); } long long int am[101]; int main() { int n; cin >> n; long long int trip; long long int str; cin >> trip >> str; long long int a, b; bool lastinc = false; cout ... |
#include <bits/stdc++.h> using namespace std; int Ss[10005], Ee[10005]; int pre[10005 * 200][26]; char A[10005], s[10005], e[10005]; int main() { scanf( %s%s%s , A, s, e); int n = strlen(A); int lens = strlen(s); int lene = strlen(e); int i, j; memset(Ss, 0, sizeof(Ss)); memset(Ee,... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long N = 1e3 + 7; long long a[N][N]; int32_t main() { long long n; cin >> n; for (long long i = 0; i < n; i++) for (long long j = 0; j < n; j++) cin >> a[i][j]; long long a12 = a[0][1], a23 = a[1][2], a13 = a[0][2]; long double a... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int mod = 1e9 + 7; int n; struct block { vector<int> v; int id; }; vector<block> b; int a[maxn]; void get_blocks() { b.clear(); block cur; int j = 1; while (j <= n) { cur.v.clear(); while... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> dp(2 * n); int mx = -1; int c = 0; dp[0] = 1; for (int i = 0; i < 2 * n; i++) { int u; cin >> u; ... |
#include <bits/stdc++.h> using namespace std; int main() { int A[101]; int B[101]; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> A[i]; int t = n / k; for (int i = 0; i < k; i++) { int max1 = 0; int max2 = 0; for (int j = 0; j < t; j++) if (A[i + j ... |
#include <bits/stdc++.h> using namespace std; void A() { cout << sjfnb << endl; exit(0); } void B() { cout << cslnb << endl; exit(0); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; long long bins(long long l, long long r) { while (l + 1 < r) { long long m = (l + r) >> 1; cout << ? << l << << m << endl; cout.flush(); char c; cin >> c; if (c == e ) return 0; if (c == y ) { l = m; }... |
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); const int inf = 0x3f3f3f3f; const double infd = 1.0 / 0.0; long long power(long long x, long long y, long long MOD) { long long res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >... |
#include <bits/stdc++.h> using namespace std; const int MX = 25; int main(int argc, char *argv[]) { ios ::sync_with_stdio(false); cin.tie(NULL); int n, k; string s; cin >> n >> k; cin >> s; if (k > (n + 1) / 2) { --k; while (k < n - 1) { cout << RIGHT << n ; ... |
#include <bits/stdc++.h> using namespace std; long long n, a[212345], ans = (1ll << 62); int main() { ios_base::sync_with_stdio(false); cin >> n; for (long long i = 0; i < 2 * n; ++i) { cin >> a[i]; } sort(a, a + 2 * n); for (long long i = n; i < 2 * n - 1; ++i) { ans = min(ans... |
#include <bits/stdc++.h> using namespace std; const int N = 2005, mod = 998244353; int n, a[N][N], f[N][N], jie[N], ans, vis1[N], vis2[N], c[N], c2[N], vis3[N]; inline int qpow(int a, int b, int res = 1) { for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) res = 1ll * res * a % mod; return res; ... |
#include <bits/stdc++.h> using namespace std; const int X[4] = {0, 0, -1, 1}; const int Y[4] = {-1, 1, 0, 0}; int dp[1001][1001], Vis[1001][1001]; char c[1001][1001]; int vis[1001][1001], i, j, m, n, p, k, ans; bool check(int x, int y, int xx, int yy) { if (x < 0 || y < 0 || x > n || y >= m) return fa... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6 + 5; struct comp { bool operator()(pair<int, int> &a, pair<int, int> &b) { if (a.first == b.first) return (a.second < b.second); return (a.first > b.first); } }; int main() { ios::sync_with_stdio(false); cin.... |
#include <bits/stdc++.h> using namespace std; const int N = 500005; int n, m, a[N], b[N]; priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > Q; long long ans; int solve(int x) { ans = 0; int num = 0; for (... |
#include <bits/stdc++.h> using namespace std; inline long long getnum() { char c = getchar(); long long num, sign = 1; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) sign = -1; for (num = 0; c >= 0 && c <= 9 ;) { c -= 0 ; num = num * 10 + c; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000; int z[N]; void computeZ(char s[]) { int n = strlen(s), L = 0, R = 0; for (int i = 1; i < n; i++) { if (i > R) { L = R = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L; R--; } else { ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<vector<int>> v; void sit(int x, int y) { while (1) { int u = max(1, x - v[x][y]), d = min(n, x + v[x][y]); for (; u <= d; ++u) { if (y - v[x][y] + abs(u - x) > 0) { if (v[u][y - v[x][y] + abs(u - x)] == 0) { ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)(1e9 + 7); const long long N = (long long)(1e5 + 7); long long p[N]; long long h[N]; int n, m; bool fun(long long dist) { queue<long long> q; for (int i = 0; i < m; i++) { q.push(p[i]); } for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; long long maxm = -1e18; long long minm = 1e18; bool isP(long long n) { if (n == 2LL) return 1; if (n % 2LL == 0LL) return 0; else if (n == 1) return 0; for (long long i = 3; i * i <= n; ++i) if (n % i == 0) return 0; return 1; ... |
#include <bits/stdc++.h> using namespace std; long long dp[5005][5005]; deque<int> dq[5005]; int a[5005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k, x; cin >> n >> k >> x; for (int i = 1; i <= n; i++) cin >> a[i]; memset(dp, -1, sizeof(dp)); dp[0][0] = 0; ... |
#include <bits/stdc++.h> using namespace std; struct edge { int t, f, w; bool operator<(const edge& e) const { return w > e.w; } edge(int from, int to, int weight) { t = to; f = from; w = weight; } }; const double EPS = (1e-5); long long binpow(long long a, long long b) { ... |
#include <bits/stdc++.h> char st[300][100], sy[10000], ss[1000000]; int main() { long a, i, j, len, po, k; strcpy(st[ > ], 1000 ); strcpy(st[ < ], 1001 ); strcpy(st[ + ], 1010 ); strcpy(st[ - ], 1011 ); strcpy(st[ . ], 1100 ); strcpy(st[ , ], 1101 ); strcpy(st[ [ ], 1110 ); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, a, b, c; cin >> n >> m; vector<int> ans(n, 0); set<int> s; for (int i = 1; i <= n; ++i) { s.insert(i); } while (m--) { cin >> a >> b >> c; auto lt = s.l... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long q[500009]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long sum = 0; long long mini = 0; for (long long i = 1; i < n; i++) { ci... |
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 100; struct node { int a, b, c; } p[N]; int nex[N]; vector<int> pre[N]; int dp[N][N]; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); int sum = k; for (int i = 1; i <= n; ++i) scanf( %d %d %d , &p[i].a, ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; if (n == 1) cout << 0; else if (n == 2) cout << m; else cout << 2 * m; puts( ); } int main() { int q; for (cin >> q; q--;) solve(); return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) #pragma comment(linker, /stack:200000000 ) using namespace std; const int GRANDOM = std::chrono::high_resolution_clock::now().time_sin... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y; } a[5], b[5]; int ans; int dis(int i, int j) { int res = (a[i].x - a[j].x) * (a[i].x - a[j].x); return res + (a[i].y - a[j].y) * (a[i].y - a[j].y); } int ok() { map<int, int> mp; for (int i = 1; i < 4; i++) fo... |
#include <bits/stdc++.h> using namespace std; long long n, k, u, v, w; unordered_map<long long, vector<long long>> m; struct Key { long long N, p; bool operator==(const Key& other) const { return (N == other.N && p == other.p); } }; struct KeyHasher { size_t operator()(const Key& k) co... |
#include <bits/stdc++.h> using namespace std; int n, m; char gride[5010]; vector<vector<char> > grid; vector<vector<int> > pesq, pesq2; vector<vector<int> > pdir, pdir2; vector<vector<int> > pcima, pcima2; vector<vector<int> > pbaxo, pbaxo2; void apaga(int i, int j) { if (pesq2[i][j] != -1) pdir2[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3, INF = 1e9; int main() { ios ::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); long long n, last = 0, id = 0, ans = 0, i = 0; cin >> n; vector<pair<int, int> > v(n); for (auto &t : v) cin >> t.first >> t.second; for... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int INF = 1e9 + 7; const int N = 1010; const double pi = 3.1415926; int n; int t[110], d[110], p[110], pre[2010], now[2010], sum[2010], good[2010]; int dp[2010]; vector<int> v[2010]; struct node { int t; int d; ... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(0); solve(); return 0; } pair<pair<double, double>, pair<double, double> > rects[100]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> rects[i].first.first >> rect... |
#include <bits/stdc++.h> using namespace std; const int maxn = 8e5 + 1000; long long re[maxn]; vector<long long> v; int sum[maxn]; struct node { long long l, r; } a[maxn]; long long ans[maxn]; int getid(long long x) { return lower_bound(v.begin(), v.end(), x) - v.begin() + 1; } int main() ... |
#include <bits/stdc++.h> using namespace std; int n, m, k, x, y, H[300005], d, ant[300005]; vector<int> v[300005], st, L; void dfs(int nod) { int ok = 0; st.push_back(nod); H[nod] = st.size(); if (H[nod] >= d) { cout << PATH n ; cout << st.size() << n ; for (auto it : st) co... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int b[n]; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(a, a + n); int left = 0, right = 0; for (int i = 0; i < n; i++) { if (b[i] != a[i]) { left = i;... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { if (a == 1 || b == 0) return 1; long long c = power(a, b / 2); long long res = 1; res = c * c; if (res >= 1000000007) res %= 1000000007; if (b % 2) res *= a; if (res >= 1000000007) res %= 1000000007... |
#include <bits/stdc++.h> using namespace std; long long N, K, dp[501][501]; long long p2[501]; void pre() { long long i; p2[0] = 1; for (i = 1; i < 501; ++i) p2[i] = (p2[i - 1] * 2) % 1000000007; } long long rec(long long maxinc, long long cur) { if (maxinc > K) return 0; if (cur > N) re... |
#include <bits/stdc++.h> using namespace std; inline int _Int() { int x; scanf( %d , &x); return x; } long long int bigMod(long long int A, long long int P, int M) { long long int R = 1; for (A %= M; P; P >>= 1) { if (P & 1) R = (R * A) % M; A = (A * A) % M; } return R; ... |
#include <bits/stdc++.h> using namespace std; const int N = 5005; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265389793238462643383279502884197169; const long long MOD = 1e9 + 7; const long long MOD1 = 998244353; const long long MODo = 1e9; const int MAXN = 2e5 + 2; const int oo = 1e9; const long long oo15 = 1e15; const long long oo18 = 1e... |
#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; const int N = 1e5 + 5; bool sortcol(const vector<int>& v1, const vector<int>& v2) { return v1[0] < v2[0]; } int main() { int n; cin >> n; vector<vector<long long> > yr; long long max = 0, count = 0, year = 0; for (int a = 0; a < n; a++) { ... |
#include <bits/stdc++.h> using namespace std; int n, k; int a[100010]; int tot[200010]; int dis[200010]; int main() { queue<int> q; scanf( %d%d , &n, &k); for (int i = 0; i <= 4000; ++i) dis[i] = 1e9; for (int i = 1; i <= k; ++i) { scanf( %d , &a[i]); a[i] -= n; ++tot[a[i] ... |
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0); int rev(int num, int lg_n) { int res = 0; for (int i = 0; i < lg_n; ++i) if (num & (1 << i)) res |= 1 << (lg_n - 1 - i); return res; } void fft(vector<complex<double>>& a, bool invert) { int n = (int)a.size(); ... |
#include <bits/stdc++.h> using namespace std; string s1, s2; int ar[200001]; int n; int n2; bool possible(int check) { int posi[200001] = {0}; for (int i = 0; i < check + 1; i++) { posi[ar[i]]++; } int start1 = 0; int start2 = 0; while (start1 < n && start2 < n2) { if (po... |
#include <bits/stdc++.h> using namespace std; template <class T> void fmax(T &a, T b) { if (a < b) a = b; } template <class T> void fmin(T &a, T b) { if (a > b) a = b; } const int N = 1e5 * 3 + 10; int a[N][3], c[N], n, m, w[N]; queue<int> Q; int main() { cin >> n >> m; for (int i ... |
#include <iostream> #include <vector> #include <numeric> #include<cstdlib> #include <algorithm> // std::random_shuffle #define MODD 998244353 #define ll long long using namespace std; ll modpow(ll x, ll y) { ll xs = x; ll answer = 1; while(y) { if (y&1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, sum = 1; cin >> n >> a >> b; if (n == 1) { puts( 1 ); return 0; } if (b == 0 && a == n - 1) { puts( -1 ); return 0; } bool fl = (b == 0); int now = 1; vector<long long> ans(n, 1)... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 1; const long long LINF = 1e18 + 1; int n; int X1_1 = 1; int Y1_1 = 1; int X2_1 = 2; int Y2_1 = 2; int X1_2 = 4; int Y1_2 = 4; int X2_2 = 5; int Y2_2 = 5; int ask(int x1, int y1, int x2, int y2) { cout << ? << x1 << ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { char ch = getchar(); long long nega = 1; while (!isdigit(ch)) { if (ch == - ) nega = -1; ch = getchar(); } long long ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); }... |
#include <bits/stdc++.h> using namespace std; long long N; int sol; int main() { scanf( %I64d , &N); while (N % 3 == 0) N /= 3; printf( %I64d n , (N + 2) / 3); return 0; } |
#include <bits/stdc++.h> using namespace std; using i64 = long long; constexpr int MAX = 400010; constexpr int MOD = 1000000007; i64 fac[MAX], inv[MAX]; int l[MAX], r[MAX], x[MAX], cnt[MAX]; i64 ModPow(i64 a, i64 b, i64 p = MOD) { i64 ret = 1; for (a %= p; b; b >>= 1) { if (b & 1) ret = ret ... |
#include <bits/stdc++.h> using namespace std; char s[2555], t[2555]; int n, ans[2555 * 3], o; int main() { scanf( %d , &n); scanf( %s , s); scanf( %s , t); o = 0; for (int i = n - 1; i >= 0; i--) { int j = n - 1 - i; while (j < n && s[j] != t[i]) j++; if (j == n) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> a; void init(int x) { vector<int> b; while (x > 0) { int tmp = x % 10; b.push_back(tmp); x /= 10; } for (int i = b.size() - 1; i >= 0; i--) { a.push_back(b[i]); } } int main() { for (int i = 0; i <= 1000;... |
#include <bits/stdc++.h> using namespace std; char s[505][505]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %c , &s[i][j]); } } bool ok = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++)... |
#include <bits/stdc++.h> using namespace std; long long int _seive_size; bitset<1000000> bs; vector<long long int> primes; void seive(long long int upperbound) { _seive_size = upperbound + 1; bs.set(); bs[0] = bs[1] = 0; for (long long int i = 2; i <= _seive_size; i++) { if (bs[i]) { ... |
#include <bits/stdc++.h> using namespace std; const long long N = (1LL << 22) + 2; long long n, m; long long a[N]; bool vis[2][N]; void dfs(long long k, long long cur) { if (vis[cur][k]) return; vis[cur][k] = 1; if (cur == 1) return dfs(k, cur ^ 1); for (long long i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int MAXN = 1000010; int get() { int x; bool f = 0; char c; while (!isdigit(c = getchar())) if (c == - ) f = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - 48; if (f) ... |
#include <iostream> #include <algorithm> #include <string.h> #include <queue> #include <vector> #define INF 987654321 using namespace std; int main() { int t; scanf( %d ,&t); while(t--){ int a,b,flag=0; scanf( %d %d ,&a,&b); if(a==b)printf( YES n );... |
#include <bits/stdc++.h> using namespace std; long long f[1200]; long long mod = 1000000007; int arr[1100]; long long pw(long long x, long long sum) { long long res = 1, power = sum, val = x; while (power) { if (power & 1) { res *= val; res %= mod; } val *= val; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 10; const long long int INFLL = 1e18 + 10; const long double EPS = 1e-8; const long double EPSLD = 1e-14; const long long int MOD = 1000000007; template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <cl... |
#include <bits/stdc++.h> const int oo = 0x3f3f3f3f; template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; } template <typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } template <typename T> T read(T &first) { int f = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; const int inf = 1e9 + 5; const double pi = acos(-1); const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; const int mod = 1e9 + 7; int p[N], cnt[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.