func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, rt, ra, ca, b; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); if (t != rt) { rt = t; ra = ca; ca = 0; } ca++; b = max(b, min(ra, ca) * 2); } printf(... |
#include <bits/stdc++.h> using namespace std; int mabs(int a) { if (a < 0) return -a; else return a; } bool vis[4010]; int main() { int x, k; int t, n1, n2; cin >> x >> k; for (int i = 0; i < k; ++i) { cin >> t; if (t == 2) { cin >> n2; vis[n2] =... |
#include <bits/stdc++.h> using namespace std; int a[200], b[200], res[200]; int main() { int n, count, i, j, m, k, ans; cin >> n >> m >> k; for (i = 0; i < m; i++) cin >> a[i]; for (i = 0; i < k; i++) cin >> b[i]; for (i = 0; i < m; i++) { for (j = 0; j < k; j++) { if (b[j] % a[i... |
#include <bits/stdc++.h> using namespace std; long long inf; const double eps = 1e-8; const double pi = acos(-1.0); template <class T> long long chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; } template <class T> long long chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; } template <clas... |
#include <bits/stdc++.h> template <class T> inline void read(T &res) { char ch; while (ch = getchar(), !isdigit(ch)) ; res = ch ^ 48; while (ch = getchar(), isdigit(ch)) res = res * 10 + ch - 48; } template <class T> inline void put(T x) { if (x > 9) put(x / 10); putchar(x % 10 +... |
#include <bits/stdc++.h> using namespace std; int n; char a[1 << 9][1 << 9]; void solve(int n) { if (n == 0) { a[0][0] = + ; return; } solve(n - 1); int mid = 1 << (n - 1); for (int i = (mid), _b = ((1 << n) - 1); i <= _b; ++i) for (int j = 0, _a = (mid); j < _a; ++j) a[i]... |
#include <bits/stdc++.h> using namespace std; long long fact[200010], cnt, cnt1[200010], cnt2[200010]; void precalc() { fact[0] = 1; for (int i = 1; i < 200010; i++) { fact[i] = (i * fact[i - 1]) % 1000000007; } } long long power(long long a, long long b, long long p) { if (b == 0) retur... |
#include <bits/stdc++.h> using namespace std; int arr[101]; int d[101]; int main() { int N; cin >> N; for (int i = 0; i < N; ++i) cin >> arr[i]; for (int i = 1; i < N; ++i) d[i] = arr[i] - arr[i - 1]; int ans = 1001; for (int i = 1; i < N - 1; ++i) { int temp1 = 0; for (int j... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; scanf( %I64d %I64d , &n, &m); long long a = min(n, m); long long b = max(n, m); long long ans; if (a == 1) { ans = b / 6 * 6; if (b % 6 == 4) ans += 2; else if (b % 6 == 5) ans += 4; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<int> prime(n + 2, 1); prime[0] = 0; prime[1] = 0; long long ans = 1; for (long long i = 2; i <= n + 1; i++) { if (prime[i] == 1 && i * i <= n + 1) { for (long long j = i * i; j <= n + 1... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> arr(n); for (auto &x : arr) cin >> x; int height = 1; for (int i = 0; i < n; i++) { if (i > 0 and !arr[i - 1] and !arr[i]) { cout << -1 << n ; return; } height += arr... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e9 + 55; const int inf = 1e9 + 77; const int MOD = 1e9 + 7; const double PI = acos(-1.0); const double eps = 1e-7; vector<int> primes; bitset<int(1e7) + 2> isprime; void seive() { isprime[0] = isprime[1] = 1; for (int i = 2; i < in... |
#include <bits/stdc++.h> using namespace std; int main() { long long L, R; int n; cin >> n; while (n--) { cin >> L >> R; for (long long k = 0; k <= 60; ++k) { if ((1LL << k) & (L)) { continue; } else { if ((1LL << k) + L <= R) { L += (1LL <... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979; const double PI2 = 6.28318530717958; const double PId2 = 1.570796326794895; inline long long pw(long long n, int p) { long long ans = 1; for (int i = 0; i < p; i++) ans *= n; return ans; } inline vector<int> Read... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << n ; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << << H; debug_out(T...); } const long long MAXN = 1e2 + 10, INF = 1e9; long long n, m, k, a, b, u, v, floyd[MAXN][MAXN], second[... |
#include <bits/stdc++.h> using namespace std; set<string> st; int main() { string s; cin >> s; string a = s + s; for (int i = 0; i < a.size() - s.size(); i++) { string k = ; for (int j = i; j < i + s.size(); j++) k += a[j]; st.insert(k); } cout << st.size(); } |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long k, n, w; cin >> k >> n >> w; long long req = ((w * (w + 1)) / 2) * k; req = req - n; if (req > 0) cout << req; else cout << 0 ; ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve() { int a, b, k; cin >> a >> b >> k; vector<int> A(k); vector<int> B(k); vector<int> cA(a + 1); vector<int> cB(b + 1); ll ans = 0; for (int i = 0; i < k; i++) { cin >> A[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t-- > 0) { int n; cin >> n; int a[n]; cin >> a[0]; for (int i = 1; i < n; i++) { cin >> a[i]; } vector<int> v; for (int i = 1; i < n - 1; i++) { if ((a[i] > ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int e = 0; e < t; e++) { long long n; cin >> n; vector<bool> used(n + 2, false); long long q; long long last = -1; vector<long long> ans; long long index = 1; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T sum = 0, fl = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) fl = -1; for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - 0 ; return sum * fl; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, a[10000]; cin >> n; cin >> m; string s[1000], f[1000]; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < m; i++) { cin >> f[i]; } cin >> k; for (int i = 0; i < k; i++) { c... |
/* { ###################### # Author # # Gary # # 2021 # ###################### */ #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #de... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n, k; cin >> t; while (t--) { cin >> n; string ans, e, ant; bool ok = 0; for (int i = 0; i < (int)n - 2;... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 1000; int n; set<int> s[4]; int main() { cin >> n; for (int i = 1; i <= n; i++) { int tmp; for (int j = 1; j <= 6; j++) cin >> tmp, s[i].insert(tmp); } ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(... |
#include <bits/stdc++.h> using namespace std; long long q, n; int main() { cin >> q; for (int i = 0; i < q; i++) { cin >> n; vector<long long> nums; long long cSum = 0, power = 0; while (cSum < n) { cSum += pow(3, power); nums.push_back(pow(3, power)); power... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> T gcd(T a, T b) { return ((b == 0) ? a : gcd(b, a % b)); } int m[1005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a... |
#include <bits/stdc++.h> #pragma warning(disable : 4786) using namespace std; long long heads[100005], tracks[100005]; int n, m; long long Abs(long long x) { return x < 0 ? -x : x; } int check(long long x) { int i, j = 0; for (i = 0; i < n; i++) { if (Abs(heads[i] - tracks[j]) > x) continue; ... |
#include <bits/stdc++.h> using namespace std; using namespace std; const int mod = (int)1e9 + 7; const long long INF = 10000005; const int inf = 1 << 30; char buf[1000]; const int N = 210; vector<int> dep[N]; vector<int> computer[3]; bool completed[N]; int n; int check(int start) { int tot =... |
#include <bits/stdc++.h> using namespace std; const int N = 500050; const int inf = 0x3f3f3f3f; const long long llinf = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; const int MOD = 1e9 + 7; const double PI = acos(-1.0); clock_t TIME__START, TIME__END; void program_end() {} const int Gmod = 3, maxn... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x7fffffff; const double eps = 1e-10; const double pi = acos(-1.0); inline int read() { int x = 0, f = 1; char ch; ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = 0; ch = getchar(); } while (ch ... |
#include <bits/stdc++.h> using namespace std; int a[200004], n, m; int c[400004]; long long greaterc(int m) { long long ans = 0, add = 0; memset(c, 0, sizeof(c)); int div = n; c[n] = 1; for (int i = 0; i < n; i++) { if (a[i] < m) div--, add -= c[div]; else add += ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int N = 100005; const double PI = 4 * atan(1); const double eps = 1e-7; const long long oo = 1e18; const int AlPHA = 26, B = 30; long long n, m, L, sr, t; long long adj[1005][1005]; long long yes[1005][1005]; long long ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read(T& x) { x = 0; int f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= (ch == - ), ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x = f ? -x : x; } ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; int CASE = 1; const int mxn = 2e5 + 1; const long long INF = 1e18; bool prime(int n) { if (n <= 1) return false; if (n == 2 or n == 3) return true; if (n % 2 == 0 or n % 3 == 0) return false; for (int i = 5; i * i... |
#include <bits/stdc++.h> using namespace std; long long n; long long power(long long base, long long expo) { if (base <= 1) return 1; long long ans = 1; while (expo) { if (expo & 1) { ans = (ans * base) % n; } base = (base * base) % n; expo >>= 1; } return ans; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; string ans = ; cin >> n; while (n > 1) { ans += 8 ; k += 1; n -= 2; } if (n == 1) { ans += 9 ; k++; n--; } if (k < 19) cout << ans; else cout << -1; re... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int a, b, c, m; cin >> a >> b >> c >> m; vector<long long int> usb; vector<long long int> p; for (long long int i = 0; i < m; i++) { strin... |
#include <bits/stdc++.h> using namespace std; map<long long, vector<long long> > M; set<long long> S; const long long N = 1000001; long long n, a[1000001], f[N]; void upd(long long i, long long mx) { for (; i > 0; i -= (i & -i)) { f[i] = max(f[i], mx); } } long long get(long long i) { ... |
#include <bits/stdc++.h> constexpr int Maxn = 53; std::vector<int> e[Maxn]; int n, m; int main() { scanf( %d%d , &n, &m); for (int i = 1, u, v; i <= m; ++i) { scanf( %d%d , &u, &v); if (u <= 50 && v <= 50) { e[u].emplace_back(v); e[v].emplace_back(u); } } n = st... |
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7; void mul(int A[2][2], int B[2][2]) { int r[2][2]; r[0][0] = ((A[0][0] * 1LL * B[0][0] + A[0][1] * 1LL * B[1][0]) % P); r[0][1] = ((A[0][0] * 1LL * B[0][1] + A[0][1] * 1LL * B[1][1]) % P); r[1][0] = ((A[1][0] * 1LL * B[0][0] + A[1... |
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 0, num; char ch; while (ch = getchar(), !isdigit(ch)) if (ch == - ) f = 1; num = ch - 0 ; while (ch = getchar(), isdigit(ch)) num = num * 10 + ch - 0 ; return f ? -num : num; } const int N = 103; char s[... |
#include <bits/stdc++.h> using namespace std; int main() { long t; cin >> t; while (t--) { long long n, k, i; cin >> n >> k; string s(n, a ); long long temp = k; i = 1; long long x = 0, y = 0; while (temp >= i) { temp -= i; i++; } if... |
#include <bits/stdc++.h> using namespace std; int z[2 * 1000 * 1000 + 10]; char s[2 * 1000 * 1000 + 10]; bool T[2 * 1000 * 1000 + 10]; int cnt[2 * 1000 * 1000 + 10]; int main() { int K, L; scanf( %d%d , &L, &K); scanf( %s , &s); for (int i = 1, l = 0, r = 0; i < L; ++i) { if (i <= r) z... |
#include <bits/stdc++.h> using namespace std; int cnt[30000]; int main() { int n; cin >> n; cnt[0] = 1; for (long long i = 0; i < n; ++i) { int a; cin >> a; for (long long q = 0; q < 30000 - a; ++q) { if (cnt[q] == 1) { cnt[q + a] = 1; } } } ... |
#include <bits/stdc++.h> using namespace std; bool rev[35]; int main() { int n, m; cin >> m >> n; for (int i = 0; i < n; i++) { printf( 1 n ); fflush(stdout); int x; scanf( %d , &x); if (x == 0) return 0; if (x < 0) rev[i] = true; else rev[i] =... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long long mod = 1e9 + 7; void __p(long long x) { cout << x; } void __p(int32_t x) { cout << x; } void __p(float x) { cout << x; } void __p(double x) { cout << x; } void __p(long double x) { cout << x; } void __p(char x) { ... |
#include <bits/stdc++.h> 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; } const int M = 4e6 + 10; i... |
#include <bits/stdc++.h> char s[100] = bear , str[10000]; int check(int index) { int i; for (i = index; i <= index + 3; i++) { if (str[i] != s[i - index]) return 0; } return 1; } int main() { int len, i, j; while (scanf( %s , str) != EOF) { int ans = 0, index = 0; int ... |
#include <bits/stdc++.h> using namespace std; struct p { int L, R, U, D; } point[5005], pos[5005]; string g[5005]; void DEL(int x) { pos[pos[x].D].U = pos[x].U; pos[pos[x].U].D = pos[x].D; pos[pos[x].R].L = pos[x].L; pos[pos[x].L].R = pos[x].R; } int main() { int m, n, i, j, l, sx,... |
#include <bits/stdc++.h> using namespace std; const long long INF = 2e9 + 7; const int M = 1e6 + 10; const int N = 51; const int POW = 20; const long long MOD = 1000 * 1000 * 1000 + 7; int a[N]; int d[2][N][N][N][N]; void add(int &a, long long add) { a = ((long long)a + add) % MOD; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 40; int f[maxn][maxn]; int dp[maxn]; char s[maxn]; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); scanf( %s , s + 1); f[n][n + 1] = f[n + 1][n] = f[n + 1][n + 1] = 0; fo... |
#include <bits/stdc++.h> using namespace std; vector<int> primes; bool sums[1003]; int n, k; bool pr[1003]; void sieve() { pr[1] = pr[0] = 1; for (int i = 2; i <= n; i++) if (!pr[i]) { for (int j = i + i; j <= n; j += i) pr[j] = 1; primes.push_back(i); } return; } ... |
#include <bits/stdc++.h> using namespace std; vector<long long> v(100003); long long solve() { long long n; vector<long long> u; string s; cin >> n; while (n > 0) { auto itr = lower_bound((v).begin(), (v).end(), n); long long a = itr - v.begin(); if (v[a] > n) a--; u.pu... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 101010; pair<int, int> arr[MAXN]; pair<int, int> a[MAXN], b[MAXN]; int N; bool cmp(const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; } int main() { ios_base::sync_with_stdio(0); cin >> N; for (in... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const double eps = 1e-9; const int INF = inf; const double EPS = eps; struct __timestamper {}; class fenv_tree { static int f(int x) { return x & -x; } vector<int> tr; public: fenv_tree(int n) : tr(n + 1, -inf) {} voi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 151, maxs = 150 * 150 / 4 + 5, inf = 1e9; vector<vector<int> > d[maxs]; int a[maxn]; int n, k, s; int main() { scanf( %d%d%d , &n, &k, &s); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } if (s >= maxs - 2) { sort... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int t; cin >> t; while (t--) { int n; cin >> n; for (int pw = 2; pw < 30; ++pw) { int val = (1 << pw) - 1; if (n % val == 0) { cout... |
#include <bits/stdc++.h> using namespace std; const int maxn = int(1.5 * 1e7); const int inf = 1e9 + 7; const long long ll_inf = 1e18 + 420; const double eps = 1e-4; const int N = 1e6; const int MAX = 2e5 + 9; const int MOD = 1e9 + 7; const long double pi = 3.14159265359; string s; bool was[10][10... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int T; cin >> T; while (T--) { long long n, m; cin >> n >> m; if (m + 1 <= n) { cout << 0 << endl; continue; } m++; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n; int a[maxn]; int c[maxn]; int main() { int ans = 0; int i, j, x; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); } int id = 0; for (i = 2; i <= n; i++) { if (a[i] < a[i - 1])... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; const int MAXN = 1e4 + 10; const int MOD = 1e9 + 7; const int inf = 1e9; const double pi = acos(-1.0); const double eps = 1e-6; int dx[] = {0, -1, 0, 1}; int dy[] = {1, 0, -1, 0}; long long dp[510][510]; int n; int a[510]; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18 + 7; int n, m; map<char, int> ch_num; int main() { int n; cin >> n; vector<string> ee(n); for (int i = 0; i < n; i++) { cin >> ee[i]; } vector<int> can_zero(27, -1); vector<pair<int, int> > le... |
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int k = s.length(); int flag = 0; for (int d = 0; d < k - 1; d++) { if (s[d] == ) { continue; } if (s[d] == a || s[d] == e || s[d] == i || s[d] == o || s[d] == u ... |
#include <bits/stdc++.h> int main() { long int l, r; scanf( %ld %ld , &l, &r); if (l == r) printf( %ld n , r); else printf( 2 n ); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000000; int main() { int n, m; cin >> n >> m; vector<int> x(n); for (int i = 0; i < n; i++) { cin >> x[i]; } vector<int> p(m), c(m); for (int i = 0; i < m; i++) { cin >> p[i] >> c[i]; } so... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; vector<int> g[N]; int a[N], b[N], last[N], indx[N], lvl[N], ans[N]; int n, m, q; void dfs(int node, int sz) { lvl[sz++] = node; for (int i = 0; i < g[node].size(); i++) { dfs(g[node][i], sz); } if (sz >= n) ans[... |
// // main.cpp // google-code-jam-2020 // // Created by Ali Naderi Parizi on 2/10/1400 AP. // #include <iostream> #include <math.h> int main(int argc, const char * argv[]) { int t; std::cin >> t; for (int i = 0 ; i < t ; i++) { double r,b,d; std::ci... |
#include <bits/stdc++.h> using namespace std; int main() { long long int q = 1; while (q--) { long long int n, i, t, j, k = 0, maxm = 0, ans; cin >> n; vector<long long int> v(n), v1(30), v2; map<long long int, long long int> m; for (long long int i = 0; i < 30; i++) v1[i] = 0;... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000003; long double pi = 3.1415926536; const int mx = 1000003; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long bp(long long a, long long b) { long long ans = 1; while (b > 0) { ... |
#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 - (a / b * b)); } long long mypow(long long a, long long b) { long long p = 1; if (b == 0) return 1; for (long long i = 0; i < b; i++) p *= a; return p; } lon... |
#include <bits/stdc++.h> using namespace std; const int inf = (1 << 30) - 1; const long long linf = (1ll << 62) - 1; const int N = 1e6 + 100; int n, m; int u[N], v[N]; set<int> g[N]; bool used[N]; int ts[N], tsLen = 0; void topSort(int v) { if (used[v]) { return; } used[v] = true; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<long long, long long>; const int N = 1e5 + 5; const long long p1 = 31; const long long p2 = 41; const long long mod1 = 1e9 + 7; const long long mod2 = 1e9 + 9; long long power1[N]; long long power2[N]; long long pr... |
#include <bits/stdc++.h> using namespace std; long long len, ans, s0, s1, s2, fac[2001], invfac[2001], S[2001][2001], lst[2001], n, a[2001], b[2001], pv[2001], nxt[2001], F[2001], f[2001], G[2001], g[2001], h[2001], k[2001], K[2001], minn[2001]; int read() { char c = 0; int sum = 0; while ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; using pii = pair<int, int>; int f[50], s[50], p[50]; ld dp[51][5000]; int main() { cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; void run() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 1 << << 1 << n << -a[0] << n ; cout << 1 << << 1 << n << 0 << n ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e5 + 5; long long mod_exp(long long cur, long long power) { long long res = 1; while (power > 0) { if (power % 2 == 0) { cur = (cur * cur) % 1000000007; } else { res = (res * cur) % 1000000007... |
#include <bits/stdc++.h> using namespace std; #define ll long long int void solve(){ ll n,i,j; cin >> n; ll arr[n]; ll hash[65] = {0}; vector<string> vec; for(i=0;i<n;i++){ cin >> arr[i]; ll m = arr[i]; ll id = 0; string s = ; whil... |
#include <bits/stdc++.h> long long gcd(long long a, long long b) { while (a && b) { if (a > b) a %= b; else b %= a; } return a + b; } long long lcm(long long a, long long b) { return (((a) / gcd(a, b))) * b; } int phi(int n) { int result = n; for (int i = 2; i * i... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long powmod(long long a, long long b, long long MOD) { if (a == 0ll) { return 0ll; } a %= MOD; ... |
#include <bits/stdc++.h> using namespace std; int T, ans; int dfs(vector<int> G[], int node, bool visit[], int k, bool first) { if (!visit[node]) { visit[node] = true; int counti = 0; for (auto it : G[node]) { if (!visit[it]) counti += dfs(G, it, visit, k, false); } ans +... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> inline bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> inline bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 2e2 + 17, maxm = maxn * maxn; int from[maxm], to[... |
#include <bits/stdc++.h> using namespace std; int comp[212345], ptr; int idx[212345]; map<int, int> place; int h, m, n; int merge(int x, int y) { if (x == -1) { return y; } return x; } struct segtree { int n; vector<int> tree; segtree(vector<int> base) { n = base.size... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n; cin >> n; if (n > 2) { for (int i = 2; i <= n; ++i) { cout << i << ; } cout << 1 << endl; } else { cout << -1 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; bool func(vector<pair<int, int> > vd, vector<pair<int, int> > vu) { for (int i = 0; i < vd.size(); i++) { if ((vd[i].first < vu[i].first && vd[i].second < vu[i].second) || (vd[i].first > vu[i].first && vd[i].second > vu[i].second)) { return t... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<long long, int> > q; vector<pair<long long, pair<int, int> > > E; vector<pair<int, int> > e[120000]; int n, m, x, y, k, z, fa[120000], i, be[120000], flag[120000]; long long dis[120000], ans; int get(int x) { return fa[x] == x ? x : (fa[x] ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int dp[N], a[N], n; int main() { cin >> n; for (int i = 0; i < n; ++i) scanf( %d , &a[i]); if (n == 1) { cout << 1; return 0; } for (int i = 0; i < n; ++i) { if (a[i] == 1) continue; int d = 2, mx = ... |
#include <bits/stdc++.h> using namespace std; const int oo = 1 << 30; const double PI = M_PI; const double EPS = 1e-15; double w, h, u; double cross(const complex<double> &a, const complex<double> &b) { return imag(conj(a) * b); } complex<double> rotate_by(const complex<double> &p, ... |
#include <bits/stdc++.h> using namespace std; void lemon() { double R1, R2; int k; scanf( %lf%lf%d , &R1, &R2, &k); k++; double xl = 1 / (R1 * 2), xr = 1 / (R2 * 2); double xc = (xl + xr) / 2, rad = abs(xc - xl); double yc = rad * (k - 1) * 2; double len = sqrt(xc * xc + yc * yc); ... |
#include <bits/stdc++.h> using namespace std; const int pp = (1e9) + 7; long long P[1000010]; long long ans, now; int N, K; long long quick(int x, int y) { long long s = 1, t = x; for (; y; y >>= 1) { if (y & 1) s = s * t % pp; t = t * t % pp; } return s; } long long get0() {... |
#include <bits/stdc++.h> using namespace std; long long G[333][333]; long long min(long long a, long long b, long long c) { return min(a, min(b, c)); } int main() { int N; cin >> N; for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) cin >> G[i][j]; int M; cin >> M; whi... |
#include <bits/stdc++.h> using namespace std; const int N = 500005; const int mod = 998244353; const long long int inf = 10e17; const long double pi = 3.14159265359; mt19937_64 rang( chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int... |
#include <bits/stdc++.h> using namespace std; set<int> m; using namespace std; bool check(int a) { m.erase(m.begin(), m.end()); int i = 0; while (a > 0) { int re = a % 10; m.insert(re); a /= 10; i++; } if (m.size() == i) { return true; } else return fa... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, l; int cnt[N]; long long sum[N]; int main() { cin >> n >> l; for (int i = 1; i < n; i++) { cin >> cnt[i]; sum[i] = sum[i - 1] + cnt[i]; } long long ans = 2e18; for (int i = l; i < n; i++) { ans =... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; int n, k; string s; int main(void) { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { cin >> n >> k; vector<int> alpha(26, 0); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; map<char, int> cnt; if (s.size() > 2) for (int i = 1; i <= s.size() - 2; i++) { cnt.clear(); cnt[s[i - 1]]++; cnt[s[i]]++; cnt[s[i + 1]]++; if (cnt[ A ] == 1 && cnt[ B ] == 1 ... |
#include <bits/stdc++.h> using namespace std; char s[1000001], s1[1000001], s2[1000001]; int n, ci, dian = -1, en, e2; int main() { scanf( %s , s); n = strlen(s); if (n == 1 && s[0] == 0 ) { puts( 0 ); return 0; } for (int i = 0; i < n; ++i) if (s[i] == . ) dian = i; ... |
#include <bits/stdc++.h> using namespace std; bool same(int l1, int r1, int l2, int r2) { if (r1 < l2 || r2 < l1) { return 0; } return 1; } signed main() { int q; cin >> q; while (q--) { int n; cin >> n; int l = 1e9 + 5, r = 0; for (int i = 0; i < n; i++) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.