func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n; char s[1000]; bool check_type() { int i; for (i = 1; s[i]; i++) { if (!isdigit(s[i]) && isdigit(s[i - 1])) return true; } return false; } void first() { int i, n = 0, m = 0; for (i = 0; !isdigit(s[i]); i++) n = 26 * n + s[i] ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 10e-9; const int INF = 1e9 + 5; const long long INFLL = (long long)INF * (long long)INF; const long long MOD = 1e9 + 7; const long double PI = 3.14159265358979323846; struct HASH { size_t operator()(const pair<int, int>& x) const { ... |
#include <bits/stdc++.h> long long int power(int x, int y) { int i = 0; long long int result = 1; for (i = 0; i < y; i++) result = result * x; return result; } int main() { int r, d, r1; int n; int x, y; int i = 0; double dist = 0; int count = 0; double temp1, temp2; ... |
#include <bits/stdc++.h> using namespace std; void getZarr(const string &str, int Z[]) { int n = str.length(); int L, R, k; L = R = 0; for (int i = 1; i < n; ++i) { if (i > R) { L = R = i; while (R < n && str[R - L] == str[R]) R++; Z[i] = R - L; R--; } els... |
#include <bits/stdc++.h> const double EPS = 1e-9; const long long MOD = 1000000007; const int INF = 2000 * 1000 * 1000 + 5; const int MAX = 1005; using namespace std; int popcount(int n) { bitset<32> b(n); return b.count(); } long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; vector<pair<int, int>> v; set<int> s; for (int i = 0; i < n; i++) { cin >> a[i]; v.push_back(make_pair(a[i], i)); s.insert(a[i]); } int m = s.size(); sort(v.begin(), v.end()); ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a, id(n + 1), res(n + 1); a.push_back(-1); for (int i = 0, j; i < n; i++) { cin >> j; if (a.back() != j) a.push_back(j); } int m = a.size() - 1; queue<array<int, 3>> q; vector<in... |
#include <bits/stdc++.h> using namespace std; int a[100010]; int b[100010]; long long dp[100010][2]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { cin >> b[i]; } dp[1][0] = a[1]; dp[1][1] = b[1]; long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, pos, l, r; cin >> n >> pos >> l >> r; if (pos > r) { if (l - 1 == 0) { cout << 0 + pos - r + 1; } else { cout << pos - r + 1 + r - l + 1; } } else if (pos < l) { if (n == r) { cout << l ... |
#include <bits/stdc++.h> using namespace std; char CRTBUFF[30000]; struct debugger { static void call(const char* it) {} template <typename T, typename... aT> static void call(const char* it, T a, aT... rest) { string b; for (; *it && *it != , ; ++it) if (*it != ) b += *it; ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; template <class T> void chmin(T &a, const T &b) { if (a > b) a = b; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } long long dp[200020]; const long long INF = 1e18; int main() { cin.ti... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; struct tree { int lt, rt; long long sumdis, sum, cnt; } a[N * 4]; int c[N], b[N], tmp[N], cnt, bb[N]; int find(int x) { int lt = 1, rt = cnt, mid; while (lt <= rt) { mid = (lt + rt) / 2; if (c[mid] == x) return m... |
#include <bits/stdc++.h> using namespace std; int tree[27][2000000 + 5]; vector<int> data[244]; int del[2000000 + 6]; int read(int t, int idx) { int sum = 0; while (idx > 0) { sum += tree[t][idx]; idx -= (idx & -idx); } return sum; } void update(int t, int idx, int val) { w... |
#include <bits/stdc++.h> using namespace std; constexpr int full = 0x7fffffff; bool is_valid(const vector<int> &idx, const int max_i, const int i) { if (max_i < 0) return true; if (idx.at(i) == max_i) { return is_valid(idx, max_i - 1, i + 1); } int j; for (j = 1; idx.at(i) + j <= max_i; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; for (int k = 0; k < t; k++) { int n, m; cin >> n >> m; vector<vector<int>> a(max(n, m), vector<int>(max(n, m))); vector<vector<int>> id(n * m, vect... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = 1e9; const long long ninf = LLONG_MIN; const double eps = 1e-12; const long long N = 1000005; const long long LOGN = 19; const double PI = 3.14159265358979323846; long long n, m; long long d[505][50... |
#include <bits/stdc++.h> using namespace std; int a[4], b[4], n, m; void f1() { a[0] = 0; b[0] = 1; a[1] = 0; b[1] = m; a[2] = 0; b[2] = 0; a[3] = 0; b[3] = m - 1; } void f2() { b[0] = 0; a[0] = 1; b[1] = 0; a[1] = n; b[2] = 0; a[2] = 0; b[3] = 0; ... |
#include <bits/stdc++.h> using namespace std; long long n, a[100005], b[100005], dp[100005][5]; long long fun(long long pos, long long ck) { if (pos > n) { return 0; } if (dp[pos][ck] != -1) { return dp[pos][ck]; } long long res = 0, res1 = 0, res2 = 0; if (ck == 0) { res... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, c, d; cin >> a >> b >> c >> d; if (a > b) { if (a == c) { if (b + d == a) { cout << Yes n ; } else { cout << NO n ; } ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const int MAX_N = 200004; char s[MAX_N], t[MAX_N]; int l[MAX_N], r[MAX_N]; vector<int> p[40]; int read() { int x; scanf( %d , &x); return x; } int num(char x) { return x - a ; } bool find(int x, int... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 10; priority_queue<int, vector<int>, greater<int> > q1; queue<int> q2; int n, a[MAXN]; int main() { ios::sync_with_stdio(0); cin >> n; long long ans = 0; for (int i = 1; i <= n; ++i) cin >> a[i], ans += a[i]; sort(a + 1... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long a[n], b[n]; long long sum = 0, tum = 0, cnt = 0, aod = 0, aev = 0, bod = 0, bev = 0; for (long long i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (a[i] % 2 == 0) aev++; if (a[i] % 2 == ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 55, dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; int n, m, k, dis[MAXN][MAXN], sx, sy, tx, ty; queue<pair<int, int> > S; char mp[MAXN][MAXN]; string ans, res; bool r[27], o; bool isval(int x, int y) { return x < n && y < m && x >= 0 && y >=... |
#include <bits/stdc++.h> using namespace std; int n, m; int price[101], fruit[101]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> price[i]; map<string, int> fruits; for (int i = 0; i < m; i++) { char x[101]; cin >> x; if (fruits.find(x) != fruits.end()) ... |
#include <bits/stdc++.h> using namespace std; void run(); int main() { ios::sync_with_stdio(0); run(); } int has[7001]; vector<tuple<int, int, int>> consider[7001]; void run() { int n, m; cin >> n >> m; unordered_map<int, int> renum; int ids = 0; for (int q = 1; q <= m; q++) { ... |
#include <bits/stdc++.h> using namespace std; char chess[8][8]; int main() { for (int i = 0; i < 8; i++) scanf( %s , chess[i]); for (int i = 0; i < 8; i++) { for (int j = 0; j < 7; j++) { if (chess[i][j] == chess[i][j + 1]) { printf( NO n ); return 0; } } ... |
#include <bits/stdc++.h> using namespace std; const int LIM = 200, INF = 1e+9; const double PI = 3.1415926535, EPS = 1e-7; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; template <class T> T gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); } int n, m; int days[] = {31, 29, 31, 30, 31, 30,... |
#include <bits/stdc++.h> using namespace std; using i64 = long long; void solve() { int n, m, k; cin >> n >> m >> k; vector<unordered_set<int> > gr(n); for (int i = 0; i < m; ++i) { int a, b; cin >> a >> b; --a; --b; gr[a].insert(b); gr[b].insert(a); } s... |
#include <bits/stdc++.h> using namespace std; const int MAX = 18; string color[MAX]; int r[MAX], b[MAX]; map<pair<int, int>, int> dp[1 << MAX]; int n; int func() { dp[0][make_pair(0, 0)] = 0; int ans = INT_MAX; for (int mask = 0; mask < (1 << n); mask++) { int R = 0, B = 0; for (in... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) using namespace std; int n, m; vector<vector<int>> grid; int f[1000011]; int visited[1000011]; vector<int> g[1000011]; int find(int x) { if (f[x] == x) return x; return f[x] = find(f[x]); } void unionset(int x, int y)... |
#include <bits/stdc++.h> using namespace std; int main() { int _; for (cin >> _; _; _--) { int n; scanf( %d , &n); double a = 3.1415926535 / n; double cosa = cos(a); double r = sqrt(0.5 / (1 - cosa)); a = a / 4; cosa = cos(a); printf( %.9lf n , r * cosa * 2); ... |
#include <bits/stdc++.h> const int N = 1e6 + 10; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; const double eps = 1e-8; const double pi = acos(-1); using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { in... |
#include <bits/stdc++.h> using namespace std; const int xi[] = {1, 1, 1, 0, 0, -1, -1, -1}; const int yi[] = {-1, 0, 1, -1, 1, -1, 0, 1}; int main() { int m, n; cin >> m >> n; char g[m][n]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) cin >> g[i][j]; int u, v; for (int i... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { int n, fuck = 0; cin >> n; vector<int> A(n); vector<int> used(n, 0); for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) { if (A[i] == i) { used[i] = 1; fuck++; ... |
#include <bits/stdc++.h> using namespace std; void debug() { cerr << n ; } template <typename H, typename... T> void debug(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << , ; debug(t...); } const int N = 52, INF = 1e9 + 5, mod = 1e9 + 7; int dp[N][N][N], opt[N][N][N]; vector<pair<pai... |
#include <bits/stdc++.h> using namespace std; int l; string a, b; int ans = 0x3f3f3f; int main() { ios::sync_with_stdio(false); cin >> l, cin >> a, b = a; sort(a.begin(), a.end()); for (int i = 0, key = 0, cnt = 0; i < l; i++, ans = min(ans, cnt / 2), key = i, cnt = 0) for (int ... |
#include <bits/stdc++.h> using namespace std; long long n, m; int main() { string a, b; cin >> a >> b; for (int i = 0; i < a.length(); i++) { if (a[i] < b[i]) { cout << -1 << endl; return 0; } } cout << b << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > ans; void gen(int n) { for (int e = 0; e < n; e++) ans.push_back({6 * e + 1, 6 * e + 2, 6 * e + 3, 6 * e + 5}); } int main() { int n, k; cin >> n >> k; cout << k * (6 * n - 1) << endl; gen(n); for (auto &it : ans)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int SIZE = 333; int n, m, a[maxn], cnta[maxn], cntc[maxn]; int H1, H2, T1, T2, done, need; long long Ans[maxn]; set<int> S; struct question { int l, r, id; bool operator<(const question &q) const { if ((l / SIZE... |
#include <bits/stdc++.h> using namespace std; namespace stuff { void solve(int test_num) { int R, C; cin >> R >> C; vector<string> grid(R); for (int r = 0; r < R; r++) cin >> grid[r]; vector<vector<int> > cnt(R, vector<int>(C, 0)); for (int r = 0; r < R; r++) { for (int c = 0; c < C;... |
#include <bits/stdc++.h> const int mod = 200003; const int gmod = 2; const int inf = 1039074182; const long long llinf = 1LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inline void chmax(T1 &x, T2 b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, temp = 0; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int i; for (i = 1; i <= n; i++) { temp += i; if (temp >= k) break; } int gap = temp - k; cout << a[i - gap - ... |
#include <bits/stdc++.h> using namespace std; long long a[200005]; set<long long> ns; long long p2[100]; int main() { int n, i, j; int cnt = 0; long long t = 1; while (t < 2000000000) { cnt++; p2[cnt] = t; t *= 2; } cin >> n; for (i = 1; i <= n; i++) { scanf... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; constexpr int N = 1e2 + 5; int n, m, k, g[N][N], ans = -1, id; unordered_set<int> dp[N][N]; char c; bool check(int i, int j, int val) { for (auto el : dp[i][j]) { if (ans == el + val) { ans ... |
#include <bits/stdc++.h> using namespace std; inline int SG(double x) { return x > -1E-8 ? x < 1E-8 ? 0 : 1 : -1; } int c[1000000]; int main() { int n, m, r, i, j, k, d; long long md; scanf( %d %d %d , &n, &m, &r); for (i = 0; i < (n); i++) { scanf( %d , &c[i]); } if (n % 2 == 0) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; double general_sum, sum; general_sum = sum = 0; int i = 0; int j = 0; cin >> n >> k; vector<int> a(n); double w = n - k + 1; for (i; i < w; i++) { if (i == 0) { for (j; j < k; j++) { cin ... |
#include <bits/stdc++.h> using namespace std; const int N = 5005; const int inf = 0x3f3f3f3f; int n, a[N], ma[N][N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int cnt = 0; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (a[i] ... |
#include <bits/stdc++.h> using namespace std; int n, m, K, f[110][110][30], ans = -1e9 - 7, a[30][30], c; char s[110], x, y; int main() { scanf( %s , s + 1); n = strlen(s + 1); scanf( %d%d , &K, &m); for (int i = 1; i <= m; i++) { scanf( %c %c %d , &x, &y, &c); a[x - a ][y - a ] =... |
#include <bits/stdc++.h> using namespace std; int arr[100001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); int cur = 1; for (int i = 0; i < n; i++) { if (cur <= arr... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int i = 1; while (i < n) { if (a[i] > a[i - 1]) i++; else break; } if (n... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n & 1) { cout << (n + 1) / 2; } else { cout << n / 2 + 1 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int a, b, c, x, y, z, q, w, e; int main() { cin >> a >> b >> c >> x >> y >> z; q = a - x; if (q > 0) q /= 2; w = b - y; if (w > 0) w /= 2; e = c - z; if (e > 0) e /= 2; if (q + w + e >= 0) cout << YES ; else cout << NO... |
#include <bits/stdc++.h> using namespace std; const double eps = 0.000000001; double x[200000]; int n; void solve() { if (abs(x[1]) < eps) { int p = 0; for (int i = 1; i < n; i++) if (abs(x[i]) > eps) p++; if (p == 0) { printf( 1 n ); exit(0); } return... |
#pragma GCC optimize ( O3 ) #include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl n const ll DIM = 607; const ll INF = 1E18; vector<pair<int,ll> > G[DIM]; ll dist[DIM],mod[DIM*4]; bool vis[DIM]; struct node{ ll dist; int x,y; }; const bool operator > ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const int N = 5001; int dp[N][26][26]; int main(void) { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.length(); for (int i = (int)(0); i < (int)(n); i++) { int ch = s[i] - a... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 123; int n, c; int made[N], preparedToSell[N]; long long goods[N], limit[N]; long long toSell[N], toSend[N]; void readData() { cin >> n >> c; for (int i = 1; i <= n; ++i) { cin >> made[i]; } for (int i = 1; i <= n; ++i... |
#include <bits/stdc++.h> using namespace std; int v[1010][1010], v1[1010][1010], tip[100], n, m; char sir[2010][1010], sir1[2010][1010]; void transpune() { for (int i = 1; i < 2 * m; i++) if (i % 2) for (int j = 1; j < n; j++) sir1[i][j] = sir[2 * j][i / 2 + 1]; else for (int j =... |
#include <bits/stdc++.h> using namespace std; template <typename T> void Read(T &cn) { char c; int sig = 1; while (!isdigit(c = getchar())) if (c == - ) sig = -1; cn = c - 48; while (isdigit(c = getchar())) cn = cn * 10 + c - 48; cn *= sig; } template <typename T> void Write(T... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long pow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = (res * x); x = (x * x); n >>= 1; } return res; } int32_t main() { i... |
#include <bits/stdc++.h> using namespace std; int n; char a[15][15]; vector<long long int> dp[1 << 14][14]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } for (int... |
#include <bits/stdc++.h> using namespace std; static const int maxn = 1000 + 10; int n, m, f[maxn][maxn]; char s[maxn], t[maxn]; int main() { scanf( %d %d , &n, &m); scanf( %s , s); scanf( %s , t); int mn = n + 1; vector<int> ans; for (int i = 0; i + n <= m; i++) { int count = 0;... |
#include <bits/stdc++.h> using namespace std; void swapll(long long *a, long long *b) { long long tmp = *a; *a = *b; *b = tmp; } void swapc(char *a, char *b) { char tmp = *a; *a = *b; *b = tmp; } void solve() { long long n; cin >> n; vector<long long> v(n, 0); for (lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, ans; cin >> n >> a >> b; if (n == 1) cout << 1 << endl; else { ans = (a + b + abs(b) * n) % n; if (ans == 0) ans = n; cout << ans << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 100010; struct Node { int l, r, w, s; } t[N << 2]; vector<int> a[N], c[N]; int p[N], q[N], L[N], R[N], s[N], z[N]; int cnt, n, m, x, y; void update(int x) { if (t[x].w) t[x].s = t[x].r - t[x].l + 1; else if (t[x].r != t[x].l) ... |
#include <bits/stdc++.h> using namespace std; long long n, ans = 0; long long f[1000001]; int main(int argc, char **argv) { cin >> n; for (int i = 1; i <= n; i++) { long long b; cin >> b; f[b - i + 400000] += b; ans = max(ans, f[b - i + 400000]); } cout << ans << endl; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 18; int a[MAXN]; long long s[MAXN << 2]; int h[MAXN << 2]; void build(int id, int l, int r) { if (l == r) { s[id] = a[l]; h[id] = 0; return; } int mid = (l + r) >> 1; build(id << 1, l, mid); build(id <<... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int z[N], t1[N], t2[N]; string s; vector<pair<int, int> > ans; int n; void BuildZArray() { int L = 0, R = 0; for (int i = 1; i < n; i++) { if (i > R) { L = R = i; while (R < n && s[R - L] == s[R]) R++; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; inline int read() { int s = 0, w = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) w |= (ch == - ), ch = getchar(); while (ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 , ch = getchar(); return w ? -s : s; } struct... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXE = 200005; const int mod = 1e9 + 7; struct Edge { int v; Edge* next; } E[MAXE], *H[MAXN], *cur; int color[MAXN]; long long dp[MAXN][2]; void clear() { cur = E; memset(H, 0, sizeof H); memset(color,... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l, x, y; cin >> n >> l >> x >> y; set<int> d; for (int i = 0; i < n; ++i) { int t; cin >> t; d.insert(t); } bool issetX = false, issetY = false; for (set<int>::iterator i = d.begin(); i != d.end(); ++i) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, flag; cin >> n >> m; int l[m], ans[n], check[n]; memset(ans, 0, sizeof(ans)); memset(check, 0, sizeof(check)); for (int i = 0; i < m; i++) cin >> l[i]; for (int i = 0; i < m - 1; i++) { if (l[i + 1] > l[i]) { ... |
#include <bits/stdc++.h> using namespace std; struct node { int x, id; } s[100101]; bool cmp(node a, node b) { return a.x < b.x; } int main() { int n, i, j, x; cin >> n; for (i = 0; i < n; i++) { cin >> s[i].x; s[i].id = i + 1; } sort(s, s + n, cmp); if (n % 2) x ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 9, MAX2 = 3e5 + 9; const long long MOD = 1e9 + 7; vector<pair<int, int> > g[MAX]; pair<int, int> e[MAX2]; int h[MAX], mark[MAX2], dp[MAX], par[MAX]; bool vis[MAX]; void dfs(int v, int height) { vis[v] = true; h[v] = height; ... |
#include <bits/stdc++.h> using namespace std; int a[500], c, i, n, big; int main() { while (~scanf( %d %d , &n, &c)) { for (i = 0; i < n; i++) { scanf( %d , &a[i]); } big = 0; for (i = 0; i < n - 1; i++) { if (a[i] - a[i + 1] - c > big) big = a[i] - a[i + 1] - c; ... |
#include <bits/stdc++.h> using namespace std; int dist[2 * 100000 + 2 + 5], N, K; vector<int> G[2 * 100000 + 2 + 5]; void addedge(const string &wall, const string &wall2, int i, int offs) { int here = i + offs, there = i + N - offs; if (wall[i] == X ) return; if (i != 0 && wall[i - 1] != X ) G[her... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (b > a) cout << b - a << endl; else { if (a % b) { cout << a / b * b + b - a << endl; } else cout << 0 << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; const int INF = (int)1e9 + 9; const int MOD = (int)1e9 + 7; void go(int x) { cout << x; exit(0); } vector<int> g[N]; set<int> st[N]; int c[N]; bool used[N]; int main() { int n, m, cnt = -1, ans = -1; cin >> n... |
#include <bits/stdc++.h> using namespace std; int h[100005], ans[100005]; int l[100005], r[100005], w[100005]; vector<int> mid2[100005]; int lo2[100005], hi2[100005]; vector<int> cur[100005]; struct st { int le, ri, len, all; }; st seg[400005]; st update_seg(st a, st b) { st res; res.len... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; bool lucky(int x) { while (x) { if (x % 10 != 4 && x % 10 != 7) { return false; } x /= 10; } return true; } int id[maxn], a[maxn], pos[maxn], n; bool f[maxn]; bool check() { for (int i = 0... |
#include <bits/stdc++.h> using namespace std; map<string, string> mp; map<string, int> stn; void Print(string cur) { string res = / ; while (cur != / ) { string tmp = cur; while (int(tmp.size()) && ( 0 <= tmp[tmp.size() - 1] && tmp[tmp.size() - 1] <= 9 )) tmp.erase(t... |
#include <bits/stdc++.h> using namespace std; struct str { int x1; int y1; int x2; int y2; }; bool compare(str &a, str &b) { if (a.x1 < b.x1) return true; else if (a.x1 == b.x1) { if (a.x2 < b.x2) return true; else if (a.x2 == b.x2) { if (a.y1 < b.y1) ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int m = 1e9 + 7; int bin_pow(int x, int k) { if (k == 0) return 1; int g = bin_pow(x, k / 2); g = (1ll * g * g) % m; if (k % 2 > 0) g = (1ll * g * x) % m; return g; } signed main() { iostream::sync_with_st... |
#include <bits/stdc++.h> using namespace std; void add_edge(vector<long long> adj[], long long a, long long b) { adj[a].push_back(b); adj[b].push_back(a); } class myComparator { public: int operator()(int p1, int p2) { return p1 > p2; } }; long long fun(long long x, long long n) { long lo... |
#include <bits/stdc++.h> using namespace std; int B[1000 * 1001]; const int base = 1000 * 1000 + 3; int main() { int n, m; int r = 1; bool ok = true; cin >> n >> m; string A[n]; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) { bool empty = true; for ... |
#include <bits/stdc++.h> using namespace std; int arr[111]; int main() { int n; scanf( %d , &n); arr[0] = 0; for (int i = (1); i < (n + 1); ++i) scanf( %d , &arr[i]); int ans = 0; if (n % 2 == 0 || n == 1) { printf( -1 n ); return 0; } for (int i = n; i >= 1; i -= 2) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010; int n, m, k; char a[MAXN][MAXN]; int pref[MAXN][MAXN]; int getSumLine(int i, int j) { return pref[i][j + k - 1] - pref[i][j - 1] - pref[i - 1][j + k - 1] + pref[i - 1][j - 1]; } int getSumRow(int i, int j) { return p... |
#include <bits/stdc++.h> using namespace std; int t; long long int a, b, n, S; int main() { cin >> t; while (t--) { cin >> a >> b >> n >> S; if (b >= S) { cout << YES << endl; continue; } if (a * n + b < S) { cout << NO << endl; continue; ... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } int main() { int n, k; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:36777216 ) template <class T> inline T &RD(T &); template <class T> inline void OT(const T &); inline int RD() { int x; return RD(x); } inline double &RF(double &); inline double RF() { double x; return RF(... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; struct Node { int t[26], len, f, tf, d, s; } a[1000500]; int tn, las; void linkd(int u) { int fa = a[u].f; a[u].d = a[u].len - a[fa].len; a[u].tf = (a[u].d == a[fa].d && a[u].d * 2 <= a[u].len) ? a[fa].tf : u; } vo... |
#include <bits/stdc++.h> using namespace std; int n, a[1003], d, u, e; vector<int> v1, v2, v3; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) v1.push_back(a[i]); if (a[i] > 0) v2.push_back(a[i]); if (a[i] == 0) v3.push_back(a[i]); } if (v2... |
#include <bits/stdc++.h> using namespace std; namespace IO { const int sz = 1 << 15; char inbuf[sz], outbuf[sz]; char *pinbuf = inbuf + sz; char *poutbuf = outbuf; inline char _getchar() { if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf; return *(pinbuf++); } inline void _... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n, i, j, k, a, b; scanf( %d , &a); if (a == 1) printf( 1 n ); else { printf( %d n , (a - 1) * a / 2 * 12 + 1); } } |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; void solve() { long long n; cin >> n; map<long long, long long> m; for (long long i = 0; i < n; i++) { long long x; cin >> x; m[x]++; } long long mx = 0; long long ans = 0; for (auto it : m... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long int, char> p1, pair<long long int, char> p2) { return p1.first > p2.first; } vector<vector<long long int> > graph; vector<bool> vis; vector<vector<long long int> > level; vector<long long int> d, childp; void dfs(long long int nod... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x7fffffff; long long a[510][510], n; int main() { while (~scanf( %I64d , &n)) { if (n == 1) { scanf( %I64d , &n); printf( 1 n ); continue; } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n;... |
#include <bits/stdc++.h> const int N = 105; int n, m, i, j, k, s[N], h[N], id[N], a[N], l[N], r[N]; int fr[N], fl[N]; bool cmp(int x, int y) { return s[x] < s[y]; } int main() { scanf( %d%d , &n, &m); for (i = 1; i <= m; ++i) scanf( %d%d , s + i, h + i), id[i] = i; if (m == 1) { printf( %d n... |
#include <bits/stdc++.h> using namespace std; int ar[111]; int in[111]; long long n, s, now, t; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; s += ar[i]; in[i] = i; } if (s < n - 1 || ar[0] == 0) { cout << -1; return 0; } for (int ii =... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 6; const long long M = 1e9 + 1; char mat[105][105]; void solve() { long long n; cin >> n; long long row[n]; vector<pair<long long, long long> > vecr; vector<pair<long long, long long> > vecc; long long col[n]; ... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; bool check(int i, int j, int k) { return (i + j > k && j + k > i && j + i > j); } int main() { int n, ct = 0; cin >> n; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { int k = i ^ j; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.