func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; string name[102]; bool istaxi(string s) { s.erase(5, 1); s.erase(2, 1); for (int i = 1; i < 6; i++) { if (s[i] != s[i - 1]) { return 0; } } return 1; } bool ispizza(string s) { s.erase(5, 1); s.erase(2, 1); for (... |
#include <bits/stdc++.h> using namespace std; int n, dist[8][8], dis[8][100010], lst[8], mask[100010], cnt[8][300], ans; long long res; char s[100010]; bool use[8]; queue<int> q; int main() { scanf( %d , &n); scanf( %s , s); for (int c = 0; c < 8; c++) lst[c] = -1; for (int i = 0; i < 8; i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4000010; long long f[MAXN], sum[MAXN], MOD; int main() { int n; scanf( %d %lld , &n, &MOD); f[n] = 1; sum[n] = 1; for (int i = n - 1; i; --i) { f[i] = (f[i] + sum[i + 1]) % MOD; for (int j = 2; j * i <= n; ++j) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; template <class T> inline void read(T &res) { char c; T flag = 1; while ((c = getchar()) < 0 || c > 9 ) if (c == - ) flag = -1; res = c - 0 ; while ((c = getchar()) >= 0 && c <= 9 ) res = res * 10 + ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1ll << 60, INF2 = 1ll << 58; queue<long long> q; vector<long long> ll, rr, g; long long lft[525000], rght[525000]; int main() { int n, r = 0, ans = 0; long long k, len = INF; scanf( %d %I64d , &n, &k); ll.resize(n), rr.resiz... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int w[100005]; int x[100005]; int main() { int n; scanf( %d , &n); int i; for (i = 0; n > i; i++) { scanf( %d , &a[i]); } w[0] = a[0]; for (i = 1; n > i; i++) { w[i] = w[i - 1] + a[i]; } int k; str... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int N = 100005; int n, i, tab[N], res, act, a, was[N]; int main() { scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &tab[i]); res = 0; act = 0; for (i = 0; i < n; i++) { scanf( %d , &a); was[a]... |
#include <bits/stdc++.h> int main() { int n; std::cin >> n; long long sum = 0; int j; for (int i = 2; i <= n / 2; i++) { j = 2; while (i * j <= n) { sum += j; j++; } } sum = sum * 4; std::cout << sum; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; if (n / k % 2 == 0) { cout << NO ; } else { cout << YES ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n; int A[N]; int main() { int t; scanf( %d , &t); while (t--) { scanf( %d , &n); n *= 2; for (int i = 1; i <= n; i++) { scanf( %d , &A[i]); } sort(A + 1, A + 1 + n); n /= 2; pr... |
#include <bits/stdc++.h> using namespace std; const int N = 1.12e5; const int LEN = 6.4 * N; int len; int c[N], sz[N]; int s[LEN], sa[LEN], *rk, ht[LEN], v[2][LEN], ct[LEN]; long long co[LEN]; void build_sa(int n, int m) { int *x = v[0], *y = v[1]; fill_n(ct, m, 0); for (int i = (0); i != (n... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long tree[400020][21], lazy[400020][21], arr[100005]; void build(int l, int r, int node, int i) { if (l == r) { tree[node][i] = 0; if (arr[l] & (1 << i)) { tree[node][i] = 1; } return; } int m... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); while (n--) { int c, sum; scanf( %d %d , &c, &sum); if (sum % c == 0) cout << c * (sum / c * sum / c) << endl; else { int temp = sum / c; long long int total = (temp * temp)... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const long double inf = 1e9 + 10; bool use(long double &f, long double w, long double a); int a[N], b[N]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; long long int n, m; long long int b = 1; while (t--) { cin >> m >> n; while (true) { if ((m | b) <= n) m = m | b; else break; b <<= 1; } cout << m << ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3fll; const long double pi = acos(-1); const int MOD = 1e9 + 7; int n, k; long long int g[41]; long long int dp[(1 << 20)]; long long int dp2[(1 << 20)]; int t1, t2; long long int A... |
#include <bits/stdc++.h> using namespace std; long long min(long long a, long long b) { return a < b ? a : b; } int ceil(int a, int b) { return (a + b - 1) / b; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; string s; cin >> s... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3100; const int inf = 1e9 + 100; struct node { int a, b; } l[maxn]; int s[maxn * 2 + 10], dp[maxn][maxn * 2 + 10], to[maxn]; int cmp(node a, node b) { if (a.b != b.b) return a.b < b.b; else { return a.a > b.a; } }... |
#include <bits/stdc++.h> using namespace std; const int N = 3000 + 10; int n, a[N], dt[N], st[N][14], pos[N][14], mark[N], lg[N]; pair<int, int> nd[N]; bool cmp1(const pair<int, int> &a, const pair<int, int> &b) { return a.first > b.first; } bool unfix(int l, int r) { return l > r; } int query(int l... |
#include <bits/stdc++.h> using namespace std; const int oo = 1000111000; int n, k, a[30300], f[222][30300][2], ans[222][30300]; int main() { int x; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> x; a[i] = a[i - 1] + x; } for (int i = 0; i <= k; i++) for (int j = 0; j ... |
#include <bits/stdc++.h> int arr[250]; int ans[250]; int main() { int num; int clr; scanf( %d%d , &num, &clr); for (int i = 1; i <= num; ++i) { scanf( %d , &arr[i]); } int res = 0; for (int i = 1; i <= clr; ++i) { scanf( %d , &ans[i]); res += ans[i]; } std::qu... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200200; const long long MOD = (int)1e9 + 7; const long long INF = (long long)2e18; const int C = 2e4 + 10; long long add(long long a, long long b) { return (a + b) % MOD; } long long sub(long long a, long long b) { a -= b; a %= MOD; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; long long fac[N], dp[N]; int mod = 1000000007; long long pow(int a, int b, int MOD) { long long x = 1, y = a; while (b > 0) { if (b % 2 == 1) { x = (x * y); if (x > MOD) x %= MOD; } y = (y * y); ... |
#include <bits/stdc++.h> using namespace std; int t; long long b[3000000]; pair<long long, long long> a[3000000]; int main() { cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; ++i) { scanf( %lld%lld , &a[i].first, &a[i].second); } for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; int n, a, b, k, q; int added[200055]; struct BIT { int dat[200055]; void add(int id, int val) { while (id < n) { dat[id] += val; id |= (id + 1); } } int sum(int id) { int ret = 0; while (id >= 0) { ret ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int h, w; vector<vector<int> > f; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; bool check(int x, int y) { return 0 <= x && x < w && 0 <= y && y < h && f[y][x]; } vector<vector<int> > was; double sumx, sumy; i... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( O3 ) using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const int inf = 2e5 + 10; int mod = 1e9 + 7; const int MAXN = 1e5 + 7; long double C(int n, int k) { long double res = 1.; ... |
#include <bits/stdc++.h> using namespace std; #define int long long int scalar(int Ax, int Ay, int Bx, int By) { return Ax * Bx + Ay * By; } bool isok(int x1, int y1, int x2, int y2, int x3, int y3) { int Ax = x1 - x2; int Ay = y1 - y2; int Bx = x3 - x2; int By = y3 - y2... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int k; cin >> k; int a[26]; int maxi = 0; for (int i = 0; i < 26; ++i) { cin >> a[i]; maxi = max(maxi, a[i]); } int val = 0; for (int i = 0; i < s.size(); ++i) { val += a[s[i] - 9... |
#include <bits/stdc++.h> using namespace std; long long qk(long long x, long long y) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % 1000000007; y >>= 1; x = x * x % 1000000007; } return ans; } const int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1}, dy[8] = {-1, ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) positive = 0; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 0 ; return positive ? x : -x;... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &t) { t = 0; char ch = getchar(); int f = 1; while ( 0 > ch || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } do { (t *= 10) += ch - 0 ; ch = getchar(); } while ( 0 <= ch &&... |
#include <bits/stdc++.h> using namespace std; const long long M = 2e5 + 7, MOD = 1e9; long long cnt = 0; long long arr[M], arrr[M]; long long sum, sum1, mx = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); long long t; cin >> t; for (int i = 0; i < t; i++) cin >> arr[i]; for... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 50; vector<int> g[maxn]; int n, k; int ans = 0; int dfs(int u, int p) { if (g[u].size() == 1) return 0; vector<int> vt; for (auto it : g[u]) { if (it != p) { vt.push_back(dfs(it, u) + 1); } } sort(vt... |
#include <bits/stdc++.h> using namespace std; queue<int> fila[100000 + 10]; int bit[100000 + 10]; int rsp[100000 + 10]; pair<pair<int, int>, int> q[100000 + 10]; int v[100000 + 10]; int ls[100000 + 10]; void add(int p, int v) { if (p == 0) return; for (; p <= 100000; p += (p & (-p))) bit[p] += v... |
#include <bits/stdc++.h> using namespace std; inline int read() { int res = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -f; ch = getchar(); } while (isdigit(ch)) { res = (res << 1) + (res << 3) + (ch ^ 48); ch = getchar(); } return res... |
#include <bits/stdc++.h> using namespace std; int Ans, Cap[55][55], From[55], K, N, T[55]; vector<int> E[55]; bool dijkstra() { priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; vector<int> d(55, 1005); d[1] = 0; q.push(make_pair(0, 1))... |
#include <bits/stdc++.h> using namespace std; template <typename... T> void read(T &...args) { ((cin >> args), ...); } template <typename... T> void write(T... args) { ((cout << args << ), ...); cout << n ; } long long gcd(long long a, long long b) { if (b > a) { return gcd(b,... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, last = 0, count = 0, sum, sum1; cin >> n; while (n >= 10) { last = n / 10; n = n / 10; count += 1; } if (count + 1 == 1) sum1 = 1; else if ... |
#include <bits/stdc++.h> using namespace std; struct line { long long x, y, dx, dy, s; } a[25000]; struct point { int i; bool f; long double x; } b[50000], c[25000]; bool comp(point a, point b) { if (a.x == b.x) { if (a.f == b.f) return (a.i < b.i); return (a.f < b.f); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long int M, k, Q, sum = 0, a = 1, W; vector<int> x; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %lld , &W); for (int j = 0; j < W; j++) { x.push_back(i); } } scanf( %lld , &M); ... |
#include <bits/stdc++.h> using namespace std; int dp[141][141][12]; int peas[141][141]; char track[141][141][12]; int main() { int n, m, k; cin >> n >> m >> k; string str; for (int i = 0; i < 141; i++) for (int j = 0; j < 141; j++) for (int p = 0; p < 12; p++) dp[i][j][p] = -1111... |
#include <bits/stdc++.h> using namespace std; int N, K, P[2100], S[2100], ans[(int)4e6 + 100], cost = 0; int abs(int a) { return a > 0 ? a : -a; } void swap(int i, int j) { cost += abs(i - j); ans[++K] = i; ans[++K] = j; P[i] ^= P[j]; P[j] ^= P[i]; P[i] ^= P[j]; } stack<int> box; i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 5; struct edge { int next, v; } e[MAXN << 1]; int n, q, root, cnt, head[MAXN], dep[MAXN], anc[MAXN][30]; void addEdge(int x, int y) { e[++cnt].v = y; e[cnt].next = head[x]; head[x] = cnt; } void dfs(int x) { for (in... |
#include <bits/stdc++.h> using namespace std; long long int n, k; long long int a[200100]; bool check(long long int x) { long long int moves = 0; for (__typeof(n + 1) i = (n / 2 + 1) - ((n / 2 + 1) > (n + 1)); i != (n + 1) - ((n / 2 + 1) > (n + 1)); i += 1 - 2 * ((n / 2 + 1) > (n + 1))... |
#include <bits/stdc++.h> using namespace std; char s[1000002]; int o = 0, len; int main() { cin >> s; if ((s[0] == 1 ) && (strlen(s) == 1)) { cout << 0; return 0; } for (int i = strlen(s); i >= 0; i--) { s[i + 1] = s[i]; } s[0] = 0 ; int i = strlen(s) - 1; whi... |
#include <bits/stdc++.h> using namespace std; #define all(cont) cont.begin(), cont.end() #define rall(cont) cont.end(), cont.begin() #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define SORT(v) sort(v.begin(), v.end()) #define MP ma... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int i = 1; long long int a[n]; while (i <= n) { cin >> a[i]; i++; } cout << n + 1 << endl; cout << 1 << << n << << 5600 << endl; i = 1; while (i <= n) { c... |
#include <bits/stdc++.h> using namespace std; int dist[551000]; long long int sum = 0; set<long long int> ans; int fTemp[551000]; int freq[551000]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> dist[i + 1]; ... |
#include <bits/stdc++.h> using namespace std; int md1 = 1e9 + 7, md2 = 1e9 + 9, B = 130; struct H { int x, y; H(int a = 0, int b = 0) : x(a), y(b) {} bool operator==(H o) { return x == o.x && y == o.y; } void operator+=(char c) { x = ((long long)x * B + c) % md1; y = ((long long)y * B ... |
#include <bits/stdc++.h> using namespace std; template <class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); } template <class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); } template <class TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << = << h << endl; } template <... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n; cin >> n; string s; cin >> s; set<char> all; for (auto c : s) all.insert(c); const long long sz = all.size(); if (sz == 1) { ... |
#include <bits/stdc++.h> using namespace std; int k, n, m, ans = 0; int dx[] = {0, 0, 0, 0, -1, 1}; int dy[] = {0, 0, 1, -1, 0, 0}; int dz[] = {1, -1, 0, 0, 0, 0}; char a[11][11][11]; bool vis[11][11][11]; void dfs(int x, int y, int z) { if (x < 0 || y < 0 || z < 0 || x >= n || y >= m || z >= k || ... |
#include <bits/stdc++.h> using namespace std; int n, a; int main() { scanf( %d %d , &n, &a); if (a % 2 == 1) { printf( %d , (a - 1) / 2 + 1); return 0; } if (a % 2 == 0) { printf( %d , n / 2 + 1 - a / 2); return 0; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, ans; struct Node { int val, p, cnt; int pre, nxt; } a[N]; struct Comp { bool operator()(const pair<int, int> &x, const pair<int, int> &y) { return x.first == y.first ? x.second < y.second : x.first > y.first; }... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i % 2 == 1) { cout << # ; } else { if ((i / 2) % 2 == 0) { if (j == 1) { cout << # ;... |
#include <bits/stdc++.h> using namespace std; int main() { long long ele, i, j, ele1, k, n, a, b, q; cin >> q; for (i = 0; i < q; i++) { cin >> n >> a >> b; if (n == 1) { cout << a << endl; continue; } else if (2 * a > b) { ele = n % 2; ele1 = n / 2; ... |
#include <bits/stdc++.h> using namespace std; void solve(string a, string b, int m, int n) { int lcs[m + 1][n + 1]; int result = 0; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 || j == 0) lcs[i][j] = 0; else if (a[i - 1] == b[j - 1]) { ... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> add_pair(pair<long long, long long> a, pair<long long, long long> b) { return make_pair(a.first + b.first, a.second + b.second); } long long power(long long a, long long b) { long long res = 1;... |
#include <bits/stdc++.h> using namespace std; const int max_n = 2000222, inf = 1000111222; int t, n, a[max_n], b[max_n]; long long sum[max_n]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } for (int i = 0... |
#include <bits/stdc++.h> using namespace std; #define int long long const int MAX = 1e6 + 7; int num[MAX]; signed main() { int T; cin >> T; while (T--) { int N, u, v; cin >> N >> u >> v; for (int i = 1; i <= N; i++) { cin >> num[i]; } int canget = 0; int flag = 0... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long lgput(long long a, long long b, long long mod) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % mod; a = (a * a) % mod; b >>= 1; } return (ret % mod); } inline long long inv(lo... |
#include <bits/stdc++.h> using namespace std; map<string, int> M; int eval(string s) { int c1 = 0, c2 = 0; string t; int indl = 0; while (indl < s.size() && s[indl] == & ) ++indl, ++c1; int ind2 = s.size() - 1; while (ind2 >= 0 && s[ind2] == * ) --ind2, ++c2; t = s.substr(indl, ind2 ... |
#include <bits/stdc++.h> using namespace std; double a[10100]; int main() { int n, m; cin >> n >> m; double ans = 0.0; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) { int aa, bb; double cc; cin >> aa >> bb >> cc; ans = max((a[aa] + a[bb]) / cc, ... |
#include <bits/stdc++.h> using namespace std; int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, -1, 1}; int n, m; vector<long long> a; void solve() { long long cnt = 0; vector<vector<pair<int, int>>> ps; queue<pair<int, int>> buff; ps.resize(m); for (int i = 0; i < m; i++) ps[i].clear(); f... |
#include <bits/stdc++.h> using namespace std; bool clash[30][30]; int dp[100001][27]; string s; int solve(int index, int lastchar) { if (index == s.size()) { return 0; } int mn = (1 << 30); if (dp[index][lastchar] != -1) { return dp[index][lastchar]; } if (!clash[s[index] -... |
#include <bits/stdc++.h> using namespace std; bool _cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { int n, x, y; scanf( %d , &n); vector<pair<int, int> > V(n); for (int i = 0; i < n; i++) { scanf( %d %d , &x, &y); V[i].first = min(x, y); V[i].... |
#include <bits/stdc++.h> using namespace std; struct Q { int a, b, c, d; Q(int x, int y, int z, int w) : a(x), b(y), c(z), d(w) {} }; pair<int, int> query(Q z) { int u, v; printf( %d%d%d%d n , z.a, z.b, z.c, z.d); fflush(stdout); scanf( %d%d , &u, &v); return make_pair(u, v); } p... |
#include <bits/stdc++.h> using namespace std; long long n, A, cf, cm, m; struct node { long long x; int i; } a[100001]; long long sum[100001]; long long ans = 0; bool cmp(node a, node b) { return a.x < b.x; } bool cmp1(node a, node b) { return a.i < b.i; } long long minc = 0; long long bsear... |
#include <bits/stdc++.h> using namespace std; int n, z[100005], a[100005], ans[100005]; string s; int main() { int i, l = 0, r = 0; cin >> s; n = s.length(); memset(z, 0, sizeof(z)); memset(ans, 0, sizeof(ans)); ans[1] = 1; for (i = 1; i < n; i++) { if (i <= r) z[i] = min(z[i -... |
#include <bits/stdc++.h> using namespace std; const int MAX_L = 200; map<int, pair<int, int> > ds; int ops[MAX_L]; int powmod(int a, int n, int mod) { int pm = 1; while (n > 0) { if (n & 1) pm = (long long)pm * a % mod; a = (long long)a * a % mod; n >>= 1; } return pm; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1E5; int a[MAXN]; long long pref[MAXN]; long long suff[MAXN]; int main() { int n, d, m; cin >> n >> d >> m; int bigger = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > m) bigger++; } sort(a, a + n); ... |
#include <bits/stdc++.h> int main() { int n; int k; char a[101]; int i = 0; scanf( %d %d , &n, &k); scanf( %s , a); if (k > n / 2) { i = k; while (i < n) { printf( RIGHT n ); i++; } } else { i = k; while (i > 1) { printf( LEFT n ); ... |
#include <bits/stdc++.h> using namespace std; typedef int arr[500005]; arr Next, a, Sa, Lcp, pos, tmp, S; int n, len; char P[500005]; vector<int> Val[2 * 500005]; bool cmp(int p, int q) { if (pos[p] != pos[q]) return pos[p] < pos[q]; p += len; q += len; if (p <= n && q <= n) return pos[p] ... |
#include <bits/stdc++.h> using namespace std; int n; pair<long long, long long> x[4000]; long long d[4000]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) cin >> x[i].first >> x[i].second; sort(x + 1, x + n + 1); d[n] = x[n].second; for (int i = n - 1; i >= 1; i--) { d[i]... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long N = 2e5 + 100; const long long INF = 1e18; long long x[N], p[N], a[N]; struct node { long long ans = 0, pref = 0, suff = 0, sum = 0; node() {} node(long long x) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 1e5 + 9; vector<int> v[N]; bool visited[N]; int c = 0; map<pair<int, int>, int> m; void dfs(int x, int parent) { visited[x] = true; bool b = false; for (int i = 0; i < v[x].size(); i++) { if (... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 0 0 << endl; string left; cin >> left; int l = 0, r = 1e9; for (int i = 1; i < n; i++) { int mid = (l + r) / 2; cout << mid << 1 << endl; string s; cin >> s; if (s == le... |
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int a, b, c, x, y, z; int spa = 0, spb = 0, spc = 0; int req = 0; cin >> a >> b >> c; cin >> x >> y >> z; if (a > x) spa = a - x; else ... |
#include <bits/stdc++.h> using namespace std; bool comp(pair<long long int, long long int> a, pair<long long int, long long int> b) { if (a.first + a.second == b.first + b.second) { return a.first < b.first; } return (a.first + a.second) < (b.first + b.second); } int main() { i... |
#include <bits/stdc++.h> using namespace std; long long dp[101][101][11][2]; long long k1, k2; long long solve(long long n1, long long n2, long long count, long long flag) { if (n1 < 0 || n2 < 0) { return 0; } if (n1 == 0 && n2 == 0) { return 1; } if (flag != -1 && dp[n1][n2][cou... |
#include <bits/stdc++.h> using namespace std; char x[55]; int swim(char *c = x, int res = 0, int round = 0) { int l = strlen(c); if (round == 2) { if (l == 0 || l > 7 || (c[0] == 0 && l > 1)) return -1; int ba2y; sscanf(c, %d , &ba2y); if (ba2y > 1000000) return -1; return... |
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { char a[4]; char b[4]; char x; int f = 0; int r = 0; for (int i = 0; i < 4; i++) { cin >> x; if (x != X ) { a[r] = x; r++; } else { if (i < 2) f = 1; } }... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; const int N = (int)2e5 + 45; const int inf = 0x3f3f3f3f; void ttf() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int z[N], p[N]; void solve() { string s; cin >> s; int n = (int)s.length(); z[0] = n; for (int i = 1, l = 0, r ... |
#include <bits/stdc++.h> using namespace std; int main() { long int n, i, t; cin >> n; long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (a[0] == 0) a[0] = a[1]; if (n >= 2) { if (a[n - 2] - a[0] < a[n - 1] - a[1]) t = a[n - 2] - a[0]; else ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int MOD = 1e9 + 7; vector<int> v; long long f[301][N]; int a[N]; int main() { for (int i = 1; i <= 300; i++) { f[i][0] = 1; for (int j = 1; j < N; j++) { f[i][j] = f[i][j - 1] * i % MOD; } } int... |
#include <bits/stdc++.h> using namespace std; int N, M, cnt[101]; int main() { int N, M, cnt[101] = {0}; scanf( %d%d , &N, &M); for (int i = 0; i < N; i++) { int t; scanf( %d , &t); int now = M - t; int ans = i; for (int j = 1; j <= 100; j++) { int get = min(now /... |
#include <bits/stdc++.h> std::vector<long long> G[100001]; std::vector<long long> psn[100001]; std::vector<long long> arr[100001][20]; long long par[100001], lvl[100001]; long long P[100001][20]; void dfs_visit(long long s, long long p) { if (p != -1) { par[s] = p; lvl[s] = 1 + lvl[p]; }... |
#include <bits/stdc++.h> using namespace std; int arr[10001]; int main() { int test; cin >> test; while (test--) { int n; cin >> n; vector<int> ans1, ans2; for (int i = 0; i < 2 * n; i++) cin >> arr[i]; vector<pair<int, int> > vp; for (int i = 0; i < 2 * n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, d; cin >> n >> d; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; long long int ans = a[0]; for (long long int i = 1; i < n; i++... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll t; cin >> t; for (ll i = 0; i < t; i++) { ll n; cin >> n; vector<ll> in(n); vector<ll> count(n + 1); f... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } struct UnionFind { vector<int> data; UnionFind(int size_) : data(size_, -1... |
#include <bits/stdc++.h> namespace Factor { const int N = 1010000; int64_t C, fac[10010], n, mut, a[1001000]; int T, cnt, i, l, prime[N], p[N], psize, _cnt; int64_t _e[100], _pr[100]; std::vector<int64_t> d; inline int64_t mul(int64_t a, int64_t b, int64_t p) { if (p <= 1000000000) return a * b ... |
#include <bits/stdc++.h> using namespace std; int n; struct point { double x, y; } a, b, t, q[100010]; struct wxz { double d1, d2; } f[100010]; double ans, delta1[100010], delta2[100010], delta; double dist(point u, point v) { return sqrt((u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y)... |
#include <bits/stdc++.h> using namespace std; bool vis[105][105]; int main() { int n; scanf( %d , &n); int m; scanf( %d , &m); for (int i = 1; i <= m; i++) { int x; scanf( %d , &x); vis[1][x] = true; } for (int i = 2; i <= n; i++) { int m; scanf( %d , &m);... |
#include <bits/stdc++.h> using namespace std; int i, n, k; double jumlah, x[101], y[101]; int main() { scanf( %d %d , &n, &k); for (i = 1; i <= n; ++i) { scanf( %lf %lf , &x[i], &y[i]); } for (i = 1; i < n; ++i) { jumlah += sqrt(((x[i] - x[i + 1]) * (x[i] - x[i + 1])) + ... |
#include <bits/stdc++.h> using namespace std; long long a[20], b[20]; long long ans = 0; void print() { for (int i = 0; i < 14; i++) cout << b[i] << ; cout << endl; } int main() { for (int i = 0; i < 14; i++) cin >> a[i]; for (int i = 0; i < 14; i++) { if (a[i]) { for (int j... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 1e6 + 7; long long t, n, k, temp; int main(int argc, char* argv[]) { cin >> t; while (t--) { cin >> n >> k; long long cnt = 0; while (n > 0) { if (n % k != 0) { cnt += n % k; ... |
#include <bits/stdc++.h> int main() { long long n, x; int q, i; scanf( %lld %i , &n, &q); while (q--) { scanf( %lld , &x); while (!(x & 1)) { x += (n - (x >> 1)); } printf( %lld n , (x + 1) / 2); } return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.