func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; inline void boost() { ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0); } const long long maxn = 1e5 + 123; const long long inf = 1e9 + 123; const long long mod = 1e9 + 7; const double infm = 1e-9; const double pi = acos(-1); int a[maxn]; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; double ans = 0; map<double, double> F; void insert(double dist, double s) { double need = dist / (s + 1); F[s] += need; if (s > 1) F[s] += dist / (s - 1); ans += need; while (need > 1e-9) { map<double, double>::it... |
#include <bits/stdc++.h> using namespace std; vector<int> arr[100100]; int dist[100100]; map<int, int> m1; void dfs(int curr, int par) { dist[curr] = dist[par] + 1; if (curr == par) { dist[curr] = 0; } for (auto x : arr[curr]) { if (x != par) { dfs(x, curr); } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, k, b, n, m, r = 0, x = 0, y = 0, z = 0, h = 0, l; string s; cin >> s; n = s.size(); int a[n]; for (i = 0; i < n; i++) { if (s[i] == ( ) x++; else if (s[i] == ) && x > 0) x--; else... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long s = 0; for (int i = 0; i < n; i++) { s = s + a[i]; if (s < 0) s = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; vector<int> gr[N]; long long int edges, z, o; int col[N], vis[N]; void color(int n) { for (int i = 0; i < gr[n].size(); i++) { if (col[gr[n][i]] == -1) { if (col[n] == 0) { o++; col[gr[n][i]] = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int arr[n]; int countx = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] <= x) { countx++; } } if (y < x) { cout << n << endl; return 0; } ... |
#include <bits/stdc++.h> inline char getThirdColor(char a, char b) { char ret; if (a == B && b == G || a == G && b == B ) ret = R ; else if (a == B && b == R || a == R && b == B ) ret = G ; else if (a == R && b == G || a == G && b == R ) ret = B ; return r... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t, n, k; cin >> t; while (t--) { long long ats = 0; cin >> n >> k; while (n) { ats += n % k; n -= n % k; while (n % k == 0 && n) n ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000001; int n, m, x; pair<int, int> a[maxn]; int st[maxn], q[maxn], cnt, ans[maxn], tail, top; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &a[i].first); } int x; for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 15; int n, a[MAXN], b[MAXN], inf = 1e9 + 19, pos, st[MAXN], en[MAXN], LIS, cnt[MAXN]; void fil() { b[0] = -inf; for (int i = 1; i < MAXN; i++) b[i] = inf; } int bs(int x) { int s = 0, e = 1e5 + 10; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<char> s(n); long long ans = 0; for (int i = 0; i < n; ++i) { cin >> s[i]; if (i > 0 and s[i] == . and s[i - 1] == . ) ++ans; } for (int i = 0; i < m; ++i) { int pos; cin ... |
#include <bits/stdc++.h> using namespace std; char ans[1005][1005]; int x[1005][1005], y[1005][1005]; int n; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; bool isvalid(int i, int j) { if (i < 0 || j < 0 || i >= n || j >= n) return 0; return 1; } void color(int i, int j) { if (i < 0 |... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 1; i += 2) { cout << a[i + 1] << << -1 * a[i] << ; } cout... |
#include <bits/stdc++.h> using namespace std; const int MAX_L = 20; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 7; int p = 100000007; template <typename T> void scan(T &x) { x = 0; bool neg = 0; register T c = getchar(); if (c == - ) neg = 1, c = getchar(); while ((c < ... |
#include <bits/stdc++.h> using namespace std; int n, k, Ord[100000 + 5]; long long ans, Set[100000 + 5][5]; inline int gcd(int x, int y) { return !y ? x : gcd(y, x % y); } int main() { scanf( %d%d , &n, &k); printf( %d n , (n * 6 - 1) * k); for (int i = 0; i < n; i++) printf( %d %d %d %d n ,... |
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) return a; else return b; } long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } const int dx[4] = {-1, 1, 0, 0}; con... |
#include <bits/stdc++.h> using namespace std; char arr[1000007]; void sieve() { arr[0] = 1; arr[1] = 1; for (int i = 4; i <= 1000007; i += 2) arr[i] = 1; for (int i = 3; i * i <= 1000007; i += 2) { if (arr[i] == 0) { for (int j = i; i * j <= 1000007; j++) { arr[i * j] = 1; ... |
#include <bits/stdc++.h> using namespace std; map<int, vector<int> > m; int main() { int n, k, query; scanf( %d %d , &n, &k); for (int i = 0; i < (int)(k); i++) { scanf( %d , &query); m[query - 1].push_back(i); } int ans = 0; std::vector<int>::iterator low; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; const int mx = 1e6 + 1; int n, m; string s[3]; int dp[mx][8]; bool isok(int i, int j) { int cnt = 0; for (int k = 0; k < 2; k++) cnt += ((i >> k) & 1) + ((j >> k) & 1); if (cnt % 2 == 0) return false; if (n == 2) return true; cnt = 0; for... |
#include <bits/stdc++.h> using namespace std; long long N, M; long long Arb[800002], Value[100002], Lazy[800002], Colour[800002]; void Build(long long K, long long L, long long R) { long long Mid = (L + R) / 2; if (L == R) { Colour[K] = L; return; } Build(2 * K, L, Mid); Build(2 ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 15; const int inf = 1e9; const int md = 1e9 + 7; const int shift = 1 << 17; int n, m; vector<vector<int> > g; set<pair<int, int> > br; int timer; int tin[maxn], fup[maxn]; int used[maxn]; void dfs(int v, int p = -1) { used[... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int q, n, a[N], pos[N], dp[N], pre[N]; long long ans = 0; int main() { scanf( %d , &q); while (q--) { ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) pre[i] = -1; for (int i = 0; i < n; i++) { s... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e17; const int MAXM = 1e5 + 5; const int MAXN = 1e6 + 4; long long fact[MAXM]; long long nChoosek(long long n, long long k) { if (k > n) return 0; if (k * 2 > n) k = n - k; if (k == 0) return 1; long long result = n; fo... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int val[501000], deg[501000]; vector<int> adj[501000]; int main() { int n,... |
#include <bits/stdc++.h> using namespace std; #define endl n #define ll long long #define INF (ll)1e18 ll i, i1, j, k, k1, t, n, m, res, check1, a[200010], a1, b, d, v, dist[200010], dp[200010], s, s1, s2; vector<ll> adj[200010]; vector<array<ll, 3>> dadj... |
#include <bits/stdc++.h> using namespace std; int n; map<int, int> mpp; map<int, int> tmp; multiset<int> adj[200005]; multiset<pair<int, int> > pairs; int cnt[200005]; int arra[100005]; int arrb[100005]; list<int> ans; void addpair(int u, int v) { pairs.insert(make_pair(u, v)); pairs.inser... |
#include <bits/stdc++.h> using namespace std; int n, ans = 1, p, m; string s; set<int> buy, sell, extra; int main() { cin >> n; while (n--) { cin >> s >> p; if (s == ACCEPT ) { if (extra.find(p) != extra.end()) { for (auto it : extra) { if (it < p) ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; template <class T, class U> inline void Max(T &a, U b) { if (a < b) a = b; } template <class T, class U> inline void Min(T &a, U b) { if (a > b) a = b; } inline void add(int &a, int b) { a +... |
#include <bits/stdc++.h> using namespace std; int num[105]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { scanf( %1d , &num[i]); } int sum = 0; int flag = 0; for (int i = 1; i <= n; i++) { sum += num[i]; int t = 0; flag = 0; for (int j = i +... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y, l, r; }; bool f(point a, point b) { return a.r > b.r; } point a[5000]; int par[5000]; void init(int n) { for (int i = 1; i <= n; i++) par[i] = i; } int root(int n) { if (par[n] == n) return n; return par[n] = root(p... |
#include <bits/stdc++.h> using namespace std; int main() { int na, ma, nb, mb; cin >> na >> ma; char ch1[na + 5][ma + 5]; for (int i = 1; i <= na; i++) { for (int j = 1; j <= ma; j++) { cin >> ch1[i][j]; } } cin >> nb >> mb; char ch2[nb + 5][mb + 5]; for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, sum, s; cin >> a >> b >> s; sum = abs(a) + abs(b); if (sum <= s && (s - sum) % 2 == 0) { cout << YES << endl; } else { cout << NO << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const int MAXN = (1 << 9) + 3; int k; int a[MAXN][MAXN]; void dien(int x) { if (x == 1) return; dien(x / 2); for (int i = 1; i <= x / 2; i++) { for (int j = 1; j <= x / 2; j++) { a[i +... |
//To debug : g++ -g file.cpp -o code //to flush output : fflush(stdout) or cout.flush() //cout<<setprecision(p)<<fixed<<var //use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll //take care of precedence rule of operators //do not forget to change the sizes of arrays and value of contants a... |
#include <bits/stdc++.h> using namespace std; bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } struct greaterr { template <class T> bool operator()(T const &a, T const &b) const { return a > b; } }; int main() { int n; scanf( %d ,... |
#include <bits/stdc++.h> long double pi = acos(-1); long long z = 1000000007; long long power(long long a, long long b) { if (b == 0) return 1; long long c = power(a, b / 2); if (b % 2 == 0) return c * c; else return c * c * a; } using namespace std; const int N = 1e6 + 7; void... |
#include <bits/stdc++.h> using namespace std; int get(long long a) { if (a < 4) return 0; if (a < 16) return 1; if (a < 82) return 2; if (a < 6724) return 0; if (a < 50626) return 3; if (a < 2562991876) return 1; return 2; } int main() { int cur = 0; int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int n, m, l; int pre[200010], other[200010], last[100010]; int flag[100010]; void connect(int x, int y) { pre[++l] = last[x]; last[x] = l; other[l] = y; } int dfs(int x, int fa) { flag[x] = 1; int cur(0); for (int p = last[x]; p; p = pr... |
#include <bits/stdc++.h> const int MAX_N = (int)1e5 + 123; const double eps = 1e-6; const int inf = (int)1e9 + 123; using namespace std; int n; vector<int> ans[MAX_N]; int k; int main() { cin >> n; ans[1].push_back(1), ans[2].push_back(1); for (int i = 3, now = 2;; i++) { if (n - now +... |
#include <bits/stdc++.h> using namespace std; long long a[1001][1001], ans[1001]; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int x = (n + 1) / 2 + 1 * ((n + 1) & 1); vector<pair<int, int> > v; for (int j = 1; j <= x; j++) { i... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int> > adj[100005]; long long int sp = 0, mst = 0, p = 100003; int n, m; int main() { cin >> n >> m; long long int c = p - (n - 2); adj[1].push_back({2, c}); m--; for (int i = 2; i <= n - 2 + 1; i++, m--) ad... |
#include<bits/stdc++.h> using namespace std; int main() { int t,n; cin >> t; while(t--) { cin >> n; int ans=0,k=n,p=n,h=0; while(ceil(sqrt(k))>=2 && k>2) { ans++; k=ceil(sqrt(k)); } cout << ans+n-2 << e... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; long long int i; cin >> n; std::vector<long long int> v; long long int s = 0; for (long long int i = 0; i < n; i++) { long long int val; cin >> val; s += val; if (i != (n - 1)) v.push_back(s);... |
#include <bits/stdc++.h> using namespace std; const int N = 35, M = 100005; int n, m, f, ans, e; char a[N][M]; int len[N], z[M], b[N][M], p[N][M]; vector<int> v[M]; void dfs(int pos) { if (f) return; z[pos] = 2; for (auto &i : v[pos]) if (!z[i]) dfs(i); else if (z[i] == 2) ... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { out << p.first << << p.second; return out; } template <class T1, class T2> istream& operator>>(istream& in, pair<T1, T2>& p) { in >> p.first >> p.second; return... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) FILE *in = stdin, *out = stdout; using namespace std; int n, ans[100005], N; int alpha[30]; char a[2005], b[2005], c[2005]; void input() { fscanf(in, %d , &n); fscanf(in, %s , &a[1]); fscanf(in, %s , &b[1]); } int most_fit(int sta... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const long long INF = 1e18; int n; int p[N]; long long dif[N]; long long ans = INF; int id; void add(int l, int r, int val) { dif[l] += val; dif[r + 1] -= val; } int main() { ios_base::sync_with_stdio(0); cin.tie(... |
#include <bits/stdc++.h> using namespace std; queue<int> q1, q2, q3, q4, q5, q6; int main() { int n, x, ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &x); if (x == 4) q1.push(i); else if (x == 8) q2.push(i); else if (x == 15) q3.pu... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y; }; point moves[2020]; queue<int> Q; const int lin[] = {1, -1, 0, 0}; const int col[] = {0, 0, 1, -1}; int A[2020][2020]; int X[3 * 2020], Y[3 * 2020]; int n; void new_point(int x, int y) { X[++X[0]] = x; Y[++Y[0]] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; n /= 1000; if (n & 1) cout << 2 << endl; else cout << 1 << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n, m; cin >> n >> m; vector<long long> v, h; for (long long idx = 0; idx < n; ++idx) { long long x; cin >> x; v.push_back(x); } ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; string s; cin >> s; long long mini = n - 1, maxi = -1; for (long long i = 0; i < n; i++) { if (s[i] == 1 ) { mini = i; break; } } for (long long i = n - 1; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2, x, y; cin >> x1 >> y1 >> x2 >> y2; cin >> x >> y; x2 = x2 - x1; y2 = y2 - y1; if (x2 % x != 0 || y2 % y != 0) cout << NO << endl; else { if (((x2 / x) & 1) == ((y2 / y) & 1)) cout <... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; const int P = 1000000007; int n, m; const int V = 5010; int main() { while (~scanf( %d%d , &n, &m)) { int mx = 0; for (int i = 1; i <= n; ++i) mx += (i - 1) / 2; if (mx < m) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 4e6 + 10; const int p = 1009; int raw[maxn], cnt[maxn]; complex<double> F1[maxn], F2[maxn]; const double PI = acos(-1.0); int rev[maxn]; void init(vector<complex<double> >& A, int n) { A.clear(); A.shrink_to_fit(); int size = 1; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const double eps = 1e-8; const int INF = 1e9 + 7; const long long inf = (1LL << 62); const int MOD = 1e9 + 7; const int M = 100010; const int maxn = 1001; const int lowbit(int x) { return x & -x; } in... |
//zxggtxdy! #include<bits/stdc++.h> using namespace std; const int M=52,N=2e3+7,p=998244353; int n,k,D,l[M],f1[N],f2[N],s[N],G[M][N],Q[M][N],dp[2][N]; inline long long pows(long long u,int v){ long long ans=1; while(v>0) {if(v&1) ans=ans*u%p; u=u*u%p,v=v>>1;} return ans; } inline int binom(int a,int b)... |
#include <bits/stdc++.h> using namespace std; char A[100 + 3], B[100 + 3], C[100 + 3], Ans[100 + 3]; int f[100 + 3][100 + 3][100 + 3], prei[100 + 3][100 + 3][100 + 3], prej[100 + 3][100 + 3][100 + 3], prek[100 + 3][100 + 3][100 + 3]; int Go[100 + 3][26], fail[100 + 3], la, lb, lc, len, ansi, ansj, ansk; ... |
#include <bits/stdc++.h> using namespace std; map<long long, bool> isMark; int main() { long long n, x, y, l; cin >> n >> l >> x >> y; bool b = 0, g = 0, d = 0, bd = 0; long long diff = y - x, B = y + x; long long tmp; long long mark = -1, mark2 = -1; bool n1 = 1, n2 = 1; for (int ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) - 0 + ch; ... |
#include <bits/stdc++.h> using namespace std; long long n, l, r, k; bool checks(long long s) { long long x = (k - r + l - 1) / (n + s); long long sp = k - r + l - 1 - x * (n + s); if (sp < r - l + 1) sp++; if (sp > r - l + 1) { return false; } if (s - sp > n - r + l - 1) { retu... |
#include <bits/stdc++.h> using namespace std; int num[26][5] = { {1,0,0,1,0}, // a {1,1,0,2,0}, // b {2,0,0,1,1}, // c {2,1,0,1,2}, // d {1,1,0,1,1}, // e {2,1,0,2,1}, // f {2,2,0,2,2}, // g {1,2,0,2,1}, // h {1,1,0,1,1}, // i {1,2,0,1,2}, // j {1... |
#include <bits/stdc++.h> using namespace std; struct node { long long w, id; bool friend operator<(node a, node b) { if (a.w == b.w) return a.id < b.id; else return a.w < b.w; } } a[1000004]; long long b[1000004][4]; long long l[1000004]; long long r[1000004]; int m... |
#include <bits/stdc++.h> using namespace std; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, p, l = -1, r = 0, i, j, ans = 0; cin >> n >> p; cin >> s; n--, p--; if (p > n / 2) p = n - p; for (i = 0; i <= n / 2; i++) { if (s[... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e3 + 9, lg = 19, MOD = 1e9 + 7, maxV = 1e6 + 9; pair<int, int> arr[3]; int dp[maxN][maxN]; pair<int, int> auxi[maxN][maxN]; bool vi[maxN][maxN]; int dst(pair<int, int> one, pair<int, int> two) { return abs(one.first - two.first) + abs(two... |
#include <bits/stdc++.h> using namespace std; const int N = 2020; struct Slope { long long x, y; bool up; Slope() {} Slope(long long x, long long y, bool up) : x(x), y(y), up(up) {} bool operator<(const Slope& m) const { pair<long long, long long> p1 = {y, x}; pair<long long, long ... |
#include <bits/stdc++.h> const int N = 55; const int M = 2e4 + 5; const long long inf = 9223372036854775807ll; int n, m, i, j, k; long long a[N][M], sum[N][M], dp[M]; long long mx[3][M << 2]; inline void push_up(int c, int u) { mx[c][u] = std::max(mx[c][u << 1], mx[c][u << 1 | 1]); } void build(in... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; cin >> n; int r[n]; for (int i = 0; i < n; ++i) { cin >> r[i]; if (r[i] % 2 == 1) ++k; } if (k % 2 == 0) cout << n - k; else cout << k; } |
#include <bits/stdc++.h> using namespace std; unsigned long long int ans = 1; int main() { int i, j, k, l, c = 0, fuck = 0; string s; cin >> s; l = s.size(); s += 9 ; for (i = 0; i < l; i++) { if (fuck == 1) { if (int(s[i] - 48) + int(s[i + 1] - 48) == 9) c += 1; ... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> struct lazysegtree { vector<T1> v1; vector<T2> v2; int n; const T1 init_value1 = 0; const T2 init_value2 = 0; lazysegtree(int sz) { n = 1; while (true) { if (n >= sz) break; n *= 2... |
#include <bits/stdc++.h> using namespace std; struct E { int to, nxt, d; } b[100005 << 1]; int fst[100005], tot; void insert(int f, int t, int d) { b[++tot] = (E){t, fst[f], d}; fst[f] = tot; b[++tot] = (E){f, fst[t], d}; fst[t] = tot; } int in[100005]; int dfn[100005]; int deep[10... |
#include <bits/stdc++.h> using namespace std; int n, k; long long f[1005][2005][4]; int main() { f[1][1][0] = f[1][1][1] = f[1][2][2] = f[1][2][3] = 1; cin >> n >> k; for (int i = 1; i <= n; i++) f[i][1][0] = f[i][1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 2; j <= k; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 3000 * 100 + 5; vector<pair<int, int> > adj[N]; pair<int, int> edge[N]; short d[N]; bool mark[N], edg[N], c[N]; int bad[N], par[N], m, n; void findd(int a, int e, int b) { while (a != b) { edg[e] = 1; if (a == edge[e].first) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; multiset<string> p; cin >> s; for (int i = 0; i < s.size(); i++) { if ((s[i] == < ) || (s[i] == > )) s[i] = ; } istringstream sin(s); multiset<string>::iterator it; string f; while (sin >> f) { ... |
// Cutiepie is a hoe! #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize ( Ofast ) #pragma GCC target ( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) #include <bits/stdc++.h> using namespace std; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template ... |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); std::string str; std::cin >> str; std::uint64_t l = 0, r = str.size() - 1; while (l < str.size() && std::isupper(str[l])) l++; while (r && std::islower(str[r])) r... |
#include <bits/stdc++.h> using namespace std; inline int read() { int ans = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar(); return ans; } int fa[5005], cnt[5005], sum[5005], dep[5005], bad[5005]; int main... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename L> bool smax(T &x, L y) { return x < y ? (x = y, true) : false; } template <typename T, typename L> bool smin(T &x, L y) { return y < x ? (x = y, true) : false; } void pre_dfs(int, int); void sack(int, int, bool); v... |
#include <bits/stdc++.h> using namespace std; void FastIO() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } vector<long long int> fib; void calc(int n) { fib.assign(n + 1, 0); fib[0] = 1; fib[1] = 1; for (int i = (int)2; i <= (int)n; i++) { fib[i] = fib[i - 1... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, cl, ce, v; cin >> n >> m >> cl >> ce >> v; vector<long long> data_l(cl), data_e(ce); for (long long i = 0; i < cl; i++) {... |
#include <bits/stdc++.h> int m, n, W, i, j, k, a[555555], b[555555], c[555555]; long long w[555555], rs; double rq; void solve(int l, int r, long long x) { if (l == r) { rs += (x * c[b[l]]) / w[b[l]]; rq += double((x * c[b[l]]) % w[b[l]]) / w[b[l]]; return; } int i = l, j = r, k, h... |
#include <bits/stdc++.h> using namespace std; int main() { int n, c = 0; string s; cin >> n >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == 1 ) c++; else { c++; break; } } cout << c; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, ai; cin >> n; map<pair<long long int, long long int>, int> mp; vector<long long int> c; for (long long int i = 0; i < n; i++) { cin >> ai; c.push_back(ai); mp[{ai, i}]++; } for (long long int... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; map<string, int> H1[maxn], H2[maxn]; vector<char> ans; char getA(string a, string b) { int c[30]; for (int i = 0; i < 26; i++) c[i] = 0; for (int i = 0; i < a.size(); i++) c[a[i] - a ]++; for (int i = 0; i < b.size(); i++) c[... |
#include <bits/stdc++.h> using namespace std; void __print(unsigned x) { cerr << x; } void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long long x) {... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> inline T smax(T &a, const S &b) { return a < b ? a = b : a; } int n, s, m, k, a[int(1500 + 20)], l[int(1500 + 20)], r[int(1500 + 20)], id[int(1500 + 20)]; int psum[int(1500 + 20)], dp[int(1500 + 20)][int(1500 + 20)], ... |
#include <bits/stdc++.h> using namespace std; char ch[60][60]; int x[4] = {-1, 1, 0, 0}; int y[4] = {0, 0, -1, 1}; bool mark[60][60]; void del(int a, int b) { for (int i = 0; i < 4; i++) if (mark[a + x[i]][b + y[i]]) { mark[a + x[i]][b + y[i]] = 0; del(a + x[i], b + y[i]); } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 400005; const long long MOD = 998244353; const long long g = 3; int n, N; int rev[MAXN]; long long m, Inv; long long f[MAXN]; long long A[MAXN]; long long B[MAXN]; long long fac[MAXN]; long long inv[MAXN]; long long wn[2][MAXN]; ... |
#include <bits/stdc++.h> inline int Get() { char ch; while ((ch = getchar()) < 0 || ch > 9 ) ; int Num = ch - 0 ; while ((ch = getchar()) >= 0 && ch <= 9 ) Num = (Num << 3) + (Num << 1) + ch - 0 ; return Num; } const int N = 1e3 + 5; const int M = 1600; int n, m, gA[N],... |
#include <bits/stdc++.h> using namespace std; string m[10]; bool win(int i, int j, int x, int y) { int X = 0; int O = 0; int D = 0; for (int c = 0; c < 5 && i >= 0 && i < 10 && j >= 0 && j < 10; i += x, j += y, c++) { if (m[i][j] == X ) { X++; } else if (m[i][j] == O... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; } template <typename T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; } int readint() { int x = 0, f = 1; char ch = getchar(); while (ch < ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, cx[120], cy[120], n, i, l = 0; string s; cin >> x >> y; getline(cin, s); getline(cin, s); n = s.size(); cx[0] = cy[0] = 0; if (x == 0 && y == 0) l = 1; for (i = 0; i < n; i++) { cx[i + 1] = cx[i]; ... |
#include <bits/stdc++.h> using namespace std; const int dx[4] = {1, 0}; const int dy[4] = {0, 1}; pair<int, vector<vector<int> > > MoveBotsDirs( const vector<vector<int> >& bots_dirs) { map<int, int> xs; map<int, int> ys; for (int i = 0; i < bots_dirs.size(); ++i) { if (bots_dirs[i][2] =... |
#include <bits/stdc++.h> using namespace std; using lint = long long; const int inf = 1000000007; const int MOD = 1000000007; void solve() { int n, k; cin >> n >> k; vector<set<int>> edge(n); for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; --a; --b; edg... |
#include <bits/stdc++.h> int x, n, m, a[2010], f[2010], min, c, i, j, k; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); if (a[i] <= m) f[a[i]]++; } c = 0; x = n / m; for (i = 1; i <= n; i++) { if (a[i] > m) { k = 1; for (j... |
#include <bits/stdc++.h> using namespace std; int a[20], b[20]; char s[110000]; int main() { int n, i, j; scanf( %s , s); for (i = 0; s[i]; i++) { if (s[i] == 5 ) a[2]++; else if (s[i] == 9 ) a[6]++; else a[s[i] - 0 ]++; } scanf( %s , s); for ... |
#include <bits/stdc++.h> using namespace std; long long n, m, N, Left, Right; long long seg[2000001], vs[2000001]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; char grid[n + 1][m + 1]; vs[0] = 0; set<pair<long long, long long>> d; for (lo... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m, k, kk, x, y; cin >> n >> m >> k; kk = k; long long int a[m]; for (long long int i = 0; i < m; i++) a[i] = 9999999999; for (long long int i = 0; i < n; i++) { cin >> x >> y; a[x - 1] = min(a[x - 1], y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.