func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, t, l, r, n, m, p, a, b, c, d, flag; cin >> t; while (t--) { cin >> n; for (i = 0; i < n; i++) { cout << (i + 1) << ; } cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == - , ch = getchar(); while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x; } int main() { int n = read(), ans = 0; for (in... |
#include <bits/stdc++.h> using namespace std; long long n, t, i, k, tam; int main() { while (scanf( %I64d , &n) > 0) { t = 0; tam = 0; for (i = 0; i < n; i++) { scanf( %I64d , &k); if (k % 2 != 0) { tam = k; } t += k; } if (t % 2 != 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, sum; while (cin >> n >> k) { for (int i = k; i >= 1; i--) { sum = ((n * k) / (i)) + i; if ((sum / k) * (sum % k) == n) { break; } } cout << sum << endl; } return 0; } ... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, /STACK:336777216 ) using namespace std; int IT_MAX = 1 << 17; int MOD = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-10; long lo... |
#include <bits/stdc++.h> using namespace std; template <typename flow_t, typename cost_t> struct min_cost_flow { const cost_t COST_INF = numeric_limits<cost_t>::max() / 2; struct edge { int node, rev; flow_t capacity; cost_t cost; edge() {} edge(int _node, int _rev, flow_t _c... |
#include <bits/stdc++.h> using namespace std; int row[1010]; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); memset(row, 0x3f3f3f3f, sizeof row); long long ans = 0; for (int i = (0); i < (n); ++i) { int r, c; scanf( %d %d , &r, &c); row[r] = min(c, row[r]); } ... |
#include <bits/stdc++.h> using namespace std; int n, m, sol[1000005]; struct ell { int dr, cnt, poz; bool operator<(const ell &A) const { return dr < A.dr; } }; multiset<ell> Q; struct el { int x, y, flag, cnt, poz; bool operator<(const el &A) const { if (x == A.x) { if (y == A... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e9 + 1; int a[201][201]; int cnt[10][10]; int calc(int x, int y) { if (x * 2 > y) return 500; else if (x * 4 > y) return 1000; else if (x * 8 > y) return 1500; else if (x * 16 > y) return 2000; else if ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b > a) swap(a, b); if (a % b == 0) return b; else return gcd(b, a % b); } long long int a, b, k, k1, k2; int main() { cin >> a >> b; k = (a * b) / gcd(a, b); k1 = k / a; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXH = 1000000; const int MAXW = 1000000; const int MAXN = 100000; const int MOD = 1000000007; typedef struct R { int x1, y1, x2, y2; } R; int h, w, n; int shead... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <typename T, typename TT> inline ostream &operator<<(ostream &os, const pair<T, TT> &t) { return os << t.first << << t.second; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &t) { ... |
/* Author: ChinmayKarnik Time: 21:14:26 Date: 16-04-2021 */ #include<bits/stdc++.h> using namespace std; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef enum {BLACK,WHITE,GRAY}... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int k, n, fl = 0; cin >> n >> k; v.resize(n); for (int i = 0; i < n; ++i) { cin >> v[i]; if (v[i] == k) fl = 1; } int ct = 0; if (!fl) { v.push_back(k); ct++; ++n; } sort(v... |
#include <bits/stdc++.h> using namespace std; long long bananaz(long long x, long long y) { return (x + 1) * (y + 1) * (x + y) / 2; } int main() { ios_base::sync_with_stdio(false); long long m, b, x = 0, y, max = -1; cin >> m >> b; y = b; while (y >= 0) { if (bananaz(x, y) > max) m... |
#include <bits/stdc++.h> using namespace std; int main() { int goal, n, stations; scanf( %i%i%i , &goal, &n, &stations); vector<pair<int, int> > points; points.push_back(make_pair(n, -1)); points.push_back(make_pair(goal, 2000000000)); for (auto e = 0; e < stations; e++) { int a, b; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)555; const int mod = (int)1e9 + 7; const int P = (int)1e6 + 7; const double pi = acos(-1.0); int a[maxn][maxn], b[maxn][maxn], n; vector<vector<int> > base{{1, 2, 4}, {5, 3, 8}, {9, 6, 7}}; void rec(int n) { if (n == 3) { for ... |
#include <bits/stdc++.h> int gcd(int a, int b) { if (a == 0) return b; else return (b % a, a); } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; long long sum = 0; for (int i = 0; i < n; i++) { ci... |
//#pragma GCC optimize( Ofast ) #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main(){ cin.tie(nullptr); i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int M = 1e5 + 10; const int INF = 2147483647; const int MOD = 1e9 + 7; int T, n, m; int sum; int a[N]; pair<int, int> b[N]; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } long long qpow(long... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10, P = 998244353; const double Pi = acos(-1); inline int read() { int x = 0, f = 1, ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + c... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 22; bool visit[2][N]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < N; i++) { visit[0][i] = 1; } for (int i = 0; i < m; i++) { int x; cin >> x; visit[0][x] = 0; } int ans = 0; for... |
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000LL; const long double EPS = 1e-9; vector<pair<int, int> > clear(vector<pair<int, int> > v) { vector<pair<int, int> > ret; int tox = v[1].first; int x = v[0].first, y = v[0].second; while (x <= tox) { ret.push_bac... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; vector<int> ans; char s1[maxn], s2[maxn]; int n; void op(int x) { for (int i = 1; i <= x; ++i) { s1[i] = s1[i] == 0 ? 1 : 0 ; } reverse(s1 + 1, s1 + 1 + x);... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e17 + 10; const int N = 1e6 + 10; const long long mod = 998244353; map<string, int> ml; long long b[N], vis[N], po[N], num[N], t, n, m, x, y, k, a[N]; long long ex, ey, cnt, ans, sum, flag; long long dist[N]; long long dp[N]; vecto... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 7; long long n, k, a, b, q; long long arr[MAXN]; void read() { cin >> n >> k >> a >> b >> q; } long long acnt[MAXN << 2], asum[MAXN << 2], bcnt[MAXN << 2], bsum[MAXN << 2]; long long getacnt(long long v, long long tl, long long tr,... |
#include <bits/stdc++.h> using namespace std; int n, a[1111], b[1111]; const int inf = 1e9; map<int, int> mp, mp1; int nsd(int x, int y) { while (x > 0 && y > 0) if (x > y) x %= y; else y %= x; return x + y; } int main() { ios_base::sync_with_stdio(false); cin.t... |
#include <bits/stdc++.h> using namespace std; char s[10], a1[] = { vaporeon }, a2[] = { jolteon }, a3[] = { flareon }, a4[] = { espeon }, a5[] = { umbreon }, a6[] = { leafeon }, a7[] = { glaceon }, a8[] = { sylveon }; int n, i; int main() { cin >> n; cin >> s; if (n == 6)... |
#include <bits/stdc++.h> using namespace std; int a[600000]; int main() { int n = 6 * 1e5; a[0] = 0; for (int i = 1; i < n; ++i) { int cur = i; int t = 0; while (cur % 5 == 0) { cur /= 5; t++; } a[i] = a[i - 1] + t; } int m; cin >> m; vecto... |
#include <bits/stdc++.h> using namespace std; int break_point() { char c; while ((c = getchar()) != n ) ; return 0; } template <typename T> void read_integer(T &r) { bool sign = 0; r = 0; char c; while (1) { c = getchar(); if (c == - ) { sign = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, t; cin >> n >> m >> k; if (k > n + m - 2) cout << -1 n ; else { if (k < max(n, m)) cout << max(n * (m / (k + 1)), m * (n / (k + 1))) << endl; else cout << max(m / (k - n + 2), n / (k - m ... |
#include <bits/stdc++.h> using namespace std; char cc[10] = RGBYW ; int d[5][5]; int cnt(int x) { int res = 0; while (x) { res += x & 1; x >>= 1; } return res; } int main() { int(n); scanf( %d , &n); for (int i = 0; i < (n); ++i) { char s[10]; scanf( %s ,... |
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T extgcd(T a, T b, T &x, T &y) { ... |
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; #define rep(i,a,b) for(i=(a);i<=(b);i++) #define ll long long #define pll pair<ll, ll> #define pii pair<int,int> #define pb push_back #define... |
#include <bits/stdc++.h> using namespace std; int v[5][5], sum; int main() { for (int i = 1; i <= 3; i++) for (int h = 1; h <= 3; h++) cin >> v[i][h]; if (v[1][1] == 0) { for (int i = 1; i <= 100000; i++) { int a = v[2][1] + v[2][3] - i; if (a + v[1][2] + v[1][3] == v[3][1] + v... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int vis[10005]; int main() { int n; scanf( %d , &n); int maxn = -1; for (int i = 1; i <= n; i++) { int tmp; scanf( %d , &tmp); vis[tmp]++; maxn = max(maxn, tmp); } long long ans1 = -1, ans2 ... |
#include <bits/stdc++.h> using namespace std; int ord[100100]; int inv_ord[100100]; int dep[100100]; int fa[100100][17]; vector<int> g[100100]; set<int> ss; int ts; void dfs(int p, int f) { ord[p] = ++ts; inv_ord[ord[p]] = p; dep[p] = dep[f] + 1; fa[p][0] = f; for (int i = 0; i < 1... |
#include <bits/stdc++.h> using namespace std; bool inrange(int y) { return ((y >= 1) && (y <= 9)); } int main() { int r1, r2, c1, c2, d1, d2; bool taken[9] = {false}; cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2; int x = (r1 + r2); int y = (c1 + c2); int z = (d1 + d2); int w; if (x == y... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 7; int n; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int _; cin >> _; while (_--) { cin >> n; for (int i = 1; i <= n; i++) { cout << i + 1 << ; } cout << endl; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m; cin >> n; vector<string> a(n); for (int i = 0; i < n; i++) cin >> a[i]; cin >> m; vector<v... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e3 + 3; long long n, mod = 1e9 + 7, dp[N][N][2]; long long f(long long idx, long long diff, long long stat) { long long &ret = dp[idx][diff][stat]; if (ret != -1) return ret; if (idx == n) { ret = 0; return ret; } ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long inf64 = 1e18; void solve() { int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)), b; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int n; int main() { ios_base::sync_with_stdio(false); int n, x[10], y[10], nx[10], ny[10]; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> nx[i] >> ny[i]; int mnx = 1000000, mny = 1000000, mxx = 0, mxy = 0; for (int i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int A[1000005], B[1000005], cnt[1000005], num[1000005]; long long dp[2][1000005]; int main() { int n, k; long long l, ans = 0; cin >> n >> l >> k; if (l <= n) { cout << l << endl; return 0; } for (int i = 0; i < n; i++) scanf( %d ... |
#include <bits/stdc++.h> int n, q[20]; long long A, B, C, a, b, c, m, m1, ans, v, p[20]; void dfs1(register int s, long long now) { if (now > m) return; if (s > n) { if (now < a) return; b = now; c = v / a / b; if (a * b + a * c + b * c < ans) ans = a * b + a * c + b * c, A... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } long long power(long long x, long long p) { if (p == 0) return 1; if (p == 1) return x; if (p % 2) return x * power(x, p - 1); long long y = power(x, p / 2); return y ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5001, M = 1e9 + 7; int n, F, vis[maxn], T = 1, mid, a[maxn], b[maxn], w[maxn][maxn], ans = 1; vector<int> g[maxn]; bool C[maxn]; bool dfs(int v) { vis[v] = T; for (int i = 0; i < g[v].size(); i++) if (vis[g[v][i]] != T) { C... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[200005]; long long eff[200005]; long long dp[200005][2]; long long dfs(int src, int polarity) { long long &ret = dp[src][polarity]; if (ret != -1) return ret; if (adj[src].size() == 0) return ret = eff[src] * polarity; long long sum... |
#include <bits/stdc++.h> using namespace std; int n, m, i, d[100005], x, y, a, b, c, r; int main() { cin >> n >> m; for (i = 1; i <= m; i++) { cin >> x >> y; d[x]++; d[y]++; } for (i = 1; i <= n; i++) { if (d[i] == 1) a++; if (d[i] == 2) b++; if (d[i] == n - 1) ... |
#include <bits/stdc++.h> using namespace std; int mult(int a, int b) { return ((long long)a * b) % 1000000007; } int binaryPow(int n, int p) { int acc = 1; while (p) { if (p & 1) acc = mult(acc, n); n = mult(n, n); p >>= 1; } return acc; } int modularInv(int n) { return binar... |
#include <bits/stdc++.h> using namespace std; int MOD; struct Modint { int val; Modint(int nval = 0) { val = nval % MOD; } Modint& operator+=(Modint r) { val = (val + r.val) % MOD; return *this; } Modint operator+(Modint r) { return Modint(*this) += r; } Modint& operator-=(Modi... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long powmod(long long a, long long b, long long p) { long long res = 1; a %= p; while (b) { if (b & 1) res = res * a % p; a = a * a % p; b >>= 1; } return res; } long long gcd(long long a, l... |
#include <bits/stdc++.h> using namespace std; const int N = 200020, P = 1000000000; int add(int a, int b) { return a + b >= P ? a + b - P : a + b; } struct mat { int r, c, a[2][2]; void construct(int r_, int c_) { r = r_, c = c_; for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j... |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::vector; int main() { long long n; cin >> n; int t = 0; while (n > 0) { if (n % 2 != 0) t++; n = n / 2; } cout << t; int h; cin >> h; return 0; } |
#include <bits/stdc++.h> using namespace std; int dist[65][65][65]; int dp[65][65][65][2]; int n, m, r, td[65][65]; vector<long long> li[1024]; int ans[222222]; void prep() { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < m; k++) dp[i][j][k][0] = dist[k][i][j... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; const int maxm = 1e4; struct tree { int x, h, Lp, Rp; } T[maxn + 5]; struct Mushroom { int x, power; } M[maxm + 5]; int n, m, cnt, L, R, posx[5 * maxn + 5]; double arr[20 * maxn + 5], lazy[20 * maxn + 5]; inline void Push_Up... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long infLL = 0x3f3f3f3f3f3f3f3fLL; const int maxn = 200 + 5; const int maxl = 1000000 + 5; int n, m, q; int g[maxn][maxn]; int a[10], b[10]; bool mrk[maxn][maxn], vis[maxn][maxn]; int cx[maxn][maxn], cy[maxn][maxn],... |
#include<map> #include<set> #include <vector> #include<stack> #include<queue> #include<cmath> #include<string> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include <numeric> // #include <boost/multiprecision/cpp_dec_float_50.hpp> // using namespace boost::multip... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1001; const int maxm = 1001; char c[maxn][maxm]; int n, m; int pair_num[maxn][maxm]; int pair_cnt; int temp_color[maxn][maxm]; map<int, int> Color; int main() { scanf( %d%d n , &n, &m); for (int i = 0, _n = (n); i < _n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n, m, x, y; cin >> n >> m >> x >> y; int arr[n][m]; for (int i = 0; i < n; i++) for (int j = 0; j < m... |
#include <bits/stdc++.h> using namespace std; vector<int> a, k; int fun(int x) { int c = 0; for (auto y : a) if (y <= x) c++; for (auto y : k) { if (y > 0 && y <= x) c++; if (y < 0 && -y <= c) c--; } return c; } int main() { ios_base::sync_with_stdio(false), cin.tie(N... |
#include <bits/stdc++.h> using namespace std; const double eps = 1E-9; const double Exp = 2.718281828459045; const double pi = 3.14159; const double E = 2.7182818284590452354; int isRight(int x1, int x2) { if (x1 < x2) return 1; else return -1; } int main() { int arr[3][2]; f... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, ar[100010]; long long int xr[50010], yr[50010], mr[50010]; while (cin >> t) { for (int i = 0; i < t; i++) { cin >> n; xr[i] = 0; yr[i] = 0; mr[i] = 0; for (int j = 0; j < n; j++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int first, second; scanf( %d%d , &first, &second); if (first > second) swap(first, second); int sum = 0; if (first <= 2) { if (first == 1) sum = second; else { if (second < 5) sum = 4; else {... |
#include <bits/stdc++.h> using namespace std; struct Ratio { long long p; long long q; Ratio(long long p_, long long q_) : p(p_), q(q_) {} bool operator<(const Ratio& o) const { return p * o.q < q * o.p; } bool operator>(const Ratio& o) const { return p * o.q > q * o.p; } bool operator==(con... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, soln; cin >> s; soln = s; for (int i = 0, idx = (n - 1) / 2; i < n; i++) { soln[idx] = s[i]; if ((n + i) % 2 == 0) idx += (i + 1); else if ((n + i) % 2 == 1) idx -= (i + 1)... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, k; string wall[2]; int water = 0; cin >> n >> k; cin >> wall[0] >> wall[1]; queue<pair<int, int> > q; q.push(make_pair(0, 0)); while (!q.empty()) { queue<pair<int, int> > next; do { pair<int, in... |
#include <bits/stdc++.h> using namespace std; int main() { long long k, d; double t; cin >> k >> d >> t; long long time1 = k; long long time2 = 0; if (k % d > 0) { time2 = (k / d + 1) * d - k; } double each_sum = k + (double)time2 / 2; double res = 0; res += (long long)... |
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << endl; err(++it, args...); } const int LIM = 1e5 + 5, MO... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > data; int ii, jj, kk, l; pair<int, int> bc(int x) { int q[4]; for (int i = 0; i < 4; i++) { q[i] = x % 10; x /= 10; } int vis[10]; memset(vis, 0, sizeof vis); vis[ii] = vis[jj] = vis[kk] = vis[l... |
#include <bits/stdc++.h> using namespace std; int x[100] = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 5; pair<int, int> seg[maxn]; int f[maxn][maxn][2]; int ans; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> seg[i].first >> seg[i].second; sort(seg... |
#include <bits/stdc++.h> using namespace std; int n, m, zero, one, tot; long long mod; long long dp[505][505]; string str[505]; long long dfs(int z, int o) { long long& ret = dp[z][o]; if (ret != -1) return ret; ret = 0; if (z == 0 && o == 0) return ret = 1; if (z > 0 && o > 0) { l... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1e6) + 7; const int inf = (1e9) + 7; const long long LLinf = (1e18) + 7; const long double eps = 1e-9; const long long mod = 1e9 + 7; const int maxlog = 31; stack<pair<int, int> > stos; int tab[maxn]; int lewo[maxn]; int prawo[maxn]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a, b; cin >> t; for (int i = 0; i < t; ++i) { bool res = true; cin >> n; cin >> a; for (int i = 1; i < n; ++i) { cin >> b; if (a < b && b - a > 1) res = false; a = b; } cout <... |
#include <bits/stdc++.h> long long quickpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % 1000000007; b >>= 1, a = a * a % 1000000007; } return ans; } using namespace std; const long long N = 1e3 + 7; const long long maxn = 2e3 + 9; long lo... |
#include <bits/stdc++.h> const double eps = 1e-10; using namespace std; int n, m, q, a, b, k; int so; int allin, games; const int N = (1111111); int in[N]; int answ; void cut(int m, int k) { for (int i = 0; i < n; i++) { if (k <= 0) break; if (in[i] != -1 && in[i] % 3 == m) { i... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); void umax(int &a, int b) { a = max(a, b); } void umin(int &a, int b) { a = min(a, b); } void file() { freopen( a.in , r , stdin); } namespace Solver { const int maxn = 220000; int n, k; long long v[maxn]; long long dp[maxn]... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, sum = 0, a, maxx = 0; scanf( %I64d , &n); for (long long i = 0; i < n; ++i) { scanf( %I64d , &a); sum += a; maxx = max(maxx, a); } if (sum - maxx >= maxx) { if (sum % 2) printf( NO n ); ... |
#include <bits/stdc++.h> using namespace std; string vow = aeiou ; const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2}; const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1}; const int dx[] = {-1, 0, 0, 1}; const int dy[] = {0, -1, 1, 0}; const long double pie = 3.14159265358979; const long long mod = 1e9 ... |
#include <bits/stdc++.h> using namespace std; vector<int> sol; int n, m, T, h, mi, cnt, fndm, v[1000100], sec; char ch; int main() { cin >> n >> m >> T; for (int i = 1; i <= n; ++i) { cin >> h; cin >> ch; h *= 3600; cin >> mi; cin >> ch; mi *= 60; cin >> sec; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e3 + 5, mod = 998244353, inf = 1e18 + 7; long long dp[N][N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, k; cin >> n >> m >> k; for (long long i = 0; i <= n; i++) { dp[i][0... |
#include <bits/stdc++.h> using namespace std; long n, m; long a[4], b[4], c[4]; int main() { cin >> n; for (int i = 1; i <= 3; i++) { cin >> a[i] >> b[i]; c[i] = a[i]; } m = a[1] + a[2] + a[3]; for (int i = 1; i <= 3; i++) { while (c[i] < b[i] && m < n) { c[i] += 1;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; const int MAXM = 1000005; const int MOD = 1000000007; const int MAMOD = 998244353; const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1.0); const double EPS = 1e-8; long long n, k, b, ... |
#include <bits/stdc++.h> int in() { int x = 0; char c = getchar(); bool f = false; while (c < 0 || c > 9 ) f |= c == - , c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return f ? -x : x; } long long lin() { long long x = 0; ... |
#include <bits/stdc++.h> const long long MOD = 1e9 + 7, INF = 1e18 + 1; using namespace std; long long a[1000000], cnt, n, m; long long p[1000000], sz[1000000]; int d[10000001]; long long gcd(long long a, long long b) { if (!b) return (a > 1); else return gcd(b, a % b); } long long f... |
#include <bits/stdc++.h> using namespace std; bool cmp(long long a, long long b) { return (a > b); } long long ceil(const long long &a, const long long &b) { if (a % b == 0) return a / b; return a / b + 1; } long long mod = 1000000007; const long long N = 100005; using namespace std; long long a... |
#include <bits/stdc++.h> using namespace std; int l[5010], r[5010]; vector<int> vc; long long f[2][10100]; int cost[10100]; int doit(int x, int y) { if (vc[x] <= l[y]) return l[y] - vc[x]; if (vc[x] >= r[y]) return vc[x] - r[y]; return 0; } int main() { int start = 0; int n; scan... |
#include <bits/stdc++.h> using namespace std; string itos(int x) { stringstream ss; ss << x; return ss.str(); } int n, m, res, bestlone; map<string, vector<int> > m1; string str; int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for (int i = 0, x; i < n; i++) { ci... |
#include <bits/stdc++.h> using namespace std; int a, b, c, d; int main() { cin >> a >> b >> c >> d; if (c - d < -1 || c - d > 1 || a < max(c, d) || b < max(c, d)) { cout << -1; return 0; } if (c - d == -1) { for (int i = 0; i < d; i++) { if (i == d - 1) for (int... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int test; cin >> test; while (test--) { int a, b, x, y; cin >> a >> b; if (a < b) swap(a, b); bool ok = 1; x = 2 * a - b; if (x % 3 != 0) ok = 0; y = x / ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int dif, same; if (a > b) { dif = b; same = (a - b) / 2; } else { dif = a; same = (b - a) / 2; } cout << dif << << same; return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T> inline string toString(T a) { ostringstream os( ); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <type... |
#include <bits/stdc++.h> using namespace std; const long long mm = 2; long long n, nn = 0, a1[mm + 1], m0[mm + 1][mm + 1], m1[mm + 1][mm + 1], tmp[mm + 1][mm + 1], mz[mm + 1][mm + 1], az[mm + 1], dv; queue<long long> q; void mul(long long x[mm + 1][mm + 1], long long y[mm + 1][mm + 1], ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { char ch = getchar(); register long long x = 0; int f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch ^ 48); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; int i = 0, j = 0; int freq[2] = {0, 0}; int ans = 0; bool over = 0; while (j < n) { while (min(freq[0], freq[1]) <= k && j < n) { freq[s[j] - a ]++; if (... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; string s; int mark[1000006]; bitset<1000006> prime; void isprime() { prime.set(); for (int i = 2; i < 1000006; i++) { if (prime[i]) { for (int j = i + i; j < 1000006; j += i) prime[j] = false; } } } int main(void) { int n, m... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } int F[100009], arr[100009], ans[100009... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); string s, str; int i, k, l, h, n; cin >> n; vector<string> v(n + 1); for (i = 1; i <= n; i++) cin >> v[i]; cin >> s; if (s.size() < 5) { cout << no ; return 0; } k = 0, h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.