func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) ... |
#include <bits/stdc++.h> using namespace std; const int INF = 99009000; const long long MOD = 1000000007; const int N = 100001; int main() { { ios::sync_with_stdio(false); cin.tie(nullptr); }; long long a, b, w, x, c; cin >> a >> b >> w >> x >> c; long long A = a * w + b; l... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 5; long long res = 0, mx = 0; long long sub[MAX_N]; int custo[MAX_N]; vector<vector<int> > g(MAX_N); void dfs(int node, int p = -1, int d = 0) { res += 1LL * d * custo[node]; sub[node] = custo[node]; for (auto to : g[node]) ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:20000000 ) using namespace std; template <typename T1, typename T2, typename T3> struct triple { T1 a; T2 b; T3 c; triple(){}; triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {} }; template <typename T1, typename T2, typename T3>... |
#include <bits/stdc++.h> using namespace std; int n, deg[8010], type[8010], in[8010]; long long ans = 0; bool e[8010][8010]; char s[8010]; queue<int> q; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %s , s + 1); for (int j = 1; j <= n / 4; j++) { int k = (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 7, MAXM = 1e5 + 5, MOD = 1e9 + 7, bit_one = (1 << MAXN) - 1; int n, ans; int w[MAXN]; int pre_process[MAXN][(1 << MAXN)][(1 << MAXN)]; int add(int a, int b) { int c = a + b; while (c >= MOD) c -= MOD; return c; } int mul(int a, i... |
#include <bits/stdc++.h> using namespace std; long long sum[1000006], add[1000006]; int Q[1000006], A[1000006]; int main() { int n, m, a; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &a); A[a + 1] = 0; int head = 1, tail = 0, mx = 0; for (int j = 1; j <= ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, m; cin >> n >> m; vector<long long int> graph[n + 1]; for (long long int i = 0; i < m; i++) { long... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const double eps = 1e-50; const int maxN = 1100; const double inf = 1e50; int n, m; vector<int> a[maxN]; double d[maxN][maxN]; int b[maxN]; double c[maxN][maxN]; bool have[maxN]; double t[maxN][maxN], s[max... |
#include <bits/stdc++.h> using namespace std; void out() { cout.flush(); int n; cin >> n; exit(0); } int tree[1 << 21]; int st = 1 << 20; void add(int pos, int d) { pos += st; for (; pos; pos >>= 1) tree[pos] += d; } int findKth(int k) { int pos = 1; while (pos < st) { ... |
#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() { cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a, b; for (int i = 0; i < n; ++i) { int x; cin >> x; if (x == 0) continue; a.push_back(x); } for (int i = 0; i < n; ++i) { int x; cin >> x; if (x == 0) continue; ... |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 7; int main() { int n, q; cin >> n >> q; vector<int> a(n + 10, 0), b; vector<pair<int, int>> v; vector<int> cnt(n + 10, 0), cnt1(n + 10, 0); set<int> s; for (int i = 1; i <= n; i++) cin >> a[i], s.insert(a[i]); for... |
#include <bits/stdc++.h> using namespace std; const int oo = 1e9 + 7; int dp[111][1 << 18], tr[111][1 << 18], prime[111], lp, mark[111]; int getbit(int x, int pos) { return (x >> pos) & 1; } int onbit(int x, int pos) { return (x + (1 << pos)); } void init() { int nt[200]; for (int i = (1), _b = (60)... |
#include <bits/stdc++.h> using namespace std; void func() { long long n; cin >> n; std::vector<pair<long long, long long> > v(n); for (long long i = 0; i < n; ++i) { cin >> v[i].first; } for (long long i = 0; i < n; ++i) { cin >> v[i].second; } sort(v.begin(), v.end()); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) cout << 8 << n - 8; else cout << 9 << n - 9; } |
#include <bits/stdc++.h> using namespace std; const long long MAX = 2005; const long long INF = 1e9 + 5; char grid[MAX][MAX]; long long dp[MAX][MAX]; auto solve(long long n, long long k) -> string { auto inside = [&](long long row, long long col) { return (row < n and row >= 0 and col < n and col ... |
#include <bits/stdc++.h> using namespace std; long long mod(long long a) { return a >= 0 ? a % 1000000009 : (1000000009 + a % 1000000009) % 1000000009; } long long st[2 * 3000010]; long long lz[2][2 * 3000010]; long long fib[2][3000010]; long long fibSum[2][3000010]; long long getFib(int i, long lon... |
#include <bits/stdc++.h> const int N = 100005; using namespace std; inline int Getint() { register int x = 0, f = 1; register char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ch = getchar()... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; long long c[2][2][maxn][maxn]; int lowbit(int s) { return s & (-s); } void modify(int x, int y, int v) { for (int i = x; i < maxn; i += lowbit(i)) for (int j = y; j < maxn; j += lowbit(j)) c[x & 1][y & 1][i][j] ^= v; return... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); long long n, k, m; cin >> n >> k >> m; vector<long long> a(k); long long second = 0; for (long long i = 0; i < k; i++) { cin >> a[i]; second += a[i]; } sort(a.begin(), a.end()); ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const double EXP = 2.7182818284590452; const double Pi = 3.14159265; const double EPS = 1e-11; const int INF = 1000 * 1000 * 1000; const long long INFL = INF * 1000 * 100; char arr[2003][2003], c; bool was[2003][2003]; int n, ... |
#include <bits/stdc++.h> using namespace std; int m; void Add(int &a, int b) { a += b; if (a >= m) a -= m; } int dp[1010][110][2]; int main() { int n, k; while (scanf( %d%d%d , &n, &k, &m) == 3) { memset(dp, 0, sizeof(dp)); dp[0][0][0] = 1; long long tmp = 1; for (int... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, m, q, a[N][N], op, x, y, R[N][N], L[N][N], U[N][N], D[N][N]; void update() { if (a[x][y]) { a[x][y] = 0; D[x][y] = U[x][y] = R[x][y] = L[x][y] = 0; for (int i = x - 1; i >= 1 && a[i][y]; --i) D[i][y] = x - i; fo... |
#include <bits/stdc++.h> using namespace std; int main() { long double n; int m; cin >> n >> m; long sum = n; long double newsum = 0.0; for (int i = 0; i < n; i++) { newsum += pow((long double)i / (long double)n, m); } cout << sum - newsum; } |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 18 | 7; int a[N], b[N], o[N]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, s; cin >> n >> s; --s; for (int i = 0; i < n; ++i) cin >> a[i], b[i] = a[i]; for (int i = 0; i < n; ++i) if (!a[i]) a... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < int(n); i++) { cin >> a[i]; } vector<vector<int>> g(n); for (int i = 0; i < int(n - 1); i++) { int p; cin ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 4e5 + 5; const int BN = 25; int n, a[N], cnt; vector<int> v[BN]; int main() { ios ::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } int res = 0; for (... |
#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 n, m; cin >> n >> m; long long ans = (n * (n + 1)) / 2; long long x = (n - m) / (m + 1); long long y = (n - m) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int x = a; while ((a / x + b / x) < n) x--; if (a < x) cout << a; else if (b < x) cout << b; else cout << x; } |
#include <bits/stdc++.h> using namespace std; long long n, v[5000], d[5000], p[5000]; bool used[5000]; int main() { cin >> n; for (long long i = 0; i < n; i++) { used[i] = true; cin >> v[i] >> d[i] >> p[i]; } vector<long long> ans; for (long long i = 0; i < n; i++) { long l... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m, nx, ny; int A[N], B[N], C[N], D[N], X[N], Y[N], vis[N]; int ans = 1; set<int> s[N << 2]; vector<int> e[N]; struct ST { int mx, mn; } tr[N << 2]; void upd(int p, int l, int r) { int ls = p << 1, rs = p << 1 | 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1007; struct P { int x, y, k; int d; void in() { scanf( %d %d %d , &x, &y, &k); d = x * x + y * y; } } p[N]; bool cmp(P a, P b) { return a.d <= b.d; } int main() { int n, s, i; int M = 1000000; while (~scanf(... |
#include <bits/stdc++.h> using namespace std; struct pst { struct node { int v; node *l, *r; node() : node(0x3f3f3f3f) {} node(int v) : v(v), l(nullptr), r(nullptr) {} }; int n; vector<node *> root; deque<node> buffer; pst(int n) : n(n) { root.push_back(build(0, n - 1... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; const int INF = (int)1e9; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; long long n, m; cin >> n >> m; vector<long long> a(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; long long x, y, z; wh... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n]; int c[101] = {0}; for (int i = 0; i < n; i++) cin >> a[i]; long long int sum = a[0]; int b[n]; b[0] = 0; c[a[0]]++; for (int i = 1; i < n; i++) { sum = sum + a[i]; long l... |
#include <bits/stdc++.h> int main() { int n, k, i, j, p; while (~scanf( %d%d , &n, &k)) { if (k < n / 2 || (n == 1 && k != 0)) printf( -1 n ); else { if (k == n / 2) { for (i = 1; i < n; i++) printf( %d , i); printf( %d n , n); } else { p = k ... |
#include <bits/stdc++.h> int main() { int a; scanf( %d , &a); int n = 7, i = 1, sum = 0, k = 1; while (a) { int num = a % 10; if (num == 4) sum += 1 * k; else sum += 2 * k; a /= 10; i++; k *= 2; } printf( %d , sum); } |
#include <bits/stdc++.h> using namespace std; long long n, m, d, nn = 0, as[200069], pst[200069], dp[256], mx[256]; pair<long long, long long> a[2][200069]; map<long long, long long> com; int main() { long long i, j, ii, k, p[2], mk, cm = 0, cr = 0, z = -1e18; scanf( %lld%lld%lld , &n, &m, &d); co... |
#include <bits/stdc++.h> using namespace std; int n, a[110]; vector<int> prime; bool flag[40010]; int cnt[40010][110]; void init(int MX) { for (int i = 2; i <= MX; i++) { if (!flag[i]) prime.push_back(i); for (int j = 0; j < prime.size() && i * prime[j] <= MX; j++) { flag[i * prime[j... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; vector<int> graph[N]; int pa[N]; int getHeight(int u, int pre) { int res = 1; pa[u] = pre; for (auto e : graph[u]) { if (e == pre) { continue; } int subHeight = getHeight(e, u); res = max(res, subHeigh... |
#include <bits/stdc++.h> long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline long long qmul(long long a, long long b, long long m) { long long res = 0; while (b) { if (b & 1) res = (res + a) % m; a = (a << 1) % m; b = b >> 1; } return res; } inline ... |
#include <bits/stdc++.h> using namespace std; const int N = 3030, D = 15; long long f[D][N] = {}; long long ans = 0; int n, k, v[N] = {}; long long w[N][N] = {}; void merge(int d, int l, int r) { copy(f[d - 1] + 1, f[d - 1] + k + 1, f[d] + 1); for (int i = l; i <= r; ++i) { int V = min(v[i],... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; struct people { int p, t, i; pair<int, int> ans; } G1[M], G2[M]; bool cmp(people a, people b) { if (a.p - a.t != b.p - b.t) return a.p - a.t < b.p - b.t; return a.p < b.p; } bool cmp1(people a, people b) { return a.p < b... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, x = 0; cin >> n >> k; char a; for (i = 0; i < n; i++) { cin >> a; if (a == # ) { x++; if (x == k) break; } else x = 0; } cout << (x == k ? NO : YES ); return 0; } |
#include <bits/stdc++.h> using namespace std; bool vowel(char c) { string s = aeiou ; for (int i = 0; i < 5; i++) if (c == s[i]) return true; return false; } bool rhyme(string s1, string s2, int k) { int i = s1.size() - 1, j = s2.size() - 1; int cnt = 0; while (i >= 0 && j >= 0) {... |
#include <bits/stdc++.h> using namespace std; int main() { int a; int x; cin >> a; x = 6 * a * (a - 1) + 1; cout << x << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, x, y; cin >> n >> x >> y; int dif = y - x; int minb = 1e9; for (int i = 1; i * i <= dif; ++i) { if (dif... |
#include <bits/stdc++.h> using namespace std; float calc(int h, int d, int c, int n) { float a; if (h % n == 0) { a = (h / n) * c; } else a = ((h / n) + 1) * c; return a; } int main() { int p = 0, q = 0; int h, d, c, n, eh; int hh, mm; cin >> hh >> mm; cin >> h >>... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int maxnnn = (int)1e6 + 10; int aaaa[maxnnn]; int bbbb[maxnnn]; int l[maxnnn]; int r[maxnnn]; int nnnnn... |
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 5; const int mod = (int)1e9 + 7; const int logN = 17; const int inf = 1e9; const int N = 1e6 + 5; int way[N][2], size[N], all[N][30][2], n, m, a[N], S = 1; void insert(int x) { int node = 1; for (int i = 29; i >= 0; i--)... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 7; int m, k; long long n, x, s, a[MAX], b[MAX], c[MAX], d[MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k >> x >> s; for (int i = 1; i <= m; ++i) { cin >> a[i]; } for (int i = 1; i <= m... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(), f = 0; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = 1; for (; c >= 0 && c <= 9 ; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18; const int mod = (int)1e9 + 7; const int MAXN = (int)4e5 + 5; long long n, ans[MAXN], ext[MAXN]; vector<pair<int, pair<int, int>>> sorg[MAXN]; vector<pair<int, int>> adj[MAXN]; int a[MAXN]; const int L = 20; int geri... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int arr = 2e5 + 10; const int ar = 2e3 + 10; const long double pi = acos(-1); const long double eps = 1e-10; const long long md = 1e9 + 7; vector<int> reb[(int)(3e5 + 10)]; bool use[(int)(3e5 + 10)]; int n, m; int pred[... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); long long n; cin >> n; string s; cin >> s; vector<long long> pref(n + 1); pref[0] = 0; char c; for (long long i = 1; i <= n; ++i) { c = (int)s[i - 1] - 48... |
#include <bits/stdc++.h> template <class T> T gcd(T a, T b) { T r; while (b != 0) { r = a % b; a = b; b = r; } return a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> T sqr(T x) { return x * x; } template <class T> T... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int MAXN = 3 * int(1e5) + 10; int pos[MAXN]; int a[MAXN]; int n, q; int deleted = -1; int fenw[MAXN]; void upd(int x, int d) { for (int i = x; i < n; i = (i | (i + 1))) fenw[i] += d; } int sum(int r) { int res = 0... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t = 1; while (t--) { long long n, m; cin >> n >> m; long long len = n, l, r; for (long long i = 0; i < m; i++) { cin >> l >> r; len = min(len, r ... |
#include <bits/stdc++.h> using namespace std; int n, m, ans; int num[1000010], flag[1000010]; int fa[1000010], vis[1000010]; int Find(int x) { return fa[x] = x == fa[x] ? x : Find(fa[x]); } void Union(int x, int y) { int fx = Find(x); int fy = Find(y); if (fx != fy) fa[fy] = fx; } int main()... |
#include <bits/stdc++.h> const int MAXN(1e5 + 5); inline int read() { char ch(getchar()); int x(0); int flag(1); while (!isdigit(ch)) { if (ch == - ) { flag = -1; } ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getcha... |
#include <bits/stdc++.h> using namespace std; template <class T> const T& max(const T& a, const T& b, const T& c) { return max(a, max(b, c)); } template <class T> const T& min(const T& a, const T& b, const T& c) { return min(a, min(b, c)); } void sc(int& a) { scanf( %d , &a); } void sc(long lo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, sz[maxn], ans[maxn]; long long sum; vector<int> adj[maxn], vec; void dfs(int u, int par) { sz[u] = 1; for (auto v : adj[u]) if (v != par) { dfs(v, u); sz[u] += sz[v]; } } void DFSend(int u,... |
#include <bits/stdc++.h> using namespace std; int n, k, mx; int a[4000400], q[4000400], dis[2005]; bool vis[2005]; int head[2005], edgenum; struct Edge { int to, nxt; } edge[4000400]; inline void add(int u, int v) { edge[++edgenum].to = v; edge[edgenum].nxt = head[u]; head[u] = edgenum; ... |
#include <bits/stdc++.h> using namespace std; const long double Fictive = 5e18; struct str { long long k, b; long double eval(long double x) { return x * (long double)k + b; } }; vector<str> vec; inline long double get_x(str fi, str se) { return (long double)(fi.b - se.b) / (long double)(se.k - ... |
#include <bits/stdc++.h> using namespace std; int n, a[3001], b[3001], cnt = 1, sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); while (1) { if (cnt == a[++sum]) cnt++; else { cout << cnt; return 0; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a(10, 0), b(10, 0); string n; string num; cin >> n >> num; for (auto w : num) { a[w - 0 ]++; } int minimum = INT_MAX; for (auto w : n) b[w - 0 ]++; for (int i = 0; i < 10; i++) { if (i != 2 && i ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 22; const int maxp = 777 + (1 << (maxn - 2)); const int maxm = 1E5 + 77; char S[maxm]; int N, M, _V[maxn][maxm], V[maxm], dp[maxn][maxp], ans = 1E9 + 7; int main() { scanf( %d%d , &N, &M); for (int i = 0; i < N; ++i) { scanf( %s ... |
#include <bits/stdc++.h> using namespace std; const int mxn = 2 * 100000 + 6; int n, root; int a[mxn]; int c[mxn]; int s[mxn]; int base; int ans = 0x3f3f3f3f; int main() { cin >> n >> root; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); if (i == root && a[i] != 0) { ++b... |
#include <bits/stdc++.h> using namespace std; const int N = 1003, INF = 2000000009; struct ban { int x, i; ban() {} ban(int x, int i) { this->x = x; this->i = i; } }; int n, m; int s, f; pair<pair<int, int>, int> b[N * 30]; vector<ban> a[N]; int hi; bool c[N]; int pi[N]... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; struct node { int next[2]; int cnt; }; node make_node() { node nd; nd.cnt = 0; nd.next[0] = nd.next[1] = -1; return nd; } node t[MAXN * 30]; int sz = 0; int bs = 29; void add(int tiv, int d) { (0); ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int n, k, m, res = 0, sm = 0, edge = -1, nb = 1; int a[200055], b[200050], nxt[200505], dp[200005] = {0}, ans[500005]; multiset<int> st, st1, st2; set<int> stres; string s, s1, s2, s3, s4; vector<int> v[200050], vnode, vans, v3... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; const int INF = 1e9; int n, ans, ansl, ansr; char s[maxn]; int a[maxn]; struct Node { int pre, min, cnt, id; Node() { pre = cnt = id = 0; min = INF; } Node(int _pre, int _min, int _cnt, int _id) : ... |
#include <bits/stdc++.h> int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2}; using namespace std; class PAIR { public: long long int first; long long int second; long long int third; }; vector<long long int> V, V2, V3; long long int ar... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 300 * 1000 + 5; int n, k, arr[Maxn]; int main() { scanf( %d%d , &n, &k); int Min = INT_MAX, Max = 0; for (int i = 0; i < n; i++) scanf( %d , &arr[i]), Min = min(Min, arr[i]), Max = max(Max, arr[i]); sort(arr, arr + n); for ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, cnt, t; scanf( %d , &t); while (t--) { scanf( %d %d , &a, &b); cnt = 0; while (a > 0 && b > 0) { if (a > b) swap(a, b); int tmp = b / a; cnt += tmp; b -= tmp * a; } printf( ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; struct Edge { int u, v, w, id; Edge() {} Edge(int a, int b, int c, int d) : u(a), v(b), w(c), id(d) {} bool operator<(const Edge e) const { return w > e.w; } } e[maxn * maxn]; int fa[maxn << 1]; int Find(int x) { return fa[... |
#include <bits/stdc++.h> using namespace std; const long long hell = 1000000007; const long long INF = 1000000000; void solve() { long long n; cin >> n; map<long long, long long> mp; long long a[n]; long long s = 0; for (long long i = 0; i < n; i++) { cin >> a[i]; s += a[i]; ... |
#include <bits/stdc++.h> using namespace std; int a[200005], f[200005], t[2000006], mx, mxbr; bool bio[2000006], p[2000006]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; p[a[i]] = 1; mxbr = max(mxbr, a[i]); } for (int i = 2; i <= 2 * mxbr; i++) ... |
#include <bits/stdc++.h> int a[100005]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int flag = -1; int sum = 0; int sum1 = 0; int ans = 1; for (int i = 1; i < n; i++) { if (a[i] == a[i - 1]) ans++; else { if (flag =... |
#include <bits/stdc++.h> int main() { int w1, h1, w2, h2, a, b, sum; scanf( %d%d%d%d , &w1, &h1, &w2, &h2); a = (h2 + h1 + 2) * 2; b = w1 * 2; sum = a + b; printf( %d n , sum); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; int N, a[169], c[169], K; long long int M = -10000000000000LL; int ned, prv[169], first[169]; long long int cap[20009], cost[20009], to[20009], nxt[20009], dist[169], pot[169]; void init() { memset(first, -1, siz... |
#include <bits/stdc++.h> using namespace std; char st[300010], opt[10]; int n, q; int main() { int i, j; scanf( %d%d , &n, &q); scanf( %s , st); int cnt = 0, ans = 0; for (i = 0; i < n; ++i) { if (st[i] == . ) cnt++; else { ans += max(cnt - 1, 0); cnt = 0... |
#include <bits/stdc++.h> using namespace std; template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int INF = (1 << 29); int n, m; int table[8][8]; void init() {} void input() { cin >> n >> m; for (int i = (0... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int res1 = max((3 * a) / 10, (a - (a / 250) * c)); int res2 = max((3 * b) / 10, (b - (b / 250) * d)); if (res1 > res2) cout << Misha << endl; else if (res1 < res... |
#include <bits/stdc++.h> using namespace std; long long func(long long a, long long b, long long c) { if (a % 2 != b % 2) return (1ll << 60); long long x = min(a + c, b + c); return a + b + c - x; } int main(void) { int i; long long a, b, c; cin >> a >> b >> c; long long ans = (1ll <... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); while (b) { long long t = b; b = a % b; a = t; } return a; } long long mul(long long a, long long b, long long m) { long long q = (long double)a * (long double)b /... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; template <class A> istream& operator>>(istream& in, vector<A>& a) { for (A& i : a) in >> i; return in; } ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; vector<string> museum; vector<vector<int> > pictures; vector<vector<bool> > used; queue<pair<int, int> > line; vector<pair<int, int> > req; void BFS(int& i, int& j) { line.push(make_p... |
#include <bits/stdc++.h> using namespace std; long long n; long long mult(long long a, long long b, long long limit) { long long x = 0, y = a; while (b > 0) { if (b % 2 == 1) { x = (x + y); if (x >= limit) return -1; } y = (y * 2); b /= 2; if (y >= limit && b ... |
#include <bits/stdc++.h> using namespace std; int n; int b[200010]; map<int, long long> S; long long solve() { S.clear(); long long df, ans = 0; for (int i = 0; i < n; i++) { df = b[i] - i; S[df] += (long long)b[i]; } map<int, long long>::iterator it; for (it = S.begin(); i... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5; vector<vector<pair<long long, long long> > > dis(maxn); long long flag[maxn]; long long c1, c2; bool ok; void dfs(long long index, long long p) { flag[index] = p; for (long long i = 0; i < dis[index].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int N, Q; vector<int> E[200005]; int P[21][200005], D[200005]; void dfs(int cur) { for (__typeof(E[cur].begin()) it = E[cur].begin(); it != E[cur].end(); it++) if (*it != P[0][cur]) D[*it] = D[cur] + 1, P[0][*it] = cur, dfs(*it); } int lca(int a, int... |
#include <bits/stdc++.h> using namespace std; pair<int, int> p[2005 * 2005]; char a[2005][2005], cg[4] = { v , < , ^ , > }; int n, m, mox[4] = {-1, 0, 1, 0}, moy[4] = {0, 1, 0, -1}; int ispoint(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < m && a[x][y] == . ); } int deg(int x, int y) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long oo = 1e9 + 7; const int mod = 1e9 + 7; double x, y, tmp; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> x >> y; tmp = log(x) / log(y); if (tmp * y * 1.00 < x) ... |
#include <bits/stdc++.h> using namespace std; void myassert(bool expr) { if (!expr) abort(); } const int64_t posinf = 9223372036854775807LL; const int64_t neginf = 9223372036854775808LL; const int64_t bigprime = (1LL << 61) - 1LL; const int64_t mult = 199; const int64_t mult2 = 3571; const int64_t... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.14159265358979; vector<pair<int, int> > A[100001]; int main() { int n, m, a, b; scanf( %d%d , &n, &m); priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q; vector<int> an... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; int m = 0; cin >> n >> m; int num = 0; num = (n * m) / 2; cout << num; } |
#include <bits/stdc++.h> using namespace std; int main() { string s, e; cin >> s >> e; int h1, m1, h2, m2; h1 = (s[0] - 0 ) * 10 + (s[1] - 0 ); h2 = (e[0] - 0 ) * 10 + (e[1] - 0 ); m1 = (s[3] - 0 ) * 10 + (s[4] - 0 ); m2 = (e[3] - 0 ) * 10 + (e[4] - 0 ); long long int total1 ... |
#include <bits/stdc++.h> using namespace std; int main() { int c = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == s[i + 1]) { c++; if (c >= 6) break; } else if (s[i] != s[i + 1]) { c = 0; } } if (c >= 6) { cout << YES ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.