func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; string s; cin >> s; map<char, int> m; for (int i = 0; i < s.size(); i++) { m[s[i]]++; } char a = A ; bool flag1 = true; for (int... |
#include <bits/stdc++.h> using namespace std; set<int> inT; set<int>::iterator it; int ans[300000]; vector<int> pak; int main() { int n, m, l, r, x, i; cin >> n >> m; for (i = 0; i < n; i++) { inT.insert(i); } for (i = 0; i < m; i++) { cin >> l >> r >> x; l--; r--... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using cd = complex<double>; const int max_n = 200500; vector<int> g[max_n]; vector<int> og[max_n]; vector<int> used(max_n); bool find_cycles(int x) { used[x] = 1; for (int i : g[x]) { if (used[i] ... |
#include <bits/stdc++.h> using namespace std; int x[2][2]; int main() { for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) scanf( %d , x[i] + j); printf( %d n , (max(1, abs(x[0][0] - x[1][0])) + max(1, abs(x[0][1] - x[1][1])) + 2) * 2); return 0; } |
#include <bits/stdc++.h> using namespace std; int x[3]; int main() { int a, b, c, n, ans = 0, t = 0; cin >> n; cin >> x[0] >> x[1] >> x[2]; n--; while (n--) { if (t == 0) { if (x[0] < x[1]) { ans += x[0]; t = 1; } else { ans += x[1]; ... |
#include <bits/stdc++.h> using namespace std; int n, k; int c[5005], h[11], f[505]; int cnt[100005]; int fcnt[100005]; int cache[5005][505]; int solve(int idx1, int idx2) { if (idx1 == 0 || idx2 == 0) return 0; int &ret = cache[idx1][idx2]; if (ret != -1) return ret; ret = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; int const mxn = 1e3 + 10; vector<pair<int, int> > ha[3], adj0[mxn][mxn], adj1[mxn][mxn]; int mark[mxn][mxn][3], fl[mxn][mxn][3]; int n, m; int ans = 1e9; string l[mxn]; void connect(int i, int j, int i2, int j2) { if (i2 < 0 or i2 >= n or j2 < 0 or j2 >=... |
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { ... |
#include <bits/stdc++.h> using namespace std; const pair<int, int> MOD = make_pair(1e9 + 7, 1e9 + 9); const int base = 1e6 + 3; const int N = 1e5 + 100, B = 600; pair<int, int> operator+(pair<int, int> a, pair<int, int> b) { return make_pair((a.first + b.first) % MOD.first, (a.second ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; template <typename X> inline bool minimize(X& p, X q) { if (p <= q) return 0; p = q; return 1; } template <typename X> inline bool maximize(X& p, X q) { if (p >= q) return 0; p = q; return 1; } const int ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline long long Max(long long x, long long y) { return x > y ? x : y; } inline long... |
#include <bits/stdc++.h> using namespace std; long long t, t0, t2, x, x2; void cmp(long double &temp, long long &o, long long &o2, long long y, long long y2) { if (y2 > x2) return; long double newTemp = (1.0 * t * y + t2 * y2) / (y + y2); if (newTemp < t0) return; if (newTemp > temp + 1... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (const auto &x : v) os << x << ; retur... |
#include <bits/stdc++.h> using namespace std; #define cp ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long int #define vint vector<int> #define vllint vector<ll> #define pair_int pair<int , int> #define pair_ll_int pair<ll , ll> #define vector_of_pair_int vector<pair_... |
#include <bits/stdc++.h> using namespace std; const int N = 205; int mem[N][N]; int asol[N]; bool query(int i, int j) { i = asol[i]; j = asol[j]; if (mem[i][j] != -1) return mem[i][j]; if (i == j) return false; cout << ? << i << << j << endl; char c; cin >> c; mem[i][j] ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while(tt--) { int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } set<int> s; s.insert(a[0]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; int x[3]; int last = 0; cin >> a[0] >> a[1] >> a[2]; cin >> x[0] >> x[1] >> x[2]; for (int i = 0; i < 3; ++i) { int t = a[i] - x[i]; if (t > 0) t /= 2; last += t; } if (last < 0) cout << No ... |
#include <bits/stdc++.h> using namespace std; const double EPS = -1e8; const double Pi = acos(-1); bool inline equ(double a, double b) { return fabs(a - b) < EPS; } int _R(int& x) { return scanf( %d , &x); } int _R(long long& x) { return scanf( % PRId64, &x); } int _R(double& x) { return scanf( %lf , &x)... |
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < b; ++i) int debug = 0; const int N = 510; int n, p[N], a[N][N]; int main() { cin >> n; rep(i, 1, n + 1) { cin >> p[i]; } rep(i, 1, n + 1) { int x = i, y = i; ... |
#include <bits/stdc++.h> using namespace std; long long getmax(long long arr[]) { long long m = 0; for (long long i = 0; i < 26; i++) { m = max(m, arr[i]); } return m; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> ... |
#include <bits/stdc++.h> using namespace std; struct ee { int d; int y; }; ee e[120]; ee r[1200]; bool ok(ee a, ee b) { return a.y > b.y; } int main() { int n; int k; while (cin >> n >> k) { memset(e, 0, sizeof(e)); memset(r, 0, sizeof(r)); for (int i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; int a[1001]; int dp[1010][1010]; int from[1010][1010][2]; int del[1010][1010][2]; int main() { int i, j, n; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; if (n % 2) n++; for (i = 0; i <= n + 2; i++) for (j = 0; j <= n + 2; j++) dp[i][j... |
#include <bits/stdc++.h> using namespace std; const int maxk = 50, maxn = 100; int k, x, n, m; inline int calc(int x, int y) { if (!x && y == 2) return 1; return 0; } struct node { long long c1[2], c2[2][2]; bool h, t; node operator+(const node &Other) const { node N = {}; N.... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, l, tot, ans, v; long long o, p; long long f[110010]; struct rec { long long x, y; } a[100010]; bool cmp(rec x, rec y) { return x.x < y.x || ((x.x == y.x) && (x.y < y.y)); } int find(int k, int l, long long x) { while (k < l) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int a[100000]; int main() { int n, k; cin >> n >> k; int sum = 0; bool ok = false; vector<int> ans; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum % k != 0) { printf( No... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 2100; struct kstr { int C[30]; bool mask[110]; } A[SIZE]; int CC[30]; int main() { int K, N, len; char S[110]; cin >> K >> S >> N; len = strlen(S); for (int i = 0; i != len; i++) CC[S[i] - a ]++; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v[100000]; int f[100000]; int d[100000]; void dfs(int x) { int i; for (i = 0; i < v[x].size(); i++) { if (f[v[x][i].first] == 0) { d[v[x][i].first] = d[x] + v[x][i].second; f[v[x][i].first] = 1; dfs(v[x... |
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long r(long long num, long long den) { if (den == 1) return num; else if (num == 1) return den; if (num > den) return num / den + r(num % den, de... |
#include <bits/stdc++.h> int n; int a[(200010) << 1], b[(200010) << 1]; int pa[(200010) << 1], sa[(200010) << 1]; int pb[(200010) << 1], sb[(200010) << 1]; struct node { int x, y; } p[(200010)]; long long solve(int t) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(pa, 0, sizeof... |
#include <bits/stdc++.h> using namespace std; inline void pisz(int n) { printf( %d n , n); } const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; template <typename T, typename TT> ost... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MXN = 1e3 + 7; const int mod = 998244353; int n, m; int ar[MXN][MXN]; int br[MXN]; struct lp { int m, v; } A[MXN][MXN], B[MXN][MXN]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; if ((a + b) * n < c - d) cout << No n ; else if ((a - b) * n ... |
#include <bits/stdc++.h> int M[50] = {0, 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, ... |
#include <bits/stdc++.h> using namespace std; long long a[200100]; int main() { long long k, Answer = 0; int n; cin >> n >> k; for (int i = 0; i < n; i++) scanf( %I64d , &a[i]); for (int i = 0; i < n; i++) { Answer += a[i] / k; a[i] = a[i] % k; if (a[i] + a[i + 1] >= k) ... |
#include <bits/stdc++.h> using namespace std; void substr(int start, int end, char in[], char out[]) { for (int i = start; i < end; ++i) out[i - start] = in[i]; out[end - start] = 0 ; } int main() { int n, p, q; char s[100]; cin >> n >> p >> q; cin >> s; int pdivmax = n / p + 1, qd... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, l, m, t; vector<int> a[10001]; cin >> n; for (i = 1; i < n; i++) { cin >> m >> t; a[m].push_back(t); a[t].push_back(m); } l = 0; m = 0; int b[30001], c[30001]; for (t = 1; t <= n; t++) { ... |
#include <bits/stdc++.h> using namespace std; bool not_prime[100000]; long long int primes[100000]; int p, prime_factors[100000], pf_count[100000], q; int a[10000]; void find_primes() { long long int i, j; p = 0; for (i = 2; i < 100000; i++) { if (not_prime[i] == false) { primes[p+... |
#include <bits/stdc++.h> using namespace std; int main() { int a[3], b[3]; int k, d; cin >> a[0] >> a[1] >> a[2] >> k; for (int i = 0; i < 3; i++) { a[i]--; b[i] = 0; } sort(a, a + 3); for (int i = 0; i < 3; i++) { d = k / (3 - i); for (int j = i; j < 3; j++) { ... |
#include <bits/stdc++.h> using namespace std; bool prime(long long int i) { if (i == 1) return false; if ((i == 2) || (i == 3)) return true; if ((i % 2 == 0) || (i % 3 == 0)) return false; else { for (long long int j = 5; j * j <= i; j += 6) if ((i % j == 0) || (i % (j + 2) == 0)... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 600; int mat[2000][2000]; int quad[20][20]; int cont[20][20]; int main() { int n, m; scanf( %d%d , &n, &m); int foi = 0; int result = -1; for (int i = 0; i < m; i++) { int x, y; for (int h = 0; h < 5; h++) { ... |
#include <bits/stdc++.h> using namespace std; inline void prnt(bool ok) { cout << (ok ? YES : NO ); } const int ppr = 257; const long long INF = 2e18; const int inf = 2e9; const int mod = 1e9 + 7; const int N = 3e6 + 123; const long double pi = 3.141592653589793238462643; const int dx[] = {1, 0, -1... |
#include <bits/stdc++.h> using namespace std; const int MAX = (int)1e5 + 5; string check(char x, int n) { string it = ; it.push_back(x); string z = ; for (int i = 0; i < n; i++) { z = z + 0 ; } it = it + z; return it; } int main() { int tc; cin >> tc; while (... |
#include <bits/stdc++.h> using namespace std; long long f[2010][2010], n, s, ans, m; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { s = 0; for (int j = 0; j <= m - 2; ++j) s = (s + f[i - 1][j]) % 1000000007, f[i][j] = ((j == 0 ? 1 : f[i][j - 1]) + s) %... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3F3F3F3F; const int MAXN = 100001; char str[MAXN]; inline void solve(int test) { int t, sx, sy, ex, ey; scanf( %d %d %d %d %d , &t, &sx, &sy, &ex, &ey); scanf( %s , str); ; int X, Y; X = ex - sx, Y = ey - sy; pair<char... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; char buf[1000]; string nextLine(int length = 100) { cin.getline(buf, length); string s(buf); return s; } string next(int length = 100) { string tmp; cin >> tmp; return tmp; } int nextInt() { int tmp; s... |
#include <iostream> #include <string> #include<bits/stdc++.h> #include<algorithm> using namespace std; int main() { int t; cin>>t; while(t--) { long long n,k; c... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5; int n; char ans[maxN + 1]; string s; int main() { ios_base::sync_with_stdio(false); cin >> n; cin.ignore(); for (int i = 0; i < n; i++) { getline(cin, s); for (int j = 0; j < s.length(); j++) { if (ans[j]... |
#include <bits/stdc++.h> using namespace std; char a[100020]; char b[100020]; int zf[100020]; int zb[100020]; int main() { scanf( %s , a); scanf( %s , b); int la = strlen(a); int lb = strlen(b); zf[0] = 0; zb[la] = lb; for (int i = 1; i <= la; i++) { if (a[i - 1] == b[zf[i ... |
#include <bits/stdc++.h> using namespace std; const long long int maxn = 1e6 + 500; const long long int mod = 998244353; int dep[maxn], low[maxn], ans[maxn], dp[maxn]; int head[maxn], cnt; int n, k; struct C { int next, to; } E[maxn]; void add(int x, int y) { E[cnt].to = y; E[cnt].next = h... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int m, n, a[100009], b[100009]; long long sa, sb; long long proca() { long long ans = 0; ans += sa; for (int(x) = (1); (x) < (n); ++(x)) { ans += min(sa, (long long)b[x]); } return ans; } long long procb() ... |
#include <bits/stdc++.h> using namespace std; struct Edge { int t, v, next; Edge() {} Edge(int a, int b, int c) : t(a), v(b), next(c) {} }; Edge e[600005]; int head[300005]; long long dis[300005]; int p[300005]; priority_queue<pair<long long, int>, vector<pair<long long, int> >, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; char s[101]; cin >> n >> m; for (i = 0; i < n; i++) { cin >> s; for (j = 0; j < m; j++) { if (s[j] == . ) s[j] = ((i + j) % 2 == 0) ? B : W ; } cout << s << endl; } return 0; } |
#include <bits/stdc++.h> int main() { srand(1598743157); int v[4]; for (int i = 0; i < 4; i++) scanf( %d , &v[i]); while (v[0] != 1 || v[1] != 1 || v[2] != 1 || v[3] != 1) { bool ok = true; bool was = false; while (ok) { ok = false; for (int i = 0; i < 4; i++) ... |
#include <bits/stdc++.h> using namespace std; long long dp[2][100010]; long long MOD = 1000000007; int main() { string s1, s2; int k; while (cin >> s1 >> s2 >> k) { s1 = s1 + s1; int cntS = 0, cntD = 0; for (int i = 0; i < s2.size(); ++i) if (s1.substr(i, s2.size()) == s2) ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; int main() { ios::sync_with_stdio(0); int n; cin >> n; string s; cin >> s; s += _ ; int ln = 0, lng = 0, imin = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == ( ) { imin = 1; ln = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; using arr2 = array<int, 2>; vector<arr2> binTrie; const int w = 30; binTrie.push_back({-1, -1}); vector<int> sz(1, 0); auto add = [&](int x) { int v = 0; for (int i = w - 1; i >= 0; --i) {... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t = 1; cin >> t; while (t--) { long long n, k; cin >> n >> k; if (k > n) { cout << NO n ; continue; } if (n % 2 ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; while ((a = a % b) != 0) { swap(a, b); } return b; } long long mpow(long long x, long long y, long long m) { long long res = 1; while (y > 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; vector<pair<int, int>> a, b; a.resize(n); for (int i = 0; i < n; ++i) { a[i].second = i; cin >> a[i].first; } sort(a.begin(), a.end()); b.resize(n); for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int getFldsFromLine(char *line, std::vector<char *> &res, const char *sep = t n v f r ); int main(int argc, char **argv) { FILE *infile = stdin; char *line; line = (char *)calloc(5000000, sizeof(char)); if (line == NULL) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, j, i, l, r, ans = 0, x, y, minimum; scanf( %d , &n); scanf( %d , &k); int count_a[n], count_b[n]; char str[n + 1], ch; scanf( %s , str); for (i = 0; i < n; i++) { count_a[i] = 0; count_b[i] = 0; } fo... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( Ofast ) using namespace std; const long long INF64 = 1e18; const long long INF32 = 1e9; const double EPS = static_cast<double>(1e-10); const double PI = 2.0 * acos(... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, q, a, b, blo, arr[N]; struct node { int a, b, id; } qq[N]; long long ans[N], dp[N]; bool cmp(node a, node b) { if (a.b != b.b) return a.b > b.b; return a.a < b.a; } int main() { scanf( %d , &n); blo = sqrt... |
#include <bits/stdc++.h> using namespace std; int main() { int stones, counter = 0; string colours; cin >> stones; cin >> colours; for (int i = 0; i < stones - 1; i++) { if (colours[i] == colours[i + 1]) { counter++; } } cout << counter << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; bool possible(int smaller, int bigger) { return (bigger <= smaller * 3 + 1); } int main() { ios::sync_with_stdio(false); int q; cin >> q; for (int i = 0; i < q; ++i) { int b, w; cin >> b >> w; if ((b < w && !possible(b, w)) || (w < b ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int man = 0, ans = 0, n, m; int a[1000]; while (cin >> n >> m) { ans = 0; if (n > m) { printf( %d n , n - m); } else { while (n < m) { if (m % 2 != 0) { m++; ans++... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double pi = acos(-1); const long long int INF = 1e18; const int inf = 1e9; const int MOD = 1e9 + 7; const int nax = 1000000 + 10; int n, arr[nax]; int main() { ios::sync_with_stdio(0); cin >> n; if (n % 10 == 0) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d %d , &n, &k); if (k > (n * n + 1) / 2) { printf( NO ); return 0; } int i, j, count = 0; printf( YES n ); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if ((i + j) % 2 == 0 and c... |
#include <bits/stdc++.h> using namespace std; const int maxn = 36; long long dp[maxn][maxn]; int main() { long long n, h; cin >> n >> h; for (long long i = 0; i <= n; i++) dp[0][i] = 1; for (long long i = 1; i <= n; i++) for (long long j = 1; j <= n; j++) for (long long k = 0; k < ... |
#include <bits/stdc++.h> using namespace std; int main() { string ans1, ans2; string s1, s2, ss1, ss2; int a, b; cin >> s1 >> s2; a = atoi(s1.c_str()) + atoi(s2.c_str()); stringstream ss; ss << a; ss >> ans1; for (int i = 0; i < s1.length(); ++i) { if (s1[i] != 0 ) { ... |
#include <bits/stdc++.h> using namespace std; unsigned long long mod, dp[18][250005]; unsigned long long fac[250005], inv[250005]; unsigned long long n, k; inline unsigned long long qpow(unsigned long long a, unsigned long long b) { unsigned long long res = 1ll, tp = a; while (b) { if (b & 1ll) ... |
#include <bits/stdc++.h> using namespace std; long long n; static const long long maxn = 2005; long long M[maxn][maxn]; long long MyM[maxn][maxn]; vector<vector<long long>*> graph; long long dsu[maxn]; bool PreCheck() { for (long long i = 0; i < n; i++) { if (M[i][i] != 0) return false; } ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 200005; int l[MAX_N], r[MAX_N]; int a[MAX_N]; int n; int F[MAX_N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { l[i] = i; while (a[l[i] - 1] >= a[i]) l[i... |
#include <bits/stdc++.h> using namespace std; namespace FFT { const int N = 20; const int MAXN = (1 << N); class cmplx { private: double x, y; public: cmplx() : x(0.0), y(0.0) {} cmplx(double a) : x(a), y(0.0) {} cmplx(double a, double b) : x(a), y(b) {} double get_real() { return... |
#include <bits/stdc++.h> using namespace std; int main() { int h; long long n, l = 1, r, rpta = 0, aux2; cin >> h >> n; r = 1LL << h; aux2 = r; int aux = 1; while (r > l) { rpta++; long long m = (l + r) / 2; if (n <= m && aux == 0) { rpta += aux2 - 1; } el... |
#include <bits/stdc++.h> using namespace std; const int MaxN = (int)1e3 + 10; int a[MaxN][MaxN]; int main() { int n, i, m, k, x, y, j; char c; scanf( %d%d%d n , &n, &m, &k); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf( %d , &a[i][j]); scanf( n ); for (i = 1; i <= m; i+... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int M = 1e4 + 10; const int MOD = 1e9 + 7; const int inf = 1e9; const double pi = acos(-1.0); const double eps = 1e-6; int dx[] = {0, -1, 0, 1}; int dy[] = {1, 0, -1, 0}; int n, m; int a[101]; int sum[102]; int l, r; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T& s) { s = 0; int f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { s = s * 10 + c - 0 ; c = getchar();... |
#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 n, i, j, o, ans, cnt, num; double a, b, c, d, first[1010], second[1010], p, ... |
#include <bits/stdc++.h> int main() { long n; scanf( %ld , &n); std::vector<long> a(n); for (long p = 0; p < n; p++) { scanf( %ld , &a[p]); } sort(a.begin(), a.end()); long cur(0); for (long p = 0; p < n; p++) { if (a[p] >= cur + 1) { ++cur; } } printf... |
#include <bits/stdc++.h> using namespace std; int main() { int q, w, e, r, t = 0, y = 0; bool s[100001], d[100001]; char a[2]; cin >> q >> w; for (e = 1; e <= q; e++) { s[e] = 1; d[e] = 0; } bool c = 1, v; for (e = 0; e < w; e++) { scanf( %s%d , a, &r); if (a[... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = acos(-1); template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x;... |
#include <bits/stdc++.h> using namespace std; char ara[100005]; map<int, int> mp; int main() { int t, test; long long a, b, c, n; char ch; double d; gets(ara); t = strlen(ara); int aa = ara[t - 1] - 0 ; int bb = ara[t - 2] - 0 ; aa += (bb * 10); if (aa % 4 == 0) { ... |
#include<cstdio> #include<vector> #include<map> #include<set> #include<algorithm> #include<cstdlib> #include<cstring> #include<cmath> #include<string> #include<deque> #include<queue> using namespace std; #define db double #define ll long long int T; struct node{ ll x,y; }p[10]; i... |
#include <bits/stdc++.h> using namespace std; int n, m; int ans; int a[2002], b[2002]; int le; int p; int ssearch(int x) { int maxd = 0; for (int i = 1; i <= n; i++) { int z = abs(a[i] - b[x - le + i]) + abs(b[x - le + i] - p); if (z > maxd) maxd = z; } return maxd; } int m... |
#include <bits/stdc++.h> #define ull unsigned long long #define ll long long #define il inline #define db double #define ls rt << 1 #define rs rt << 1 | 1 #define pb push_back #define mp make_pair #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define ... |
#include <bits/stdc++.h> using namespace std; int count1(int x) { int ans = 0; while (x) { ans += x & 1; x >>= 1; } return ans; } int main() { int n, p; cin >> n >> p; for (int x = 0; x * (p + 1) <= n; x++) if (count1(n - x * p) <= x) { cout << x; re... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; using vii = vector<ii>; const ll MOD = 998244353; const ll INF = 1e18 + 9; const int MAXN = 1000006; const int MAXC = 20; int n, arr[MAXN], num[MAXC]; ll... |
#include <bits/stdc++.h> using namespace std; long long a[3000], b[3000]; map<long long, pair<long long, long long> > mymap; pair<long long, long long> p1, p2; int main() { std::ios::sync_with_stdio(false); long long n, m, sa = 0, sb = 0; p1.first = p1.second = p2.first = p2.second = -1; mymap... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); vector<int> vt; while (n) { int lst = -1; for (int i = 2;; i++) { if (1ll * i * (i - 1) / 2 <= n) lst = i; else... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 50; int n, cnt[maxn], a[maxn]; vector<int> q; int main() { cin >> n; int sign = 0; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; if (x > y) swap(x, y); if (y != n) sign = 1; cnt[x]++; ... |
#include <bits/stdc++.h> using namespace std; const long long int mxn = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int i, j, k, n, m; string s; cin >> s; n = s.length(); string a, b, c; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 650; int kd[MAXN], edges[100010][2]; int idA[MAXN], idB[MAXN]; int g[MAXN][MAXN]; int P; inline int advPow(int a, int b) { int ret = 1; while (b) { if (b & 1) ret = (long long)ret * a % P; a = (long long)a * a % P; b ... |
#include <bits/stdc++.h> using namespace std; int main() { double r, x, y, x1, y1; cin >> r >> x >> y >> x1 >> y1; double dist = sqrt(pow(x - x1, 2) + pow(y - y1, 2)); double ans = dist / (2 * r); cout << ceil(ans) << endl; } |
#include <bits/stdc++.h> using namespace std; const int MAX = 3e5; int a[MAX] = {}; int main() { int t; cin >> t; while (t--) { char c; long long s; cin >> c >> s; long long a1 = 0; for (int i = 0; i < 18; i++) { a1 = a1 * 2 + s % 2; s /= 10; } ... |
#include <bits/stdc++.h> using namespace std; vector<int> l[100007]; int parent[100007]; int color[100007]; int k; int p; int dfs(int u, int c) { int sz = l[u].size(); { for (int i = 0; i < sz; i++) { if (color[u] - color[l[u][i]] >= k && color[l[u][i]] != 0) { parent[l[u][... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; int n, m, k; int p[40]; struct query { int l, r, x; }; struct query q[500005]; int max0[500005], max1[500005]; long long dp[500005]; long long s[500005]; void solve() { cin >> n >> k >> m; p[0] = 1; for ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; bool dentro[410000]; int main() { int n, k; scanf( %d %d , &n, &k); int vazio = 0; int v[n]; vector<int> proximo(n, inf); vector<int> mapa(n, -1); for (int i = 0; i < n; i++) { scanf( %d , &v[i]); if (mapa... |
#include <bits/stdc++.h> using namespace std; int mapping[200001]; int main(int narg, char **arg) { int h, m, n; cin >> h >> m >> n; int hh = 0, occup_size = 0; while (true) { mapping[hh] = occup_size; hh += m; hh %= h; occup_size++; if (!hh) break; } int n_oc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.