func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, h; pair<int, int> arr[100010]; int res[100010]; int ptr = -1; int cnt, bits; int main() { cin >> n >> h; for (int i = 0; i < n; i++) { scanf( %d , &arr[i].first); arr[i].second = i; res[i] = 1; } sort(arr, arr + n); ... |
#include <bits/stdc++.h> using namespace std; inline long long add(long long a, long long b) { return (a % 1000000007 + b % 1000000007) % 1000000007; } inline long long mul(long long a, long long b) { return (a % 1000000007 * b % 1000000007) % 1000000007; } long long pwr(long long a, long long b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, i, a1, b1, y, y1, ans, ans1, ans2, x; cin >> n >> a >> b; for (i = 1; i <= n; i++) { cin >> x; y = x * a; ans = y % b; if (a != 0) cout << ans / a << ; else cout << x << ; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int dp[100005][30] = {0}; int A[40][40] = {0}; int main() { string s, b; cin >> s; int k; cin >> k; for (int i = 0; i < k; i++) { cin >> b; int x, y; x = b[0] - a ; y = b[1] - ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const long long oo = ((long long)1e18) + 7; int N, M, T, K, Q; vector<int> G[MAXN]; int num[MAXN]; int dep[MAXN]; int pa[MAXN][25]; int LOG = 20; int cnt = 0; int child[MAXN]; int DFS(int u, int par, int depth) { num[u] =... |
#include <bits/stdc++.h> using namespace std; bool checkPal(string s) { for (int i = 0, j = s.size() - 1; i <= j; i++, j--) { if (s[i] != s[j]) { return false; } } return true; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; ci... |
#include <bits/stdc++.h> using namespace std; long long a[1000010]; pair<long long, long long> st[1000010]; bool check(pair<long long, long long> a, pair<long long, long long> b, pair<long long, long long> c) { double k1 = 1.0 * (b.second - a.second) / (b.first - a.first); double k2 = 1.0 *... |
#include <bits/stdc++.h> int A[50], B[50]; int main() { int N, M, i, j, Max, now, Cnt; while (scanf( %d , &N) != EOF) { for (i = 0; i < N; ++i) { scanf( %d , &A[i]); } scanf( %d , &M); for (i = 0; i < M; ++i) { scanf( %d , &B[i]); } for (Max = i = 0; i < N... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 5; int arr[5], sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; } if (sum == 0) cout << -1 << endl; else if (sum % 5 != 0) cout << -1 << endl; else { int s = sum / 5; ... |
#include <bits/stdc++.h> using namespace std; const int N = 840; long long cnt[10]; long long f[10][N]; int main() { long long w; cin >> w; for (int i = 1; i <= 8; i++) cin >> cnt[i]; memset(f, 0xcf, sizeof f); f[0][0] = 0; long long res = 0; for (int i = 1; i <= 8; i++) { fo... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long int n, a, b; cin >> n >> a >> b; string s; cin >> s; long long int ans = n * (a + 2 * b) + 2 * a; int st = 0, e... |
#include <bits/stdc++.h> const int kN = 18; const int kT = 1 << kN; const int kInf = 0x3f3f3f3f; int a[kT]; bool fan_of[kT]; std::map<std::pair<int, int>, int> cal[4]; int Cal(int l, int r, int st) { if (r == l + 2) { int cnt_fan = (int)fan_of[l] + fan_of[l + 1], cnt_st = (st & 1) + (st >> 1); ... |
#include <bits/stdc++.h> using namespace std; long long d[111111]; long long sum[111111]; int q[111111]; long long cat[111111]; long long dp[101][100001]; long long getDP(int i, int j, int k) { return (long long)j * cat[j] + dp[i - 1][k] - j * cat[k]; } long long getUP(int i, int j, int k) { r... |
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 5; struct BIT { int a[N], n; void Init(int n) { this->n = n; } void add(int p, int v) { for (p = p + 1; p <= n; p += p & -p) a[p] += v; return; } int query(int p) { int res = 0; for (p = p + 1; p >= 1;... |
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { string integer; string decimal; bool isnegative = false; bool isdecimal = false; int pos = 0; if (s[0] == - ) { isnegative = true; pos++; } for (; pos < s.... |
#include <bits/stdc++.h> using namespace std; string op, s1, s2; map<string, int> mp; int solve(string s) { int ast, amp; ast = count(s.begin(), s.end(), * ); amp = count(s.begin(), s.end(), & ); return ast - amp; } string remove(string s) { s.erase(remove(s.begin(), s.end(), * ), s.e... |
#include <bits/stdc++.h> using namespace std; unsigned long long power(unsigned long long x, unsigned long long y) { if (y == 0) return 1; unsigned long long tmp = power(x, y / 2); tmp *= tmp; if (y % 2) tmp *= x; return tmp; } unsigned long long get(unsigned long long n) { if (n <= 9) r... |
#include <bits/stdc++.h> int main() { int n, m; while (scanf( %d %d , &n, &m) != EOF) { if (n * m < 2) { printf( 0 n ); } else { printf( %d n , n * m / 2); } } } |
#include <bits/stdc++.h> using namespace std; template <class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; } typedef vector<int> VI; typedef vector<pair<int, int> > VII; typedef vector<string> VS; struct Treap { int val, priority; int maxVal, size; ... |
#include <bits/stdc++.h> using namespace std; struct Dinic { struct Edge { int to, flow, next; }; vector<Edge> edges; vector<int> head, act, h; int S, D; void AddEdge(int from, int to, int f, int rev_f = 0) { edges.push_back({to, f, (int)edges.size()}); swap(edges.back().ne... |
#include <bits/stdc++.h> bool g[1111][1111]; int main() { int n, m; memset(g, false, sizeof(g)); scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf( %d%d , &u, &v); g[u][v] = true; } int count = 0; for (int i = 2; i < n; i++) { bool flag = false;... |
#include <bits/stdc++.h> char s1[100100], s2[100100], s3[100100]; bool dist[100100]; int pos[100100]; int main() { int n, t, i; int num = 0, po = 0; memset(dist, false, sizeof(dist)); scanf( %d%d , &n, &t); scanf( %s%s , s1, s2); for (i = 0; i < n; i++) s3[i] = 1 ; for (i = 0; i < n... |
#include <bits/stdc++.h> const int N = 517; const int mod = 998244353; using namespace std; inline int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - 0 , ch = getchar(); return x; } int n, k; long long d... |
#include <bits/stdc++.h> using namespace std; int t; long long sx, sy, ex, ey; int main(void) { cin >> t >> sx >> sy >> ex >> ey; int ans = 0; for (int i = 0; i < t; i++) { char c; cin >> c; if (sx == ex && sy == ey) { cout << ans << n ; return 0; } if... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100010]; int t[100010], p[18][100010], L[100010], d[100010]; vector<int> a[18][100010], c[100010]; void dfs(int u) { for (int i = 0; i < (int)g[u].size(); i++) { int v = g[u][i]; if (t[v] == -1) { t[v] = u; d[v] = d[u]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, c; cin >> n; for (long long i = 1; i <= n; i++) { cin >> c; ans += c; } c = (n == 1 ? 1 : n - 1); if (ans == c) cout << YES ; else cout << NO ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INT_INF = 1e9; const long long LL_INF = 1e18; const int MAXN = 200003; int n, m; int A[MAXN]; long long calc(int m) { long long ret = 0; map<int, int> dp; int sum = 0; dp[sum] = 1; long long add = 0; for (int i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-12; const int INF = 1 << 30; const long long LINF = 1ll << 61; const int BUFFER_SZ = 1 << 20; const int MOD = 1000 * 1000 * 1000 + 7; char BUFFER[BUFFER_SZ]; int gi() { int x; scanf( %d , &x); return x; } double gd() { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n, m, i, ans = 0, z, j; pair<long long, long long> a[105]; vector<pair<long long, long long> > q; cin >> n >> m; for (i = 1; i <= n; i++) a[i].second = 0; for (i = 1; i <= n; i++) cin >... |
#include <bits/stdc++.h> using namespace std; const long long M = 998244353; long long p[400001]; long long n; vector<long long> a(100001); bool check(long long x) { long long cnt[n + 1]; for (int i = 1; i < n + 1; i++) cnt[i] = 0; for (int i = 0; i < n; i++) cnt[a[i]]++; set<pair<long long,... |
#include <bits/stdc++.h> using namespace std; int n, m; char x[5][105]; int main() { cin >> n >> m; for (int i = 0; i < 4; i++) { for (int j = 0; j < n; j++) { x[i][j] = . ; } } if (m % 2 == 0) { printf( YES n ); for (int i = 1; i <= m / 2; i++) { x[1][i]... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> m; long long n, p; int main() { cin >> n; while (cin >> n) m[n]++; for (n = 1; n < 11; n++) p += m[n] * m[n * -1]; cout << p + m[0] * (m[0] - 1) / 2; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100], s, sum = 0; cin >> n >> s; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n - 1; i++) sum += a[i]; if (sum <= s) cout << YES n ; else cout << NO n ; return 0; } |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); int ar[1000]; int i; for (i = 0; i < n; scanf( %d , &ar[i++])) ; int b = 0, e = n - 1; int s = 0, d = 0; i = 1; while (b <= e) { if (ar[b] > ar[e]) { if (i == 1) s = s + ar[b]; else ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; const long long infll = 1e18 + 5ll; const long double eps = 1e-9; const int maxn = 1e5 + 100; const long long maxlog = 21; const int P = 97; const int mod = 1e9 + 9; int n, m, lvl[maxn], up[maxlog][maxn], sub[maxn], par[maxn], ans[... |
#include <bits/stdc++.h> using namespace std; int n, m, ed, x, y; int l[200005], qd[200005], qn[200005], p[200005]; void bd(int x, int y) { qd[++ed] = y, qn[ed] = l[x], l[x] = ed; } int notinE(int x, int y) { for (int i = (l[x]); i; i = qn[i]) if (qd[i] == y) return 0; return 1; } int main()... |
#include <bits/stdc++.h> using namespace std; int cmpfunc(const void *a, const void *b) { return (*(int *)a - *(int *)b); } long long int gcd(long long int m, long long int n) { if (n == 0) return m; return gcd(n, m % n); } long long int fastpow(long long int a, long long int b, long long int m) { ... |
#include <bits/stdc++.h> using namespace std; long long blockSize; long long cnt[100005]; long long ans[100005]; struct Query { long long L, R, idx; }; bool compare(Query x, Query y) { if (x.L / blockSize != y.L / blockSize) return x.L / blockSize < y.L / blockSize; return x.R < y.R; }... |
#include <bits/stdc++.h> #pragma warning(disable : 4101) using namespace std; const double pi = acos(-1.0); const int INF = 1000000000; const int MAX = 100007; const int MAX2 = 2000000; const int inf = (int)1e9 + 5; const long long mod = 1e9 + 7; const int BASE = 10; const int ST = 1000003; const ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } long long fun(long long n) { for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return i; } return n; } int main() { ios_base::sync_with_stdio(false); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 5009; string s[MAX]; int n, m, b[MAX], ans, a[MAX]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < m; i++) { memset(a, 0, siz... |
#include <bits/stdc++.h> using namespace std; const int maxN = 200 * 1000 + 10; pair<int, int> a[maxN]; int nx[maxN]; stack<int> curr; int main() { ios::sync_with_stdio(false); cin.tie(0); int d, n, m; cin >> d >> n >> m; for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second; ... |
#include <bits/stdc++.h> using namespace std; int ar[300005]; char ch[300005]; int n, m, ii, k; int pre[300005]; vector<pair<int, int>> v; void solve() { v.clear(); scanf( %d%d%s , &n, &m, ch); for (int i = 1; i <= n; i++) { pre[i] = pre[i - 1]; if (i & 1) { if (ch[i - 1] =... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; namespace math { int inc(int x, int y) { return x + y >= mod ? x + y - mod : x + y; } int qpow(int a, int x, int mo) { int res = 1; while (x) { if (x & 1) ... |
#include <bits/stdc++.h> using namespace std; const long long p = 1e9 + 7; long long read() { long long s = 0; char c = getchar(), lc = + ; while (c < 0 || 9 < c) lc = c, c = getchar(); while ( 0 <= c && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return lc == - ? -s : s; } void... |
#include <bits/stdc++.h> using namespace std; const int Nmax = 100000 + 10; int n; int nr[Nmax]; char s[Nmax], ans[Nmax]; bool ok(int L, int R) { int i, sum; if (L > R) return 0; for (i = 1; i <= n; ++i) nr[i] = s[i] - 0 ; if (L == 1 && nr[R] == 0) return 0; if (L == 2 && nr[1] != 1) re... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; set<int> ab[MAXN][2]; int N, M, Q; struct segTree { int f, t, mini, maxi; bool ans; segTree *L, *R; segTree(int _f, int _t) : f(_f), t(_t) { ans = false; mini = INT_MAX; maxi = INT_MIN; if (f != t) {... |
#include <bits/stdc++.h> using namespace std; int n, sum, m[17], r[17]; double ans; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> m[i]; for (int i = 1; i <= n; i++) cin >> r[i]; for (int i = 1; i <= 999999; i++) for (int j = 1; j <= n; j++) if (i % m[j] == r[j]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int o; long long w, s, t; cin >> o; for (int i = 0; i < o; i++) { cin >> w >> s >> t; long long minnn = min(s, t); cout << (w - minnn) + 1 << n ; } } |
#include<bits/stdc++.h> using namespace std; #define ll long long #define mtv(kit) cout<<#kit<< - <<kit<< n ; #define ff first #define ss second #define pb push_back #define rep(i,a,b) for(ll i=a;i<b;i++) #define pii pair<ll , ll> #define all(x) x.begin(),x.end() #define nl n #define ump ... |
#include <bits/stdc++.h> using namespace std; int cnt[5]; int main() { int n, t; cin >> n; memset(cnt, 0, sizeof(0)); for (int i = 0; i < n; i++) { cin >> t; cnt[t]++; } bool flag = true; int ret = 0; int minN = min(cnt[1], cnt[2]); cnt[3] += minN; cnt[1] -= min... |
#include <bits/stdc++.h> using namespace std; int m, n, t, k; int main() { while (scanf( %d%d , &n, &k) == 2) { if (k > n || (n >= 2 && k == 1)) printf( -1 n ); else if (k == 1) printf( %c n , a ); else { int m = n - (k - 2); for (int i = 0; i < m; i++) print... |
#include <bits/stdc++.h> using namespace std; inline 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> #pragma GCC optimize( O3 ) using namespace std; const long long INF = (long long)1e18 + 100; long long safe_sum(long long a, long long b) { long long s = (a + b); s = min(s, INF); return s; } long long safe_mult(long long a, long long b) { if (a == 0 || b == 0) retur... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int a[N][N]; int dp1[N][N] = {0}, dp2[N][N] = {0}, dp3[N][N] = {0}, dp4[N][N] = {0}; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j]; for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; struct pvec { long long int x, y; pvec(long long int x = 0, long long int y = 0) : x(x), y(y) {} pvec operator-(pvec p) { return pvec(x - p.x, y - p.y); } bool operator==(pvec p) { return x == p.x and y == p.y; } long long int dot(pvec p) { return x ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a = 1, n; cin >> n; for (int i = 0; i < n; i++) { a *= i + 1; } cout << a * 2 / n / n; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long l, r, b, c, a; long long m; cin >> l >> r >> m; for (long long i = l; i <= r; i++) { a = i; long long... |
#include <bits/stdc++.h> using namespace std; double a, v, d, w, l, ans, mid, t2, t; bool check(double maxv) { return d - ((maxv + w) / 2) * (((maxv - w) * 2) / a) > 1e-8; } int main() { scanf( %lf %lf %lf %lf %lf , &a, &v, &l, &d, &w); w = min(min(w, v), sqrt(2 * a * d)); if (2 * a * d + w * ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200020; int n, a[Maxn]; long long sum[Maxn]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , a + i); for (int i = 0; i < n - 1; i++) { int cur; for (cur = 1; cur <= i;) { int val = i / cur; ... |
#include <bits/stdc++.h> int main() { int n, i; int maximum, maxIndex, target; int A[1000]; scanf( %d , &n); maximum = -1; for (i = 0; i < n; ++i) { scanf( %d , &A[i]); if (A[i] > maximum) { maximum = A[i]; maxIndex = i; } } A[maxIndex] = -2; targe... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; } vector<int> v(n), d(n); queue<int> q; q.push(0); v[0] = 1; int l = 0; while (!q.empty()) { int nn = q.size(... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, k; int a[2011]; long long pre[1 << 11 + 1]; long long cur[1 << 11 + 1]; void solve() { memset(pre, 0, sizeof(pre)); pre[0] = 1; for (int i = 0; i < n; i++) { memset(cur, 0, sizeof(cur)); for (int... |
#include <bits/stdc++.h> using namespace std; const long long dp = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n, a; cin >> n >> a; vector<int> vec(n); int cnt = 0; for (int i = 0; i < n; i++) { cin >> vec[i]; if (vec... |
#include <bits/stdc++.h> const int maxn = 2005; const int inf = 1e9; using namespace std; vector<pair<int, int>> G[maxn]; vector<int> C[maxn], v; bool critical[maxn * maxn]; vector<int> seen, sum, col, depth, up; void dfs(int node, int ind) { seen[node] = 1; int minFromSons = inf; up[node] =... |
#include <bits/stdc++.h> int main() { int x, count = 0, i; char ar[50]; for (i = 0; i < 9; i++) scanf( %c , &ar[i]); for (i = 0; i < 9; i++) { if (ar[i] == ar[8 - i]) count++; } if (count == 9) printf( YES ); else printf( NO ); } |
#include <bits/stdc++.h> using namespace std; const int shape[4][4][2] = {{{1, 0}, {2, 0}, {1, 1}, {1, 2}}, {{1, 0}, {2, 0}, {2, -1}, {2, 1}}, {{0, 1}, {0, 2}, {-1, 2}, {1, 2}}, {{0, 1}, {0, 2}, {1, 1}, {2, 1}}}; int x, y; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100009; int sol, qs[N], qe[N], sorted[N], ans[N], a[N], s, e; unordered_map<int, int> freq; void add(int el) { sol -= !(freq[el] ^ el); freq[el]++; sol += !(freq[el] ^ el); } void remove(int el) { sol -= !(freq[el] ^ el); freq... |
#include <bits/stdc++.h> using namespace std; template <class T> using min_pq = priority_queue<T, vector<T>, greater<T>>; const int MAXN = 1e5 + 10, MAXQ = 3e5 + 10, MAXL = 20, ALP = 26, MOD = 1e9 + 7, MAXK = 17, INF = 1e9 + 10, MAXA = 30, MAXB = 24, MAXBB = (1 << MAXB); const string no = NO n , ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, sum1 = 0, res1 = 0, last = 0; bool flag = true; cin >> n; unordered_map<long long int, long long int> m; vector<pair<long long int, long long i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long int t, temp, i, ans = 0, n, m, index, j; cin >> n >> m; vector<pair<long long int, long long int> > pa; vector<long long int> v(n), finger(m); for (i = 0; i < n; i++) { cin >> v[i]; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long inf2 = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; namespace fastio { char in[100000]; int itr = 0, llen = 0; char get() { if (itr == llen) llen = fread(in, 1, 100000, stdin), itr... |
#include <bits/stdc++.h> using namespace std; const int N = 5555; int hackable[N]; int sols[N]; int pts[N][13]; int score[N]; int z[N]; int bound[N]; int cnt_hack[N]; int rgt[N]; int task[N][13]; int guys[N]; int main() { int n; scanf( %d , &n); for (int j = 0; j < 3; j++) { ... |
#include <bits/stdc++.h> using namespace std; long long m, l, r, k; struct Matrix { long long W[2][2]; }; Matrix operator*(const Matrix& A, const Matrix& B) { Matrix S; memset(S.W, 0, sizeof(S.W)); for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int l = 0; l < 2; ++l... |
#include <bits/stdc++.h> using namespace std; int N; vector<int> a, b, c; multiset<int> m; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> N; a.resize(N); b.resize(N); c.resize(N); for (int i = 0; i < N; i++) { cin >> a[i]; } for (i... |
#include <bits/stdc++.h> using namespace std; struct node { int h, w, r; } edge[110]; bool vis[11]; int x[5000000]; int n, k, t; void init() { cin >> n >> k >> t; for (int i = 1; i <= k; i++) cin >> edge[i].h >> edge[i].w >> edge[i].r; } void solve() { int l = 0; for (int j = 1; j ... |
#include <bits/stdc++.h> using namespace std; const int TAM = 100000 + 15; const long long MOD = 1000000007LL; const double PI = 3.14159265359; long long add(long long x, long long y) { return (x + y + 2 * MOD) % MOD; } long long mult(long long x, long long y) { return (add(x, 0) * add(y, 0)) % MOD; }... |
#include <bits/stdc++.h> using namespace std; bool compare(pair<int, int> p1, pair<int, int> p2) { return p1.first > p2.first; } long long int power(int a, int b) { if (b == 0) return 1; return a * power(a, b - 1); } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }... |
#include <bits/stdc++.h> using namespace std; long long ans, i, N, H, alive, last1, last2, last3, a, b, c; long long A[2][32][32][32], B[2][32][32][32]; int main() { cin >> N >> H; A[1][0][0][0] = 4; for (i = 1; i < N; i++) { for (alive = 0; alive < 2; alive++) for (last1 = 0; i - last... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e5 + 10; long long t[2][4 * N], a, b; void update(int l, int r, int j, int pos, int val) { if (r < pos || pos < l) return; if (pos <= l && r <= pos) { t[0][j] = min(a, t[0][j] + val); t[1][j] = min(b, t[1][j] + val); retu... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int a[N], b[N]; bool p[N]; vector<int> P; pair<bool, int> c[N]; int num(string s) { int x = 0; for (int i = 1; i < s.size(); i++) x = x * 10 + (s[i] - 0 ); return x; } int main() { int n, m, t = 0, T = 0; string s... |
#include <bits/stdc++.h> using namespace std; int n, w, m; double a[100]; int kol[100]; vector<pair<int, double> > v[100]; int main() { cin >> n >> w >> m; double q = n * w * 1.0 / m; memset(kol, 0, sizeof(kol)); for (int i = 0; i < 100; ++i) a[i] = w; for (int i = 0; i < m; ++i) { ... |
#include <bits/stdc++.h> using namespace std; struct Antenna { int iniLeft, iniRight; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int nbAntennas, totLen; cin >> nbAntennas >> totLen; vector<Antenna> ants(nbAntennas); for (int iAnt = 0; iAnt < nbAntennas; ++iAnt) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m, k; cin >> n >> m >> k; vector<ll> vec(m); for (ll &v : vec) cin >> v; ll ans = 0, i = 0; while (i < m) { ll t = (vec[i] - i - 1) / k, j = i + 1; ... |
#include <bits/stdc++.h> using namespace std; int p[2222], n; int D[2222]; int Find(int x) { if (D[x] != 0) return D[x]; if (p[x] == -1) return D[x] = 1; else return D[x] = Find(p[x]) + 1; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &p[i]); in... |
#include <bits/stdc++.h> using namespace std; const int64_t INF = 4e18, MOD = 998244353; template <int64_t maxn> struct NTT { constexpr static int lg2(int n) { return 32 - __builtin_clz(n - 1); } const static int MAXN = 1 << lg2(maxn), MOD = 998244353, root = 3; int rev[MAXN], rt[MAXN]; int mul(... |
#include <bits/stdc++.h> using namespace std; using ll = long long; #define f(i,q,n) for(int i=(int)q;i<n;i++) #define pb push_back #define debug(x) cout<<#x<< <<x<<endl; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t=1; cin>>t; while(t--){ int n,m; ... |
#include <bits/stdc++.h> using namespace std; using namespace std; long long a[200005]; struct poi { long long val; int pos; } tp; bool operator<(const poi &a, const poi &b) { return (a.val > b.val) || (a.val == b.val and a.pos > b.pos); } priority_queue<poi> q; int main() { int n; ... |
#include <bits/stdc++.h> using namespace std; string str; const long long MOD = 1e9 + 7; template <class T> inline void amin(T &x, const T &y) { if (y < x) x = y; } template <class T> inline void amax(T &x, const T &y) { if (x < y) x = y; } int read() { long long s = 0, f = 1; char c... |
#include <bits/stdc++.h> using namespace std; string str; int make(int star, int en) { if (en - star >= 7) return -1e7; if (en - star >= 1 && str[star] == 0 ) return -1e7; if (str[star] == 0 && str[en] != 0 ) return -1e7; int sum = 0; for (int i = star; i <= en; i++) { sum = sum * 10... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-9; static const double PI = acos(-1.0); char ans[4][110]; int main() { int n; while (scanf( %d , &n) > 0) { if (n == 1) { printf( a na nb nb n ); continue; } ans[0][0] = a ; ans[1][0] = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a; vector<pair<int, int> > v; cin >> n; for (i = 0; i < n; ++i) { cin >> a; v.push_back(make_pair(a, i + 1)); } for (i = 0; i < n; ++i) { cin >> a; v.push_back(make_pair(a, i + 1)); } long lo... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } int main() { ios_base::sync_with_stdio(false... |
#include <bits/stdc++.h> using namespace std; const bool debug = 0; struct mout { int i, j; long long first; mout(){}; mout(int i, int j, long long first) : i(i), j(j), first(first) {} }; int main() { if (!debug) { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); } ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e14; const long long TE3 = 1005; const long long TE5 = 300005; const string YN[2] = { NO , YES }; using namespace std; long long f(long long n, vector<long long>& q1, vector<long long>& q2) { unorder... |
#include <bits/stdc++.h> using namespace std; const long long oo = 1e18; struct dta { int u, id; dta(int _u = 0, int _id = 0) { u = _u; id = _id; } }; struct TDij { long long val; int x; TDij(long long _val = 0, int _x = 0) { x = _x; val = _val; } }; inl... |
#include <bits/stdc++.h> using namespace std; vector<string> solve(int k) { vector<string> s; if (k == 0) { s.push_back( + ); return s; } vector<string> prev = solve(k - 1), rev; for (int i = 0; i < prev.size(); i++) { string temp; for (int j = 0; j < prev.size(); j++) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0; char c; while ((c = getchar()) < 0 || c > 9 ) ; do { s = s * 10 + c - 0 ; } while ((c = getchar()) >= 0 && c <= 9 ); return s; } const int N = 3010, M = 310; int n, m, rp[M]; double f[M][2... |
#include <bits/stdc++.h> using namespace std; const int siz = 1e5 + 10; const long long modu = 1e9 + 7; int pre[13] = {1, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 341}; int main() { int n; scanf( %d , &n); if (n < 13) { cout << pre[n] << endl; return 0; } long long n1 = ... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int main() { int n, num, flag = 1, f; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &num); ++mp[num]; } map<int, int>::iterator it = mp.begin(); int ln = it->first; int lm = it->second; int l =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.