func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i < 100000; i++) { n *= 3; m *= 2; if (n > m) { cout << i << endl; return 0; } } } |
#include <bits/stdc++.h> using namespace std; const int M = 500; int R, n, m, d[M][M]; pair<int, int> hd[M], tl[M], par[M][M]; bool wins = 0, draw = 0; int mark[M][M]; void dfs(int x, int y) { if (x < 0 || y < 0) return; if (x + y > R) { mark[x][y] = 2; return; } mark[x][y] = 1... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool sorted = 0; int a, b, c; c = count(s.begin(), s.end(), c ); a = count(s.begin(), s.end(), a ); b = count(s.begin(), s.end(), b ); string ss = s; sort(ss.begin(), ss.end()); for (int i = 0; ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long mod = 1e9 + 7; int mp[510][510]; struct mon { int x, y, t; } t[510 * 510]; int n, m, k, q; int cmp(mon a, mon b) { return a.t < b.t; } int sum[510][510]; int check(int tim) { int i, j; memset(mp, 0, siz... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int c = 0; int i; for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { c = 1; break; } } if (c == 1) cout << YES n << i + 1 << << i + 2 << n ;... |
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)1e9 + 7; const int SIZE = 2e5 + 5; const long long INF = 1LL << 60; const double eps = 1e-4; const double PI = 3.1415926535897932; int last[26]; int main() { string s; cin >> s; int n = ((int)(s).size()); for ... |
#include <bits/stdc++.h> using namespace std; int main() { long long l1, r1, l2, r2, k; scanf( %I64d %I64d %I64d %I64d %I64d , &l1, &r1, &l2, &r2, &k); long long l, r; l = max(l1, l2); r = min(r1, r2); long long ans = (r - l) + 1; if (k <= r && k >= l) ans--; ans = max(0LL, ans); ... |
#include <bits/stdc++.h> using namespace std; bool comp(int x, int y) { return x > y; } int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { int n; cin >> n; vector<pair<int, int> > a(n); for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; char kata[1005]; int panjang, total[30], batas; int main() { scanf( %s , kata); panjang = strlen(kata); for (int i = 0; i < panjang; ++i) ++total[kata[i] - a ]; scanf( %d , &batas); int cek = 0; for (int i = 0; i < 26; ++i) if (total[i... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, dem = 0; cin >> n; dem = n / 2520; cout << dem; } |
#include <bits/stdc++.h> using namespace std; int cnt[1000000 + 10]; int a[1000000 + 10]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] <= m) { cnt[a[i]]++; } } for (int i = m; i >= 1; i--) { for (int j = i; (j += i)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 160; const int maxM = (int)1e6 + 100; const int mod = (int)1e9 + 7; const int maxlog = (int)20; const int P = mod; int n, q, l[maxn], r[maxn], mx[maxn], mn[maxn], t[maxn], v[maxn], b[maxn], cnt[maxn], ans = INT_MAX, tot = 5000000, was[ma... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T sqr(T t) { return t * t; } inline void files() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n1, m1, n2, m2; int a[150][150], b[150][150]; int mx, ansx, ansy; int main() { files(); c... |
#include <bits/stdc++.h> int main() { char a[10], e[10]; int b[10], d[10], i, j, c = 0, t; scanf( %s , a); scanf( %s , e); for (i = 0; i < strlen(a); i++) { b[i] = a[i] - 0 ; b[i] = b[i] - 48; d[i] = e[i] - 0 ; d[i] = d[i] - 48; } for (i = 0; i < strlen(a); i++)... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << ( << p.first << , << p.second << ) ; } template <typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_sam... |
#include <bits/stdc++.h> using namespace std; int f(string s) { int answer = 0; answer += 600 * (int(s[0]) - 48); answer += 60 * (int(s[1]) - 48); answer += 10 * (int(s[3]) - 48); answer += (int(s[4]) - 48); return answer; } string s(int a) { string answer; answer.clear(); an... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); pair<int, char> p[200005]; for (int i = 0; i < n; i++) { scanf( %d %c , &p[i].first, &p[i].second); } sort(p, p + n); int minred = 1e9 + 1, maxred = 1e9 + 1; int mingreen = 1e9 + 1, maxgreen = 1e... |
#include bits/stdc++.h using namespace std; #define ffor(n) for(int i = 0; i < n; i++) #define fffor(n) for(int j = 0; j < n; j++) #define uwu ios_base::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize( Ofast ) const int INF = 1e9 + 7; const long long INF2 = 1e15; void solve(void) {... |
#include <bits/stdc++.h> using namespace std; int a[1005], dp[1005][1005], dp_sum[1005][1005]; int main() { ios::sync_with_stdio(false); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); int limit = a[n] / (k - 1); int ans = 0; for (int diff... |
#include <bits/stdc++.h> using namespace std; long long t, n, a[205], b, c[205]; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> t; while (t--) { cin >> n >> b; for (int i = 0; i < n; i++) { cin >> a[i]; c[a[i]] = 1; } fo... |
#include <bits/stdc++.h> using namespace std; int d[8], f1[8], f2[8]; bool Check(int f[], int a, int b, int c) { return (f[1] + f[2] + f[3] + f[4] <= a) && (f[1] + f[2] + f[5] + f[6] <= b) && (f[1] + f[3] + f[5] + f[7] <= c); } int main() { int t; cin >> t; while (t--) { int a... |
#include <bits/stdc++.h> using namespace std; int a[100005]; vector<pair<int, int>> t; bool pairsort(pair<int, int> e1, pair<int, int> e2) { return e1.first <= e2.first; } int main() { int n; cin >> n; int pos, pow; for (int i = 1; i <= n; i++) { scanf( %d%d , &pos, &pow); t.... |
#include <bits/stdc++.h> using namespace std; struct fenwickTree { long long n; vector<long long> bit; fenwickTree() {} fenwickTree(long long siz) : n(siz + 5), bit(siz + 5, 0) {} void add(long long pos, long long upd) { for (; pos < n; pos += pos & (-pos)) bit[pos] += upd; } long ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, inf = 0x3f3f3f3f; int main() { int a, b, h1, h2; while (cin >> h1 >> h2) { cin >> a >> b; int add = a * 12, de = b * 12, first = 8 * a; if (a <= b) { if (h1 + first >= h2) puts( 0 ); else ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 159, INF = 2e9 + 9; struct mat { bitset<MAX> a[MAX]; mat(int v = 0) { for (int i = 0; i < MAX; i++) for (int j = 0; j < MAX; j++) if (i == j) a[i][j] = v; else a[i][j] = 0; } } adj... |
#include <bits/stdc++.h> using namespace std; int getint() { int x = 0; char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) x *= 10, x += (c - 0 ), c = getchar(); return x; } vector<pair<int, int> > v[2]; int n, a[2][10010]; void XOR(int i, int j, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, zheng = 0, mmax = 0, strc, stra, cuowu; char a[1000], b[26], c[1000]; double bb[26], sheng[26], bisheng[26], cc[26]; cin >> a; cin >> n; sort(a, a + strlen(a)); memset(c, 0, sizeof(c)); b[0] = a ; for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<pair<int, int>> vec; int n, a, b; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; if (a != b) { cout << rated ; return 0; } vec.push_bac... |
#include <bits/stdc++.h> #define int long long #define F0R(i, n) for(int i = 0; i < (n); i++) using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int T; cin >> T; F0R(cas,T) { int N; cin >> N; vector<int> a(N); for(int... |
#include <bits/stdc++.h> #pragma optimize( TKACHENKO-GORYACHENKO ) using namespace std; const int maxn = 11e5; const int inf = 1e18; int n, m, k; int A[maxn]; int B[maxn]; int C[maxn]; int V[4 * maxn]; int T[4 * maxn]; inline void push(int v, int tl, int tr) { if (T[v] == 0) { return; ... |
#include <bits/stdc++.h> using namespace std; int main() { bool tr = false; int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; if (x != y) tr = true; } if (tr) cout << Happy Alex n ; else cout << Poor Alex n ; return 0; } |
#include <bits/stdc++.h> using namespace std; bool ACS(string s) { int n1 = s.length(); for (int i = 1; i < n1; i++) if (s[i] != s[0]) return false; return true; } int main() { long long int t; cin >> t; while (t--) { string s; cin >> s; if (s.length() == 1) ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; void fn(long long int a[], long long int a1, long long int b, long long int n) { for (long long int i = 0; i < n; i++) { a[i] = a1; a1 += b; } } void solve() { long long int n, x, y; cin >> n >> x >> y... |
#include <bits/stdc++.h> using namespace std; vector<int> v[3]; int main() { int n; cin >> n; string s1, s2; cin >> s1 >> s2; int ans1 = 0, ans2 = 0; for (int i = 0; i < s1.size(); i++) { if (s1[i] == a ) { ans1++; } if (s2[i] == a ) { ans1++; } ... |
#include <bits/stdc++.h> using namespace std; namespace sat { const int MAX = 200010; bool vis[MAX]; vector<int> ed[MAX], rev[MAX]; int n, m; vector<int> order; int comp[MAX]; inline int inv(int x) { return ((x) <= n ? (x + n) : (x - n)); } void init(int vars) { n = vars, m = vars << 1; for ... |
#include <bits/stdc++.h> using namespace std; long long modpow(int a, int b, int m) { long long res = 1; long long base = a; base %= m; while (b > 0) { if (b % 2 == 1) { res = (res * base) % m; } b >>= 1; base = (base * base) % m; } return res; } long long... |
#include <bits/stdc++.h> using namespace std; int main() { long long int sum, limit, start = 0, end = 0; cin >> sum >> limit; vector<pair<long long int, long long int>> v; vector<long long int> ans; for (long long int i = 1; i <= limit; i++) { long long int t = i, cn = 0; while (t > ... |
#include <bits/stdc++.h> using namespace std; long long read() { long long ret = 0, f = 1; char x = getchar(); while (!(x >= 0 && x <= 9 )) { if (x == - ) f = -1; x = getchar(); } while (x >= 0 && x <= 9 ) ret = ret * 10 + x - 0 , x = getchar(); return ret * f; } char... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } vector<pair<int, int>> vec; if ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; long long x[200001], y[200001]; set<long long> sx, sy; long long indx[200001], indy[200001]; long long find_indx(long long a) { long long l = 0, r = n - 1; long long ind = -1; while (l <= r) { long long mid = (l + r) / 2; ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MAX_N = 1e6 + 5; using pii = pair<long long, long long>; struct edge { long long to, flow, cap, cost, rev; }; struct MinCostMaxFlow { long long nodes; vector<long long> prio, curflow, prevedge, prevnod... |
#include <bits/stdc++.h> using namespace std; const int L = 2e5 + 7; long long out[L], a[L], counter[1000001], szs = 900; struct node { long long l, r, q; }; bool comp(node x, node y) { long long xx = x.l / szs, yy = y.l / szs; if (xx == yy) return x.r < y.r; return x.l < y.l; } long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int a, b, c, d, k; cin >> a >> b >> c >> d >> k; int x = (a + c - 1) / c; int y = (b + d - 1) / d; if (x + y <= k) cout << x << << y << endl; else ... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const double pi = acos(-1); long long dp[1000006]; int main() { long long n; cin >> n; long long a[n + 1]; memset(dp, 0, sizeof(dp)); dp[0] = 1; for (long long i = 1; i <= n; i++) { cin >> a[i]; vect... |
#include <bits/stdc++.h> using namespace std; int n; const int N = 50; const int M = 10000000; const int MOD = 1e9 + 7; string st[N]; int fa[N], lst[N], tot, cnt[N], ss[N]; int V[N], col[N], res; int get_f(int t) { if (fa[t] == t) return t; else return get_f(fa[t]); } int ID[M]... |
#include <bits/stdc++.h> using namespace std; long long sol(long long a, long long b, long long h, long long w, int n, vector<long long> v) { int p = 0; long long th = h, tw = w; for (; p < n; ++p) { if (th < a) th *= v[p]; else if (tw < b) tw *= v[p]; e... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; class event { public: long long t; int id, type; event() {} event(long long a, int b, int c) { t = a; id = b; type = c; } bool operator<(const event& other) const { if (t != other.t) return ... |
#include <bits/stdc++.h> using namespace std; static const int MAXN = 1e5 + 10; int n, k; int ans; int data[MAXN]; int has[MAXN]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; ++i) { scanf( %d , &data[i]); ++has[data[i] % 10]; ans += data[i] / 10; } for (int... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n << n ; for (int i = 0; i < n; i++) { cout << 1 << ; } cout << n ; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long sum1[maxn]; long long sum2[maxn]; long long a[maxn]; long long pos[maxn]; int n; long long lowbit(long long x) { return x & -x; } void add(long long *sum, long long x, long long v) { while (x <= n) { sum[x] += ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; int h[100000], max[100001]; cin >> n; for (int i = 0; i < n; ++i) { cin >> h[i]; } max[n] = h[n - 1] - 1; for (int i = n - 1; i >= 0; --i) { if (h[i] > max[... |
#include <bits/stdc++.h> int const N = 1100; int n, m, ans, ans1; int map[N][N]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) map[i][j] = -1; for (int i = 1; i <= n; ++i) { int x; scanf( %d , &x); for (int j = 1; j <= x; ++j) ... |
#include <bits/stdc++.h> using namespace std; int n, m; int x, y; int ans = 10000000; int bar[2001]; int dp[1002][1002][2]; string str[2001]; int dfs(int si) { int res = 10000000; for (int i = 0; i < m - si; i++) { int rr = 0; for (int j = 0; j < m; j++) { if (j >= i && j < i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60000000 ) 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 = 3.1415926535897932384626433832795; template <class T> T sqr(T x) { return x *... |
#include <bits/stdc++.h> using namespace std; const int Size = 1e5; long long n, m; bool onField(long long x, long long y) { return (x <= n && x >= 1) && (y <= m && y >= 1); } int main() { long long x, y, dx, dy, k; long long ans = 0; cin >> n >> m; cin >> x >> y; cin >> k; for (... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n, k, ans = INT_MIN; cin >> n >> k; long long A[n]; for (int i = 0; i < n; i++) cin >> A[i]; for (long... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n = 0; cin >> n; string s; cin >> s; int pos = 0; vector<int> v(n); int flag = 1; for (int i = 0; i < n; i++) { cin >> v[i]; } for... |
#include <bits/stdc++.h> using namespace std; vector<int> g[300001]; int arr[300001]; int dp[300001]; int maxi = -(int)1e10, max_pos; bool flag = false; void dfs(int beta, int baap) { if (flag) return; if (arr[beta] == maxi) dp[beta] = 0; else dp[beta] = -(int)1e10; for (int i ... |
#include <bits/stdc++.h> const int INF = INT_MAX; using namespace std; const int N = 3e5 + 10; int arr[N]; int main() { ios_base::sync_with_stdio(false); stringstream ss; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } map<int, bool> ma; vector<pair<int, i... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; int t; void solve() { int n, res = 0, j = 0; string s; cin >> n >> s; map<int, int> m; for (int i = 0; i <= n; i++) { if (s[i] == x ) { m[j]++; } else { j++; } } for (auto i... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) long long arr[100010], dpArr[100010], dpQuery[100010]; int main() { ios::sync_with_stdio(false); cin.t... |
#include <bits/stdc++.h> using namespace std; long long n, m, x, y, z, flag = 0; vector<long long> sum(200005), mx(200005, INT_MIN); vector<int> adj[200005 + 1]; vector<int> pl(200005 + 1); map<int, int> vis; void dfs(int a) { vis[a] = 1; for (int i = 0; i < adj[a].size(); i++) { if (vis[adj... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n, m, i, j, k, l, a, b, sz[2], v1[2][5005]; string s; bool used[5005]; int main() { ios_base ::sync_with_stdio(); cin.tie(0); cin >> s; n = s.size(); if (n == 1) { cout << s; return 0; } int... |
#include <bits/stdc++.h> const int MAXQ = 5e5 + 5; using namespace std; struct edge { int v, next; } ed[MAXQ * 4]; int head[MAXQ * 2]; int topE; void addE(int u, int v) { ed[++topE].v = v; ed[topE].next = head[u]; head[u] = topE; return; } int dep[MAXQ * 2]; int fa[MAXQ * 2][25];... |
#include <bits/stdc++.h> using namespace std; char m[1000000]; int main() { int t, i, j; string s; cin >> t; cin >> s; int l = s.length(); for (i = 0; i < l; i++) m[i] = s[i]; for (i = 1; i < t; i++) { cin >> s; for (j = 0; j < l; j++) { if (m[j] == ? ) m[j] = s[j]... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lb = 1000; void azmuth(long long n = 12) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(n) << fixed; } void solve() { long long... |
#include <bits/stdc++.h> using namespace std; long long int n, k; string str[400007]; long long int a[400007], p[400007][4]; long long int m1[200005], m2[200005]; int main() { string s; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == A ) { p[i][0] = 1; if (i -... |
#include <bits/stdc++.h> using namespace std; template <typename T, class F = function<T(const T&, const T&)>> class SparseTable { public: int n; vector<vector<T>> sp; F func; SparseTable(const vector<T>& a, const F& f) : func(f) { n = static_cast<int>(a.size()); int max_log = 32 - ... |
#include <bits/stdc++.h> using namespace std; int treas[310][310]; long long dp[310][310]; long long d[310][310]; vector<pair<int, int> > G[110000]; vector<pair<long long, pair<int, int> > > lst; queue<pair<long long, pair<int, int> > > bfs; int dir[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; long lon... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, i, j, sum = 0, k; cin >> x >> y; for (i = 1; i <= x; i++) { j = i % 5; k = y + j; sum = sum + (k / 5); } cout << sum << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int inf = (int)2e9; const long long md = 1000000007; int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<int, int> > v(n); for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; void yes() { cout << YES << n ; return; } void no() { cout << NO << n ; return; } template <typename T> void p(T a) { cout << a << ; return; } template <typename T> void pnl(T a) { cout << a << n... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx2,avx ) #pragma GCC optimize( unroll-loops ) using namespace std; string YES[2] = { NO , YES }; string Yes[2] = { No , Yes }; string yes[2] = { no , yes }; template <class T> using pq = priority_queue<T>; template <class T... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; long long p, q, b; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } bool ok() { long long m = gcd(p, q); q /= m; m = b; while (q != 1) { m = gcd(q, m); q /= m; if (m == 1) break; ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; template <class T> bool cmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool cmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } struct starter { high_resolution_clock::time_point t1, ... |
#include <bits/stdc++.h> using namespace std; namespace io { char ibuf[(1 << 20)], *iS, *iT, obuf[(1 << 20)], *oS = obuf, *oT = oS + (1 << 20) - 1, c, qu[55]; int f, qr; inline void flush(void) { return fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void(); } inline char getch(void) { return... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ar[n]; long long br[n]; for (auto x = 0; x < n; x++) { cin >> ar[x]; br[x] = ar[x]; } sort(br, br + n); long long m; cin >> m; while (m--) { long long pos, k; s... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; if (n >= k) { cout << (k - 1) / 2 << endl; } else if (k - n > n) { cout << 0 << endl; } else { cout << (n - (k - n) + 1) / 2 << endl; } } int main() { solve(); return 0... |
#include <bits/stdc++.h> using namespace std; long long n, k; long long pow(long long a, int b) { if (b == 0) return 1; long long base = pow(a, b >> 1); base = base * base; if (b & 1) base = base * a; return base; } long long f(long long n) { if (n == 1) return 1; map<long long, in... |
#include <bits/stdc++.h> int A[100020] = {0}; int main() { int n, i, dis1, dis2 = 0, dis = 0, min; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &A[i]); if (min > A[i] || i == 1) min = A[i]; } for (i = 1; i <= n; i++) if (A[i] == min) { if (dis2 == 0) dis2 = i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, t; cin >> s; cin >> t; int sc[26] = {0}, tc[26] = {0}; for (int i = 0; i < n; i++) { sc[s[i] - a ]++; tc[t[i] - a ]++; } int flag = 1; for (int i = 0; i < 26; i++) { if (... |
#include <bits/stdc++.h> using namespace std; inline int dblcmp(double x) { if (abs(x) < 1e-8) return 0; return (x > 0) ? 1 : -1; } inline double sqr(double x) { return x * x; } const double pi = acos(-1.0); struct point { double x, y; point() {} point(double _x, double _y) : x(_x), y(_y... |
#include <bits/stdc++.h> using namespace std; long long n, k; bool check(long long mid) { long long sum = (mid + k - 1) * (k - mid) / 2; return (sum >= n - 1); } int main() { scanf( %I64d%I64d , &n, &k); if (n == 1) { printf( 0 ); return 0; } long long l = 1, r = k - 1, mid... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int n, a = 0, b = 0; cin >> n; string str; cin >> str; for (int i = 0; i < n - 1; i++) { if (str[i] == S && str[i + 1] == F ) a++; else if (str[i] == ... |
#include <bits/stdc++.h> using namespace std; int n, ans; int main() { int i, j, k; scanf( %d , &n); for (i = k = 0; i < n; i++) { scanf( %d , &j); if (j == 0 && k == 0) continue; else if (j == 0 && k == 2) k = 1; else if (j == 0 && k == 1) k = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5 + 10; const int INF = 1E9 + 10; int n; int a[MAXN][4]; int d[MAXN]; int dis[MAXN], pre[MAXN]; vector<int> lst[MAXN]; int val[MAXN << 2]; int choose(int l, int r) { return a[lst[l].back()][1] < a[lst[r].back()][1] ? l : r; } v... |
#include <bits/stdc++.h> using namespace std; int f[105][105]; string sa[105], sb[105]; void solve() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> sa[i]; } sort(sa + 1, sa + n + 1); for (int i = 1; i <= n; ++i) { cin >> sb[i]; } sort(sb + 1, sb + n + 1); ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; using ll = long long; using ld = long double; using pt = complex<ld>; constexpr ld EPS = 1e-9; ld cross(pt a, pt b) { return imag(conj(a) * b); } ld cross(pt p, pt a, pt b) { return cross(a - p, b - p); } int orientation(pt a, ... |
#include <bits/stdc++.h> using namespace std; struct Node { int len, link; int nxt[26]; long long val; }; struct Automaton { int sz, last; Node s[200100 * 10]; void init() { sz = last = 0; s[0].len = 0; s[0].link = -1; s[0].val = 0; memset(s[0].nxt, 0, sizeo... |
#include <bits/stdc++.h> using namespace std; int t, n; long double ang, ca, PI = acos(-1); int main() { ; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> t; while (t--) { cin >> n; ang = 2 * PI / (2 * n); ca = 0.5 / tan(ang / 2); cout << fixed... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h, m, s, t1, t2; cin >> h >> m >> s >> t1 >> t2; h %= 12; t1 %= 12; t2 %= 12; m /= 5; s /= 5; if (t1 > t2) swap(t1, t2); if (((h >= t1 && h < t2) + (m... |
#include <bits/stdc++.h> using namespace std; int key(int x); int main() { int t; cin >> t; int str[t]; for (int u = 0; u < t; u++) { str[u] = key(u); } for (int u = 0; u < t; u++) cout << str[u] << n ; return 0; } int key(int x) { int n, k, d, mini = 1000, m = 0; c... |
#include <bits/stdc++.h> int allocator_pos = 0; char allocator_memory[(int)1e5]; inline void *operator new(size_t n) { char *res = allocator_memory + allocator_pos; allocator_pos += n; assert(allocator_pos <= (int)1e5); return (void *)res; } inline void operator delete(void *) noexcept {} te... |
#include <bits/stdc++.h> using namespace std; int main() { int a[200]; int t, n, x; for (int i = 0; i <= 100; i++) a[i] = 0; for (int i = 0; i <= 100; i++) for (int j = 0; j <= 100; j++) { t = 3 * i + 7 * j; if (t > 100) break; a[t] = 1; } cin >> n; for (i... |
#include <bits/stdc++.h> using namespace std; template <class t> inline t read(t &x) { x = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) f |= c == - , c = getchar(); while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); if (f) x = -x; return x; } template ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 3e5 + 10; const long long MAXE = 3e5 + 10; const long long INF = 2e18 + 3; long long n, m, k, ec; long long from[2 * MAXE], to[2 * MAXE], prv[2 * MAXE], w[2 * MAXE], head[MAXN], sec[2 * MAXE]; long long comp[MAXN], d[MAXN], ss[MAXN... |
#include <bits/stdc++.h> using namespace std; bool hs(int mask, int i) { return mask & (1 << i); } int dp[300000]; void dfs2(vector<int> &adj, int i, int &c) { c++; dp[i] = 3; int u = adj[i]; if (dp[u] == 3) { return; } dfs2(adj, u, c); } void dfs(vector<int> &adj, int i, int &... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double PI = acos(-1.0); const int MAXN = 100005; const long long MOD = 1000000007; void base() { ios_base::sync_with_stdio(false); cin.tie(NULL); } pair<int, int> arr[100005]; int occ[100005]; int main() { base(... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, x = 1, y = 1; cin >> n; while (n--) { cin >> s; if (s == ULDR ) x++, y++; else if (s == UR || s == DL ) x++; else y++; } cout << 1LL * x * y << endl; } |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } int n; int m; int x, y; int main() { scanf( %d%d , &x, &y); int ans = 0, d = 1, xx = 0, yy = 0; while (true) { if (yy == y && xx <= x && xx + d >= x) break; ans++; xx ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.