func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> inline int in(); inline void wr(int); inline int gcd(int, int); int main(int argc, char** argv) { register int T = in(); while (T--) { register int p1 = in(), p2 = in(), k = in(); if (p1 > p2) p1 ^= p2 ^= p1 ^= p2; if (k == 1) { puts( REBEL ); c... |
#include <bits/stdc++.h> using namespace std; struct pt { long long int x, y; }; istream &operator>>(istream &input_stream, pt &a) { input_stream >> a.x >> a.y; return input_stream; } ostream &operator<<(ostream &output_stream, pt a) { output_stream << a.x << << a.y; return output_st... |
#include <bits/stdc++.h> using namespace std; struct rua { char s[100001]; int n, a[100001], b[100001], x, y; void _() { int cnt = 0; for (int i = 1; i <= n; i++) if (s[i] == A ) a[i] = ++cnt, b[i] = b[i - 1]; else a[i] = cnt = 0, b[i] = b[i - 1] + 1; ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<int, int> > adj[100005]; int dp[300005]; int x[300005]; int main() { ios_base::sync_with_stdio(0); int i, j; cin >> n >> m; while (m--) { int u, v, e; cin >> u >> v >> e; adj[e].push_back(make_pair(u, v)); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, c, i, l; cin >> n; int ar[n]; l = 0; for (i = 0; i < n; i++) { cin >> ar[i]; if (ar[i] == 1) l++; } c = 0; if (l == n) { cout << c << endl; exit(0); } for (i = 1; i < n - 1; i++) { ... |
#include <bits/stdc++.h> using namespace std; char a[6][6]; char tl[2] = { x , o }; int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; bool judge(int x, int y, int nu) { for (int i = 0; i < 8; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (a[xx][yy] ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[200010]; int a, b, ans = 1; int main() { pair<int, int> arr[200010]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> a >> b, arr[i].first = a + b, arr[i].second = a - b; sort(arr, arr + n); int tmp = arr[0].first;... |
#include <bits/stdc++.h> using namespace std; int n; int a[210000][3]; set<pair<int, int> > st; int nxt[210000][2]; int x[210000]; vector<pair<int, int> > re; map<long long, int> mp; int pp[210000]; long long hsh(int x, int y, int z) { if (y > z) swap(y, z); if (x > y) swap(x, y); if (y ... |
#include <bits/stdc++.h> template <class T> const T& min(const T& a, const T& b, const T& c) { return min(a, min(b, c)); } template <class T> const T& max(const T& a, const T& b, const T& c) { return max(a, max(b, c)); } using namespace std; int gcd(long long a, long long b) { while (true) {... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == - , ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 0 ), ch = getchar(); return f ? -x : x; } inline void write(long long... |
#include <bits/stdc++.h> using namespace std; int main() { int n, digit; int S = 0, max = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> digit; S += digit; if (digit > max) max = digit; } S = abs(S - max); cout << abs(S - max) + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; long long int X, Y, Z; bool run(vector<long long int> &x, vector<long long int> &y, vector<long long int> &z, long long int mid) { long long int bound[4][2]; long long int t0 = x[0] + y[0] + z[0]; long long int t1 = -x[0] + y[0] + z[0]; long... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int q; cin >> q; while (q--) { int n; cin >> n; long long dp[n][3]; long long a[n], b[n]; for (int i = 0; i < n; i++) { cin >> a[i] >> b... |
#include <bits/stdc++.h> using namespace std; int main() { int sol = 0; int n; cin >> n; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { for (int k = i - j; k <= j; ++k) { if (((k ^ j) ^ i) == 0 && k + j > i) ++sol; } } } cout << sol << n... |
#include <bits/stdc++.h> using namespace std; long long n, k; long long ans; long long matriz[505][505]; int main() { ans = 0; cin >> n >> k; long long aux = (n - k + 1) * n; aux = n * n - aux + 1; long long curr1 = 1; long long curr2 = aux; for (int i = 0; i < n; ++i) { int ... |
#include <bits/stdc++.h> using namespace std; int IN() { int x = 0, f = 0, ch; for (; (ch = getchar()) < 0 || ch > 9 ;) f = (ch == - ); for (; ch >= 0 && ch <= 9 ; (ch = getchar())) x = x * 10 + ch - 0 ; return f ? -x : x; } int M, edge[1005][1005], son[1005][1005], idx[1005][1005]; in... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:200000000 ) const double EPS = 1E-9; const int INF = 1000000000; const long long INF64 = (long long)1E18; const double PI = 3.1415926535897932384626433832795; const int NMAX = 310000; set<pair<int, int> > q[3][3]; int a[NMAX... |
#include <bits/stdc++.h> using namespace std; long long int sqr(long long int a) { return a * a; } int main() { ios::sync_with_stdio(false); long long int a, n, m; string str; cin >> n; long long int arr[n + 1], brr[n + 1], crr[n + 1]; long long int sum = 0, maxx = 0; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; class A { public: int a; int b; int c; int d; } aa[100005]; int a[103][103]; int main() { int n, m, q; cin >> n >> m >> q; int i; for (i = 0; i < q; i++) { cin >> aa[i].a >> aa[i].b; if (aa[i].a == 1 || aa[i].a == 2) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, d, ans; struct node; struct edge { node *ed; edge *next; } E[N << 1], *newE = E; struct node { edge *son; node *pa; bool flag; int dist[2], dis; void dfs() { dist[0] = dist[1] = dis = -1e8; ... |
#include <bits/stdc++.h> using namespace std; int n, a[20]; vector<long long> v; int main() { cin >> n; int s = 1; for (long long i = 1; i < 1e5; ++i) v.push_back(i); while (v.size() > 8e4) v.erase(v.begin()); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); sort(a, a + n); for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); string s; cin >> s; s = 0 + s; vector<int> v(int(s.size()), 0); for (int i = int(s.size()) - 1; i >= 0; i--) { if (s[i] == 1 ) { v[i] = -1; while (s[i] != 0 ) i--; v[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, c1, c2; cin >> n; int x, y; x = n / 3; y = n % 3; if (y == 1) { c1 = x + 1; c2 = x; } else if (y == 2) { c1 = x; c2 = x + 1; } ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m, k; int t, x; int c[200010]; int f1[200010]; int f2[200010]; vector<int> w, a, b; vector<int> d; vector<ll> ww, aa, bb, dd; int main() { ios::sync_with_stdio(false); cin >> n >> m >> k; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; inline char nc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline void read(int &x) { char c = nc(), b = 1; for (; !(c... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; multiset<char> ms; for (char c : s) ms.insert(c); string t, u; for (int i = 0; i < (s.size()); i++) { ms.erase(ms.find(s[i])); t += s[i]; while (!t.empty() && ms.lower_bound(t.back()) == ms.begin... |
#include <bits/stdc++.h> using namespace std; const int maxn = 25e4 + 1; const long long inf = 1e18; int n, m, k, h[maxn], par[maxn], tests, ted; bool vis[maxn]; vector<int> e[maxn]; vector<int> ans[maxn]; void path_ans(int v) { cout << PATH << n ; cout << tests << n ; for (int test = ... |
#include <bits/stdc++.h> using namespace std; long long dp[2][52][52][52][52] = {{{{{0}}}}}; int d[52]; int n; const int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> d[i]; } dp[1][d[0] == 2][d[0] == 3][d[1] == 2... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; vector<vector<int> > v(n, vector<int>(7, 0)); for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < 7; j++) v[i][j] = s[j] - 0 ; } vector<int> cnt(7, 0); for (int i = 0; i < 7; i+... |
#include <bits/stdc++.h> int n, C, orig[600010], top, stk[300010], all, Add[300010], One[300010], cost[600010], ctop; struct info { int mx, ord, skdmx; } c[3000010]; info merge(info a, info b) { info c; if (a.mx > b.mx) c = a, c.skdmx = std::max(c.skdmx, b.mx); else c = b, c.sk... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -1; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; return x * f; } inline long long readll() { long long x = ... |
#include <bits/stdc++.h> using namespace std; int main() { string luck[7] = { 1869 , 1968 , 1689 , 6198 , 1698 , 1986 , 1896 }; string str; cin >> str; int ans = 0; bool vis[10]; int zero = 0; memset(vis, 0, sizeof(vis)); for (int i = 0; i < str.length(); i++) { if (str[i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; template <typename T> using pair2 = pair<T, T>; using pii = pair<int, int>; using pli = pair<ll, int>; using pll = pair<ll, ll>; mt19937 rng(chrono::steady_clock... |
#include <bits/stdc++.h> using namespace std; int N, X; int main() { scanf( %d%d , &N, &X); string s; if (N == 5) s += >...v nv.<.. n..^.. n>.... n..^.< n1 1 ; else if (N == 3) s += >vv n^<. n^.< n1 3 ; else if (N == 100) s += v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.... |
#include <bits/stdc++.h> using namespace std; long long binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } long long n, p; const long long N = 1e6 + 2; long lon... |
#include <bits/stdc++.h> using namespace std; const long long INF = (1LL << 60) - 1; void solve() { set<int> st; int n, k, arr[1001]; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> arr[i]; st.insert(arr[i]); } if ((int)st.size() >= k) { puts( YES ); int lst = -... |
#include <bits/stdc++.h> #include <stack> using namespace std; #define ll long long #define rep(i,a,b) for(ll i=a; i<b; i++) #define repi(i,a,b) for(ll i=b-1; i>=a; i--) #define pb push_back #define mod 1000000007 void fastscan(ll &num){ bool n=false; register ll c; num=0; c=getc... |
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; long sum = 2; int k = 1; int b = 0; for (int i = 1;; i = i + k) { if (i == n) { break; } b++; if (b == 2) { b = b % 2; k++; } if (i > n) { break; ... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z, a, b, c; cin >> x >> y >> z; cin >> a >> b >> c; if (a < x) { printf( No ); return 0; } if (a + b < x + y) { printf( No ); return 0; } if (a + b + c < x + y + z) { printf( No ); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long int d, k, a, b, t, x = 0, ans = 0, y; cin >> d >> k >> a >> b >> t; ans = a * min(d, k); x = min(d, k); if (x < d) { y = (d - x) / k; if (t * ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; long long BIT[6][N]; int n, arr[N]; inline long long getPrefix(int z, int i) { i = n - i - 1; ++i; long long ret = 0; while (i) ret += BIT[z][i], i -= i & -i; return ret; } inline void add(int z, int i, long long v)... |
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0; char zf = 1; char ch; while (ch != - && !isdigit(ch)) ch = getchar(); if (ch == - ) zf = -1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * zf; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500055; int n, m, r, k; set<pair<int, int> > rec; const int dir[2][4] = {{0, 0, 1, -1}, {1, -1, 0, 0}}; struct node { int x, y, val; node() {} node(int _x, int _y, int _val) : x(_x), y(_y), val(_val){}; bool operator<(const node ... |
#include<bits/stdc++.h> #define int long long int #define pb push_back #define all(x) (x).begin(), (x).end() using namespace std; int solve(int a,int b) { if(a<=0) return 0; return min(1+solve(a/b,b), 2+solve(a/(b+1),b+1)); } signed main() { ios_base::sync_with_stdio(false);cin... |
#include <bits/stdc++.h> using namespace std; inline int nxt() { int x; scanf( %d , &x); return x; } using ld = long double; int main() { mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n = nxt(); long long k; scanf( %lld , &k); vector<int> a(n); fo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); cin.sync_with_stdio(0); int n; cin >> n; vector<string> a(2 * n - 2); map<string, vector<int>> m; for (int i = 0; i < 2 * n - 2; ++i) { cin >> a[i]; m[a[i]].emplace_back(i); } ... |
#include <bits/stdc++.h> using std::make_pair; using std::pair; const int N = 3e5 + 1e3; int n, k; int tot, rt; struct Pair { int l, r, pos, v1; bool operator<(const Pair m) const { return v1 > m.v1; } } p1[N], p2[N]; int sum[N << 4], ls[N << 4], rs[N << 4], mn[N << 4]; int r[N], a[N], mx[N], ... |
#include <bits/stdc++.h> using namespace std; long long i, j, t, n, m, l, r, k, z, y, x; long long a, b, ans; int main() { scanf( %I64d%I64d%I64d , &t, &a, &b); if (t == 1) { if (a == 1) { if (a == b) printf( inf n ); else printf( 0 n ); return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long k, b, n, t, z = 1, cnt = 0; cin >> k >> b >> n >> t; while (z <= t) { cnt++; z = k * z + b; } cout << n - min(n, cnt - 1); return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, m, k, t; long long cnm[N]; long long h[N], w[N], e[N], ne[N], idx; vector<long long> g[N]; int vis[N]; long long ans; vector<int> res; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } void dfs(int u, i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, q, l[N], r[N], level[N], p[N][20], res[N]; int import[N], numCity, numVirus; vector<int> adj[N]; vector<pair<int, int> > newAdj[N]; struct T { int city, speed; }; T virus[N]; pair<pair<int, int>, int> top; struct Less ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c; cin >> a >> b >> c; long long int temp1, temp2, temp3; temp1 = a / c; temp2 = b / c; if (a % c != 0) temp1++; if (b % c != 0) temp2++; cout << temp1 * temp2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 45; int n, m; char G[maxn][maxn]; int sg[maxn][maxn][maxn][maxn][2]; int SG(int x0, int x1, int y0, int y1, int d) { int &g = sg[x0][x1][y0][y1][d]; if (g != -1) return g; char s[maxn * 2 + 1]; memset(s, 0, sizeof(s)); for (i... |
#include<bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef std::vector<ll> vi; typedef std::vector<std::vector<ll> > vv; typedef std::vector<std::pair<ll,ll> > pii; #define mod 1000000007 #define IO ios_base::sync_with_stdio(false);cin.tie(NULL); #define fo(i,a,b) for(i=... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, l, q, num, ll; cin >> n >> m >> l; vector<long long> len(n); vector<bool> is_long(n, false); long long prev_long = 0; long long count = 0; bool was_long = false; for (long long i = 0; i < n; ++i) { cin >... |
#include <bits/stdc++.h> using namespace std; const int N = 16; const int inf = 1e9 + 7; int f[N][N][N][2][2][2]; struct node { int x; int y; int z; int i1; int j1; int k1; int p1; int fi1, fi2; } pre[N][N][N][2][2][2]; int a[N], b[N], c[N]; char s[N * 5]; inline void U... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int s = 0; s = n * (n); s = s + (n - 1) * (n - 1); cout << s; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; for (int i = 0; i < (int)s.size(); i++) { if (s[i] == . ) cout << 0 ; else { if (s[i + 1] == . ) cout << 1 ; else ... |
#include <bits/stdc++.h> using namespace std; const int N = 1009; int a, b, sum = 0; int arr[N][N], ans[N]; void llop_over(int r, int c) { for (int i = 0; i < r; ++i) { for (int g = 0; g < c; ++g) scanf( %d , &arr[i][g]); sum ^= arr[i][0]; } } int main() { scanf( %d %d , &a, &b); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); char arr[1000]; cin >> arr; int flag = 1, curr = 0; for (int i = 0; i < strlen(arr); i++) { if (i == 0) curr = 1; else if (flag == 1) { if (arr[i] == arr[i - 1]) { c... |
#include <bits/stdc++.h> using namespace std; long long int sf[26][200005], tf[26][200005]; int main() { long long int n, i, j; cin >> n; double ans = 0.0; string s, t; cin >> s >> t; for (i = 0; i < n; ++i) { sf[s[i] - A ][i] += (i + 1); tf[t[i] - A ][i] += (i + 1); if... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; long long a[maxn], b[maxn], c[maxn]; int num[64]; int n; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < n; i++) cin >> c[i]; long long sum = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; vector<long long int> v(n, 0); priority_queue<pair<long long int, pair<long long int, long long int>>> pq; pq.push({n, {0, n - 1}}); long lon... |
#include <bits/stdc++.h> using namespace std; bool isPal(string s) { for (long long i = 0, j = s.length() - 1; i < j; i++, j--) if (s[i] != s[j]) return 0; return 1; } string lts111(long long n) { string a = 00:00 ; long long hr = n / 60; long long min = n % 60; long long fh = hr ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 0; int temp; stack<int> st; for (int i = 0; i < n; ++i) { cin >> temp; while (!st.empty() && st.top() < temp) { ans = max(ans, (st.top() ^ temp)); st.pop(); } if (!st... |
#include <bits/stdc++.h> using namespace std; long long int fastExpo(long long int a, long long int n, long long int mod) { long long int result = 1; while (n > 0) { if (n & 1) result = (result * a) % mod; a = (a * a) % mod; n >>= 1; } return result; } long long int modInverse(... |
#include <bits/stdc++.h> using namespace std; vector<int> num, sum; int NUM[1005], Ind[1005]; int Set[1005]; int Top_sort(int n, int m) { queue<int> q; int i, j, ret; for (i = 1; i <= n; i++) if (Ind[i] == 0) q.push(i); while (!q.empty()) { i = q.front(), q.pop(); int now = 0... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int MOD = 1e9 + 7; const int MOD2 = 1e9 + 9; const int PR = 727; const int INF = INT_MAX; const long long... |
#include <bits/stdc++.h> using namespace std; const int N = 3e6 + 50; const int oo = 1e9; const int mod = 1e9 + 7; long long a[N]; int main() { long long n, m; cin >> n >> m; long long c = 1; int cur = 0; for (int i = 30; i; i--) { while (n >= (1 << i) - 1) { for (int j = 1... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long res = 0; while (a >= 1 && b >= 1) { if (a < b) swap(a, b); res += a / b; a %= b; } cout << res; return 0; } |
#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; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {... |
#include <bits/stdc++.h> using namespace std; const long long MAX_N = 1e6 + 7, K = 21, M = 1e9 + 7; long long n; signed dp[MAX_N][K][2]; long long get(long long x) { if (x > n) return 0; return (n / x); } signed main() { memset(dp, 0, sizeof(dp)); cin >> n; long long poww = 0, cur = 1;... |
#include <bits/stdc++.h> using namespace std; void debug(int n, ...) { va_list v1; va_start(v1, n); for (int i = 0; i < n; i++) { int val = va_arg(v1, int); printf( %d , val); } va_end(v1); printf( n ); } double n, k; double sum; int ans; int main() { cin >> n >> ... |
#include <bits/stdc++.h> using namespace std; long long const M = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10; long long par[M][30], dp[M], zt[M], sum[M], val[M][30], sum2[M], n, dp2[M], len = 0, h[M]; vector<long long> adj[M], edg[M], inc[M]; long long mrg(long long x, long long y, long long sm, long long ... |
#include <bits/stdc++.h> using namespace std; void Read(int &x) { static char c; while (!isdigit(c = getchar())) ; x = (c ^ 48); while (isdigit(c = getchar())) x = x * 10 + (c ^ 48); return; } void Print(int x, char end) { static int i; for (i = 1; i * 10LL <= x; i *= 10) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, k, dep[N], fa[N]; bitset<N> s[2], t[4], a, b; vector<bitset<N> > S; inline bitset<N> qry(bitset<N> x, int y) { y = min(y, n - 1); char c[N]; putchar( ? ); for (int i = 1; i <= n; i++) printf( %d , x[i] ? y : 0); pu... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, m, a[N], b[N], t[N]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) scanf( %d%d , &a[i], &b[i]); int x = a[1], cnt = 0; for (int i = 1; i <= m; i++) if (a[i] == x || b[i] == x) cnt++; for (in... |
#include <bits/stdc++.h> using namespace std; int n, x, y, pos[100001]; vector<int> d[100001]; void sieve() { memset(d, 0, sizeof(d)); for (int i = 1; i < 100001; i++) for (int j = i; j < 100001; j += i) d[j].push_back(i); memset(pos, 0, sizeof(pos)); } int main() { sieve(); scanf(... |
#include <bits/stdc++.h> const long long inf = 1ll << 60; const long long maxn = 30010; using namespace std; struct lsg { long long x, y; } a[maxn], b[maxn]; signed n, q, ffa[maxn], ffb[maxn], ban[maxn], x, y; long long f[maxn], w1[maxn], w2[maxn], w3[maxn]; bool pd(lsg a, lsg b) { return a.x < b.x;... |
#include <bits/stdc++.h> using namespace std; int n, m, c[105]; int sum[105][10005], h[105][10005], f[105][10005]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &c[i]); sum[i][0] = 0; for (int j = 1; j <= c[i]; j++) { int x; scanf( %d , ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> nums(n); vector<string> nums_str(n); unordered_map<string, int> counts; for (int i = 0; i < n; i++) { cin >> nums[i]; num... |
#include <bits/stdc++.h> using namespace std; long long n, ans = 3; int main() { cin >> n; while (n % ans == 0) { ans *= 3; } cout << n / ans + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, i, ans, a[500001], f[2][1200001]; int main() { scanf( %lld , &n); f[0][0] = 1; for (i = 1; i <= n; i++) { scanf( %lld , &a[i]); a[i] ^= a[i - 1]; ans += f[i % 2][a[i]]; f[i % 2][a[i]]++; } printf( %lld , ans); ... |
#include <bits/stdc++.h> using namespace std; long long int fac(long long int n) { long long int g = 1; for (int x = 1; x <= n; x++) g *= x; return g; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long q, m, n, i, j, dummy, a, b, x, y, t, x1, y1; cin >> n >> m >> q; vector<vector<long> > R(100, vector<long>(100, 0)); vector<vector<long> > C(100, vector<long>(100, 0)); vector<vector<long> > E(100, vector<long>(100, 0)); for (i ... |
#include <bits/stdc++.h> using namespace std; const long long losn = 1e6 + 5; const long long maxn = 1e5 + 5; const long long minn = 1e3 + 5; const long long tiny = 1e2 + 5; const long long inf = 1e9; const long long mod = 1e9 + 7; const long long hmod = 4698571; long long n; char c[maxn * 2]; map... |
#include <bits/stdc++.h> using namespace std; int lcs(string X, string Y) { int i, j, m = X.length(), n = Y.length(); int L[m + 1][n + 1]; for (i = 0; i <= m; i++) { for (j = 0; j <= n; j++) { if (i == 0 || j == 0) L[i][j] = 0; else if (X[i - 1] == Y[j - 1]) L[i... |
#include <bits/stdc++.h> using namespace std; const int K = 1e6 + 6; const int mod = 1e9 + 7; int n, k; int val[K]; int ans, cur; int power(int a, int b) { int res = 1; while (b) { if (b & 1) { res = (1LL * res * a) % mod; } a = (1LL * a * a) % mod; b >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; const int mm = 2e5 + 30; long long a1, a2, a3, a4, a5, a6, a7, a8, a9, ez1, ans, n, m, k, sum; string s, s1, s2, s3; int flag[mm]; bool y = 0; bool omm(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } void input() { c... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 998244353; int add(int x, int y) { return (x + y) % MOD; } int sub(int x, int y) { return (x + MOD - y) % MOD; } int mul(int x, int y) { return (1ll * x * y) % MOD; } int modpow(int base, int exp) { base %= MOD; in... |
#include <bits/stdc++.h> using namespace std; long long Pow[10005]; long long ans[10005]; int main() { long long N, X, now = 1, i, con = 0, t; Pow[0] = 1; for (i = 1; i <= 40; i++) Pow[i] = Pow[i - 1] * 2; scanf( %lld %lld , &X, &N); for (i = 40; i >= 0; i--) { while (X && X - (Pow[i] ... |
#include <bits/stdc++.h> const int maxn = 1000 + 10; const int maxm = 4e5 + 10; const int inf_max = 0x3f3f3f; using namespace std; int a, b, c; int main() { int t; cin >> t; while (t--) { cin >> a >> b >> c; string ans = ; if (a) ans += 0 ; for (int i = 1; i <= a; ++i)... |
#include <bits/stdc++.h> using namespace std; using ll = long long; ll inf = 1e18; using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll =... |
#include <bits/stdc++.h> using namespace std; int main() { long long sumfirst = 0, sumsecond = 0; long long n; vector<long long> first, second; long long arr[200000]; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > 0) sumfirst += arr[i]; else if ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 220000; const long long MOD = 1e9 + 7; int n; int was[MAXN * 2]; vector<int> beds[MAXN * 2]; int go[MAXN * 2]; int tm1; long long dfs1(int v) { was[v] = 1; long long ans = 1; for (int u : beds[v]) ans = (ans + dfs1(u)) % MOD; ... |
#include<bits/stdc++.h> using namespace std; #define int long long int #define intu unsigned long long int #define vi vector<int> #define ii pair<int,int> #define pb push_back #define ff first #define ss second #define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL); # define PI ... |
#include <bits/stdc++.h> using namespace std; long long a[2000000]; int main() { long long n, t, i; cin >> n; for (i = 0; i < n; i++) { scanf( %lld , &a[i]); } cin >> t; for (i = 0; i < t; i++) { long long x; scanf( %lld , &x); a[x - 1] = -a[x - 1]; } stack<... |
#include <bits/stdc++.h> using namespace std; int n, a, b, x, y; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> x >> b >> y; while (a != x && b != y) { ++a; if (a == n + 1) { a = 1; } --b; if (b == 0) { b = n; } if ... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y, i; long long dx, dy; }; vector<vector<int> > e; vector<int> sz; vector<int> ans; vector<point> pt; int dfs(int s) { sz[s] = 1; for (int i = 0; i < e[s].size(); i++) if (sz[e[s][i]] == 0) sz[s] += dfs(e[s][i]); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.