func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, a[16], b[16]; int main() { double cnt = 0; ios::sync_with_stdio(false); cin >> n; for (register int i = 0; i < n; i++) cin >> a[i]; for (register int i = 0; i < n; i++) cin >> b[i]; for (register int i = 0; i < 1e6; ++i) { register... |
#include <bits/stdc++.h> using namespace std; long long n, k1, k2; long long a[1005]; long long b[1005]; void ReadData() { cin >> n >> k1 >> k2; for (long long i = 1; i <= n; i++) cin >> a[i]; for (long long i = 1; i <= n; i++) cin >> b[i]; } long long c[1005]; void process() { long long... |
#include <bits/stdc++.h> using namespace std; const int N = 1002, M = 10002; pair<int, long long> dp[N][M]; map<long long, int> di; bool vis[N][M]; int nxt[N][M]; long long a[N], b[N], k; int T[M][N]; int n; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b)... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int a[100005]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (n == 1) { cout << -1 << endl; return 0; } bool flag = true; for (int i = 1; i < n;... |
#include <bits/stdc++.h> using namespace std; vector<long int> fib(46, -1); int adv_fib(int n) { if (n == 0 || n == 1) { return 1; } else if (fib[n] == -1) { return fib[n] = adv_fib(n - 1) + adv_fib(n - 2); } else { return fib[n]; } } int main() { int n, curr = 1; cin... |
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, m, n, t, a[211111], b[211111], c[111111], d, s; string p[111111], q[111111]; int main() { cin >> n; for (i = 1; i <= n; i++) scanf( %I64d , &a[i]); for (i = 1; i <= n; i++) scanf( %I64d , &b[i]); i = 1; j = 1; while (i <... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (auto &x : v) cin >> x; int mine = *min_element(v.begin(), v.end()); vector<int> temp; for (int i = 0; i < n; i++) { if (v[i] == mine) temp.push_back(i); } for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; int n, a[maxn], ans, maxx = 0; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; maxx = max(maxx, a[i]); } cout << maxx; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const long long INFL = 1e18 + 123; const double PI = atan2(0, -1); mt19937 tw(960172); long long rnd(long long x, long long y) { static uniform_int_distribution<long long> d; return d(tw) % (y - x + 1) + x; } const int MAXV =... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long a, b, c, i, j; cin >> a >> b >> c; string f, s, third; if (a) { s = string(a + 1, 0 ); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; for (int i = 0; i < s1.size(); i++) { s1[i] = tolower(s1[i]); s2[i] = tolower(s2[i]); } if (s1 < s2) { cout << -1; } else if (s2 < s1) { cout << 1; } else { cout << 0;... |
#include <bits/stdc++.h> using namespace std; const float pi = acos(-1.0); const int maxn = 1e5 + 5; int c[maxn]; long long a[5][maxn], b[maxn]; vector<int> vec[maxn]; void dfs(int u, int fa) { for (auto p : vec[u]) { if (p != fa) { c[p] = 6 - c[u] - c[fa]; dfs(p, u); } ... |
#include <bits/stdc++.h> using namespace std; int n, a, b, d[500], s; int main() { scanf( %d , &n); for (int i = 1; i <= 2 * n; i++) scanf( %d , &d[i]); for (int i = 1; i <= 2 * n; i++) for (int j = 1; j <= 2 * n; j++) if (d[i] == d[i + (2 * j - 1)]) s++; printf( %d , s); scanf( ... |
#include <bits/stdc++.h> template <class T> T Min(const T &a, const T &b) { return a < b ? a : b; } template <class T> T Max(const T &a, const T &b) { return a > b ? a : b; } template <class T> bool Chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <class T> bool Chkma... |
#include <bits/stdc++.h> using namespace std; struct S { long long prime; int q, h, ji; }; S xxx[300000]; priority_queue<S> sum[4]; bool biao[300000]; bool operator<(const S &a, const S &b) { return a.prime > b.prime; } int main() { int x, y; cin >> x; for (int a = 0; a < x; a++) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long n, m, a, b, c, k, temp, x, y; const int MAXN = 1e5 + 11, mod = 1e9 + 7; inline long long max(long long a, long long b) { return ((a > b) ? a : b... |
#include <bits/stdc++.h> using namespace std; int main() { int a[101], dif[100], i, unique[101], c = 0; int min = 0, n, dif1, dif2; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); unique[c] = a[0]; c++; for (i = 1; i < n; i++) { if (a[i] != a[i - 1]... |
#include <bits/stdc++.h> using namespace std; long long n; int k; long long a[100050]; int main() { cin >> n >> k; for (int i = 1; i <= k; i++) cin >> a[i]; long long A = 1, B = 0, C = 0; for (int i = 1; i <= k; i++) { if (n - n % a[i] > C) { A = 1ll * i, B = n / a[i]; C ... |
#include <bits/stdc++.h> using namespace std; int n, q, A[100005 * 3], B[100005 * 3], ans[100005]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } vector<pair<int, int> > G[100005]; vector<int> E[100005]; pair<int, int> SL(pair<int, int> a) { int t = gcd(abs(a.first), abs(a.second)); a.firs... |
#include <bits/stdc++.h> using namespace std; inline int inp() { return 0; } inline int inp(bool& A) { if (cin >> A) return 1; return -1; } inline int inp(char& A) { return scanf( %c , &A); } inline int inp(int& A) { return scanf( %d , &A); } inline int inp(float& A) { if (cin >> A) return 1;... |
#include <bits/stdc++.h> using namespace std; string s, ss; int idx; int main() { cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == . ) { idx = i; break; } } if (s[idx - 1] != 9 ) { if (s[idx + 1] < 5 ) { ss = s.substr(0, idx); } else... |
#include <bits/stdc++.h> using namespace std; int n, i, k, x; string s; int main() { cin >> n >> k >> s; for (i = 0; i < n; i++) { if (s[i] == # ) x++; else x = 0; if (x == k) { cout << NO ; return 0; } } cout << YES ; } |
#include <bits/stdc++.h> using namespace std; struct Node { int u; map<char, int> child; }; vector<Node> grafo; int win[100005], lose[100005]; void addTrie(int u, string &s) { for (char c : s) { if (grafo[u].child.count(c) == 0) { Node novo; novo.u = grafo.size(); g... |
#include <bits/stdc++.h> using namespace std; template <class T> using v2d = vector<vector<T> >; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } mt19937 rng(chrono::system_clock:... |
#include <bits/stdc++.h> using namespace std; inline int qr() { int f = 0, fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << 1) + c - 48; c = getchar(); } return f *... |
#include <bits/stdc++.h> using namespace std; long long a[1000006]; map<pair<long long, long long>, long long> mp; int main() { long long n, k; cin >> n >> k; if (k == 0 && n != 1) { cout << No solution ; return 0; } if (n == 1) { cout << k; return 0; } if (k... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int64_t k; cin >> k; int64_t r = 2, c = 3; cout << r << << c << endl; int64_t arr[2][3]; int64_t ones = ((int64_t)1 << 18) - 1; arr[0][0] = ones; arr[0][1... |
#include <bits/stdc++.h> using namespace std; int main() { int a[2][2]; cin >> a[0][0] >> a[0][1] >> a[1][0] >> a[1][1]; int n[2]; if (!a[0][0] && !a[1][0] && !a[0][1] && !a[1][1]) { cout << 0 ; return 0; } for (int i = 0; 1; i++) { int temp = i * (i - 1) / 2; if (te... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; long long moves = 0; cin >> n; vector<long long> arr(n, 0); for (int i = 0; i < n; i++) cin >> arr[i]; long long last = arr[0]; long long min = INT_MAX; bool found = false; for (int i = 1; i < n; i++) { i... |
#include <bits/stdc++.h> using namespace std; long a, b, r; int main() { ios_base::sync_with_stdio(0); cin >> a >> b >> r; if (min(a, b) >= 2 * r) cout << First << endl; else cout << Second << endl; cin.get(); cin.get(); return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> struct ma : array<T, N> { T &operator[](size_t n) { return (*static_cast<array<T, N> *>(this))[n]; } }; template <class T> string to_str(const T &a) { ostringstream os; os << a; return os.str(); } template <> ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; vector<int> v; int n, d, p = 0, cnt = 0, mx = -1; cin >> n >> d >> s; for (int i = 0; i < n; i++) if (s[i] == 1 ) v.push_back(i); for (int i = 1; i < v.size(); i++) { if (v[i] - v[i - 1] > mx) mx = v[i] - v[i -... |
#include <bits/stdc++.h> using namespace std; struct Hill { int Lid, Mid, Rid; long long Lv, Mv, Rv; bool valid; Hill() : valid(false) {} Hill(int Lid, int Mid, int Rid, long long Lv, long long Mv, long long Rv) : Lid(Lid), Mid(Mid), Rid(Rid), Lv(Lv), Mv(Mv), Rv(Rv), valid(true) {} i... |
#include <bits/stdc++.h> using namespace std; pair<int, pair<int, int> > A[2003 * 2003], B[2003 * 2003]; pair<int, int> a[2003], b[2003]; int m, n, r, s, x, y, i, j, asd; long long t1, t2, mn; bool h; int main() { cin >> m; for (i = 1; i <= m; i++) { cin >> a[i].first; t1 += a[i].first... |
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j, n, x, y; cin >> x >> y; bool c = 0; char a; for (i = 0; i < x; i++) { for (j = 0; j < y; j++) { cin >> a; if (a != W && a != B && a != G ) c = 1; } } if (c) puts( #Color ); ... |
#include <bits/stdc++.h> double const EPS = 3e-8; using namespace std; template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a); } template <class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } struct debugger { template <typename T> debugger& operator,(const ... |
#include <bits/stdc++.h> int main() { int n, k; while (~scanf( %d%d , &n, &k)) { int ant[55] = {0}; int temp = 0; int count = k; for (int i = 1; i <= n; i++) { scanf( %d , &ant[i - 1]); if (i == k) temp = ant[i - 1]; } if (temp) for (int i = k + 1; i... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << << *it << = << a; err(++it, args...); } template <typename T, typename U> inline void min_self(T... |
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; double res = 0; long double t1x, t1y, t2x, t2y; cin >> t1x >> t1y; for (int i = 1; i < N; ++i) { t2x = t1x; t2y = t1y; cin >> t1x >> t1y; res += sqrt((t1x - t2x) * (t1x - t2x) + (t1y -... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int down[N], sz[N], up[N], n; vector<pair<int, bool> > adj[N]; void dfs(int s, int p) { sz[s] = 1; for (auto it : adj[s]) { if (it.first != p) { dfs(it.first, s); sz[s] += sz[it.first]; if (it.second) ... |
#include <bits/stdc++.h> double p[1010][1010]; int a[1010]; int n, m; int main() { double t, ans; int i, j, x, y; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d , &a[i]); for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) if (a[i] > a[j]) p[i][j] = 1; ... |
#include <bits/stdc++.h> using namespace std; int one, two, three, four; bool check(deque<int> x) { int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; for (int i = 0; i < x.size(); i++) { if (x[i] == 0) cnt1++; if (x[i] == 1) cnt2++; if (x[i] == 2) cnt3++; if (x[i] == 3) cnt4++; } ... |
#include <bits/stdc++.h> using namespace std; long long range(long long L) { switch (L & 3) { case 0: return L; case 1: return 1; case 2: return L + 1; case 3: return 0; } } int main() { for (int N; cin >> N;) { long long sum = 0; f... |
#include <bits/stdc++.h> using namespace std; struct trie { char ch; int son, next, father, suffix; vector<int> danger; int sum; }; trie a[205]; int now, m; void clear(int x) { a[x].son = a[x].next = 0; a[x].danger.clear(); } void insert(char *s, int l, int t, int x) { if (!a... |
#include <bits/stdc++.h> #include <cmath> #include <regex> #define ff first #define ss second #define pb push_back #define mp make_pair #define ba back #define ppb pop_back #define eb emplace_back #define eps 1e-6 #define vec vector<long long int> #define sz(x) (int((x.size()))) #define all(x)... |
#include <bits/stdc++.h> using namespace std; int read() { int x; scanf( %d , &x); return x; } const int N = 1123456; int a[N]; vector<int> v[N]; int c[N]; priority_queue<int> q[N]; void dfs(int x, int t) { c[x] = t; q[t].push(a[x]); for (int i = 0; i < v[x].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; stack<pair<int, int> > a; int main() { int n, m = 0, i = 1; cin >> n; while (n--) { int b, c; char d, e, f[40]; scanf( ); scanf( %c , &d); scanf( %d%c%d , &b, &e, &c); gets(f); b %= 12; if (f[1] == p ) b ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100010; const long long inf = 1e9 + 7; long long n, a[maxn]; long long minv = inf; long long sum[3]; int main() { scanf( %I64d , &n); for (long long i = 1; i <= n; i++) { scanf( %I64d , &a[i]); minv = min(minv, a[i]);... |
#include <bits/stdc++.h> using namespace std; inline long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); } long long n, k, x, type(1), amt, box; int main() { ios::sync_with_stdio(0); cin.tie(0);... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } void clock_out() { cerr << nTime Elapsed : << 1.0 * clock() / CLOCKS_PER_SEC << s n ; } void fileio() { freopen( /home/dwai/Desktop/cp/input.txt , r , stdin); freopen( /home/dwai/Desktop/cp/output.txt , w , st... |
#include <bits/stdc++.h> using namespace std; int N, K; int T[200005]; vector<int> danger; vector<pair<int, int> > v; bool cf(pair<int, int> x, pair<int, int> y) { return x.second * y.first > y.second * x.first; } int main() { scanf( %d %d , &N, &K); for (int i = 0; i < N; i++) { scanf... |
#include <bits/stdc++.h> #define ff first #define ss second #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define pii pair<int, int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> #defin... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops ) std::pair<int, int> DR[] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {-1, -1}, {1, 1}, {1, -1}}; using namespace std; const long long mod = 998244353; long long nop = 70; vecto... |
#include <bits/stdc++.h> using namespace std; char str[100010]; int ct[100010][4]; int main() { int N, x[5], R, L, M; scanf( %s , str); N = strlen(str); for (int i = 1; i <= N; i++) { for (int j = 0; j < 3; j++) ct[i][j] = ct[i - 1][j]; ct[i][str[i - 1] - x ]++; } scanf( %d ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, a[maxn]; struct node { int pre; bool flag; int other; } num[2 * maxn]; int main(int argc, char const *argv[]) { while (cin >> n) { bool flag = true; for (int i = 0; i <= n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; int mymax(int x) { int max = 0; while (x) { int s = x % 10; if (s > max) max = s; x /= 10; } return max; } int zh(int x, int n) { int s = 0, p = 1; while (x) { s += x % 10 * p; x /= 10; p *= n; } re... |
#include <bits/stdc++.h> using namespace std; class Constellation { static const long long N = 100010; inline long long sign(long long x) { return x > 0 ? 1 : x == 0 ? 0 : -1; } struct point { long long x, y, num; } b[N]; long long n; long long cross(const point &a, const point &b, con... |
#include <bits/stdc++.h> double eps = 1e-9; using namespace std; int main() { std::ios::sync_with_stdio(false); int x, y, z, w, b, a; cin >> x >> y >> z >> w >> b >> a; cout << (2 * (2 * x + a + y) * (z + y) - (a * a + b * b + y * y + z * z)) / 2; return 0; } |
#include <bits/stdc++.h> using namespace std; int dirx[] = {1, 0, -1, 0}; int diry[] = {0, 1, 0, -1}; int a; vector<int> graph[100005]; int dist[100005]; bool visit[100005]; int cnt = 0; bool flag = false; int dfs(int u, int par) { visit[u] = true; for (int i = 0; i < graph[u].size(); i++) {... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:167772160000 ) using namespace std; long long dp[5100][5100]; long long x[5100]; int a[5100], b[5100], c[5100], d[5100]; int main() { int leftminright = 0; int n, s, e; cin >> n >> s >> e; s--; e--; for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-8; const long long INF = 0x3f3f3f3f3f3f3f3f; inline long long readll() { long long x(0), op(1); char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) op = -1; ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 200222, inf = 1000111222; int n, m, a[max_n]; bool check(int cnt) { long long sum = 0; int last = 1; for (int i = 0; i < n; ++i) { if (i % cnt == 0) --last; if (a[i] + last < 0) break; sum += (a[i] + last); } r... |
#include <bits/stdc++.h> using namespace std; long long t[4 * 100100], dp[100100], a[100100], b[100100]; long long K = 1, n, m; void build() { while (K < m + 2) K <<= 1; } long long query(long long l, long long r) { long long ans = 0; for (l += K - 1, r += K + 1; l ^ r ^ 1; l >>= 1, r >>= 1) { ... |
#include <bits/stdc++.h> using namespace std; int n, k, c[100005], visit[100005], tp = 0; vector<int> a[100005], ans; bool ok[100005]; void dfs(int u) { visit[u] = tp; for (int i = 0; i < a[u].size(); i++) { int v = a[u][i]; if (ok[v]) continue; if (visit[v] == tp) { cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int sum = n * (n - 1) / 2; if (n == 0) { cout << 0; return 0; } if ((n % 2 == 0 && n % 4 != 0) || (n % 2 == 1 && n % 4 != 3)) cout << 1; else cout << 0; return 0; ... |
#include <bits/stdc++.h> using namespace std; template <typename F, typename S> ostream &operator<<(ostream &os, const pair<F, S> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; typename vecto... |
#include <bits/stdc++.h> template <class T> void cxk(T& a, T b) { a = a > b ? a : b; } template <class T> void cnk(T& a, T b) { a = a < b ? a : b; } long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == - , ch = getchar(); while (isdigit(ch)... |
#include <bits/stdc++.h> using namespace std; #define me(a, b) memset(a, b, sizeof(a)) #define IOS() ios::sync_with_stdio(false), cin.tie(0) #define endl n typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; const int INF = 0x3f3f3f3f; const int maxn = 2e5 + 5; const ll... |
#include <bits/stdc++.h> using namespace std; int f[100001], g[100001], h[100001]; int n, cnt; bool work() { cnt = -1; for (int i = 0; i < n; ++i) { if (g[i] != -1) { if (f[i] != i) return false; } else { if (g[f[i]] == -1) { g[i] = ++cnt; h[cnt] = f[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << n / 2 + 1; } |
#include <bits/stdc++.h> using namespace std; const int maxl = 200005; int T, n, mk, seq[maxl]; char s[maxl]; inline char read() { char ch = getchar(); while (ch != < && ch != > ) ch = getchar(); return ch; } int main() { scanf( %d , &T); while (T--) { scanf( %d , &n); m... |
#include <bits/stdc++.h> using namespace std; int main() { ifstream in( date.in ); ofstream out( date.out ); long long nr2, k, rez[4001], con = 0, nr, n, pli[4001], plp[4001], inc[4001], i, j; cin >> n; for (i = 1; i <= n; i++) cin >> pli[i] >> plp[i] >> inc[i]; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 128; int num[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> num[i]; } int m; cin >> m; for (int i = 0; i < m; ++i) { int x, y; cin >> x >> y; num... |
#include <bits/stdc++.h> using namespace std; int p[3010000], n; int main() { scanf( %d , &n); for (int i = 1; i < n + 1; i++) p[i] = i; for (int i = 2; i < n + 1; i++) { int s = p[i - 1], ns; for (int j = i - 1; j <= n + i - 2; j += i) { ns = p[j + i]; if (j + i <= n + i -... |
#include <bits/stdc++.h> using namespace std; int main() { int arr[101]; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int i = 0; i < n; i++) { cout << arr[i] << ; } } |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; long long arr[N], d[N], tree[N << 2], mx[N << 2]; void build(int rt, int l, int r) { if (l == r) { tree[rt] = mx[rt] = arr[l]; return; } int m = (l + r) / 2; build(rt << 1, l, m); build(rt << 1 | 1, m + 1, r);... |
#include <bits/stdc++.h> using namespace std; const int a[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2,... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool fs(T &x) { int c = getchar(); int sgn = 1; while (~c && c < 0 || c > 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x *= ... |
#include <bits/stdc++.h> using namespace std; int solve(vector<pair<int, int> > v, int price) { if (v.size() < 2) return 0; vector<int> p, b; for (int i = 0; i < v.size(); i++) p.push_back(v[i].first), b.push_back(v[i].second); int amx[v.size()]; amx[0] = b[0]; for (int i = 1; i < b.si... |
#include <bits/stdc++.h> using namespace std; int _, n; char s[100005]; int main() { scanf( %d , &_); while (_--) { scanf( %d , &n); s[0] = a ; scanf( %s , s + 1); int p = -1; for (int i = n; i >= 1; i--) { if (s[i] == 0 ) { p = i; break; ... |
#include <bits/stdc++.h> using namespace std; int n, ans, notOK; map<int, int> M; int main() { cin >> n; for (int i = 0, x; i < n; i++) cin >> x, M[x]++; for (map<int, int>::iterator it = M.begin(); it != M.end(); it++) { if (it->first) { if (it->second == 2) ans++; e... |
#include <bits/stdc++.h> using namespace std; vector<int> cr1[27]; vector<int> cr2[27]; int s1[27]; int s2[27]; struct node { int x; int y; }; int main() { int n; cin >> n; char c; for (int i = 0; i < n; i++) { cin >> c; if (c == ? ) { s1[26]++; cr1[2... |
#include <bits/stdc++.h> using namespace std; void actionFun() { long long n; cin >> n; long long c = 2; for (int i = 0; i < n; i++) { cout << c << ; ++c; } cout << endl; return; } int main() { int t; cin >> t; while (t--) { actionFun(); } } |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf( %d , &n)) { int cnt = 0; for (int i = 1; i < n; i++) { for (int j = i + 1; j < n; j++) { int sum = i * i + j * j; if (sum <= n * n) { if ((int)sqrt(sum) * (int)sqrt(sum) == su... |
#include <bits/stdc++.h> using namespace std; int k[1005], n, i, j; long long kx[1005]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> k[i]; kx[1] = 2; for (i = 2; i <= n; i++) { if (k[i] == i) kx[i] = 2; else { for (j = k[i]; j < i; j++) kx[i] = (kx[i] + kx[j... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << YES ; return 0; } vector<long long> v; ... |
#include <bits/stdc++.h> using namespace std; #pragma GCC push_options #pragma GCC optimize( unroll-loops ) int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int INF = 10e18; long long t; cin >> t; while (t--) { long long n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int contrib[312345] = {0}; bool in_set[312345] = {0}; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<int> ans; int cnt = 0; for (int i = 1; i <= n / 2; i++) { if (cnt + co... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; void qread(int &x) { int neg = 1; x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = 10 * x + c - 0 , c = getchar(); x *= ne... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << -1 << endl; return 0; } cout << n << << n + 1 << << n * (n + 1) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; using int64 = long long; using pii = pair<int, int>; using vchar = vector<char>; using vvchar = vector<vchar>; using vint = vector<int>; using vint64 = vector<int64>; using vvint = vector<vint>; using vbool = vector<bool>; using vpii = vector<pii>; tem... |
#include <bits/stdc++.h> using namespace std; int a[500000]; int mina, maxa; int n, k; long long sum = 0; bool check(int c) { sum = 0; for (int i = 0; i < n; i++) { if (a[i] + c < mina) { sum += mina - c - a[i]; } else { break; } } if (sum > k) return false;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, s, f, i; cin >> n >> m >> s >> f; long long t; map<long long, pair<int, int>> h; pair<int, int> R; for (i = 0; i < m; i++) { cin >> t >> R.first >> R.second; h[t] = R; } i = 1; if (s < f) while... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int d[n]; int total = 0; for (int i = 0; i < n; i++) { cin >> d[i]; total += d[i]; } int s, t; cin >> s >> t; if (s == t) { cout << 0; return 0; } if (s > t) swap(s, t); ... |
#include <bits/stdc++.h> using namespace std; int n, m, Q; double sy, l[200100], r[200100], sum[200100], zl, zr, x, y, ans; struct Node { double x, y; } bj[2][200100], tmp, L, R; inline bool lef(Node u, Node v, Node w) { if (u.x == v.x) return w.x < u.x; double t; t = v.x - (v.x - u.x) * (v.... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const int MAX_N = 1000009; const long long mod = 998244353; long long modpow(long long a, long long b, long long m) { long long p = 1, q = a; for (int i = 0; i < 32; i++) { if ((b / (1LL << i)) % 2 == 1) { p *=... |
#include <bits/stdc++.h> using namespace std; const long double pi = 4 * atan((long double)1); const long long mod = 1e9 + 7; const long long inf = 922337203685477; const long long nax = 1e5 + 5; long long n, p, m; long long d[nax], t[nax]; int main() { ios_base::sync_with_stdio(false); cin.tie(... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int SIZ_TREE = 3e5 + 10; int n, m; struct Node { int u, v; Node(int U = 0, int V = 0) { u = U, v = V; if (u < v) swap(u, v); } bool operator<(const Node A) const { if (u < A.u || (u == A.u && v < A.v)... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e6 + 3; long long power(long long base, long long exp) { long long ans = 1; while (exp) { if (exp & 1) ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; } int main() { ios_base::sy... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n, k, i; cin >> n >> k; vector<pair<long long, long long> > v; long long a[n], b[n]; long long x, y; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.