func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 250000; int n, dfn[N], size[N], cnt, Q; struct node { int tag, sum; } t[N << 2]; vector<int> V[N]; void dfs(int x) { dfn[x] = ++cnt; size[x] = 1; for (int i = 0, s = V[x].size(); i < s; i++) dfs(V[x][i]), size[x] += size[V[x... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 7; const long long INF = 1e9 + 7; vector<long long> g[MAXN]; bool bad[MAXN]; long long best = -1; long long besth = -1; void jfs(long long u, long long parent, long long h) { if (besth < h) { best = u; besth = h; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, ans = 0, a, b = 0, N; cin >> N; for (long long i = 1; i <= 1e6; i++) { n = N; a = i * 2; n -= a; b = ((i - 1) * (i * 3) / 2); n -= b; ... |
/* 2013-08-11 10:03:33.914034 */#include<iostream> #include<cstdio> #include<cstdlib> #include<ctime> #include<cmath> #include<cctype> #include<cstring> #include<algorithm> #include<map> #include<set> #include<vector> #include<string> #include<queue> using namespace std; char s[1011... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a; if (a == 1) { cout << 1 ; return 0; } if (a == 2) { cout << 13 ; return 0; } long long sol = 1; sol += 1LL * 6 * a * (a + 1) / 2; sol += 1LL * 6 * ((a - 2) * (a - 1) / 2 - 1);... |
#include <bits/stdc++.h> using namespace std; int N, x[3], y[3], xx, yy, jump[111111]; pair<long long, long long> dist[111111]; long long maxR2[111111], ans = LONG_LONG_MAX; int main() { scanf( %d %d %d %d %d , &N, &x[1], &y[1], &x[2], &y[2]); for (int i = 1; i <= N; i++) { scanf( %d %d , &xx, &... |
#include <bits/stdc++.h> using namespace std; string run(vector<string> &vec) { vector<bool> used(vec.size(), false); vector<char> ans(100, 1 ); for (int i = 0; i < vec[0].size(); ++i) { ans[50 + i] = vec[0][i]; } used[0] = true; while (true) { int count = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 998244353; const long long int MAXN = 3e3 + 5; const long long int inf = 1e17; int main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); ; long long int t; cin >> t; while (t--) { long long ... |
#include <bits/stdc++.h> using namespace std; const double pi = 4.0 * atan(1.0); int64_t num; queue<int64_t> qu; bool ifgood(int64_t x) { int64_t a, b; a = 0; b = 0; while (x) { if (x % 10 == 4) ++a; else if (x % 10 == 7) ++b; else return false; ... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); long long A, B, n; cin >> A >> B >> n; while (n--) { long long l, t, m; cin >> l >> t >> m; if (t < A + (l - 1) * B) { cout << -1 << endl; continue; } long long ... |
#include <bits/stdc++.h> struct f { int pos; int num; } a[108]; int cmp(const void *a, const void *b) { return (*(struct f *)a).num - (*(struct f *)b).num; } int main() { int n, k; while (scanf( %d%d , &n, &k) == 2) { int i; for (i = 0; i < n; i++) { scanf( %d , &a[i].n... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, max = -100000; int a[200], inter[200], exter[200]; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { int sum = 0; vector<int> inter, exter;... |
#include <bits/stdc++.h> using namespace std; struct _d { int r1, c1, r2, c2; }; int n, m; char arr[500][501]; bool ans[600000]; _d queries[600000]; bitset<500> DPU[500][500], DPD[500][500]; void dnc(int l, int r, vector<int> &qid) { if (l > r) return; int mid = (l + r) / 2; vector<int... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int N = 1e5 + 7; int pre[N], sz[N], cnt[N], n, lencnt, dx, one; pair<int, int> a[N]; void init() { memset(pre, -1, sizeof(pre)); } int fd(int n) { return pre[n] == -1 ? n : pre[n] = fd(pre[n]); } void mg(int a, int b) { ... |
#include <bits/stdc++.h> const int G = 3; const int K = 40001; const int inv2 = 499122177; const int MaxN = 6e5 + 10; const int mod = 998244353; int n, k, lim, w[MaxN], rev[MaxN], _inv[MaxN]; void Mod(int &x) { x += x >> 31 & mod; } void __init() { _inv[1] = 1; for (int i = 2; i < MaxN; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int i, count = 0; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 1; i < n - 1; i++) { if (a[i] == 0 && a[i - 1] == 1 && a[i + 1] == 1) { count++; i += 2; } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 11; const long long oo = 1e17 + 123; int tcases = 1; int n, m = 0; long long a[N], b[N], s[N], res[N]; pair<int, int> q[N]; struct Point { double x, y; Point() { x = y = 0; } Point(double _x, double _y) : x(_x), y(y) {} }; ... |
#include <bits/stdc++.h> using namespace std; int n, v[5000], d[5000], p[5000], f[5000], ans; queue<int> q; void work() { int i, j, k; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d%d%d , &v[i], &d[i], &p[i]); for (i = 1; i <= n; i++) { if (f[i] == 0) { f[i] = 1; for (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 34; int n, m; int f[MAXN][MAXN], s[MAXN][MAXN]; int work2(int j) { s[m][m + 1 + j] = s[m][j] * s[m][m]; int tot = s[m][j] * f[m][j] + s[m][m + 1 + j] * f[m][m + 1 + j]; for (int i = 0; i < m; ++i) { int x = f[i][j] + s[i][m] * f[... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t) { t--; long long a, b; cin >> a >> b; long long n = a / b + (bool)(a % b); cout << b * n - a << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; void PLAY() { cout << fixed << setprecision(10); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; return b; } long long f... |
#include <bits/stdc++.h> using namespace std; void _dbg(string) { cout << endl; } template <class H, class... T> void _dbg(string s, H h, T... t) { int l = s.find( , ); cout << s.substr(0, l) << = << h << , ; _dbg(s.substr(l + 1), t...); } template <class T, class U> ostream& operator<<(... |
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i += 6) {... |
#include <bits/stdc++.h> int main() { char s[105]; int i, n, j; scanf( %d , &n); getchar(); for (i = 0; i < n; i++) { scanf( %c , &s[i]); } for (i = 0; i < n; i++) { if (s[i] == o && s[i + 1] == g && s[i + 2] == o ) { printf( *** ); for (j = i + 3; j < n; j... |
#include <bits/stdc++.h> using namespace std; int n; long long K; vector<int> E[200000 + 5]; void addEdge(int u, int v) { E[u].push_back(v); E[v].push_back(u); } int sz[200000 + 5], deep[200000 + 5], fa[200000 + 5]; int msz[200000 + 5], root; void dfs1(int x, int f) { sz[x] = 1; msz[x]... |
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 5, inf = 2e9; const long double EPS = 1e-9L; vector<pair<int, int> > pairs[26]; vector<int> mn[26]; int leftSub[N], rightSub[N]; void computeSub(string& a, string& b, int ans[]) { for (int i = 0; i < (int)(a).size(); ++i) { int... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int T, n, k; long long ans, p; int main() { scanf( %d , &T); while (T--) { scanf( %d%d , &n, &k); ans = 0; p = 1; for (int i = 0; i <= 31; i++) { if (((long long)(1 << i) & k) != 0) ans = (ans + p... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> inline T lowbit(T x) { return x & -x; } const int N = 2e5 + 10; int n, m; int q; int res; int les[N], more[N]; bool vis[N]; void solve() ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int nmax = 100005; const long long inf = 1e9; const double eps = 1e-6; long long dp[1005][1005]; long long gp[1005][1005]; long long a[1005][1005]; long long rdp[1005][1005]; long long rgp[1005][1005]; int main() { io... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 5; template <typename T> void chkmax(T& x, T y) { if (y > x) x = y; } template <typename T> void chkmin(T& x, T y) { if (y < x) x = y; } int N, c[MAXN]; long long ans; int main() { scanf( %d , &N); for (int i = 1;... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int B = 250; int p1 = 5000000, p2 = 0; char buf[5000005], wbuf[5000005]; int gc() { if (p1 >= 5000000) fread(buf, 1, 5000000, stdin), p1 = 0; return buf[p1++]; } int rd() { int x = 0, ch = gc(); while (!isdigit(c... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; char s1[N], s2[N], s[N]; int n, lst, nod, len[N], fail[N], diff[N], anc[N], ch[N][26]; int f[N], pos[N], pre[N]; void init() { fail[0] = fail[1] = nod = 1; len[1] = -1; } void extend(int c, int i) { int p = lst; while ... |
#include <bits/stdc++.h> using namespace std; int grid[33][33]; int main() { int test; scanf( %d , &test); for (int _T = 1; _T <= test; _T++) { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> grid[i][j]; } } ... |
#include <bits/stdc++.h> using namespace std; int n, m, ave1, ave2, ans1, ans2; int a[567890], sum; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]), sum += a[i]; sort(a + 1, a + n + 1); int ave1 = sum / n; if (ave1 * n == sum) ave2 = ave1; else a... |
#include <bits/stdc++.h> using namespace std; int GCD(int a, int b) { if (b == 0) return a; return (a % b == 0 ? b : GCD(b, a % b)); } long long int POW(long long int base, long long int exp) { long long int val; val = 1; while (exp > 0) { if (exp % 2 == 1) { val = (val * base)... |
#include <bits/stdc++.h> int main() { int n, m; scanf( %d %d , &n, &m); int c[n], a[m]; int i; for (i = 0; i < n; i++) { scanf( %d , &c[i]); } for (i = 0; i < m; i++) { scanf( %d , &a[i]); } int j = 0, count = 0; int t = 0; for (i = 0; i < m;) { if (j >= n... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int c[maxn], ans[maxn]; int k, n, maxb, t; int b[maxn]; void update(int x, int d) { for (; x <= maxb; x += x & -x) { if (d > c[x]) c[x] = d; } } int get(int x) { int ans = 0; for (; x > 0; x -= x & -x) if ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int e[maxn], ne[maxn], h[maxn], idx = 0; int sz[maxn]; int ans = 0; void add(int a, int b) { e[idx] = b, ne[idx] = h[a]; h[a] = idx++; } void dfs(int now, int fa) { sz[now] = 1; for (int i = h[now]; i != -1; i = ne[... |
#include <bits/stdc++.h> using namespace std; struct node { int sum = 0, mx = 0; node *left = nullptr, *right = nullptr; node *getLeft() { if (left == nullptr) left = new node; return left; } node *getRight() { if (right == nullptr) right = new node; return right; } ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const double eps = 0.01; void solution() { int n; cin >> n; vector<int> h(n + 1); map<pair<int, int>, int> data; map<pair<int, int>, int>::iterator iter; for (int i = 1; i <= n; i++) { cin >> h[i]; data... |
#include <bits/stdc++.h> int grid[1001][1001]; int start[100000]; int main(void) { int n, m, k; scanf( %d %d %d , &n, &m, &k); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %d , &grid[i][j]); } } for (int i = 0; i < k; i++) { scanf( %d , &start[... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-10; const int MODULO = 1000000007; typedef struct { int i, m, v; } P; vector<P> mv; bool mLt(const P& x, const P& y) { return (x.m != y.m) ? less<int>()(x.m, y.m) : less<int>()(x.v, y.v); } int n, k, h; bool C(double ... |
#include <bits/stdc++.h> using namespace std; int s[10]; struct node { int l, r, now, h, a; } f[10][10]; int i, j, k, l, n, m, x, y, h, a, ans = 100000, ans1; inline void work(int o) { if (o != n && s[n] > ans) return; int gt = 0; if (o == 1) { if (s[o] + s[n] == 0 && s[o] <= 0) { ... |
#include <bits/stdc++.h> int bus_bin(int[], int, int, int); int main() { int n, k, q, i, j, l, y, aux, existeB; scanf( %d%d , &n, &k); int monedas[n]; for (i = 0; i < n; i++) scanf( %d , &monedas[i]); scanf( %d , &q); int cant[q]; for (i = 0; i < q; i++) scanf( %d , &cant[i]); for (i... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; bool IsPowerOfTwo(long long int x) { return (x != 0) && ((x & (x - 1)) == 0); } long long int poer(long long int a, long long int b) { long long int rs = 1; while (b > 0) { if (b & 1) rs *= a; a *= a; b /=... |
#include <bits/stdc++.h> using namespace std; void getint(int &v) { char ch, fu = 0; for (ch = * ; (ch < 0 || ch > 9 ) && ch != - ; ch = getchar()) ; if (ch == - ) fu = 1, ch = getchar(); for (v = 0; ch >= 0 && ch <= 9 ; ch = getchar()) v = v * 10 + ch - 0 ; if (fu) v = -v; } ... |
#include <bits/stdc++.h> using namespace std; int n; int a[28 * 2]; bitset<1250005> bleh[28][28 * 2]; int sm; vector<int> in[2]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < (signed)(n); i++) { cin >> a[i]; sm += a[i]; } for (... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846; const double eps = (1e-5); long long isGreater(long double x, long double y) { if (abs(x - y) < eps) return 0; if (x > y) return 1; return -1; } long long n; bool valid(long long i) { return i >= 0 && i < n... |
#include <bits/stdc++.h> using namespace std; long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + f * (c - 0 ), c = getchar(); return x; ... |
#include <bits/stdc++.h> using namespace std; vector<int> v(110, 0); int main() { int n, a, flag = 0, b; vector<int> m; cin >> n; b = n; while (n--) { cin >> a; m.push_back(a); v[a]++; } sort(m.begin(), m.end()); for (int i = m[0]; i <= m[b - 1]; i++) { for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int time = INT_MAX, check = 0; for (int i = 0; i < n; i++) { check = 0; int no = a[i]; for (int j = 0; j < no; j++) { int ite... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 12); int cnt[maxn]; pair<int, int> res[maxn][maxn]; int pr[maxn][maxn]; int w[13]; int len; int bsearch(int i, int k) { int l = 0, r = len; while (r - l > 1) { int mid = (r + l) / 2; if (res[i][mid].first <= k) ... |
#include <bits/stdc++.h> using namespace std; long long int m, n, i; long long int a[1000000], ans, sum[1000000] = {0}, x; int check(long long int k) { x = 0; for (i = 1; i <= n; i++) { if (a[i] - (i - 1) / k > 0) x = x + a[i] - (i - 1) / k; } if (x >= m) return 1; else ret... |
#include <bits/stdc++.h> using namespace std; int main() { string str[101]; int n; cin >> n; for (int i = 0; i < n; ++i) cin >> str[i]; int maxi = 1; for (int i = 0; i < n - 1; ++i) { int m = 1; for (int j = i + 1; j < n; ++j) { if (str[i] == str[j]) ++m; } ma... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5, INF = 1e9; string s2, s; struct data { int next[30]; int cnt; bool least; }; data t[N]; int sz = 1, ans; string p; inline void add(string s) { int v = 0; t[v].cnt++; for (int i = 0; i < s.size(); ++i) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; const int MAXN = 1e5 + 9; const int MOD = (int)(1e9 + 7); const int LOG2MAXN = 17; const int INF = 1e9; const long double eps = 1e-9; int di[] = {0, 1, 0, -1}; int d... |
#include <bits/stdc++.h> using namespace std; int n, m, f[105], s[105], ans; int Getf(int x) { return (f[x] == x ? x : Getf(f[x])); } int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) f[i] = i, s[i] = 1; int x, y; for (int i = 0; i < m; i++) { scanf( %d%d , &x, &y); int... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i, left, right, p[52]; vector<long long> bin; cin >> n >> m; m--; while (m) { if (m & 1) bin.push_back(1); else bin.push_back(0); m /= 2; } for (i = bin.size(); i < n - 1; i++) bi... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, l, r; cin >> n >> l >> r; long long mn[l], t1 = 1, mx[r], sum1 = 0, sum2 = 0; for (int i = 0; i < l; i++) { mn[i] = t1; sum1 += mn[i]; t1 *= 2; } for (int i = 0; i < n - l; i++) { sum1 += mn[0]; ... |
#include <bits/stdc++.h> using namespace std; long long int n, m; void solve() { cin >> n >> m; vector<vector<long long int>> v(m, vector<long long int>(n)); vector<long long int> sum(n); for (long long int i = 0; i < (m); i++) { for (long long int j = 0; j < (n); j++) { cin >> v[i][... |
#include <bits/stdc++.h> using namespace std; long long A, B, C, D, X, Y; inline long long gcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long res = gcd(b, a % b, x, y); long long t = x; x = y; y = t - (a / b) * y;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; while (n--) { cin >> m; if (m % 2 == 1) cout << (m + 1) / 2 << endl; else cout << 1 + m / 2 << endl; } } |
#include <bits/stdc++.h> using namespace std; set<pair<int, int> > z[200010], f[200010]; map<int, int> use[200010]; int n, m, k, dir; int sx, sy; inline void insert(int x, int y) { z[x - y + m + 1].insert(make_pair(x, y)); f[x + y].insert(make_pair(x, y)); use[x][y] = 1; } void init() { ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, inf = 1e9 + 7; long long n, k; string s, t; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long i, j, a, b, ans = 0; cin >> n >> k >> s >> t; ans = n; i = 0; while (i < n && s[i] == t[i])... |
#include <bits/stdc++.h> int main() { puts( Karen ); } |
#include <bits/stdc++.h> using namespace std; long long n, m, k; vector<vector<pair<int, int> > > v2; long long costs[(int)1e5 + 5]; int parent[(int)1e5 + 5]; vector<int> answer; void dikstra() { priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long l... |
#include <bits/stdc++.h> using namespace std; long long mpow(long long a, long long b) { long long c = 1; while (b) { if (b & 1) c = c * a % 998244353; a = a * a % 998244353; b /= 2; } return c; } long long minv(long long a) { return mpow(a, 998244353 - 2); } int n; long lo... |
#include <bits/stdc++.h> using namespace std; int n; struct hh { int t, nxt; } edge[1000020 << 1]; int head[1000020], ecnt; void make_edge(int f, int t) { edge[++ecnt] = (hh){t, head[f]}; head[f] = ecnt; edge[++ecnt] = (hh){f, head[t]}; head[t] = ecnt; } int dep[1000020], size[100002... |
#include <bits/stdc++.h> using namespace std; const int N = (int)5e5 + 5; int n, m, k, dp[1 << 15][110], nxt[N][16]; vector<int> a; map<string, int> mp; void update(int &x, int y) { if (x == -1 || x > y) x = y; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i ... |
#include <bits/stdc++.h> int main() { char old_h[1001][21], new_h[1001][21]; int q, i, j; char temp[21]; scanf( %d , &q); for (i = 0; i < q; i++) { scanf( %s %s , old_h[i], new_h[i]); } for (i = 0; i < q; i++) { for (j = i + 1; j < q; j++) { if (strcmp(new_h[i], old_h[j... |
#include <bits/stdc++.h> using namespace std; long long n, d, ans = 0; vector<long long> a; int main() { ios::sync_with_stdio(false); cin >> n >> d; while (n--) { long long temp; cin >> temp; a.push_back(temp); } for (long long i = 0; i < a.size(); i++) { long long id... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(0.0) * 2.0; const double eps = 1e-12; const int step[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } templa... |
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0, -1, 1, -1, 1}; int dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; const double eps = 1e-6; const int N = 1e9; void moha() {} bool vis[1505][1505]; int comp[1505][1505][2]; char x[1505][1505]; int n, m; int row(int x) { return (x + n * 150... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int a[101]; signed main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); int ans = 0; for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; template <typename T> inline void read(T &x) { char c; bool nega = 0; while ((!isdigit(c = getchar())) && (c != - )) ; if (c == - ) { nega = 1; c = getchar(); } x = c - 48; ... |
#include <bits/stdc++.h> long long tt, x, y, z, sum, n, i, j, h, k, t, d, m, l, ll, rr, r, a[1000006], b[1000006], f[1000006]; using namespace std; long long xl(long long i) { long long res = 0; for (j = 1; j <= d; j++) b[j] = a[j]; l = 1; r = i; tt = 1; z = b[1]; x = 1; whil... |
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX; const int inf = INT_MAX; const int mod = 1e9 + 7; const int pi = acos(-1); const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}; const int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1}; const int N = 2e5 + 5; const int MAXN = 1e5 + 1; int... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 8; const int mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long n, m; cin >> n >> m; long long arr[n][m]; long long x = 0; for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, colour[105], p[105]; memset(colour, -1, sizeof colour); bool flag = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> p[i]; colour[p[i]] = 2; } for (int i = 0; i < 101; i++) { if (colour[i] == 2) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<long long int>> grid(51, vector<long long int>(51, 0)); vector<pair<long long int, long long int>> a; int t1 = 4 * n + 1; while (t1--) { int u, v; ... |
#include <bits/stdc++.h> using namespace std; int n, m, dp[3005][3005], a[1000005]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; ++i) scanf( %d , a + i); if (n <= m) { dp[1][a[1] % m] = 1; for (int i = 2; i <= n; ++i) { for (int j = 0; j < m; ++j) { a[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; if (m == 0) { cout << 1 << endl; return 0; } if (m <= n / 2) { cout << m << endl; } else { long long res = n - m; cout << res << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; struct Point { int x; int y; int index; double angle; void Translate(int dx, int dy) { x += dx; y += dy; } void CalculateAngle() { angle = atan2(y, x); } bool operator<(const Point& p) const { return angle < p.angle; } }; ... |
#include <bits/stdc++.h> using namespace std; const long long oo = 1e18; const long long MAXN = 110; long long N; vector<string> query(long long a, long long b) { cout << ? << << a << << b << n ; fflush(stdout); long long sz = b - a + 1; vector<string> vect; for (long ... |
#include <bits/stdc++.h> using namespace std; void task(); int main() { srand(time(0)); task(); return 0; } const int INF = 0x3f3f3f3f; const int N = 1e5 + 10; const int M = 1e5 + 10; int n, x; int l[N]; int r[N]; long long int dp[2 * N + 10]; vector<int> v; void task() { scanf... |
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fr first #define sc second #define MOD 1000000007 #define len(x) x.size() #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) #define all(v) v.begin(), v.end() #define alla(a,n) a, a + n using... |
#include <bits/stdc++.h> using namespace std; long long Answer = 0, idx[300100], edges[300100], dis[300100]; int n, m, x, y, w, u; vector<pair<pair<int, int>, int> > v[300100]; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > Q; void dik() { for (... |
#include <bits/stdc++.h> using namespace std; inline int nxt() { int x; cin >> x; return x; } int gettm(char c) { if (c == G ) { return 5; } else if (c == W ) { return 3; } else if (c == L ) { return 1; } else { assert(false); } } int main() { m... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<int> vec(n + 1, 0); vector<pair<int, pair<int, int>>> arr; for (int i = 0; i < m; i++) { int si, di, ci; scanf( %d %d %d , &si, &di, &ci); arr.push_back(make_pair(di, make_pair(s... |
#include <bits/stdc++.h> using namespace std; int arr[1005], half; pair<int, int> info[1005]; bool cmp(pair<int, int> A, pair<int, int> B) { if (A.first == B.first) return A.second < B.second; else return A.first < B.first; } int main() { int n, k; scanf( %d %d , &n, &k); for... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, m, i, min, count, a[101], sum, count0; cin >> t; while (t--) { cin >> n >> m; count = 0; sum = 0; count0 = 0; for (i = 0; i < (n * m); i++) { cin >> a[i]; if (a[i] < 0) { count++;... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > v; bool cmp(pair<long long, long long> &a, pair<long long, long long> &b) { if (a.first == b.first) return a.second < b.second; return b.first < a.first; } long long func(pair<long long, long long> &a, pair<long long, lo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const long long inf = 1e15; const int mod = 1e6; void faster() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const long long N = 3e5 + 10; int n, m; long long a[N]; int main() { faster(); cin >> n; if... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000000 + 10, MOD = (int)1e+9 + 7; long long fac[MAXN], Ifac[MAXN], T; int k, w; long long Pow(long long a, long long b) { long long d = 1; for (; b; d = (b & 1) ? d * a % MOD : d, a = a * a % MOD, b /= 2) ; return d; } long ... |
#include <bits/stdc++.h> int main() { long long int a, b, c, d, x; int t; scanf( %d , &t); while (t--) { scanf( %lld%lld%lld%lld , &a, &b, &c, &d); x = a / d + (((a / d) / b) * c); printf( %lld n , x); } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int arr[4]; int t = 0; int s = 0; for (int i = 0; i < 4; i++) cin >> arr[i]; for (int m = 0; m < 4; m++) { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { if (arr[m] < arr[j] + arr[k] && arr[j] < arr[m... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 7; const double EPS = 1e-9; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long x, y, z; cin >> x >> y >> z; long long sasha = x % z; long long masha = y % z; if ((s... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; struct state { int l, r, v, d; } node[N]; int n, m, cnt, bit[2][N * 2]; vector<int> g[N]; void add(int x, int val, int *b) { while (x <= n * 2) { b[x] += val; x += (x & (-x)); } } int get(int x, int *b) { i... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t, n, x; cin >> t; while (t--) { cin >> n; long long m[n + 5]; bool flag[n + 5]; memset(m, 0, sizeof(m)); memset(f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.