func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int maxn = 51000; int a[1000000], b[1000000], t[1000000], n, flag = 0; void dfs(int m) { if (flag) return; if (m == n) { cout << YES << endl; for (int i = 1; i < n; i++) { cout << t[i] << ; } cout << t[n] << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = 155; int a[N], n, k, s, oo = 1e9, dp[N][N * N], ans; int main() { cin >> n >> k >> s; for (int i = 1; i <= n; i++) cin >> a[i]; s = min(s, n * (n - 1) / 2); for (int i = 0; i <= n; i++) for (int j = 0; j <= n * n; j++) dp[i][j] = ... |
#include <bits/stdc++.h> using namespace std; int fun(pair<int, int> x, pair<int, int> y) { return x.second < y.second; } int main() { vector<pair<int, int> > vii; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int x; cin >> x; vii.push_back(make_pair(x, x % 10)); } ... |
#include <bits/stdc++.h> int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int ans[maxn]; struct node { int l, r; bool operator<(const node& a) const { int s1 = r - l + 1; int s2 = a.r - a.l + 1; if (s1 == s2) return a.l < l; else return a.r - a.l + 1 > r - l + 1; ... |
#include <bits/stdc++.h> const int mod = 1e9 + 7; const int maxn = 1e6 + 3; using namespace std; int bj[maxn]; long long a[100010], f[maxn], inv[maxn], pri[maxn]; long long pre[maxn], per[maxn]; long long BM(long long k) { pre[0] = 1; per[0] = 1; for (int i = 1; i <= maxn; i++) { pre[i] ... |
#include <bits/stdc++.h> unsigned long long u64; using namespace std; int n, m, qr; long long c[2 * 200000], cnt[2 * 200000]; void lazy_update(int v, int i, int j, int qi, int qj, long long x) { if (qi > j || qj < i) return; if (qi <= i && j <= qj) { c[v] += (x + i - qi), ++cnt[v]; return;... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; const int size = 1e6 + 1; int n; double a[size]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin >> n; double l, r, c1, c2; l = r = c1 = c2 = 0; string s; cin >> s; for... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1000000000; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t-- > 0) { int n; cin >> n; string s, s1; cin >> s >> s1; int x = 0;... |
#include <bits/stdc++.h> using namespace std; long long U[10001], V[10000], dis[10000]; long long n, m; vector<long long> adj[10001]; bool bfs() { queue<long long> q; for (long long i = 1; i <= n; i++) { if (U[i] == 0) { dis[i] = 0; q.push(i); } else dis[i] = INT_MA... |
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; const int MOD = (int)998244353; const int INF = (int)1e18; bool cmp(const pair<long long, long long>& a, const pair<long long, long long>& b) { if (a.second == b.second) return a.first < b.first; return a.second > b... |
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; } ll nCr(ll n, ll r) { ll a = 1, b = 1; if (n < r) return 0; if (r == 0) return 1; if (n - r < r) r = n - r; while (r) { a *= n... |
#include <bits/stdc++.h> using namespace std; const int N = (int)2e5 + 5; const int INF = (int)1e9 + 7; int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; int ini() { int x; scanf( %d , &x); return x; } long long inl() { long long x; scanf( %lld , &x); ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; int N, M; int A[MAXN]; int ans[MAXN][MAXN]; void gen(int x) { if (x <= 2) { for (int i = 0; i < x; i++) { A[i] = 3 + i; } return; } else if (x == 3) { A[0] = 1; A[1] = A[2] = 2; return; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 + 17; int n, A[MAXN], L[7], R[7]; void Solve(int u) { bool st = true; for (int i = 1; i <= n; ++i) if (A[i] != i) st = false; if (st) { cout << u - 1 << n ; for (int i = u - 1; i >= 1; --i) cout << L[i] << <<... |
#include <bits/stdc++.h> using namespace std; int n, res[300010], c[300010], trie[300010][30], dif[300010], ans, cans; vector<vector<int> > gr; string s; void merge(int big, int small) { dif[big] = 1; for (int i = 0; i < 26; ++i) { if (trie[small][i] and trie[big][i]) { merge(trie[big][i... |
#include <bits/stdc++.h> using namespace std; long long fact[200001], inv_fact[200001], dp[2010][26]; bool cmp(pair<int, int> a, pair<int, int> b) { return a.first + a.second < b.first + b.second; } long long ModExp(int a, int n) { long long x = a % 1000000007, y = 1 % 1000000007; while (n > 0) { ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; vector<int> lista; vector<int> posicion; vector<set<int> > s; void genera(int u, int p, int lis, int pos) { lista[u] = lis; posicion[u] = pos; vector<int> &ar = g[u]; for (int i = 0; i < int(ar.size()); i++) if (ar[i... |
#include <bits/stdc++.h> using namespace std; int n, m; struct ac { int x, y; } t[202400]; bool cmp(const ac &a, const ac &b) { if (a.x != b.x) { return a.x < b.x; } else { return a.y < b.y; } } bool wfHas(int x, int y) { int l = 0, r = m - 1, mid; while (l < r) { ... |
#include <bits/stdc++.h> using namespace std; long long fen[2][2][1010][1010]; int n, m; void updateFen(int a, int b, int x, int y, long long t) { for (int i = x; i <= n / 2 + 5; i += i & (-i)) for (int j = y; j <= n / 2 + 5; j += j & (-j)) fen[a][b][i][j] ^= t; } long long getFen(int a, int b, in... |
#include <bits/stdc++.h> using namespace std; const int N = 1000004; int a[N]; int spf[N], prime[N]; int cntp[N]; void sieve() { int i, j; for (i = 2; i < N; i++) { if (!prime[i]) { for (j = 1; 1LL * i * j < N; j++) { prime[i * j] = 1; if (!spf[i * j]) spf[i * j] = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int sum = 0; cin >> n; char a[n + 5]; int c[n + 5]; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == R ) c[i] = 0; else if (a[i] == G ) c[i] = 1; else if (a[i] == B ) c... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; long long n, m, cost[105], fri[105], cst, need[105], sscc[110], ss, pd[30], now[30], nn; bool qc[1200000], ttp, ttp2, ttp3, ttp4, ttp5, ttp6; map<pair<long long, long long>, long long> ans; map<long long, long long> jl1, jl2, jl3; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; void output(long long x) { if (x < 0) putchar( - ), x = -x; if (x == 0) { putchar( 0 ); return; } int a[20], num = 0; while (x) a[++num] = x % 10, x /= 10; while (num > 0) putc... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1005; const int INF = 1 << 30; int n, m, xs, xf, ys, yf; char a[4][NMAX][NMAX]; int d[4][NMAX][NMAX]; bool inq[4][NMAX][NMAX]; deque<pair<int, pair<int, int>>> q; bool u(int dir, int x, int y) { char c = a[dir][x][y]; return c == ... |
#include <bits/stdc++.h> using namespace std; int n, t, r, x, A[2000], B[2000], CODE = 0, ans = 0, z, j; void Init() { cin >> n >> t >> r; if (r > t) CODE = 1; else for (int i = 0; i < 1000; i++) { A[i] = 0; B[i] = 0; } } int main() { Init(); if (CODE == 1... |
#include <bits/stdc++.h> using namespace std; int n, K; int CtoI(int x) { if (x == R ) return 1; if (x == Y ) return 2; if (x == B ) return 3; if (x == W ) return 0; } int ItoC(int x) { if (x == 1) return R ; if (x == 2) return Y ; if (x == 3) return B ; if (x == 0) retu... |
#include <bits/stdc++.h> using namespace std; int main() { long long int q, l1, r1, l2, r2; cin >> q; while (q--) { cin >> l1 >> r1 >> l2 >> r2; if (l1 == l2 && r1 == r2) cout << l1 << << r1 << endl; else if (l1 == l2 && r1 != r2) cout << r1 << << r2 << endl; ... |
#include <bits/stdc++.h> using namespace std; void input(vector<int>& v, int n) { int i, io; for (i = 0; i < n; i++) { cin >> io; v.push_back(io); } } void output(vector<long long> v) { long long i; for (i = 0; i < v.size(); i++) cout << v.at(i) << ; } int main() { ios... |
#include <bits/stdc++.h> using namespace std; long long n, k; priority_queue<long long, vector<long long>, greater<long long> > q; signed main() { scanf( %lld%lld , &n, &k); while (n--) { long long s, m; scanf( %lld%lld , &s, &m); if (q.size() >= k) s = max(s, q.top()), q.pop()... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long a, b; cin >> a >> b; long long sum = 0; long long notes = 0; while (sum + notes + 1 <= a + b) { ++notes; sum += notes; } set<int> possible; for (int ... |
#include <bits/stdc++.h> using namespace std; map<int, long long> mp; const int maxn = 1e6 + 10; char str[maxn]; int num[30]; int main() { int n; scanf( %d , &n); while (n--) { scanf( %s , str); memset(num, 0, sizeof num); int len = strlen(str); for (int i = 0; i < len; i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3452; vector<int> G[maxn]; pair<int, int> snd[maxn][maxn]; int size[maxn][maxn]; long long f[maxn][maxn]; int n, cur, nxt; void dfs(int p, int fl = -1) { if (fl == cur) { nxt = p; } size[cur][p] = 1; snd[cur][p] = make_... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t, n; cin >> t; while (t--) { cin >> n; if (n >= 2) cout << n - 2 << n ; else cout << n - 1 << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const int N = 100; long long bit[60]; int n, m; int a[N][N]; int main() { bit[0] = 1; for (int i = 1; i < 60; i++) bit[i] = bit[i - 1] << 1; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m... |
#include <bits/stdc++.h> using namespace std; int n; int l[305]; int c[305]; map<pair<int, int>, long long int> m; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } long long int solve(int i, int g) { if (g == 1) return 0; if (i == n) { if (g != 1) return (long long int)1000000000... |
#include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc; cin >> tc; while (tc--) { int n, mx = 0, mn; cin >> n; vector<int> v(n); for (int &vi : v) { cin >> vi; mx... |
#include <bits/stdc++.h> using namespace std; int main() { int N, M; scanf( %d%d , &N, &M); long long ans = 0; for (int b = M + 1; b <= (N + 1) / 2; b++) { for (int a = M + 1; a <= N - M; a++) { int coe = (b * 2 - 1 == N ? 3 : 6); int num = (2 * b - a) * (N + 1 - b); in... |
#include <bits/stdc++.h> using namespace std; const int mxn = 2e5 + 10; int sp[mxn], arr[mxn]; vector<int> required[mxn], bit[mxn]; int ask(int p, int x) { int idx = lower_bound(required[p].begin(), required[p].end(), x) - required[p].begin(); int ret = 0; while (idx > 0) ret = max(r... |
#include <bits/stdc++.h> const long long mod9 = 1e9 + 7; const long long maxsize = 2e9 + 1; const long long mod = 998244353; const long long mod2 = 1073741824; using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; vector<long long> a(n); long l... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a; priority_queue<long long int> o, e; for (long long int i = 0; i < n; i++) { cin >> a; if (a % 2 == 0) e.push(a); else o.push(a); } if (e.size() == o.si... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; long double PI = 4 * atan(1); pair<int, int> p[3]; set<pair<int, int> > second; bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.second > p2.second; } int main() { ios::sync_with_stdio(0), cin.tie(0); for (int i = ... |
#include <bits/stdc++.h> using namespace std; const int maxm = 3e6 + 7; const int maxn = 2e5 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; deque<int> q; int n, ans = 0; bool judge[maxn]; int num[maxn], sum[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(... |
#include <bits/stdc++.h> using namespace std; int a[7001][2], cnt[7001][2], p[2], n, b[7001][2], r, o; queue<pair<int, int> > h; bool f[7001][2]; int main() { scanf( %d , &n); scanf( %d , &p[0]); for (int i = 0; i < p[0]; i++) scanf( %d , &b[i][0]); scanf( %d , &p[1]); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000007; const long long linf = 1LL << 62; const unsigned long long ulinf = 1ULL << 63; const double eps = 0.000001; const double pi = 3.14159265358979323846; template <class T> T abs(T a) { return a >= 0 ? a : -a; } template <clas... |
#include <bits/stdc++.h> using namespace std; const long long INF = 9223372036854775807LL; const long double PI = acos(-1); const int MAX_N = 1e+6; const string digits = 0123456789 ; const string alph = abcdefghijklmnopqrstuvwxyz ; void solve() { long long n, root, answer; cin >> n; for (lon... |
#include <bits/stdc++.h> using namespace std; char s[100005]; int main() { int n; scanf( %d , &n); scanf( %s , s); s[n] = # ; for (int i = 0; i < n; i++) { if (s[i] == a || s[i] == e || s[i] == i || s[i] == o || s[i] == u || s[i] == y ) { if (s[i] == e || ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC target( avx ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 ... |
#include <bits/stdc++.h> const int N = 1000; bool vis[N + 100]; int v[N + 100]; int top = 0; int n = 0; int main() { scanf( %d , &n); for (int i = 2; i <= n; i++) { if (!vis[i]) { vis[i] = true; for (int j = 0; j < n; j++) { if (!vis[j]) continue; if (i * j ... |
#include <bits/stdc++.h> using namespace std; long long min(long long a, long long b) { if (a < b) return a; else return b; } static long long gcd(long long a, long long b) { long long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long ... |
#include <bits/stdc++.h> using namespace std; char str1[1000005], str2[1000005]; int cnt[3]; unsigned long long bao[1000005], base[1000005]; long long base2[1000005], da[1000005]; int main() { int n, m, i, j, ans = 0; scanf( %s , str1 + 1); scanf( %s , str2 + 1); n = strlen(str1 + 1); m ... |
#include <bits/stdc++.h> #define int long long using pii=std::pair<int,int>; using namespace std; const int maxn = 2e5 + 5; int n, u, v, a[maxn], in[maxn], out[maxn], order[maxn], timer = -1, st[4 * maxn], need[4 * maxn]; vector<int> adj[maxn]; map<int, vector<int>> avals; void dfs(int x, int p... |
#include <bits/stdc++.h> #pragma GCC target( avx ) #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using std::cin; using std::cout; using std::lower_bound; using std::string; using std::upper_bound; using s... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; int n, m, k; int x[MAXN], y[MAXN]; void read_input() { cin >> n >> m >> k; for (int i = 0; i < k; i++) { cin >> x[i] >> y[i]; } } const int INF = 1e9; int pref[2][MAXN]; void update(int x, int val) { for (int... |
#include <iostream> #include <cmath> using namespace std; typedef long long int ll; int main(){ int cases; ll num; double temp; cin >> cases; bool cube = false; for(int a = 0; a < cases; a++){ cin >> num; cube = false; for(ll b = max(int(cbrt(double(num/2))), 1); b < cbrt(... |
#include <bits/stdc++.h> using namespace std; template <typename... T> void see(T&... args) { ((cin >> args), ...); } template <typename... T> void put(T&&... args) { ((cout << args << ), ...); cout << n ; } void err(istream_iterator<string> it) {} template <typename T, typename... Ar... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int s, v = 0; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n - 1; i++) { if (arr[i] > arr[i + 1]) { s = i + 1; v++; } } if (arr[n - 1] >... |
#include <bits/stdc++.h> using namespace std; int main() { string t1, t2, t3, t4; cin >> t1 >> t2 >> t3 >> t4; string b = t1 + t2[1] + t2[0], e = t3 + t4[1] + t4[0]; b.erase(b.find( X ), 1); e.erase(e.find( X ), 1); for (int i = 0; i < 3; ++i) { string a1 = e.substr(i); string a2... |
#include <bits/stdc++.h> using namespace std; template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) { os << p->first << : << p->second << ; } return os; } templa... |
#include <bits/stdc++.h> using namespace std; int main() { string st, st1; cin >> st >> st1; if (st == st1) { cout << st << endl; } else { cout << 1 << endl; } } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct ... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.1415926535897932384626433832795; const long double eps = 0.000000001; const int INF = 1E9; const int MAXN = 100000; int ans, a[2], mn; string s[2]; char c; bool f[2]; int getn(char c) { return ( 0 <= c && c <= 9 ) ? (c - 0 ) :... |
#include <bits/stdc++.h> using namespace std; int t, n; string s; int main() { cin >> t; for (int tc = 0; tc < t; ++tc) { cin >> n >> s; int res = n - 1; for (int i = 0; i < n; ++i) if (s[i] == > || s[n - 1 - i] == < ) res = min(res, i); cout << res << endl; } ... |
#include <bits/stdc++.h> using namespace std; int main(int, char**) { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; ; int k; cin >> k; ; int out = 0; long long d = 1; for (int i = 0; i < k; i++) { d *= 10; } while (atoi(s.c_str()) % d != 0) {... |
#include <bits/stdc++.h> using namespace std; int in[201000]; int main() { int n; scanf( %d , &n); for (int i = 0; i < (n); i++) { scanf( %d , &in[i]); in[i] += i; } sort(in, in + n); for (int i = 0; i < (n - 1); i++) { if (in[i] == in[i + 1]) { puts( :( ); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); const int maxn = 1e6 + 5e5; vector<int> pr(maxn); iota(pr.begin(), pr.end(), 0); for (long long i = 2; i < maxn; ++i) if (pr[i] == i) for (long long j = i * i; j < maxn; j +... |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::string; using std::vector; static const int MOD = 1000000000 + 7; static long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); } int read_int() { int x = 0, c = 0; c = getchar(); while (c <= 32) c =... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int n = a + b + 1; int A[100000] = {0}; int x = n - a; for (int i = 0; i < a + 1; i++) { A[i] = x; x++; } x = n - a - 1; for (int i = a + 1; i < n; i++) { A[i] = x; x--; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int a, b, c, d, m, n, p, q, r, x, y, z, aa, bb, cc, dd; double pp, qq, rr, xx, yy, zz; char ch1, ch2, ch3, ch4, ch5; long long int i, j, k, l; long long int cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0, sum = 0, sum2 = 0, ... |
#include <bits/stdc++.h> int main() { char s1[3000][11], s2[3000][10], s3[3000][11]; int m, n, i, j, k; int len1, len2; scanf( %d %d , &m, &n); for (i = 0; i < n; i++) { scanf( %s , &s1[i]); gets(s2[i]); } for (i = 0; i < m - 1; i++) { scanf( %s , &s3[i]); } get... |
#include <bits/stdc++.h> int main(void) { int i, j, k, m, n, mm[110][110]; mm[0][0] = mm[1][0] = 0; mm[1][1] = 1; mm[0][1] = 2; for (i = 2; i <= 100; i++) { if (i == 2) k = 5; for (j = 0; j <= i; j++) mm[i][j] = k; for (j = i - 1; j >= 0; j--) mm[j][i] = k + 1; k = mm[i][0]... |
#include <bits/stdc++.h> const long long int mx = 1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n, t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<pair<int, int>> vp, vpAns; map<int, int> mp, m... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; const int mod = 1e9 + 7; int t; int n; int m; long long p[maxn]; int size[maxn]; vector<int> g[maxn]; void dfs(int u, int pre) { size[u] = 1; for (int v : g[u]) { if (v == pre) continue; dfs(v, u); si... |
#include <bits/stdc++.h> using namespace std; int S[100009], cnt[1 << 7], num[1 << 7]; char s[100009]; int len, n, nu; inline long long rd() { long long x = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) { if (c == - ) f = 1; c = getchar(); } while (isdigit(c)) { ... |
#include <bits/stdc++.h> long long nmax[11] = {0, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, 9999999999LL}; long long P[11][11]; long long cnt[11][11][11], C[11][11], totalcnt[11][11], tmp; long long nsel[11][11][11][11][11], fact[11], nw... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; cin >> a >> b >> n; cout << min(b, n) - n + min(a, n) + 1 << n ; } |
#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]; vector<int> ans; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ans.push_back(a[0]); for (int i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0, count = 0; for (int i = 0; i < n; i++) { if (s[i] == 8 ) cnt++; } while (cnt) { n = n - 1; cnt = cnt - 1; if (n / 10 > 0) { count++; n... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 50, mo = 998244353; int head[N], nn[N << 1][2], cnt; void link(int u, int v) { nn[++cnt][1] = v, nn[cnt][0] = head[u], head[u] = cnt; nn[++cnt][1] = u, nn[cnt][0] = head[v], head[v] = cnt; return; } int f[N][3]; void dfs(int x, ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long m, x, p[22], a[22], b[22], len, res = 1; map<long long, int> Map[22]; inline void init(long long n) { for (register long long i = 2; i * i <= n; i++) if (n % i == 0) { len++; p[len] = i; whi... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const int M = 1000010; const int MAX = M; struct BIT { int bit[MAX + 1], N; BIT() {} BIT(int N) : N(N) { memset(bit, 0, sizeof(bit)); } int sum(int i) { i++; int ret = 0; while (i) { ret += bit[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> newvec; int n; int x; int ans; cin >> n; for (int i = 0; i < n; i++) { cin >> x; newvec.push_back(x); } sort(newvec.begin(), newvec.end()); if (newvec.size() % 2 == 1) { ans = newvec[newvec.s... |
#include <bits/stdc++.h> using namespace std; const long long MOD = pow(10, 9) + 7; long long fac[1001]; template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (x < y) x = y; } void ... |
#include <bits/stdc++.h> using namespace std; int T; int n; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> T; while (T--) { cin >> n; float FloatN = n; int Num8 = ceil(FloatN / 4); int Num9 = n - Num8; for (int i = 0; i < Num9; ++i) { cout << 9; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 12; int b[MAXN][MAXN][MAXN], ans, k, n, m; bool mark[MAXN][MAXN][MAXN]; void dfs(int i, int j, int l) { mark[i][j][l] = true; if (j > 0) if (b[i][j - 1][l] == 0 && !mark[i][j - 1][l]) { ans++; dfs(i, j - 1, l); ... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) #pragma GCC optimize( Ofast ) using namespace std; vector<int> g[2097312]; int a[2097312][2]; char st[2097312]; int f[2097312]; int find(int x) { if (f[x] == x) return x; return f[x] = find(f[x]); } int main() { i... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; long long flag = 0, p = 0, ne = 0; if (... |
#include <bits/stdc++.h> using namespace std; inline int read() { int sum = 0, p = 1; char ch = getchar(); while (!(( 0 <= ch && ch <= 9 ) || ch == - )) ch = getchar(); if (ch == - ) p = -1, ch = getchar(); while ( 0 <= ch && ch <= 9 ) sum = sum * 10 + ch - 48, ch = getchar(); return s... |
#include <bits/stdc++.h> using namespace std; int n; bool go(int x, multiset<int> &hand, deque<int> &dq) { if (hand.find(x) == hand.end()) return false; hand.erase(hand.find(x)); hand.insert(dq.front()); dq.pop_front(); dq.push_back(x); return true; } multiset<int> hand; deque<int> d... |
#include <bits/stdc++.h> using namespace std; const int inf = 2147483647, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1}; const int N = 100005, M = 1000005, K = 200005, mod = 1000000007; const long long llinf = 9223372036854775807ll; long long n, m, s, ans, ar; long long f(long long a, long long b) { return (n ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; pair<long long, long long> dif[maxn]; long long x[maxn], y[maxn], pref[maxn], suff[maxn], ans[maxn]; vector<int> adj[maxn]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %lld %lld ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int ans = -1; int sum = 7; int i = 1; while (sum <= n) { int y = n - sum; if (y % 4 == 0) ans = i; sum += 7; i++; } if (ans != -1) { int s = 7 * ans; int y = n - s; ... |
#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; inline int read() { int x = 0, flag = 1; char ch = getchar(); for (; ch > 9 || ch < 0 ; ch = getchar()) if (ch == - ) flag = -1; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = (x << 3) + (x << 1) + ch - 0 ; return x * flag; } ... |
#include <bits/stdc++.h> const int MAXN = 100010; int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], val[MAXN << 1], tot; void addedge(int b, int e, int v) { nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v; nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = v; } int n, Q; ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; void read(int &x) { x = 0; int f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -f; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; x *= f; } void print(int x) { ... |
#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 MAXN = 3e5 + 5; const int mod = 1e9 + 7; int n; int num[MAXN]; bool vis[MAXN]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &num[i]); int e = n; printf( 1 ); int sum = 0; for (int i = 1; i <= n; ++i) ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) int Map[50002][7]; int main() { int m, n; scanf( %d%d , &m, &n); for (int i = 1; i <= m; i++) for (int j = 1; j <= n; j++) scanf( %d , &Map[i][j]); for (int i = 1; i <= m; i++) Map[i][1] += ... |
#include <bits/stdc++.h> using namespace std; bool cmpDouble(const double& a, const double& b) { return std::fabs(a - b) < std::numeric_limits<double>::epsilon(); } int main() { int n, k; cin >> n >> k; int arr[5001]; int ans[5001]; for (int i = 0; i < n; ++i) { cin >> arr[i]; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.