func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; char s[200]; int main() { int T; scanf( %d , &T); for (int t = 1; t <= T; t++) { bool num = 0, xx = 0, dx = 0; vector<int> res; scanf( %s , s + 1); int len = strlen(s + 1); for (int i = 1; i <= len; i+... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int sum = 0; for (int i = 0; i < n - 1; i++) sum += (a[n - 1] - a[i]); cout << sum; } |
#include <bits/stdc++.h> void swap(int *, int *); int main() { int i, j, k; int n; scanf( %d , &n); int arr[n]; for (i = 0; i < n; i++) { scanf( %d , &arr[i]); } int limit = n / 2; for (i = 0; i < limit; i++) { if (i % 2 == 0) { swap(&arr[i], &arr[n - i - 1]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); int a, b, a_min, b_min; scanf( %d %d , &a_min, &b_min); for (int i = 1; i < n; i++) { scanf( %d %d , &a, &b); if (a * b_min < a_min * b) { a_min = a; b_min = b; } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; struct P { long long x, y; bool a; P() {} P(long long _x, long long _y, bool _a) : x(_x), y(_y), a(_a) {} long long operator^(const P &t) const { return x * t.y - y * t.x; } bool operator<(const P &t) const { if (y == t... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long double EPS = 1e-6; const int N = 200020, MOD = 998244353; int n, k; long long a[N + 20], fact[N + 20], inv[N + 20]; long long qpow(long long a, long long b, long long p = MOD) { long long ans = 1; for (; b; b >>= ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> A; vector<pair<int, int> > M; vector<int> PP; int turn; set<int> Go; int ans(int x) { cout << x + 1 << endl; if (Go.empty()) exit(0); cin >> x; return x - 1; } signed main() { ; cin >> n >> m; A.resize(n ... |
#include <bits/stdc++.h> using namespace std; int ans[500][500], st[500][500]; vector<pair<int, int> > go[500][500]; vector<vector<int> > cc; vector<int> c; int mv[1 << 20]; int it; void pr(int n, int k) { if (k == 1) { c.push_back(n); mv[(((c[4] * 16 + c[3]) * 16 + c[2]) * 16 + c[1]) * ... |
#include <bits/stdc++.h> using namespace std; int n, i; int a, b, c, d; vector<long long> v; long long ans; void add(int a, int b) { ans += a - b; v.push_back(a + b); } void add_stack() { if (a + b >= c + d) { add(a, b); add(c, d); return; } if (a > d) add(a - d, d ... |
#include <bits/stdc++.h> using namespace std; const int M = 4005; int read() { int x = 0, f = 1; char c; while ((c = getchar()) < 0 || c > 9 ) { if (c == - ) f = -1; } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); } return x * f... |
#include <bits/stdc++.h> using namespace std; int n, m, q, l, r; double d, s, t, x, y; int tree[2000010 * 4], pl[2000010 * 4], pr[2000010 * 4], cnt = 1; bool flag[2000010 * 4]; void change(int l, int r, int id, int l1, int r1) { if (l >= l1 && r <= r1) { tree[id] = r - l + 1; flag[id] = 1; ... |
#include <bits/stdc++.h> using namespace std; map<string, string> m; int main() { int n; string j, x; cin >> n; while (n--) { cin >> j >> x; if (m.count(j) == 0) m[x] = j; else { m[x] = m[j]; m.erase(j); } } cout << m.size() << endl; map<... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int cnt, lst, fa[N * 2], len[N * 2], ch[N * 2][26]; long long w[N * 2], ans; int od[N * 2], rk[N * 2], l = 1; char s[N]; void Init() { cnt = lst = 1; } void Insert(int c) { int p = lst, np = lst = ++cnt; len[np] = len[p] + 1; ... |
#include <bits/stdc++.h> using namespace std; int t, n, m, ans; vector<vector<int>> gh, used; int dx[8] = {1, 1, 1, 0, 0, -1, -1, -1}; int dy[8] = {1, 0, -1, 1, -1, 1, 0, -1}; bool onseg(double x1, double y1, double x2, double y2, double x, double y) { double d1 = sqrt((x - x1) * (x - x1) + (y - y1) * (... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2000; int N; int board[MAX_N][MAX_N]; int cur[MAX_N][MAX_N]; int row[MAX_N], col[MAX_N]; char buf[MAX_N + 10]; void pb(int arr[MAX_N][MAX_N]) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { printf( %d , arr[i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; const int P = 998244353; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1;... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n, x; cin >> n, x = n; long long cnt = 0, d = n; for (int i = 2; 1LL * i * i <= x; i++) { if (x % i == 0) { cnt++, d = i; whi... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1E-8; inline bool eq(double a, double b) { return a - b < EPS && b - a < EPS; } inline bool ne(double a, double b) { return a + EPS < b || b + EPS < a; } inline bool ls(double a, double b) { return a + EPS < b; } inline bool gr(double a, doubl... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include <bits/stdc++.h> using namespace std; const int N = 28; vector<int> g[N]; int vis[2000000]; int main() { int k, n; string ss, s; cin >> k >> ss; for (int i = 0; i < k; ++i) s += ss; for (int i = 0; i != s.size(); ++i) g[s[i] - a ].push_back(i); cin >> n; vector<int>::itera... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int n, m; int adj[N][N], d[N][N]; bool check(int a, int b) { if (a >= 0 && a < n && b >= 0 && b < m && adj[a][b] != -1) return 1; return 0; } void bfs(int x, int y) { d[x][y] = 0; queue<pair<int, int> > q; q.push({x, ... |
#include <bits/stdc++.h> using namespace std; inline string GetString() { char S[1000005]; scanf( %s , S); string ret = S; return ret; } inline char getc() { char c = ; while (c == || c == t || c == r || c == n ) c = getchar(); return c; } template <typename t> t... |
#include <bits/stdc++.h> using namespace std; int arr[1003][1003]; int n, m; int dp[1003][1003]; int vis[1003][1003]; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int dfs(int i, int j, int x) { if (vis[i][j] == 2) { printf( Poor Inna! n ); exit(0); } if (dp[i][j] != -1) ... |
#include <bits/stdc++.h> using namespace std; int ex, ey; bool a[207][207]; bool vis[207][207]; int dx[4] = {0, 0, 1, -1}; int dy[4] = {-1, 1, 0, 0}; int bfs() { queue<pair<int, int>> q; vis[100][100] = true; q.push(make_pair(100, 100)); int dep = 0; while (int(q.size())) { int s... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 513; int N, ans[MAXN]; multiset<int> m; int gcd(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } void solve() { for (int k = N; k >= 1; k--) { ans[k] = -(*m.begin()); m.erase(m.fi... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-6; const long double pi = acos(-1.0); int dx[] = {0, 1, 0, -1, 1, 1, -1, -1, 0}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1, 0}; int aq[5][5]; int main() { int n; cin >> n; for (int i = 0; i < (int)(n); ++i) { int x, y... |
#include <bits/stdc++.h> using namespace std; const int64_t INF = 0x3f3f3f3f; const int64_t INFLL = 0x3f3f3f3f3f3f3f3f; const int64_t MOD = 1e9 + 7; const double EPS = 1e-9; const double PI = acos(-1); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int64_t rand(int64_t x, int64_t y... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const double inf = 1e10; int n, m, q, Eu[N], Ev[N], all[N], vis[N]; vector<int> V; map<pair<int, int>, int> F, S; struct P { double x, y; } p[N]; inline P operator+(const P& a, const P& b) { return (P){a.x + b.x, a.y + b.y}; } i... |
#include <bits/stdc++.h> int main() { int a, b, c, d, flag = 0; scanf( %d %d %d %d , &a, &b, &c, &d); if (a + b > c && b + c > a && c + a > b) flag = 1; else if (b + c > d && c + d > b && d + b > c) flag = 1; else if (c + d > a && d + a > c && a + c > d) flag = 1; else if (a ... |
#include <bits/stdc++.h> const int MAXN = 1000; int ba[MAXN], bb[MAXN]; int a, b, da, db, t, x, l1, l2; int main() { scanf( %d %d %d %d %d %d , &x, &t, &a, &b, &da, &db); int tm = 0; while (a >= 0) { ba[l1++] = a; a -= da; tm++; if (tm >= t) break; } tm = 0; while... |
#include <bits/stdc++.h> using namespace std; struct Item { int id, t, d, p; Item(int _id = 0, int _t = 0, int _d = 0, int _p = 0) : id(_id), t(_t), d(_d), p(_p) {} bool operator<(const Item &rhs) const { return d < rhs.d; } }; constexpr int kN = 101, kT = 2001; Item a[kN]; int dp[kN][kT... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; set<int> s; while (1) { int k = s.size(); s.insert(n); int m = s.size(); if (k == m) break; n = n + 1; while (n % 10 == 0... |
#include <bits/stdc++.h> using namespace std; bool comp(pair<long long, long long> a, pair<long long, long long> b) { return a.first > b.first; } long long findBest(vector<pair<long long, long long> >& ps, long long x) { long long res = 0; for (long long i = 0; i < ps.size(); i++) { long long ... |
#include <bits/stdc++.h> using namespace std; struct node { int i; int num; } a[1005]; bool cmp(node x, node y) { return x.num < y.num; } int main() { int t; scanf( %d , &t); while (t--) { int n, m; scanf( %d %d , &n, &m); int i, j; int ans = 0; for (i = 1; i ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 + 7, MAX_SUM = 10 * 1000 + 7, DELTA = 1000 * 1000 * 1000 + 7; long long inputArray[MAXN], numberOfSubarrays[MAXN][2 * MAX_SUM], PSum; int main() { int numberOfInput; cin >> numberOfInput; for (int i = 0; i < numberOfInpu... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct heap { vector<pair<int, int> > v; int loc[N]; heap() { v.push_back(make_pair(-1, -1)); memset(loc, -1, sizeof loc); } void push(pair<int, int> p) { int cur; cur = v.size(); loc[p.second] = ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1111; const int INF = 0x7f7f7f7f; int cases; const double EPS = 1e-8; inline int sgn(double a) { return a < -EPS ? -1 : a > EPS; } int main() { double s, a, b, c; cin >> s >> a >> b >> c; if (!sgn(a) && !sgn(b) && !sgn(c)) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int cnt[4]; int main() { int n; scanf( %d , &n); getchar(); for (int i = 0; i < n; ++i) { char ch = getchar(); if (ch == A ) { ++cnt[0]; } else if (ch == C ) { ++cnt[1]; } else if ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long MAX = 1e6 + 10; long long a[100005]; int main() { long long n, k, m, sum, t, len; string s, d; while (cin >> n) { int flag = 1; sum = 0; if (n % 2 == 0) { cout << n / 2 << endl; ... |
#include <bits/stdc++.h> using namespace std; long long a[200010], t; int n; long long b[200010]; int g[200010]; bool no[200010]; int main() { scanf( %d %I64d , &n, &t); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int maxn = 2e5 + 100; long long dp[52][52][52]; bool vis[52][52][52]; long long val[52][52][52]; int a[maxn], w[maxn]; long long qmod(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) a... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int N = 200005; const int M = 300; const int OFF = N * M; int _cnt[N + N * M]; int *cnt = _cnt + OFF; int main() { char s[N]; scanf( %s , s); int n = strlen(s); int psum[N]; for (in... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2005, MOD = 998244353; char ch[MAXN]; long long cnt[MAXN], dp[MAXN][MAXN]; long long KSM(long long a, long long t) { long long ans = 1; while (t) { if (t & 1) ans = ans * a % MOD; t >>= 1; a = a * a % MOD; } retur... |
#include <bits/stdc++.h> int main() { int i, j, l, x = 0; char s[100005]; gets(s); l = strlen(s); for (i = 0, j = l - 1; i < l / 2; i++, j--) { if (s[i] != s[j]) { x = 1; break; } } if (x == 1) { printf( NO n ); } else { for (i = 0; i < l; i++) {... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int MAX = 2e3 + 5; const long long MAX2 = 11; const long long MOD = 998244353; const long long MOD2 = 1000005329; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, 0, -1, 1... |
#include <bits/stdc++.h> using namespace std; const long long int inf = 1e18; int n, m, k, x, p; int mat[1005][1005]; void solve(int tc) { cin >> n >> m >> k >> p; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> mat[i][j]; } } multiset<int, greater<int> >... |
#include <bits/stdc++.h> using namespace std; const long long PR = 1000000009; long long n, A[3][100009], dp[3][100009]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < 100009; i++) A[0][i] = A[1][i] = A[2][i] = 0, dp[0][i] = dp[1][i] = dp[2][i] = -1 * 10000000000... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.1415926535; const double eps = 1e-6; struct TE { int a, b, c; } E[501000]; int tr[501000], n, x[501000], m; bool cmp(TE a, TE b) { return a.a < b.a; } int low(int a) { return (a & (-a)); } int ask(int a) { int ret = 1992837465; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int n, u, v, x, trie[maxn << 1][26], sz[maxn << 1], tot, cnt[maxn], res; char op[2]; int merge(int a, int b) { if (!a || !b) return a + b; int rt = ++tot; memset(trie[rt], 0, sizeof trie[rt]); sz[rt] = 1; for (int i = 0... |
#include <bits/stdc++.h> using namespace std; const long long int p = 1e9 + 7; const int N = 1e5 + 1; long long int fact[N]; long long int ncr[N]; long long int n_1cr[N]; void factorial() { fact[0] = fact[1] = 1; for (int i = 2; i < N; i++) { fact[i] = i * fact[i - 1]; fact[i] %= p; ... |
#include <bits/stdc++.h> using namespace std; int n, m, M; vector<set<int> > A; vector<set<pair<int, int> > > B; vector<int> d, f, F, G; vector<bool> v; inline void upd(int& a, int b) { if (d[a] > d[b]) a = b; } void ff(int x, int y) { f[x] = x, v[x] = 1; for (set<int>::iterator i = A[x].b... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int T = 1; while (T--) { long long int n, i, j; cin >> n; long long int a[n + 5]; long long int b[n + 5]; unordered_map<long long int, long long in... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MAXN = 2e5 + 7; long long a[MAXN]; bool good[MAXN]; long long want[MAXN], pref[MAXN], next_[MAXN]; signed main() { ios_base::sync_with_stdio(false); cout.precision(40); long long n; cin >> n; f... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, m; cin >> n >> m; long long sum = 0; for (long long i = 0; i < n; i++) { long long x; cin >> x; sum += x; } cout << min(sum, m) << n ... |
#include <bits/stdc++.h> using namespace std; int n; int x, y; int p[1000003]; int r[1000003]; map<int, int> a; int ans[200003]; int s; int parent(int x) { if (p[x] < 0) return x; return p[x] = parent(p[x]); } void join(int x, int y) { p[y] = parent(x); } int main() { fill_n(p, 10000... |
#include <bits/stdc++.h> using namespace std; long long C(int a, int b) { long long ans = 1; for (int i = 0; i < b; ++i) ans *= (a - i), ans /= (i + 1); return ans; } int main() { int n; while (cin >> n) cout << C(n + 4, 5) * C(n + 2, 3) << endl; } |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 10; struct Seg { long long mn, id; }; long long arr[maxn], N, P, ans[maxn]; Seg seg[maxn << 2]; inline Seg pushup(long long cur) { Seg l = seg[cur << 1], r = seg[cur << 1 | 1]; if (l.mn == r.mn) { return l; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; while ((count * (count + 1)) / 2 <= n) { ++count; } --count; int val = (count * (count + 1)) / 2; int diff = n - val; cout << count << n ; for (int i = 1; i <= count; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int t; int n; int a[100086]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int x = 0, y = a[1]; for (int i = 2; i <= n; i++) { if (a[i] > a[i - 1]) { ... |
#include <bits/stdc++.h> using namespace std; int k, b, n; map<int, int>::iterator it; int main() { map<int, int> mp; while (scanf( %d%d%d , &k, &b, &n) != EOF) { mp.clear(); if (b == 0) { int a, sum = 0; long long res = 0; mp[0] = 1; for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int a[N], cnt[N * 2], n, m; long long solve(int m) { int s = n; memset(cnt, 0, sizeof(cnt)); cnt[s] = 1; long long add = 0, ans = 0; for (int i = 1; i <= n; i++) { if (a[i] >= m) add += cnt[s], s++; else... |
#include <bits/stdc++.h> using namespace std; long long t1, t2, x1, x2, t; bool Check(long long y1, long long y2) { return t1 * y1 + t2 * y2 >= t * (y1 + y2); } double HotBath(long long y1, long long y2) { return 1.0 * (t1 * y1 + t2 * y2) / (y1 + y2); } int main() { cin >> t1 >> t2 >> x1 >> x2... |
#include <bits/stdc++.h> using namespace std; const int maxN = 2000 + 5; int n, mark[maxN], m, st[maxN], start, high[maxN], on[maxN], cnt; vector<int> adj[maxN]; vector<int> s; void DFS(int v) { s.push_back(v); on[v] = mark[v] = 1; st[v] = high[v] = start++; for (int i = 0; i < adj[v].size()... |
#include <bits/stdc++.h> using namespace std; int main() { int w, h, ring, plate = 0; cin >> w >> h >> ring; for (int i = 0; i < ring; i++) { if (i > 0) { w -= 4; h -= 4; } plate += (w * 2) + ((h - 2) * 2); } cout << plate; return 0; } |
#include <bits/stdc++.h> using namespace std; long long b, ans; int main(void) { cin >> b; for (long long i = 1; i * i <= b; i++) { if (b % i == 0) { ans = ans + 2; } if (i * i == b) ans--; } cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, q, i, num, x, y; cin >> n >> q; for (i = 0; i < q; i++) { cin >> x >> y; if ((x + y) % 2 == 0) { x--; num = (n / 2 + n % 2) * (x / 2 + x % 2) + (n / 2) * (x / 2) + (y / 2 + y % 2); ... |
#include <bits/stdc++.h> int main() { long long int n; std::cin >> n; if (n % 2 == 0) { std::cout << n / 2 << std::endl; } else { std::cout << -(n + 1) / 2 << std::endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e18; const string nl = n ; int32_t main() { ios::sync_with_stdio(0); cin.tie(nullptr); long long n, k, second, t; cin >> n >> k >> second >> t; vector<pair<long long, long long>> a(n); ... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-9; int main() { ios_base::sync_with_stdio(false); int n, arra[100010], arrb[100010]; cin >> n; for (int i = 0; i < (int)(n); i++) { cin >> arra[i]; arrb[i] ... |
#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; long long MOD = 1e9 + 7, MAX = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n0, n1, n2, i; cin >> n0 >> n1 >> n2; string second = ; if (n1) { ... |
#include <bits/stdc++.h> using namespace std; int l[123], r[123]; int d[123]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; l[0] = 0; for (int i = 1; i < n; ++i) { int x; cin >> x; l[i] = l[i - 1] + x; } r[n - 1] = 0; vector<int> a; for (in... |
#include <bits/stdc++.h> using namespace std; inline long long max3(long long a, long long b, long long c) { return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c)); } inline long long min3(long long a, long long b, long long c) { return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool mmax(T &m, const T q) { if (m < q) { m = q; return true; } else return false; } template <typename T> bool mmin(T &m, const T q) { if (m > q) { m = q; return true; } else return false... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int lazy[maxn << 2]; int a[maxn], c[maxn]; void pushup(int l, int r, int rt) { lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt]; lazy[rt] = 0; } void update(int L, int R, int c, int l, int r, int rt) { if (L <= l && R >= r) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, x; scanf( %d , &n); priority_queue<int, vector<int>, greater<int> > que; long long ans = 0; for (int i = 0; i < n; i++) { scanf( %d , &x); if (que.empty() || que.top() > x) que.push(x); else { ... |
#include <bits/stdc++.h> using namespace std; mt19937 rndll(chrono::steady_clock::now().time_since_epoch().count()); const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int N = 2e5 + 5; int n, q, a, b, cnt, k, par[N]; vector<int> adj[N], v; pair<int, int> rng[N]; void dfs(int u, int p) { par[u] = (p !=... |
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<int> v; cin >> n; int x = 1; for (int i = 1; i <= n; i++) { int d; cin >> d; if (d == x) { v.push_back(i + 2000); x++; } } cout << v.size() << endl; for (int i = 0; i < v.... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 7; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; long long ans; int a[maxn]; int ned[maxn]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); ned[i] = a[i] + 1; } ... |
#include <bits/stdc++.h> using namespace std; vector<long long> A; long long B[1000000] = {0}; bool cmp(long long x, long long y) { return x > y; } int main() { A.clear(); string S1, S2; cin >> S1; for (long long i = 0; i < S1.size(); i++) A.push_back(S1[i] - 0 ); cin >> S2; for (long... |
#include <bits/stdc++.h> using namespace std; struct Point { int num; int next[3001]; int count; }; Point a[3001]; int dis[3001]; int p[3001]; int cir[3001]; int cir1[3001]; int f(int n) { int i, num = 0, d = 1; loop: while (1) { num = 0; for (i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chkmin(T &x, T y) { return x > y ? x = y, 1 : 0; } template <typename T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } template <typename T> inline void read(T &x) { char ch = getchar(); in... |
#include <bits/stdc++.h> using namespace std; const int _ = 600 + 7; const int __ = 1e5 + 7; const int S = 601, T = 602; const int inf = 0x3f3f3f3f; int n; int lst[_], nxt[__], to[__], cap[__], tot = 1; long long ans; int gi() { int x = 0; bool f = 0; char c = getchar(); while (!isdigi... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[100010]; cin >> n >> k; if (n / 2 > k) printf( -1 n ); else { if (n == 1) { if (k == 0) printf( 1 n ); else printf( -1 n ); } else { int t = k - (n / 2 - 1); p... |
#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 a, b, n, s; cin >> a >> b >> n >> s; long long int r = s % n; long long int q = s / n; if (q <= a) { ... |
#include <bits/stdc++.h> using namespace std; string itos(int x) { stringstream ss; ss << x; return ss.str(); } int xorsum, n, a[110]; map<int, int> grun; int sieve[31700]; vector<int> p; int mex(set<int> &s) { for (int i = 0;; i++) if (not s.count(i)) return i; } int getGrundy... |
#include <bits/stdc++.h> using namespace std; const long long int Maxn3 = 1e3 + 10; const long long int Maxn4 = 1e4 + 10; const long long int Maxn5 = 1e5 + 10; const long long int Maxn6 = 1e6 + 10; const long long int Maxn7 = 1e7 + 10; const long long int Maxn8 = 1e8 + 10; const long long int Maxn9 = 1e... |
#include <bits/stdc++.h> std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n, w, m; std::cin >> n >> w >> m; std::cout << std::setprecision(10) << std::fixed; std::vector<std:... |
#include <bits/stdc++.h> using namespace std; constexpr int INF = 1e9 + 1; constexpr long long LLINF = 1e18 + 1; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } void solve() { int n, t; cin >> n; vect... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; cout << a[1] - a[0] << << a[n - 1] - a[0] << endl; for (int i = 1; i <= n - 2; i++) { cout << min(a[i] - a[i - 1], a[i + 1] - a[i]) << ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int power(int v, int u) { if (!u) return 1; int ok = power(v, u >> 1); if (u & 1) return (long long)ok * ok % mod * v % mod; return (long long)ok * ok % mod; } const int maxm = 2e5; int b[maxm + 10]; int main() { ... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = acos(-1); template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x;... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long Power(long long a, long long b) { if (a == 0) return 0LL; long long ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; a = (a * a) % mod; b >>= 1; } return ans; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long dp[20][20][20]; int a[20]; long long num[20]; long long dfs(int pos, int pre, int sta, bool flag) { if (pos == 0) { if (pre == sta) return 1; else return 0; } if (dp[pos][pre][sta] != -1 ... |
#include <bits/stdc++.h> using namespace std; int a[29]; int main() { int n, k; char s[105]; scanf( %d , &n); scanf( %d , &k); scanf( %s , s + 1); bool f(true); for (int i = 1; i <= n; ++i) { int temp = s[i] - a ; a[temp]++; if (a[temp] > k) { f = false; ... |
#include <bits/stdc++.h> const int mod = 1000003; char str[2010]; int f[2010][2010]; int main() { int n, i, j, len; bool flag = true; gets(str); n = strlen(str); for (i = 0; i <= n; i++) { if (str[i] == * || str[i] == / || i == n) if (i == 0 || str[i - 1] < 0 || str[i - 1... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using pi = pair<int, int>; namespace output { void pr(int x) { cout << x; } void pr(long x) { cout << x; } void pr(ll x) { cout << x; } void pr(unsigned x) { cout << x; } void pr(unsi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long int cal(long long int num) { return (num * (num + 1)) / 2ll; } void solve() { long long int n; scanf( %lld , &n); n--; long long int ans = 0, k = 1; for (long long int i = 1; i <= n; i <<= 1) { ans += ((... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 9; const double eps = 1e-5; const int maxN = 2e3 + 10; const int inf = 1e9; int n, m; vector<pair<int, int> > a[maxN]; int vis[maxN], c[maxN]; vector<int> pat; inline void dfs(int v, int f = -1) { for (int i = 0; i < a[v].size()... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> edge[110000]; vector<pair<int, int> > R; set<int> N; int find(int rt, int to) { int i; for (i = 0; i < edge[rt].size(); i++) { if (edge[rt][i] == to) return 1; } return 0; } int dfs(int rt) { if (R.size() == m ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.