func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > a[100010]; vector<int> ans; string s, s1, s2; int n, m; int v, e, p, q; int main() { cin >> n; if (n == 2) { cout << 0; return 0; } int ans = n / 2 - 1; if (n % 2) ans++; cout << ans; } |
#include <bits/stdc++.h> using namespace std; const int N = 100008; int a[N]; int b[N]; int main() { int n = 0; int x = 0; scanf( %d %d , &n, &x); for (int i = 1; i <= n; ++i) { scanf( %d , a + i); } for (int i = 1; i <= n; ++i) { scanf( %d , b + i); } sort(a + 1, a... |
#include <bits/stdc++.h> using namespace std; long long n, ans, l; bool flag = 0; inline long long getLen(long long x) { long long cnt = 0; while (x) { cnt++; x /= 10; } return cnt; } inline long long getSum(long long x) { long long cnt = 0; while (x) { cnt += x % 1... |
#include <bits/stdc++.h> using namespace std; int n; int a[100010]; int isIn[1000010]; int inCount; std::vector<int> ans; std::vector<int> inNums; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &(a[i])); if (a[i] > 0) isIn[a[i]] = 0; } inCount = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; double p[maxn], dp[maxn]; int n; int main() { int i; while (scanf( %d , &n) != EOF) { double ans = 0; for (i = 1; i <= n; i++) { scanf( %lf , &p[i]); ans += p[i]; } dp[0] = 0; for (i = ... |
#include <bits/stdc++.h> using namespace std; map<string, int> m; string s, c, a; int n, i, p; int main() { for (cin >> n >> s; i < n - 1; i++) { c += s[i]; c += s[i + 1]; m[c]++; if (p < m[c]) p = m[c], a = c; c.clear(); } cout << a; } |
#include <bits/stdc++.h> using namespace std; int a[100000], s[100000]; void qs(int q, int w) { int e = q, r = w, t = a[q + (rand() % (w - q + 1))], y; do { while (a[e] < t) e++; while (a[r] > t) r--; if (e <= r) { y = a[e]; a[e] = a[r]; a[r] = y; y = s[e]... |
#include <bits/stdc++.h> using namespace std; int n, temp; int first = -1, sec = -1; int ifirst = -1, isec = -1; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> temp; if (temp > first) { sec = first; isec = ifirst; first = temp; ifirst = i + 1; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9; const long long MOD = 1e9; const long long N = 100100 * 5; char a[N], b[N], c[N]; long long n, f[33][33], ans; bool flag; void floyd(int n) { for (int k = 0; k <= n; k++) for (int i = 0; i <= n; i++) for (int j = ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); double a, b, r; cin >> a >> b >> r; if (a / 2 >= r && b / 2 >= r) { cout << First ; } else { cout << Second ; } } |
#include <bits/stdc++.h> using namespace std; const int maxN = 2 * 1000 * 100 + 100; const int maxS = 4 * maxN; vector<int> seg[maxS]; int f[maxS], toxor[maxS]; int n; inline vector<int> merge(vector<int> a, vector<int> b) { for (auto x : b) { for (auto y : a) if (x & (y & -y)) x ^= y; ... |
#include <bits/stdc++.h> using namespace std; bool a[2000][2000], b[2000][2000], c[2000][2000]; int n, m; void jian() { memcpy(c, b, sizeof(b)); for (int i = 1; i < n - 1; i++) { for (int j = 1; j < m - 1; j++) { if (!b[i + 1][j] || !b[i][j + 1] || !b[i - 1][j] || !b[i][j - 1]) c... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 10, MN = 2e5 + 10; const long double eps = 1e-6; pair<int, int> p[MN], L[MN], R[MN]; int n; bool check(long long val) { long long Sq = ceil(sqrt(val) + eps); while (Sq * Sq > val) --Sq; long long T = L[n].first - L[n].second; ... |
#include <bits/stdc++.h> using namespace std; pair<int, pair<int, int>> sm[26]; map<int, vector<pair<int, int>>> smv; int ca[26]; vector<pair<int, int>> sh; int main(int argc, char const *argv[]) { int n, m, x; cin >> n >> m >> x; char a[n][m]; for (int i = 0; i < n; i++) { for (int j ... |
#include <bits/stdc++.h> using namespace std; int a[20][5000 + 5]; vector<pair<int, int> > e[20][5000 + 5]; int vis[20][5000 + 5]; int n[5000 + 5]; long long sum[20]; vector<pair<int, int> > cycle[5000 * 15 + 5]; int N; vector<int> bit[(1 << 15) + 5]; pair<int, int> sta[5000 * 15 + 5]; int top; ... |
#include <bits/stdc++.h> using namespace std; int c[100004], i, n, t, q, w, nr, r, d, s; char a[100004], b[100004]; int main() { scanf( %d %d n , &n, &t); for (i = 1; i <= n; i++) scanf( %c , &a[i]); scanf( n ); for (i = 1; i <= n; i++) scanf( %c , &b[i]); for (i = 1; i <= n; i++) { i... |
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, ... |
#include <bits/stdc++.h> using namespace std; const int N = 205; const int mod = 1e9 + 7; long long f[2][N][N]; int n, tot; struct point { long long x, y; point(long long _x = 0, long long _y = 0) { x = _x; y = _y; } point operator-(const point &rhs) const { return point(x ... |
#include <bits/stdc++.h> using namespace std; struct T { T *l, *r; int v; int c; T(int v) : v(v), c(1) { l = r = NULL; } T(T *a) { l = a->l; r = a->r; v = a->v; c = a->c; } T() {} }; T pool[(5000000) + 10000]; int stack_size; T *my_new(int v) { return &(po... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int a, b; cin >> a >> b; for (int i = 1; i <= a; ++i) cout << i << ; cout << a + b + 1; for (int i = a + b; i > a; --i) cout << << i; return 0; } |
#include <bits/stdc++.h> using namespace std; long long mod = 1000LL * 1000LL * 1000LL + 7; long long n, k, len; vector<long long> a, b; vector<vector<long long> > dp; void init() { cin >> n >> len >> k; a.resize(n + 1); b.resize(n); for (int i = 1; i <= n; ++i) { cin >> a[i]; b[... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200050; int n, num[MAXN], pre[MAXN], g[MAXN], ans; int st[MAXN]; map<int, int> f; int main() { int u; ans = -1; st[0] = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &num[i]); if (!f.count(num[i] ... |
#include <bits/stdc++.h> using namespace std; const int N = 400 * 1000 + 10; vector<int> graph[N]; int n, num[N], par[N], ans[N], c1[N], c2[N]; void dfs(int v) { num[v]++; for (int i = 0; i < (int)graph[v].size(); i++) { int u = graph[v][i]; if (u != par[v]) { par[u] = v; d... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 300050; const long long LINF = 0x3f3f3f3f3f3f3f3f; map<int, int> odd, even; int buf[MAXN], pre[MAXN]; int main() { ios::sync_with_stdio(false); long long n; cin >> n; for (long long i = 1; i <= n; i++) { cin >> buf[i]... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } void relax(int &x, int y) { x = max(x, y); } const int inf = 1e9; int n, k; int dp[20][1 << 18][2][2]; int like[1 << 18]; int main() { ios_base::sync_with_stdio(false); c... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265359; const long long MOD = (long long)998244353ll; const long long MAXN = (long long)2e5 + 10; const long long INF = (long long)2242545357980376863; const long double EPS = (long double)1e-8; long long su = 0; long long a[MAX... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& x) { return os << ( << x.first << , << x.second << ) ; } vector<int> E[505][505]; long long dp[505][505], W[505][505]; vector<pair<int, int>> verts[505][505], hors[50... |
#include <bits/stdc++.h> using namespace std; void st() {} string str; int n; int main() { st(); cin >> n >> str; if (str.find( L ) == string::npos) { int x = str.find( R ); int y = str.find( . , x); printf( %d %d n , x + 1, y + 1); return 0; } if (str.find( R ) == ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 9, LOG = 20; int n, a, b; int h[maxn], par[LOG][maxn], siz[maxn]; vector<int> adj[maxn]; void DFS(int v, int p = -1) { par[0][v] = p; for (int i = 1; i < LOG; i++) par[i][v] = par[i - 1][par[i - 1][v]]; siz[v] = 1; for (aut... |
#include <bits/stdc++.h> using namespace std; multiset<int, greater<int>> m1, m2; int n, m; int main() { cin >> n >> m; for (int i = 0; i < n; ++i) { int a; cin >> a; m1.insert(a); } for (int i = 0; i < n; ++i) { int a; cin >> a; m2.insert(a); } vector... |
#include <bits/stdc++.h> using namespace std; int main() { string s, spr; vector<string> valer; cin >> s; char h; int k = (int)s.size(); valer.push_back(s); for (int i = 1; i < k; i++) { h = s[k - 1]; for (int j = k - 1; j > 0; j--) { s[j] = s[j - 1]; } s[... |
#include <bits/stdc++.h> using namespace std; int i, n, m, j, y, pos, fed = 0; int mice[100001], cheese[100001], taken[100001]; int main() { scanf( %d %d %d %d , &n, &m, &y, &y); for (i = 0; i < n; i++) scanf( %d , &mice[i]); for (i = 0; i < m; i++) scanf( %d , &cheese[i]); for (i = 0; i < m; i+... |
#include <bits/stdc++.h> using namespace std; const int M = 998244353; int n; vector<int> v; vector<set<int> > g; int all[300011] = {}; set<pair<int, int> > ed; pair<int, int> DFS(int u, int p) { pair<int, int> ret(v[u], 1); if (v[u] == 0) ret = {-1, 0}; for (auto v : g[u]) if (v != p)... |
#include <bits/stdc++.h> const long long int inf = LLONG_MAX; using namespace std; int main() { int n, a[4], dp[4005] = {0}, i, j; dp[0] = 0; cin >> n >> a[0] >> a[1] >> a[2]; for (i = 1; i <= n; i++) { for (j = 0; j < 3; j++) { if (i < a[j]) continue; if (dp[i - a[j]] != 0) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int cnt[n + 1]; memset(cnt, 0, sizeof cnt); cnt[0] = 1; int lvl = 0; int ind = 1; ... |
#include <bits/stdc++.h> using namespace std; unsigned long long int dp[1001], sum[1001]; unsigned long long int nCrModp(unsigned long long int n, unsigned long long int r) { unsigned long long int p = 1000000007; n = n + r - 1; r = r - 1; unsigned long long int C[... |
#include <bits/stdc++.h> using namespace std; const int nax = 1e2 + 5; string s; int n, k; int bonus[26][26]; const int inf = 1e9; long long int cnt = 0; int dp[nax][26][nax]; int solve(int i, int prev, int changes) { if (i >= s.length()) return 0; if (dp[i][prev][changes] != -inf) return dp[i... |
#include <bits/stdc++.h> const int MaxN = 5000; using namespace std; int a[MaxN + 5]; long long res; long long dp[MaxN + 5][MaxN + 5]; int n; long long Solve(int l, int r) { if (l > r) return 0; if (l == r) { return a[l] != 0; } int MinPos = l; for (int i = l; i <= r; i++) ... |
#include <bits/stdc++.h> using namespace std; long long cnk[50][50] = {1}; long long calc(long long mask, long long mx, int cnt, int n) { if (mask > mx) return 0; if (cnt == 0) return 1; if (cnt > n + 1) return 0; if (mask + (1LL << (n + 1)) - 1 <= mx) return cnk[n + 1][cnt]; return calc(mask ... |
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? YES : NO ); exit(0); } void addmod(int& x, int y, int mod = 1000000007) { x += y; ... |
#include <bits/stdc++.h> using namespace std; int fir = 0; char s[1100000]; int check() { for (int i = 0; s[i]; i++) { if (s[i] == ) continue; if (s[i] == # ) return 1; else return 0; } return 0; } int main() { while (gets(s)) { if (check()) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 10000000; bool f[N] = {1, 1}; long long p, q, rub, primepi, res; long long rev(long long x) { long long res; for (res = 0; x; x /= 10) { res = res * 10 + x % 10; } return res; } int main() { cin >> p >> q; for (long ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } struct Point { int x, y; }; struct Line { int A, B, C; Line(int a = 0, int b = 1, int c = 0) : A(a), B(b), C(c) { ... |
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 7; int n, arr[M], d[M], b = 1, t = 0; bool used[M]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &arr[i]); d[arr[i]]++; } for (int i = 1; i <= n; i++) { if (d[arr[i]] > 1) { ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int deg[1000]; int arr[1000][1000]; int jo[1000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int node, edge; cin >> node >> edge; for (int i = 0; i < edge; i++) { int n1... |
#include <bits/stdc++.h> using namespace std; int a[111]; char in[1000]; int main() { int t, m, i, j; scanf( %d%d , &t, &m); int aid = 1; while (t--) { scanf( %s , in); int k; if (in[0] == a ) { scanf( %d , &k); for (i = 0; i <= m - k; i++) { for (j =... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-6; template <typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 100; vector<int> edge[N]; vector<long long> w[N]; int n, q, top[N], dfn[N], hson[N], siz[N]; int fa[N]; long long val[N], f[N], g[N]; long long a[N], dv[N]; long long dep[N], faw[N]; void dfs(int x) { f[x] = 0; siz[x] = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, ans; bool pr[100003]; bool mark[100003]; vector<int> v; vector<int> e; vector<pair<int, int> > res; int main() { scanf( %d , &n); for (int i = 2; i <= n; i++) if (!pr[i]) { v.push_back(i); for (int j = 2 * i; j <= n; j +=... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, i, j; cin >> n; int arr[n], locked[n]; for (i = 0; i < n; i++) cin >> arr[i]; for (i = 0; i < n; i++) cin >> locked[i]; vector<int> unlocked; for (i = 0; i < n; i++) if (!locked[i]) unlocked.push_back(arr[i]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i; cin >> n >> m; int a[n], b[m]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < m; i++) cin >> b[i]; sort(b, b + m); for (i = 0; i < n; i++) if (binary_search(b, b + m, a[i])) cout << a[i] << ; retur... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long power(long long base, long long expo, long long md = mod) { if (base == 0) return 0; long long res = 1; base %= md; while (expo > 0) { if (expo & 1) { res = res * base; res %= md; } e... |
#include <iostream> using namespace std; int main() { long long t; cin >> t; while(t--) { long long n, s = 0, mx = 0; cin >> n; long long a[n + 1]; for(long long i = 1; i <= n; ++i){ cin >> a[i]; s += a[i]; m... |
#include <bits/stdc++.h> using namespace std; queue<pair<long long, long long> > q; int32_t trace[5005][5005]; int32_t n, m, t, dp[5005][5005]; vector<pair<long long, long long> > adj[5005]; void solve() { dp[1][1] = -t - 1; q.emplace(1, 1); while (q.size()) { long long node = q.front().fi... |
#include <bits/stdc++.h> using namespace std; int n, flag; int a[100005], b[100005], t[100005]; int main() { cin >> n; for (int i = 1; i <= n - 1; i++) cin >> a[i]; for (int i = 1; i <= n - 1; i++) cin >> b[i]; memset(t, -1, sizeof(t)); for (int i = 0; i <= 3; i++) { t[1] = i; in... |
#include <bits/stdc++.h> using namespace std; const long long sz = 2e6 + 5, mod = 1e9 + 9; long long t, n, m, k, q; const long long inf = 3e18; long long dx[] = {1, 0, -1, 0}; long long dy[] = {0, 1, 0, -1}; bool vis[sz]; vector<vector<long long> > gr(sz); vector<long long> cnt(sz, 0); void DFS(long... |
#include <bits/stdc++.h> using namespace std; bool solve(long long n, long long k) { int r = n % k; long long turn = n / k; if (turn % 2 == 1) { return false; } return true; } int main() { long long n, k; cin >> n >> k; if (!solve(n, k)) cout << YES << endl; els... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); int a[n]; for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } int temp1, temp2, flag = 0; for (int i = 0; i < n; ++i) { temp1 = a[i] - 1; temp2 = a[temp1] - 1; if (a[temp2] - 1 == i) { flag = 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize -O3 using namespace std; const int MAXN = 2100; int n, m; long long a[MAXN]; long long aa[MAXN]; long long b[MAXN]; long long bb[MAXN]; long long x; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:600000000 ) using namespace std; template <class T> T sqr(T x) { return x * x; } double const pi = 3.1415926535897932384626433832795; int const inf = (int)1e9; long long const inf64 = (long long)4e18; const string name = a ; const int NMA... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; long long factor[maxn], cnt, n, k, num; void process() { int m = sqrt(n); cnt = num = 0; for (int i = 1; i <= m; i++) { if (n % i == 0) { factor[cnt++] = i; if (n / i != i) factor[cnt++] = n / i; } ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 200011; const int limit = 1000000; const int maxBit = 20; long long n, X, Y, i, bts, max_conf; long long a[maxN]; vector<pair<long long, long long> > divs, divs2, act; vector<long long> to_check; vector<long long> A, B; long long data[1 ... |
#include <bits/stdc++.h> using namespace std; int n, maxi, ans; int a[200100], g[1001000]; int main() { cin >> n; for (int i = 1; i <= n; i++) { scanf( %d , a + i); g[a[i]] = a[i]; } sort(a + 1, a + 1 + n); maxi = a[n]; for (int i = 1; i <= maxi; i++) { if (g[i] != i) g... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, a; while (cin >> s >> n) { a = s.length(); if (a % n != 0) cout << NO << endl; else { int b, c = 0; b = a / n; for (int i = 0; i < a; i += b) { for (int j = 0; j < b ... |
#include <bits/stdc++.h> using namespace std; long long ans, f[300005]; ; vector<pair<int, int> > adj[300005]; int w[300005]; void dfs(int v, int fa) { f[v] = w[v]; ans = max(ans, 1ll * w[v]); for (auto i : adj[v]) { if (i.first != fa) { dfs(i.first, v); ans = max(ans, f[v]... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<int> v(7, 0); for (int i = 0; i < s.size(); i++) { if (s[i] == B ) v[0]++; else if (s[i] == u ) v[1]++; else if (s[i] == l ) v[2]++; else if (s[i] == b ) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200020; const int MOD = 1000000000; int add(int a, int b) { return a >= MOD - b ? a - MOD + b : a + b; } int mul(int a, int b) { return a ? (b < MOD / a ? a * b : (long long)a * b % MOD) : 0; } int sub(int a, int b) { return a < b ? a - b ... |
#include <bits/stdc++.h> using namespace std; vector<long long> nclaws(2000001, 0); void solve() { int n; cin >> n; cout << ((nclaws[n] * 4) % 1000000007) << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); nclaws[1] = 0; nclaws[2] = 0; nclaws[3] = 1; nclaws[4]... |
#include <bits/stdc++.h> using namespace std; const int N = 100000, M = 10, pw[5] = {1, 10, 100, 1000, 10000}; const unsigned long long mod = 1ULL << 58, inv = 6723469279985657373ULL; struct comp { unsigned long long a[4]; comp(int X = 0) { a[0] = X; a[1] = a[2] = a[3] = 0; } unsigne... |
#include <bits/stdc++.h> using namespace std; const int N = 2000000 + 10; int n, h, m, x, t, d, c; vector<int> v; int main() { scanf( %d%d%d%d%d%d , &h, &m, &t, &d, &c, &n); double need = (t + n - 1) / n * c; if (m != 0 && h < 20) { t += (60 - m) % 60 * d; h = (h + 1) % 24; } i... |
#include<bits/stdc++.h> #define LL long long #define ULL unsigned long long #define P pair<int,int> #define PI acos(-1.0) #define ls o<<1 #define rs o<<1|1 using namespace std; const int mod=1e9+7; const int base=19260817; const LL INF=1e18; const int maxn=2e5+10; const double eps=1e-8; i... |
#include <bits/stdc++.h> int main() { long long n, k, f[10005], t[10005], i, j, s = -1000000005, g = -1000000005, r; scanf( %lld %lld , &n, &k); for (i = 0; i < n; i++) { scanf( %lld %lld , &f[i], &t[i]); } for (j = 0; j < n; j++) { if (t[j] > k) { r = f[j] - (t[j] - k); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a1, a2, a3, a4; cin >> a1 >> a2 >> a3 >> a4; long long total = 0; long long minn = min(a1, a3); minn = min(minn, a4); total += 256 * minn; a1 -= minn; minn = min(a1, a2); total += 32 * minn; cout << total <<... |
#include <bits/stdc++.h> using namespace std; int ans[100009]; int cmp(int a, int b) { return a <= b; } int main() { int n; while (scanf( %d , &n) != EOF) { for (int i = 0; i < n; i++) scanf( %d , &ans[i]); sort(ans, ans + n); int vaule = 0; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000 * 1000 * 1000; const long long inf64 = 1ll * inf * inf; struct DSU { int n; vector<int> par, color, h; DSU() { n = 0; } DSU(int nn) { n = nn; par.resize(n + 1); color.resize(n + 1); h.resize(n + 1); ... |
#include <iostream> #include <algorithm> #include <cstring> #include <string> #include <queue> typedef long long ll; using namespace std; int main() { // what is greedy? int T; cin >> T; while (T--) { int len, a, b; cin >> len >> a >> b; string s; cin >> s; if (b >... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n + 1], b[n + 1]; for (long long i = 1; i <= n; i++) { long long x; cin >> x; a[x] = i; } for (long long i = 1; i <= n; i++) { long long x; cin >> x; b[x] = i; ... |
#include <bits/stdc++.h> using namespace std; char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } long long read() { char ch = getchar(); long long x = 0; int o... |
#include <bits/stdc++.h> using namespace std; int n, dad[200000 + 1], u[200000 + 1], v[200000 + 1]; long long w[200000], pop[200000], initsum, S; std::vector<int> adjl[200000 + 1]; int cnode(int node, int ed) { return node ^ u[ed] ^ v[ed]; } void dfs(int u) { int isleaf = 1; if (u != 1) pop[dad[u]] ... |
#include <bits/stdc++.h> using namespace std; char str[50]; pair<int, pair<int, char*> > p[100001]; long long c[100005]; vector<int> ans; map<int, int> mp; int main() { std::ios::sync_with_stdio(false); long long n, m, x; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> c[i]; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const long long MOD = 1000000007; const long long INF = 1LL << 60; long long xn[101010]; int solve() { long long a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; long long ans = 0; for (long long i = 0; i <= d; i++... |
#include <bits/stdc++.h> using namespace std; const int N = 1E5 + 10; string s[N]; map<string, vector<string>> E; map<string, long long> cnt; map<string, long long> len; map<string, bool> vis; vector<pair<string, vector<string>>> e; string to_lower(string &s) { int ret = 0; for (auto &c : s) {... |
#include <bits/stdc++.h> using namespace std; int a[100100]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; const long long max_pow = 1e9 * 1e5; vector<long long> powers = {1}; if ... |
#include <bits/stdc++.h> using namespace std; int a[100009]; int n; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); long long res = 0; for (int i = 0; i < n;) { int j = i + 1; while (j < n && a[j] == a[i]) j++; long long sz = j - i; res += sz... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); string to_string(const string&); string to_string(const char* s); string to_string(bool b); template <typename A> string to_string(A v); template <typename A, typename B> string to_string(... |
#include <bits/stdc++.h> using namespace std; int main() { double a, d; int n; while (scanf( %lf%lf%d , &a, &d, &n) != EOF) { double sum = 0; for (int i = 1; i <= n; i++) { sum = (sum + d); sum -= (int)(sum / (a * 4)) * (a * 4); double x, y; int dir = ((int)(s... |
#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; int n; bool check(vector<vector<char>>& v, int x, int y) { if (x + 2 >= 0 && y - 1 >= 0 && y + 1 < n && v[x + 1][y] == # && v[x + 2][y] == # && v[x + 1][y + 1] == # && v[x + 1][y - 1] == # ) { v[x][y] = v[x + 1][y] = v[x + 2][y] = v[x + 1][y +... |
/* anshu shandilya */ /* 2300 codechef rating before 31 December 2020 */ /* 2100 codeforces rating before 31 December 2020 */ #include <bits/stdc++.h> using namespace std; typedef long double LD; typedef long long ll; #define int ll #define itn int #define pb push_back #de... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; if (n & 1) cout << ((n / 2) + 1) << n ; else cout << (n / 2) << n ; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; whi... |
#include <bits/stdc++.h> using namespace std; const int max_n = 1000005; int n, k; int a[max_n], d[max_n]; long long sum[max_n]; long long suf[max_n]; long long pre[max_n]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , a + i); for (int i = 1; i <= n; i++) scanf... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int a[N + 2], p[N + 2]; void solve() { int n; cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; a[x] = i, p[i] = 0; } p[n + 1] = 1; int nx = -1; for (int i = 1; i <= n; i++) { if (nx == -... |
#include <bits/stdc++.h> using namespace std; const unsigned int maxn = 35000, maxk = 50; class STree { public: void build(const unsigned int l, const unsigned int r, STree*(&cur), unsigned int dat[]) { lv = l; rv = r; mv = (l + r) >> 1; if (r - l == 1) return; ... |
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long me(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char c = getchar(); int fh = 1; while (!isdigit(c)) { if (c == - ) fh = -1; c = getchar(); } while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); x *= fh; } struct Info { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); int arr[(int)1e5 + 5]; for (int i = 1; i <= n; i++) scanf( %d , &arr[i]); vector<int> vec; for (int i = 2; i <= n; i++) vec.push_back(arr[i] - arr[i - 1]); sort(vec.begin(), vec.end());... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int a[3]; for (long long int i = 0; i < 3; i++) { cin >> a[i]; } sort(a, a + 3); if (a[0] == a[1] && a[1] == a[2]) { cout << YES << endl; ... |
#include <bits/stdc++.h> int main() { int n, count = 0; scanf( %d , &n); while (n--) { int t = 3, s = 0; while (t--) { int a; scanf( %d , &a); s = s + a; } if (s > 1) { count++; } } printf( %d , count); return 0; } |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f; } ... |
#include <bits/stdc++.h> const int N = 55; using namespace std; int n; int a[N], w[N][N]; int f[N][N][N][N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n - i + 1; ++j) scanf( %d , &w[i][j]); for (int ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.