func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf( %d , &n) == 1) { if (n == 1) printf( -1 n ); else if (n == 2) { printf( 2 2 n ); } else if (n == 4) printf( 4 2 n ); else { int a, b; if (n % 2 == 0) { a ... |
#include <bits/stdc++.h> template <typename T> inline void read(T& x) { T res = 0, flag = 1; char ch; ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) { res = res * 10 + ch - 48; ch = getchar(); } x = res *... |
#include <bits/stdc++.h> using namespace std; long long powmod(long long base, long long exponent, long long mod) { long long result = 1; while (exponent > 0) { if (exponent % 2 == 0) { exponent /= 2; base = (base * base) % mod; } else { result = (result * base) % mod; ... |
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> v[1005], a[1005]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> x; a[x].push_back(i); v[i].resize(n + 1, 0); } int st = -1; for (int i = n; i >= 1; --i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int h = 0; int w = 1; int total = 0; cin >> n; while (n >= w) { total += w; n -= w; h += 1; w += h + 1; } cout << h << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; class solution { public: void solve() { int n; cin >> n; int i = 1; int prev = 0; vector<int> sol; while (n != 0) { if (n > prev) { prev++; sol.push_back(prev); n = n - prev; } else... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const long long mod = 1e9 + 7; long long n, m; long long fac[maxn]; long long ksm(long long a, long long b) { long long ans = 1, base = a % mod; while (b) { if (b & 1) ans = ans * base % mod; base = base * base % mo... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { int n; unsigned int a[200]; unsigned int ans; scanf( %d , &n); ans = 0; for (int i = 0; i < n; i++) scanf( %u , &a[i]); for (int i = 0; i < n; i++) { unsigned int temp = a[i]; if (temp > ans) ans... |
#include <bits/stdc++.h> using namespace std; void result() {} string resultstr() { string ans; return ans; } int resultint() { int ans; return ans; } long long resultlong(long long n) { long long c5; return c5; } bool checkValidity(long long a, long long b, long long c) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; constexpr long long mod = 998244353; const long long INF = mod * mod; const long double eps = 1e-12; const long double pi = acosl(-1.0); long long mod_pow(long long x, long long n, long long m =... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, n, k, s, min, max; cin >> n >> k; if (k % n) cout << k / n + 1; else cout << k / n; return 0; } |
#include <bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long n; cin >> n; cout << (n / 2) + 1 << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long mul(long long a, long long b, long long p = 1000000007) { return ((a % p) * (b % p)) % p; } long long add(long long a, long long b, long long p = 1000000007) { return (a % p + b % p) % p; } void input(long long a[], long long sz) { for (lon... |
#include <bits/stdc++.h> using namespace std; const int C = 500001; vector<vector<int> > gr(C), E(C); int ij[C], ji[C], a, b, n, m; int s[C], sE[C], low[C], pre[C], nV[C], nE[C], par[C], cor[C], corn; bool ch[C], chE[C]; int main() { int i, j, is = 1, iE = 0, iV = 1, ip = 2, k, e, vn, en; scanf( %... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; bool r[MAXN]; int main() { int n; vector<pair<int, pair<int, int>>> v; cin >> n; for (int i = 0; i < n; ++i) { int l, r; cin >> l >> r; v.emplace_back(l, make_pair(1, i)); v.emplace_back(r + 1, make_pa... |
#include <bits/stdc++.h> using namespace std; int qp(int a, long long b) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % 1000000007; a = 1ll * a * a % 1000000007; } while (b >>= 1); return ans; } int ans[222222], atot = 0; char s[222222], t[222222]; long long ct[26]; int n... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, const T &b) { return b > a ? a = b, true : false; } template <class T> inline bool chmin(T &a, const T &b) { return b < a ? a = b, true : false; } template <class T> using MaxHeap = priority_queue<T>; te... |
#include <bits/stdc++.h> using namespace std; int a[2 * 100000 + 5]; int k, n; long long dp[2][2 * 100000 + 5]; int mark[2 * 100000 + 5]; inline long long solve(int i, int lst) { if (i == 0) { if (lst == 1) return 1ll; else return 0ll; } long long &ret = dp[lst][i]; ... |
#include <bits/stdc++.h> using namespace std; int tree[300000]; int ar[100005]; int make(int l, int r, int ind) { if (l >= r) { tree[ind] = ar[r]; return tree[ind]; } int mid = (l + r) / 2; tree[ind] = make(l, mid, 2 * ind + 1) + make(mid + 1, r, 2 * ind + 2); return tree[ind]; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; void dout() { cerr << endl; } template <typename Head, typename... Tail> void dout(Head H, Tail... T) { cerr << H << ; dout(T...); } mt19937 rnd(time(0)); struct Node { Node* left = nullptr; Node* right = nullptr; ... |
#include <bits/stdc++.h> int k, i, n, t; int main() { std::cin >> t; for (; t; i++) { k = i; n = 0; while (k) { n += k % 10; k /= 10; } if (n == 10) t--; } std::cout << i - 1; } |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int inf = 0x3f3f3f3f; const long long INF = 1e18; const int maxn = 200000 + 10; const int maxm = 1000000000 + 7; const int mod = 1000000000 + 7; int gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline long... |
#include <bits/stdc++.h> using namespace std; long long a[5005]; long long dp[5005], mod = 998244353, bnd[5005], fac[5005], inv[5005]; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % mod; b >>= 1; a = a * a % mod; } return an... |
#include <bits/stdc++.h> bool debug = 1; const long long MOD = 1000000007; const double PI = acos(-1.0); const double eps = 1e-9; using namespace std; int main() { int n, m; int c[100100], a[100100]; cin >> n >> m; for (int i = 0; i < n; i++) { scanf( %d , &c[i]); } for (int i ... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-10; int n, q, t; double plc[500005], ans[500005]; struct Point { long double x, y; Point() {} Point(long double _x, long double _y) { x = _x, y = _y; } Point operator+(Point p) { return Point(x + p.x, y + p.y); } } P[50... |
#include <bits/stdc++.h> using namespace std; const int N = 2000020; pair<int, int> a[N], b[N]; bool comp(int x, int y) { return a[x].second > a[y].second; } int n, m, K; vector<int> A[N], B[N]; int g[4 * N]; bool t[4 * N]; long long T[4 * N]; set<pair<int, int> > S; set<pair<int, int> >::iterator... |
#include <bits/stdc++.h> using namespace std; int const N = 22, M = 1 << 22; inline int nextInt() { char c; c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); int n = 0, s = 1; if (c == - ) s = -1, c = getchar(); while (c >= 0 && c <= 9 ) n *= 10, n += c - 0 , c = ... |
#include <bits/stdc++.h> using namespace std; int main() { char ar[100]; int len, count = 0, i, j; gets(ar); len = strlen(ar); if (isupper(ar[0]) && islower(ar[1])) { cout << ar; } else { for (i = 0; ar[i] != 0 ; i++) { if (isupper(ar[i])) { count++; }... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; const long long CONST = 314000000LL; const long long inf = (1LL << 60); bool mark[MAXN], INF[MAXN], bad[MAXN]; int m, n, cntComp; long long cnt[MAXN], func[MAXN], deg[MAXN], comp[MAXN], type[MAXN], len[MAXN]; long long mini[MAXN... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); stack<int> s1; int ans = 0; int x = 1; for (int i = 0; i < (2 * n); i++) { char s[10]; scanf( %s , s); if (strlen(s) == 3) { int a; scanf( %d , &a); s1.push(a); ... |
#include <bits/stdc++.h> using namespace std; int data[(int)2e5]; int dp[5001][5001]; int used[5001][5001]; string s; int magic(int l, int r) { if (l > r) return 1; if (used[l][r] != -1) return used[l][r]; if (l == r) { data[1]++; return used[l][r] = 1; } int lk, rk, k, flag ... |
#include <bits/stdc++.h> using namespace std; int x, y, a, b, r, m, t, pr; int poc, kraj, uk; int drvo[2000], sveca[2000]; void apdejt(int a, int b) { while (a <= 2000) { drvo[a] += b; a += (a & -a); } } int koliko(int a) { int zbir = 0; while (a > 0) { zbir += drvo[a]; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; cout << s; for (int i = s.size() - 1; i >= 0; i--) { cout << s[i]; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; struct edge { int u, v, w, num; } e[N], c[N]; map<long long, int> mp; int n, m, q, s, siz[N], fa[N]; long long L[N], R[N]; bool vis[N]; int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; } bool comp(edge x, edge y) { ret... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int sz = 3; const double eps = 1e-9; const int maxn = 1e3 + 500, base = 1e9 + 7, maxm = 10; string second[maxn]; int main() { ios_base::sync_with_stdio(0); ; cin.tie(0); int n; cin >> n; if (n == 1) { co... |
#include <bits/stdc++.h> const long base = 151; const long long MM = 1ll * 1000000007 * 1000000007; using namespace std; int BIT(int i, long long x) { return (x & (1 << i)); } long long ONBIT(int i, long long x) { return (x | (1 << i)); } long long OFFBIT(int i, long long x) { return (x & ~(1 << i)); } lo... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = 3.1415926535897932384626; const double e = exp(1.0); int main() { int t; double a, b, c; double x, y, z; double s; while (~scanf( %lf , &s)) { scanf( %lf%lf%lf , &a, &b, &c); double tt = a ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; } template <class T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; } inline int nxt() { int wow; scanf( %d , &wow); return wo... |
#include <bits/stdc++.h> using namespace std; long long RAND(long long n) { return abs((rand() << 15) + rand()) % n; } bool check(int i, int j, int n) { return ((i >= 0) && (j >= 0) && (i < n) && (j < n)); } int move_x[] = {1, 0}; int move_y[] = {0, 1}; vector<vector<vector<vector<bool>>>> solve(vecto... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int d, n; cin >> d >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int day = 0, res = 0; for (int i = 0; i < n; i++) { day = (day + a[i] - 1) % d + ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } template <class T> inline void umin(T &a, T b) { if (a > b) a = b; } template <class T> inline T abs(T a) { return a > 0 ? a : -a; } template <class T> inline T gcd(T a,... |
#include <bits/stdc++.h> using namespace std; long long int modular(long long int n, long long int pow, long long int N) { long long int res = 1; while (pow) { if (pow & 1) res = (res % N * n % N) % N; n = (n % N * n % N) % N; pow = pow / 2; } return res; } long long int d, x, ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, m; int head[N], nxt[N * 2], to[N * 2], tot; int vis[N], stp[N]; int dp[N][20]; int dfn[N], low[N], dep = 0; int stk[N * 5], top = 0; int belong[N], block = 0; int odd[N], col[N]; void init() { memset(head, -1, sizeof(he... |
#include <bits/stdc++.h> using namespace std; double p[8][10020]; int main() { int n; int l[8], r[8]; scanf( %d , &n); double ex = 0; double all = 1.0; for (int i = 0; i < n; i++) { scanf( %d %d , &l[i], &r[i]); all *= (r[i] - l[i] + 1); } for (int i = 1; i <= 10000; ++... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } int main() { int n, m; cin >> n >> m; int a0, b0, x; for (int i = 0; i < n + 1; i++) { cin >> x; if (!i) a0 = x; } for (int i... |
#include <bits/stdc++.h> using namespace std; long long dp[200000][3]; string s; signed main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin >> s; long long l = s.size(); vector<vector<bool> > in(l, vector<bool>(3)); dp[0][0] = dp[0][1] = dp[0][2] = 10000000000; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MX = 2e5 + 1; bool sieve[MX], in_graph[MX], vstd[MX]; vector<int> pos[MX], adj[MX]; int mu[MX]; ll res[MX]; void init() { vector<int> primes; mu[1] = 1; for (int i = 2; i < MX; ++i) { if (!sieve[i]) { ... |
#include <bits/stdc++.h> using namespace std; long long n, low, high, chs; long long x1up, x2up, x1down, x2down, y1down, y2down, y1up, y2up; int query(long long x, long long y, long long xx, long long yy) { cout << ? << x << << y << << xx << << yy << endl; cout << flush; int res; ... |
#include <bits/stdc++.h> using namespace std; int main() { bool a[5][5]; int b[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { cin >> b[i][j]; a[i + 1][j + 1] = true; } for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { if (b[i][j] % ... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 998244353; const long long int INF = 3e18; long long int power(long long int base, long long int exp) { long long int res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res * base); base = (base * base); exp /= 2;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, prindex, k, kingdom, ki, prince; cin >> t; for (int h = 0; h < t; h++) { cin >> n; vector<int> vec(n + 7, 0); prindex = 0, k, kingdom, ki, prince = 1; for (int i = 1; i <= n; i++) { cin >> k; ki ... |
#include <bits/stdc++.h> using namespace std; int const maxn = (int)2e6 + 1, inf = (int)2e9 + 1; map<char, int> pidr; int n, m, ans, cur, sz, a[maxn], b, l[maxn], r[maxn], x[maxn]; bool used[maxn]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++)... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 7; const long double EPS = 1e-8; const long long MAXI = 20000; const long long MOD = 16714589; const long long MAXST = 2000000; const long double PI = 3.14159265358979323; ostream &operator<<(ostream &stream, const pair<long long... |
#include <bits/stdc++.h> using namespace std; bool asdfill[1100000]; int main() { int n; cin >> n; int last_known; for (int i = 0; i < (n); ++i) { int a; cin >> a; asdfill[a] = true; last_known = a; } double min_alpha = 10; double max_alpha = 1e200; int fill... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5 * 100 * 1000 + 14; vector<int> comp[MAXN], adj[MAXN]; set<int> res; int ans = 0; void dfs(int v) { comp[ans].push_back(v); auto it = res.begin(); while (it != res.end()) { if (find(adj[v].begin(), adj[v].end(), *it) == adj[v]... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> v; for (int i = 0; i < n; i++) { long long int x; cin >> x; v.push_back(x); } if (n > 1) { cout << 1 1 << endl; cout << (long long int)(-1) * v[0] << en... |
#include <bits/stdc++.h> using namespace std; const int LIM = 200100; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); int mini, maxi; mini = 1e9 + 3; maxi = 0; for (auto &e : a) { cin >> e; mini = min(mini, e); maxi = max(maxi, e)... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int n, d, arr[2001], mx; long long ans, dp[2001][2]; vector<int> adj[2001]; void DFS(int u = 1, int p = -1) { for (int i : adj[u]) if (i != p) DFS(i, u); dp[u][arr[u] == mx] = 1; dp[u][0] *= (arr[u] >= (mx - d)) && (... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 10; int n, a, b; int main() { cin >> n >> a >> b; int table1_count = 0; int table2_count = 0; int one_two_count = 0; int ans = 0; for (int i = 0; i < n; i++) { int t; cin >> t; if (t == 1) { boo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<bool> x; vector<bool> y; x.assign(n + 1, 1); y.assign(n + 1, 1); x[1] = 0; y[1] = 0; x[n] = 0; y[n] = 0; for (int i = 0; i < m; i++) { int tmp_x, tmp_y; scanf( %i %i , &... |
#include <bits/stdc++.h> struct val { long long x; int y, d; val *p, *l, *r; } g1[100001], g2[100001], *rt1[100001], *rt2[100001], *nil = g1; struct node { long long x; int y; bool operator<(const node &b) const { return x < b.x; } } a[100001]; struct vale { long long x; int y;... |
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 10; const long long inf = 1ll << 60; const long long mod = 1e9 + 7; void GG() { cout << Impossible n ; exit(0); } long long mpow(long long a, long long n, long long mo = mod) { long long re = 1; while (n > 0) { if ... |
#include <bits/stdc++.h> const int mod = 1e9 + 7; const int MAXN = 1e5 + 5, MAXSIZ = 3; template <typename _T> void read(_T &x) { x = 0; char s = getchar(); int f = 1; while (s < 0 || 9 < s) { f = 1; if (s == - ) f = -1; s = getchar(); } while ( 0 <= s && s <= 9 ... |
#include <bits/stdc++.h> using namespace std; int a, b, x, y; int main() { cin >> a >> b; x = a % b; b = b - x; cout << a + b; } |
#include <bits/stdc++.h> using namespace std; int n, k, ans, a[1000002], f[2002], team[1000002], tot; bool vis1[2002], vis[2002]; int main() { scanf( %d%d , &n, &k); bool p1 = 0; for (int i = 1; i <= k; i++) { int x; scanf( %d , &x), x -= n; if (vis1[x + 1000]) continue; vis1... |
#include <bits/stdc++.h> using namespace std; const int MX = 300002; long long N; int ans[MX], arr[MX], was[MX]; int take; void f(int L, int R, int vL, int vR) { if (L > R) return; if (vL == vR) { for (int i = L; i <= R; i++) { ans[i] = vL; } return; } int mid = L +... |
#include <bits/stdc++.h> using namespace std; int arr[100010]; int sieve[100010]; int main() { int n, i, j, m, x, a, b, ans, q, flag = 0, cnt = 0; scanf( %d , &n); for (i = 2; i <= n; i++) { if (!sieve[i]) { for (j = i * i; j <= n; j += i) sieve[j] = 1; for (j = i; j <= n; j = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int a, b, k, v; bool check(int x) { return min(x * k, (x + b)) * v >= a ? true : false; } int main() { scanf( %d%d%d%d , &k, &a, &b, &v); for (int i = 1; i <= 1000; i++) { if (check(i)) { printf( %d n , i); ... |
#include <bits/stdc++.h> using namespace std; void snum(long long &x) { scanf( %lld , &x); } void snum(long long &x, long long &y) { scanf( %lld %lld , &x, &y); } void snum(long long &x, long long &y, long long &z) { scanf( %lld %lld %lld , &x, &y, &z); } vector<long long> adj[100100]; long long outDe... |
#include <bits/stdc++.h> using namespace std; int main() { stack<int> s; int n; cin >> n; int max_ = 0; for (int i = 0; i < n; i++) { int a; cin >> a; max_ = max(max_, a); if (s.empty()) { s.push(a); } else { if (a == s.top()) { s.pop(); ... |
#include <bits/stdc++.h> using namespace std; long long int n, k, dp[2009][2009], cnt; long long int solve(int pos, int mx) { if (pos == k) return 1; long long int &res = dp[pos][mx]; if (res != -1) return res; res = 0; int lim = mx; if (lim == 0) lim = 1; if (mx == 0) { for (int... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const long double EPS = 1e-9; vector<vector<int>> g; vector<vector<int>> hlca; vector<vector<int>> lca; vector<vector<long long>> dp; int N; int get_num_bit(int mask) { int cnt = 0; while (mask) { cnt += mask &... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, d; char c; cin >> a >> c >> b; cin >> d; for (int i = 1; i <= d; i++) { b += 1; if (b == 60) { a++; b = 0; } if (a == 24) { a = 0; } } if (a >= 0 && a < 10 && b >= 0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 10; char g[maxn][maxn]; long long dp[1 << maxn][1 << maxn]; int main() { int n, mask1, mask2, i, j, m, k, a, b, count; long long ans; cin >> n >> m >> k; for (i = 0; i < m; i++) { cin >> a >> b; a--; b--; g[... |
#include<bits/stdc++.h> using namespace std; const int N=1505; const int Q=11; int read() { int s=0; char c=getchar(),lc= + ; while (c< 0 || 9 <c) lc=c,c=getchar(); while ( 0 <=c&&c<= 9 ) s=s*10+c- 0 ,c=getchar(); return lc== - ?-s:s; } void write(int x) { if (x<0) putchar( - ),x=-x... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7, M = 20; const double eps = 1e-10, pi = acos(-1.0); double dis[N], op[N][M]; struct node { long long x, y; } e[N]; int n, k, f[N][M]; struct query { double x, y; } w[N]; inline int read() { int num = 0; char t = + ,... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pli = pair<ll, int>; const int INF = 0x3f3f3f3f, N = 3e3 + 5; const ll LINF = 1e18 + 5; int n; vector<int> G[N]; int sz[N][N], f[N][N]; ll dp[N][N], maxn; void dfs(int u, int fa, int rt) { sz[... |
#include <bits/stdc++.h> constexpr int N = 55; int n; char a[N][N]; int f[N][N][N][N]; int dfs(int x, int y, int xx, int yy) { if (~f[x][y][xx][yy]) { return f[x][y][xx][yy]; } else { if (x == xx && y == yy) { return f[x][y][x][y] = (a[x][y] == # ); } else { int res ... |
#include <bits/stdc++.h> using namespace std; long long t, n, i, a[404040], x[404004]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; long long te = 1; x[1] = -1; x[2] = -1; x[3] = -1; long long ban = 0;... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int N = 2e5 + 10; char s[3][N]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= 2; i++) for (int j = 1; j <= n; j++) { cin >> s[i][j]; if ... |
#include <bits/stdc++.h> using namespace std; long long int k, v, n, m, ans, sum, sum1, l, r, i, j, mx, mn, c, z, x, y, a[111111], d[111111], t[111111]; string s, sos, ss; char ch; bool used[111111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; cout << (n - 1) / 2; ... |
#include <bits/stdc++.h> using namespace std; bool check(vector<int> &a) { return a[0] + a[1] + a[2] == a[3] + a[4] + a[5]; } signed main() { int n; cin >> n; vector<int> a(n, 0); for (int i = 0; i < n; ++i) cin >> a[i], --a[i]; vector<int> used(n, 0); int cnt = 0; for (int i = n - 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long int n, arr[200001], ctr[200001]; set<long int> s; vector<long int> s2; list<long int> s1; memset(ctr, 0, sizeof(ctr)); cin >> n; for (long int i = 0; i < n; i++) { cin >> arr[i]; s.insert(arr[i]); ctr[arr[i... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; template <typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> p) { os << ( << p.first << , << p.second << ) ; return os; } template <typename T, typename U> istream &operator>>(istream &is, pair<T, U>... |
#include <bits/stdc++.h> using namespace std; int T[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int W[24]; bool ok(int n) { bool l = false; for (int i = 0; i < 12; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2005; pair<int, int> q[MAX * MAX]; char a[MAX][MAX]; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; char tt[4] = { v , < , ^ , > }; int n, m; bool isav(int x, int y) { return (0 <= x && x < n && 0 <= y && y < m && a[x][y] == ... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; void _print(long long t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _p... |
#include <bits/stdc++.h> using namespace std; int a[8][8], b[8][8]; long long get() { char c = getchar(); long long x = 0LL; while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) { x *= 10LL; x += (c - 0 ); c = getchar(); } return x; } int main() { ... |
#include <bits/stdc++.h> using namespace std; int n, kk, a[500010], b[500010]; int sum1[500010], sum2[500010], sum3[500010], num[500010], k1[500010], k2[500010], k3[500010]; unordered_map<int, int> mp; int main() { scanf( %d%d , &n, &kk); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const int N = 5e5 + 2; int seg[N * 4]; int lazy[N * 4]; int hi[N]; int h[N]; int n; vector<int> g[N]; vector<int> y[N]; pair<int, int> t[N]; void dfs(int v, int p) { t[v] = t[p]; if (hi[t[v].second] > hi[v]) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; void solve() { ll n, k; cin >> n >> k; vector<ll> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; ll dp[n][n]; for (int i = 1; i < n; i++) dp[0][i] = 0; ll curr = 0; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const long long int maxn = 2e5 + 1; void solve() { string s, even, odd; cin >> s; for (long long int i = 0; i < s.length(); i++) { long long int val = s[i] - 0 ; if (val % 2 == 0) even += s[i]; else odd += s[i]; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n; cin >> n; vector<int> a(n); int odd = 0; for (auto &i : a) cin >> i, odd += i & 1; if (odd > 0 && odd < n) sort(a.begin(), a.end()); for (auto &i : a) cout << i << n [&i == ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int mxn = 1000001, k = 4; const char c[k] = { ( , ) , ? , ? }; int n; string second; long long first[mxn], rf[mxn], iv[mxn], a[k]; vector<long long> dp[mxn]; long long sol() { int x = a[2] + a[3], y = a[1] + a[3] - a... |
#include <bits/stdc++.h> using namespace std; int main() { char key[] = (8[ ; char fir[100], sec[100]; int i, len, a, b, c; scanf( %s%s , fir, sec); len = strlen(fir); c = 0; for (i = 0; i < len; i += 2) { a = strchr(key, fir[i]) - key; b = strchr(key, sec[i]) - key; i... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128_t LL; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define F first #define S second #define pb push_back mt19937 rnd; const int N = 1e5 + 10; bool good[N], ban[N]; vector... |
#include <bits/stdc++.h> using namespace std; int dirx[8] = {0, 0, 1, -1, 1, 1, -1, -1}; int diry[8] = {1, -1, 0, 0, 1, -1, 1, -1}; string tostring(long long n) { if (!n) return 0 ; string ans = ; while (n != 0) { ans += (n % 10) + 0 ; n /= 10; } reverse(ans.begin(), ans.end(... |
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; cout << Mike n ; int freq[26] = {0}; freq[str[0] - a ]++; for (int i = 1; i < str.length(); i++) { int val = 0; for (int j = 0; j < str[i] - a ; j++) { if (freq[j] > 0) { val =... |
#include <bits/stdc++.h> using namespace std; int a[105][105]; int main() { vector<int> v; int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cin >> a[i][j]; v.push_back(i); } int cnt = 0; for (int i = 1; i <= n; i++) { int flag = 0; fo... |
#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; } const int N = 500005, INF = 1e9; const doubl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.