func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m, k; char s[504][504]; int vis[504][504]; vector<pair<char, pair<int, int> > > v; vector<pair<int, int> > ord; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; void dfs(int x, int y) { ord.push_back(make_pair(x, y)); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; void solve() { char S[110]; scanf( %s , S); int len = strlen(S); sort(S, S + len); for (int i = 0; i < len - 1; i++) { if (S[i + 1] - S[i] != 1) { printf( NO n ); return; } } printf( YES n ); } int main() { ... |
#include <bits/stdc++.h> using namespace std; long long int sqr(long long int x) { return x * x; } inline long long int add(long long int a, long long int b) { long long int c = a + b; if (c >= 1000000007) c -= 1000000007; return c; } inline long long int mul(long long int a, long long int b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { string str; cin >> str; bool flag = true; if (n < 3) { if (n == 1) { if (str[0] == 1 ) cout << Yes << endl; else cout << No << endl; }... |
#include <bits/stdc++.h> using namespace std; struct SCC { vector<pair<int, int>> minmax; int size; SCC(vector<int> v) { minmax.resize(v.size()); for (int i = 0; i < (int)v.size(); i++) { minmax[i].first = v[i]; minmax[i].second = v[i]; } size = 1; } bool ... |
#include <bits/stdc++.h> using namespace std; struct he { int ind; int val; he(int ind_ = 0, int val_ = 0) : ind(ind_), val(val_) {} bool operator<(const he oth) const { return val > oth.val; } }; int n, m, k; vector<int> p[200200], c[200200]; int minv[200200], maxv[200200]; int np[200200]... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { int num; cin >> num; mp[num]++; } if (mp.size() != 2) { cout << NO ; exit(0); } i... |
#include<cstdio> #include<iostream> #include<cstring> #include<string> #include<cmath> #include<map> #include<algorithm> #include<vector> #include<set> #define Quick ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define ll long long #define INF 0x3f3f3f3f #define PI acos(-1) #define mem... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int par[N], ran[N]; struct DSU { DSU() { for (int i = 1; i < N; ++i) par[i] = i, ran[i] = 1; } int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } bool unite(int a, int b) { a = find(a), b = find(b);... |
#include <bits/stdc++.h> using namespace std; template <class T> T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; } template <class T> T mod_inv(T a, T m) { T x,... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; bool dp[505][505]; int c[505]; int N, K, a[505], b[505]; long long s1, s2; int main() { ios::sync_with_stdio(false); cin >> N >> K; for (int i = 1; i <= N; ++i) cin >> a[i] >> b[i], s1 += a[i], s2 += b[i]; dp[0][0] =... |
#include <bits/stdc++.h> using namespace std; int main() { char ch; int n, cnt = 0; long long x, a; scanf( %d%I64d , &n, &x); for (int i = 0; i < n; i++) { while (isspace(ch = getchar())) ; scanf( %I64d , &a); if (ch == + ) x += a; else { if (x < ... |
#include <bits/stdc++.h> using namespace std; int n, a[100009]; int main() { cin >> n; if (n == 1) cout << 1; else if ((n / 2) % 2 == 1) cout << -1; else { for (int i = 1; i <= (n / 2 / 2); i++) { a[i * 2 - 1] = i * 2; a[i * 2] = n - (i - 1) * 2; a[n - i *... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int cnt[N]; int n, k; int cut[N]; vector<pair<int, int> > arr; struct Sub { bool operator()(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) { if (a.first != b.first) return a.first < b.first; else ... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; long long n, a[N], t; map<long long, bool> vis; int solve() { scanf( %lld , &t); while (t--) { scanf( %lld , &n); vis.clear(); bool imp = 0; for (int i = 1; i <= n; i++) { scanf( %lld , &a[i]); ... |
#include <bits/stdc++.h> using namespace std; void file() {} void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); } const int N = 510 + 20; const double PI = acos(-1.0); bool cmp(complex<double> a, complex<double> b) { if (a.real() == b.real()) return a.imag() < b.imag(); return... |
#include <bits/stdc++.h> using namespace std; int a[300001]; const long long mod = 1000000007; int main(int argc, const char* argv[]) { string S; cin >> S; int n = (int)S.size(); string A(n, 2 ); int scr = 0; for (int i = 0; i < n; ++i) { char a = S[(i + n - 1) % n]; char b ... |
#include <bits/stdc++.h> using namespace std; string s; int main() { int n, a, b, k; scanf( %d%d%d%d , &n, &a, &b, &k); int tot = 0; cin >> s; int prev = -1; for (int i = 0; i < n; i++) if (s[i] == 1 ) { tot += (i - prev - 1) / b; prev = i; } tot += (n - pr... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; const int inf = 0x3f3f3f3f; const ll linf = 0x3f3f3f3f3f3f3f3f; const ll mod = 1e9 + 7; //const ll mod = 998244353; ll ksm(ll x,ll k) { ll r... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b); bool prime(int n); long long sumdigit(long long n); bool ispowerof2(int n); long long onesinbinary(long long n); long long power(long long a, long long b); bool cmp(pair<int, int> x, pair<int, int> y) { return x.second < y.second; } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int p, c = 0; cin >> p; long long int x = p; long long int n = std::numeric_limits<int>::digits - 1; std::string s; s.reserve(n + 1); do s.push_back(((x >> n) & 1) + 0 ); while (--n > -1); for (auto x : s) ... |
#include <bits/stdc++.h> using namespace std; struct Str { int l; char *s; } str[50010 << 2]; int tot; char s[3100000]; int k; int n, l[50010], r[50010]; char ans[3100000]; int cut(int pos) { for (int i = 0; i < tot; i++) if (pos == 0) { tot++; for (int k = tot - 1; k... |
#include <bits/stdc++.h> using namespace std; long long L[100005], R[100005], odd[100005], s[100005], dp[100005], ans = 0; int n; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) scanf( %I64d , &s[i]); L[0] = 0; for (int i = 1; i < n; i++) { if (s[i] == 1) L[i] = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { long long i = 5, cnt = 1, x, ans = 0, y, z = 5, m; if (n < 5 || n == 5) { if (n == 1) cout << Sheldon << endl; else if (n == 2) cout << Leonard << endl; else... |
#include <bits/stdc++.h> using namespace std; const int modd = 998244353; const int maxn = 2000 + 10; int n, k; long long dp[maxn][maxn][4]; void solve() { dp[1][1][0] = dp[1][1][3] = 1; dp[1][2][1] = dp[1][2][2] = 1; for (int i = 2; i <= n; i++) { dp[i][1][0] = dp[i][1][3] = 1; dp[i... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; int ans[N], vis[N]; vector<int> G[N], s[N], tmp; void dfs(int u, int fa) { int sz = s[u].size(); for (int i = 1; i <= sz; i++) vis[i] = 0; for (int j : s[u]) { if (ans[j] && ans[j] <= sz) vis[ans[j]] = 1; } for (int ... |
#include <bits/stdc++.h> using namespace std; const long long Time = 12622780800ll; int i, j, k, n, ch, s, m, h, day, date, month, Fg; long long t; struct cc { int s, m, h, day, date, month, year; int Js() { if (month == 4 || month == 6 || month == 9 || month == 11) return 30; if (month !=... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 1 || n == 2) cout << -1 n ; else if (n == 3) cout << 210 n ; else { if (n % 6 == 1) { cout << 1 ; for (int i = 3; i < n; i++) cout << 0 ; ... |
#include<bits/stdc++.h> using namespace std; bool ok[100005]; typedef long long int ll; int gcd(int a ,int b) { if(b==0) return a; else if(a==0) return a; else return gcd(b,a%b); } int main() { int n; cin>>n; ll prod=1; for(int i=1;i<n;i++)... |
#include <bits/stdc++.h> using namespace std; int inf = 1000000000, mxx, mxy, mnx = inf, mny = inf, n, m, i, j, r = 0, x[2000001], y[2000001]; char a[3001][3001], c[3001][3001]; bool ok(int mxx, int mxy, int mnx, int mny) { for (int i = 0; i < r; i++) if (x[i] < mnx || x[i] > mxx || y[i] < mny |... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 11, MAXL = 100000 + 10; struct State { int len, fa, num[MAXN], tr[26]; State() : len(0), fa(0) { memset(num, 0, sizeof(num)); memset(tr, 0, sizeof(tr)); } State(int len, int fa, int numr, int ref) : len(len), fa(fa) { ... |
#include <bits/stdc++.h> using namespace std; set<long long int> st; set<long long int>::iterator it; long long int cnt[200010]; int main() { long long int n, a, b, x, y, z, p, m, d, mn, mx, t, i; scanf( %lld , &t); while (t--) { scanf( %lld , &n); p = 0; for (i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; bool prime[1500000 + 10]; bool a[1500000 + 10]; int func(int N, int x) { int i, ans = 0; if (x == 2) return 0; if (a[1]) return 1; if (x >= 1500000) return -1; for (i = 2; i <= x - 1; i++) if (prime[i]) if (a[i]) ans++; ... |
#include <bits/stdc++.h> using namespace std; void task(); int main() { srand(time(0)); ios_base::sync_with_stdio(0); task(); return 0; } vector<int> prefix_function(string s) { int n = s.length(); vector<int> p(n, 0); for (int i = 1; i < n; ++i) { int j = p[i - 1]; whi... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int maxn = 3e5 + 10; const int maxv = 1e3 + 10; const double eps = 1e-9; std::vector<int> G[maxn]; int ans[maxn]; void inv(int i) { ans[i] ^= 1; } bool bad(int u) { int cnt = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; int n; char s[105]; string S; multiset<string> st; vector<string> v; inline bool cmp(string a, string b) { return a.length() < b.length(); } int cnt[26]; char ans[105]; int f[105][26]; int main() { scanf( %d , &n); if (n <= 3) { if (n == ... |
#include <bits/stdc++.h> using namespace std; long long a, b; vector<long long> A, B, C; int main() { scanf( %lld %lld , &a, &b); for (long long i = 1; i <= sqrt(a); i++) if (a % i == 0) A.push_back(i); for (long long i = 1; i <= sqrt(b); i++) if (b % i == 0) B.push_back(i); for (lon... |
#include <bits/stdc++.h> using namespace std; vector<int> a, b, e; char s[5]; long long ans; int c; int main() { int n, f; scanf( %d , &n); while (n--) { scanf( %s %d , &s, &f); if (s[0] == 0 && s[1] == 1 ) a.push_back(f); else if (s[0] == 1 && s[1] == 0 ) ... |
#include <bits/stdc++.h> using namespace std; ifstream fin( Sisend.txt ); int n, c; bool b[100005]; vector<int> v, v1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0); cin >> n; for (int(i) = (0); ((i)) < ((n)); ((i))++) { cin >> c; v.emplace_ba... |
///****In the name of ALLAH, most Gracious, most Compassionate****// #include<bits/stdc++.h> #define Input freopen( in.txt , r ,stdin) #define Output freopen( out.txt , w ,stdout) #define ll long long int #define ull unsigned long ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; const long long BIG_INF = 1e18; const long long MOD = 1e9 + 7; const int maxn = 1e5 + 5; vector<int> g[maxn]; int p[maxn], max_height, deep_v; void dfs(int v, int height) { if (height > max_height) { max_height = height; ... |
#include <bits/stdc++.h> int main() { char a[19]; int i, c = 0, t = 0, x = 0; scanf( %s , &a); for (i = 0; a[i] != 0 ; i++) { t = t + a[i]; } x = a[0] - 1 + (i - 1) * 9 ; if (t >= x) printf( %s , a); else { if (a[1] != 9 ) { for (i = 0; a[i] != 0 ; i++) ... |
#include <bits/stdc++.h> using namespace std; long long n; long long a[1006]; long long fac[1000006]; long long power(long long a, long long i) { if (i == 0) return 1 % 1000000007; long long t = power(a, i / 2); long long ans = t * t % 1000000007; if (i % 2 == 1) ans = ans * a % 1000000007; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, k; cin >> n >> k; long long int a[n], s = 0; vector<pair<long long int, long long int> > v; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= k) { v.push_back({a[i], i + 1}); s += a[i];... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const long long INF = 1e12; const int MOD = 1e9 + 7; const unsigned long long BIT_FLAG_0 = (1 << 0); const unsigned long long BIT_FLAG_1 = (1 << 1); const unsigned long long BIT_FLAG_2 = (1 << 2); const unsigned long long BIT_FLAG_... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; int main() { ios_base::sync_with_stdio(0); long long q; cin >> q; while (q--) { long long n; cin >> n; long long cnt = 0; long long flag = 1; while (n != 1) { if (n % 2 == 0) { n ... |
#include <bits/stdc++.h> using namespace std; int main() { int x; while (cin >> x) { map<char, int> p1; string str, strr; ; bool l = 0; int sum; cin >> str; for (int i = 0; i < str.size(); i++) { p1[str[i]]++; } for (int i = 0; i < str.size(); i+... |
#include <bits/stdc++.h> using namespace std; const int N = 200200; const int mod = 1e9 + 7; int n, a, b; vector<int> q; int main() { cin >> n >> a >> b; q.push_back(a); q.push_back(a); q.push_back(a); q.push_back(a); q.push_back(b); q.push_back(b); sort(q.begin(), q.end()); ... |
#include <bits/stdc++.h> using namespace std; using lli = long long int; lli mod = 1000000007.0; int main(void) { long long t; cin >> t; lli x; lli n; while (t--) { cin >> n; x = 1; for (lli i = 2 * n; i >= 3; i--) { x *= i; x = x % mod; } cout <... |
#include <bits/stdc++.h> using namespace std; int n, x[210], y[210], ans, dp[210][210]; long long S[210][210]; bool in[210][210][210]; int gogo(int x) { if (x % n == 0) return n; return x % n; } long long cp(int a, int b, int c) { return 1LL * (x[a] - x[c]) * (y[b] - y[c]) - 1LL * (... |
#include <bits/stdc++.h> using namespace std; int round_up(int i) { while (i & (i - 1)) { i = ((i - 1) | i) + 1; } return i; } class seg_t { public: vector<int> seg, ar; int n; seg_t(vector<int>& a) { n = a.size(); ar = a; int si = round_up(n); seg.resize... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; int const N = 1e5 + 20, MAX = 7000 + 20; int n, q; bitset<MAX> bt[N]; int a[MAX]; vector<int> dv[MAX]; bitset<MAX> save[MAX]; void pre() { a[1] = 1; for (int i = 1; i < M... |
#include <bits/stdc++.h> using namespace std; int n; int k; vector<pair<long double, long double> > vp; const long double PI = 2 * acos(0.0); bool check(long double r) { vector<pair<long double, int> > events; for (int i = 0; i < n; ++i) { long double ang = atan2(vp[i].second, vp[i].first); ... |
#include <bits/stdc++.h> using namespace std; int a[] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; const int Q = 1e9 + 7; int main() { string s, t; cin >> s >> t; vector<int> p(t.length()); for (int i = 1; i < t.length(); ++i) { int k = p[i - 1]; while (k > 0) { if (t[k] == t[i]) { ... |
#include <bits/stdc++.h> using namespace std; long long check(long long x) { long long i = 0, ans = 0; while (x > 0) { if ((x & (1)) == 1) { ans = max(ans, i); } x = x >> 1; i++; } return ans; } void solve() { long long n; cin >> n; long long a[n + 1];... |
#include <bits/stdc++.h> using namespace std; int cnt = 0; vector<int> ans; vector<vector<int> > adj; void dfs(int u, int col) { if (ans[u] != -1) return; ans[u] = col; for (int i = 0; i < adj[u].size(); ++i) dfs(adj[u][i], col); } char conv(int first) { if (first == 0) return b ; if ... |
#include <bits/stdc++.h> typedef std::function<long long(long long)> fun; class Map { int n, w, r; std::vector<int> A, B; std::function<int(long long)> lower, upper; std::vector<long long> who; std::vector<int> val; void find_array(std::vector<int> &a, const std::vector<long long> &S, fun f,... |
#include <bits/stdc++.h> using namespace std; int n, m, q, num, tot, tp, cnt, ans, w[200100], head[200100], dfn[200100], c[200100], low[200100], sta[200100]; int dfc, sz[200100], d[200100], f[200100], son[200100], top[200100], tree[200100], mn[200100 * 4]; vector<int> v[200100]; multiset<int> s[20... |
#include <bits/stdc++.h> using namespace std; int n; int a[111][111]; char c[111]; int main() { int i, j, k; int p, q, r; int t, tt, ttt; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %s , c); for (j = 1; j <= n; j++) { if (c[j - 1] == E ) a[i][j] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100001; vector<int> v, w; char s[1000001]; int main() { scanf( %s , &s); int len = strlen(s); for (int i = (0); i < (len); i++) { if (s[i] == @ ) v.push_back(i); if (s[i] == . ) w.push_back(i); } int t = 0, tmp = ... |
#include <bits/stdc++.h> using namespace std; int n, m, c; int ans[1001]; int zero; inline void send(int x, int p) { if (ans[x] == 0) --zero; ans[x] = p; printf( %d n , x); fflush(stdout); } int main() { scanf( %d %d %d , &n, &m, &c); int mid = (c + 1) / 2; zero = n; for (i... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000000000; const int MOD = 1073741824; const int M = INF; const double RRR = 180.0 / PI; vector<vector<int> > g; vector<bool> used; void dfs(int v) { used[v] = 1; for (vector<int>::iterator it = g[v].b... |
#include <bits/stdc++.h> using namespace std; long long mcd(long long a, long long b) { if (b > a) swap(a, b); if (b == 0) return a; else return mcd(b, a % b); } long long i, j, n, m, q, a, l, r, b; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin... |
#include <bits/stdc++.h> using namespace std; const long long modulo = 998244353; const long long p = modulo; vector<int> edges[300005]; int father[300005]; long long rCount[300005]; long long oCount[300005]; long long eCount[300005]; pair<int, int> gcd(long long a, long long b) { if (b == 0ll) re... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)1e2, maxM = (int)1e2, intMax = INT_MAX, maxValue = 44721; const long long llmax = LLONG_MAX, INF = (long long)1e9 + 1, mod = 998244353; long long nod(long long a, long long b) { while (a != 0 && b != 0) { if (a < b) b %= a; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; int diff = INT_MAX; int a1, b1, c1; for (int i = 1; i <= 10000; i++) { for (int j = i; j <= 20000; j += i) { for (int k = j; k <= 500... |
#include <bits/stdc++.h> using namespace std; int n, k, q; int it[35][800005]; struct point { int a[10]; point(){}; int &operator[](int x) { return a[x]; } }; point p[200005]; int sign(point &p, int bit) { int ans = 0; for (int i = 0; i < k; i++) { if (bit & 1 == 1) { ans... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int N; int X[206], Y[206]; int D[202][202]; long long area(int i1, int i2, int i3) { return 1LL * X[i1] * Y[i2] + 1LL * X[i2] * Y[i3] + 1LL * X[i3] * Y[i1] - 1LL * Y[i1] * X[i2] - 1LL * Y[i2] * X[i3] - 1LL * Y[i3] * X[i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; struct Node { int a, b, d; } p[MAXN]; int n, k; bool cmp(Node aa, Node bb) { return aa.d < bb.d; } bool cmp2(Node aa, Node bb) { return aa.d > bb.d; } int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) sca... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> dp; dp.push_back(0); dp.push_back(1); while (dp.back() <= n - 1) { dp.push_back(dp[dp.size() - 1] + dp[dp.size() - 2] + 1); } cout << dp.size() - 2 << endl; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; const int inf = numeric_limits<int>::max() / 2; const long double eps = 1e-9; const long double pi = acos(-1); inline void solve(), read(); int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; vector<pair<int, int>> adj[N], fish[N]; int n, m, now, depth[N]; struct node_t { int x, d, v; node_t(int x, int d, int v, int t = 0) : x(x - d * t), d(d), v(v) {} bool operator<(const node_t &b) const { int p = x + now * d, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k; double maxm, sum, r; cin >> n; double A[n]; for (i = 0; i < n; i++) cin >> A[i]; sort(A, A + n); maxm = A[n - 1]; for (i = n - 1; i >= 0; i--) { sum = 0; for (j = n - 1; j >= i; j--) { r = ... |
#include <bits/stdc++.h> void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T> inline void gmax(T &a, T b) { if (b > a) a = b; } template <class T> inline void gmin(T &a, T b) { if (b < a) a = b; } using namespace std... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); int mx = (b - a) * 2; if (a > mx || b > mx || c > mx) cout << -1 n ; else { if (c > mx / 2) cou... |
#include <bits/stdc++.h> using namespace std; int n, a[50100]; long long m, ans; struct node { int s, cnt[30]; node *ch[2]; node(); } * tp, *nul, *root[50100]; int getint() { char ch; while (!isdigit(ch = getchar())) ; int x = ch - 0 ; for (; isdigit(ch = getchar()); x = x... |
#include <bits/stdc++.h> using namespace std; int a[200001]; void op(int i) { int res = a[i] ^ a[i + 1] ^ a[i + 2]; a[i] = a[i + 1] = a[i + 2] = res; } vector<int> push_left(int i) { vector<int> v; while (i - 2 >= 1 && a[i] == 0 && a[i - 1] == 1 && a[i - 2] == 1) { op(i - 2); v.pus... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T& x) { x = 0; char s = (char)getchar(); bool f = false; while (!(s >= 0 && s <= 9 )) { if (s == - ) f = true; s = (char)getchar(); } while (s >= 0 && s <= 9 ) { x = (x << 1) + (x ... |
#include <bits/stdc++.h> using namespace std; const int kN = 100 + 1; const int kA = 256; bool dp[kN][kN][kA]; bool used[kN][kN][kA]; vector<pair<int, int> > g[kN]; bool Dp(int u, int v, int mark) { if (!used[u][v][mark]) { used[u][v][mark] = true; dp[u][v][mark] = false; for (const ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int n, S, L; int a[300005]; int dp[300005]; void solve() { deque<pair<int, int> > dqmin, dqmax, dqdp; int pos = 0; for (int i = 1; i <= n; i++) { if (i >= L) { while (dqdp.size() && dqdp.back().first >= dp[i - L... |
#include <bits/stdc++.h> using namespace std; const long long MaxN = 600005; template <class t> inline void rd(t &s) { s = 0; register char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar(); return; } long long a[MaxN],... |
#include <bits/stdc++.h> using namespace std; template <typename T> void printvec(vector<T>& vec) { for (long long int i = 0; i < vec.size(); i++) { cout << vec[i] << ; } cout << endl; } int main() { ios_base::sync_with_stdio(false); long long int n; cin >> n; vector<pair<... |
#include <bits/stdc++.h> using namespace std; const int s = 1000000; int a[1000001]; bool belongs[1000001]; bool used[1000001]; vector<int> ans; int main() { int n; cin >> n; for (int i = 0; i <= s; i++) belongs[i] = used[i] = false; for (int i = 0; i < n; i++) { scanf( %i , &a[i]); ... |
#include <bits/stdc++.h> using namespace std; string n; int sz; long long mul; long long ans; long long powe(long long a, long long b) { if (!b) return 1; long long tmp = powe(a, b / 2); tmp = (tmp * tmp) % 1000000007; if (b % 2 == 1) return (tmp * a) % 1000000007; else retur... |
#include <bits/stdc++.h> const double pi = acos(-1); const int o = 524288; int a[1111111]; double x[1111111], y[1111111]; int z[1111111]; int main() { double tx, ty; int i, j, k, n, m, tz; scanf( %d%d , &n, &m); for (i = 0; i < n; i++) a[i + o] = x[i + o] = 1; for (i = o - 1; i >= 0; i--... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; long long MOD = 998244353; double eps = 1e-12; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 10000; const int maxm = 20000; const int maxk = 10; const int inf = 25; int tot_edge, sz; int head[maxn]; int nxt[maxm]; int to[maxm]; int cap[maxm]; int flow[maxk + 1][maxm]; int qu[maxn]; int prv[maxn]; int when[maxn]; int pa... |
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; cout << 25 << endl; return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const int maxn = 1000100; int cnt_neg = 0, cnt_pos = 0; int arr[maxn << 1]; int main() { int n; scanf( %d , &n); for (int e = 1; e <= n; e++) scanf( %d , arr + e), arr[e + n] = arr[e]; int hi = 2 * n, lo = n + 1, now... |
#include <bits/stdc++.h> using namespace std; long long mod(long long v, long long k, long long p) { long long res = 1; for (long long i = 0; i < 4; i++) res *= v, res %= p; res -= ((k * v) % p); if (res < 0) res += p; return res; } int main() { ios_base::sync_with_stdio(false); cin.... |
#include <bits/stdc++.h> using namespace std; const long long INF = 200000000 + 1; const int N = 300006, M = 80; int dp[2][101][10005], a[105], cnt[105]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; fo... |
#include <bits/stdc++.h> const int MAXN = 1e6 + 5; int n, m, k; char str[21]; int x[MAXN], y[MAXN]; int s[MAXN], t[MAXN]; int p[21]; int f[(1 << 20) + 3], g[(1 << 20) + 3]; inline void presum() { for (int i = 0; i <= k - 1; ++i) { for (int S = 0; S <= (1 << k) - 1; ++S) { if ((S >> i) ... |
//頑張って #include <bits/stdc++.h> #define ff first #define ss second #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; #define all(x) x.begin(), x.end() void solve() { int n; cin >> n; vector <int> a(n); for (auto &i : a) cin >> i; int... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const int N = 1234567; long long a[N], b[N]; int main() { int n, k; scanf( %d %d , &n, &k); n++; for (int i = 0; i < n; i++) { int foo; scanf( %d , &foo); a[i] = foo; } long long z = ... |
#include <bits/stdc++.h> using namespace std; const int di[] = {-1, 0, 1, 0}; const int dj[] = {0, 1, 0, -1}; const long long MOD = 1e9 + 7; const long long INF = 1e9; const double EPS = 1e-11; class UnionFind { private: vector<long long> p, rank, setSize; int numSets; public: UnionFi... |
#include <bits/stdc++.h> using namespace std; template <typename T> using minheap = priority_queue<T, vector<T>, greater<T>>; int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { long long w, h; cin >> w >> h; vector<vector<long long>> a(4); for (... |
#include <bits/stdc++.h> using namespace std; char a[5][6] = { aabb , abab , abba , aaaa }; char s[5][10005]; bool f[5]; int find(char s[], int k) { int p1 = -1; int len = strlen(s); int cnt = 0; for (int i = len - 1; i >= 0; i--) { if (s[i] == a || s[i] == e || s[i] == i || s[i... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct edge { int to, index; edge(int t = 0, int i = 0) { to = t; index = i; } }; vector<edge> g[N]; int num[N], ans[N], dep[N], fa[18][N], n, m; void add(int from, int to, int index) { g[from].push_back(edge(to, i... |
#include <bits/stdc++.h> using namespace std; int n, a[2 * 100004], b[2 * 100004], c[2 * 100004], poz, x; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; c[a[i]] = 1; } poz = 1; for (int i = 1; i <= n; ++i) { cin >> b[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, cou = 0; cin >> n; string s; cin >> s; int res = n + 1; for (int i = 0; i < n; i++) { if (s[i] == H ) cou++; } for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < cou; j++) { if (s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.