func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int x, k; cin >> x >> k; long long int temp = k % 4; long long int i = 1; while (temp--) { if (x % 2) { x += ((k / 4) * 4) + i; } else { ... |
#include <bits/stdc++.h> using namespace std; string s; vector<char> t; int main() { cin >> s; for (int i = 0; i < s.size(); i++) { if (t.size() != 0 and t.back() == s[i]) { t.pop_back(); } else { t.push_back(s[i]); } } for (int i = 0; i < t.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, d, i, j, k, s, t, ans; cin >> n >> d; s = 0; for (i = 0; i < n; i++) { cin >> t; s += t; } if (s + (n - 1) * 10 > d) ans = -1; else ans = (d - s) / 5... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int a, b, c, d; int main() { scanf( %d %d %d %d , &a, &b, &c, &d); int t, bo; if (a * d >= c * b) { t = b * c; bo = d * a; } else { ... |
#include <bits/stdc++.h> using namespace std; long long spf[101]; long long fac[101]; void sieve() { spf[1] = 1; for (long long i = 2; i < 101; i++) spf[i] = i; for (long long i = 4; i < 101; i += 2) spf[i] = 2; for (long long i = 3; i * i < 101; i++) { if (spf[i] == i) { for (long... |
#include <bits/stdc++.h> using namespace std; unsigned long long hs[1050], hL[1 << 15], bs[50]; int main() { mt19937_64 rnd(time(0)); srand(time(0)); int n, s, d; scanf( %d%d%d , &n, &s, &d); for (int i = 0; i < 1050; i++) hs[i] = rnd(); random_shuffle(hs, hs + 1050); for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; long long int x_array[5000], y_array[5000]; long long int dx[50001], dy[50001]; int main() { int a; char str[5000]; long long int cnt = 0; scanf( %d , &a); scanf( %s , str); int len = strlen(str); for (int i = 0; i < len; i++) { int... |
#include <bits/stdc++.h> using namespace std; const int64_t N = 1e6 + 10; string second; int64_t X, Y, n, m; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int64_t i = 0; i < n; i++) { cin >> second; for (int64_t j = 0; j < second.si... |
#include <bits/stdc++.h> using namespace std; int n, m, d[1002], s[1002], t, f, sum, k; int main() { cin >> m >> k; for (int i = 2; i <= m + 1; i++) { cin >> d[i]; } for (int i = 1; i <= m; i++) { cin >> s[i]; } for (int i = 1; i <= m; i++) { f += s[i]; t = max(t, s... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { vector<long long> arr(3); for (int i = 0; i < 3; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); if (arr[2] <= arr[1] + arr[0] + 1) cout << Yes << endl; else cout <... |
#include <bits/stdc++.h> const int mod = 1000000007; using namespace std; int dp[5009][5009]; char s1[5009], s2[5009]; int main() { while (scanf( %s%s , s1, s2) == 2) { memset(dp, 0, sizeof(dp)); int len2 = strlen(s2); for (int i = 1; s1[i - 1]; i++) { for (int j = 1; s2[j - 1]; ... |
#include <bits/stdc++.h> using namespace std; template <typename A> ostream &operator<<(ostream &cout, vector<A> const &v); template <typename A, typename B> ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << ( << p.first << , << << p.second << ) ; } template <typename A... |
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; #define R register int #define I inline #define N 100001 vector<int>G[N],C[N],H[N]; int dep[N],g[448][N],fa[N],b[448],sz[N]; char ans[N]; bool f[448][N]; struct Painter{ char Character; int LeftNum; }; I void DFS... |
#include <bits/stdc++.h> using namespace std; string s, u; stack<char> t; vector<char> mins; int main() { cin >> s; u = ; int inicio = 0, tam = s.length(); char ant = z + 1; for (int i = tam - 1; i >= 0; i--) { ant = min(ant, s[i]); mins.push_back(ant); } reverse(mi... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long double eps = 1e-6; const long long maxn = 1e6 + 100; vector<long long> g[maxn]; long long szc1[maxn], szc2[maxn]; vector<long long> used; void dfsc(long long v, long long col) { used[v] = 1; szc1[col]++; szc... |
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int> > adj(1e5 + 1); set<int> rem; vector<int> ord; void search(int pred1, int pred2) { if (ord.size() == n) return; int nxt = 0; for (int j = 0; j < 4 && nxt == 0; j++) { for (int k = 0; k < 4; k++) { int x = adj[p... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 6.66; const int MAXN = MAX << 2; const int N = MAX << 1; pair<int, int> p[MAX]; int up[MAXN]; int down[MAXN]; int uppre[MAXN], upsuf[MAXN], downpre[MAXN], downsuf[MAXN]; int main() { memset(down, 63, sizeof down); memset(downp... |
#include <bits/stdc++.h> using namespace std; const long long dx[] = {-1, 0, 0, 1}; const long long dy[] = {0, -1, 1, 0}; const int Mass = (int)2e5 + 5; const int inf = (int)1e9 + 5; const long long linf = (long long)1e18 + 5; const long long Mod = (long long)1e9 + 7; long long ModFix(long long a, long ... |
#include <bits/stdc++.h> const int N = 1000 + 10; struct tnode { int x, y; long long val; tnode() {} tnode(int _x, int _y, long long _val) { x = _x; y = _y; val = _val; } }; int n, m, r, c; int a[N][N], b[N][N], f[N][N]; long long sum[N][N]; int Q[N], head, tail; st... |
#include <bits/stdc++.h> using LL = long long; const LL inf = 1LL << 60; const int kN = 14; int a[kN], n; int delta[kN]; int cnt[1 << kN]; LL f[1 << kN]; int decode(char c) { if (c >= 0 && c <= 9 ) return c - 0 ; return c - a + 10; } char encode(int x) { if (x < 10) return x + 0 ;... |
#include <bits/stdc++.h> using namespace std; int n, b, g, ans; int main() { scanf( %d%d%d , &b, &g, &n); for (register int i = 0; i <= n; ++i) { register int a = i, f = n - i; if (a <= b && f <= g) ++ans; } printf( %d n , ans); return 0; } |
#include <bits/stdc++.h> using namespace std; int t, a, b, c; int main() { cin >> t; for (; t; t--) { cin >> a >> b >> c; int res = 0; if (c >= b) { swap(b, c); } if (b >= a) { swap(a, b); } if (c > 0) { c--; res++; } if... |
#include <bits/stdc++.h> using namespace std; struct node { long long v; bool c; } arr[12000]; bool comparator(node a, node b) { return a.v < b.v; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long i, j, p, v, l, n = 0, a, ans = 0; cin >> a; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3000 + 50; struct Edge { int to, next; long long w; } edge[maxn * 2]; int k = 1, head[maxn]; void add(int u, int v) { edge[++k].to = v; edge[k].next = head[u]; head[u] = k; } long long n, m, b[maxn], w[maxn], v[maxn], sz[... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } const int maxn = 100007; int BLOCKSIZE = 250; set<int> s[maxn]; int a[maxn]; int nxt[maxn]; int prv[... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, int> > p1, p2, p12; int n, s1, s2; int num1[3005]; int num2[3005]; bool vis[3005]; int ans1[3005]; int ans2[3005]; int main() { cin >> n >> s1 >> s2; for (int i = 0; i < n; i++) { scanf( %d , &num1[i]); p1.push(... |
#include <bits/stdc++.h> using namespace std; const int mx = 2e6 + 10; int n, m; bool vis[mx]; int sta[mx], siz, is; int dfn[mx], id[mx]; int be[mx], ty; vector<int> g[mx]; void tarjan(int u) { dfn[u] = id[u] = ++is; sta[++siz] = u; vis[u] = 1; for (int v : g[u]) { if (!dfn[v]) {... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, m, k, i; bool t = 0; cin >> n >> m >> k; if ((2 * m * n) % k > 0) cout << NO ; else { if (k == 2) cout << YES n0 0 n << n << 0 n0 << m; else ... |
#include <bits/stdc++.h> using namespace std; inline long long read(long long num = 0, char c = 0) { while (c > 9 || c < 0 ) c = getchar(); while (c >= 0 && c <= 9 ) num = num * 10 + c - 48, c = getchar(); return num; } struct node { int x, y, val, num; void in() { x = read(), y = read... |
#include <bits/stdc++.h> using namespace std; bool isSafe(const int n, const int m, const int row, const int col) { return row >= 0 && row < n && col >= 0 && col < m; } int main(int argc, char* argv[]) { int n, m; static pair<int, int> pos[] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 0}, ... |
#include <bits/stdc++.h> using namespace std; struct box { int a, o; int id; }; int n; box x[201000]; int cmp(box a, box b) { return a.a < b.a; } int used[201000]; int main() { int t; scanf( %d , &t); for (int tt = 0; tt < t; tt++) { scanf( %d , &n); n = 2 * n - 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) using namespace std; void err(istream_iterator<string> it) { cerr << endl; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << t ; err(++it, args...); } template <ty... |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define M 1000000007 int main() { std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin>>t; while(t--) { string s; cin>>s; for(i... |
#include <bits/stdc++.h> using namespace std; const int Maxlen = 2e5 + 2; long long ans; long long lt[Maxlen], ls[2 * Maxlen]; int n, m, dpt[Maxlen], dps[Maxlen]; char ct[Maxlen], cs[2 * Maxlen]; long long cmp(int pos) { if (cs[0] != ct[pos] || ls[0] > lt[pos]) return 0; if (m == 1) return lt[pos]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1500; const int MOD = 1e9 + 9; int ing[128]; long long dp[1005][105][15]; int n, m; struct ac_auto { int nxt[maxn][4], fail[maxn], ed[maxn], q[maxn]; int L = 0; void inserta(char buf[]) { int now = 0; int len = strlen(b... |
#include <bits/stdc++.h> using namespace std; int r[100005], g[100005], b[100005], nr, ng, nb, pos; long long ans = 9e18; long long calc(long long a, long long b, long long c) { long long temp = (a - b) * (a - b) + (a - c) * (a - c) + (b - c) * (b - c); return temp; } int bsearch(int a[], int len, i... |
#include <bits/stdc++.h> using namespace std; int a[100005], f[100005]; int l[100005], r[100005]; int main() { int n; while (cin >> n) { memset(a, 0, sizeof(a)); memset(f, 0, sizeof(f)); for (int i = 0; i < n; i++) { cin >> a[i]; } int m; cin >> m; for (... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; int wyn = 0; long long a, b; cin >> n; a = 1; m = 2; while (m <= n) { wyn++; b = m; m += a; a = b; } cout << wyn << n ; } |
#include <bits/stdc++.h> using namespace std; int n, m; string s, t; vector<char> vv; int main() { cin >> n >> m; cin >> s; for (int i = 0; i < n; i++) vv.push_back(s[i]); sort(vv.begin(), vv.end()); if (((int)(s).size()) < m) { t = s; for (int i = ((int)(s).size()); i < m; i++... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; sort(a.begin(), a.end()); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100000; const double eps = 1e-15; int n; double p[N + 9], q[N + 9]; void into() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %lf , &p[i]); for (int i = 1; i <= n; ++i) scanf( %lf , &q[i]); } double a[N + 9], b[N + 9]; do... |
#include <bits/stdc++.h> using namespace std; const int OO = (int)1e6; set<pair<int, int> > nods; map<pair<int, int>, bool> vis; pair<int, int> fr, sc; int n, r, a, p, ans, sz; bool ok = true; int rx[] = {1, 1, 1, 0, 0, -1, -1, -1}; int ry[] = {1, 0, -1, 1, -1, 1, 0, -1}; bool val(pair<int, int> per... |
#include <bits/stdc++.h> using namespace std; inline int in() { int x; scanf( %d , &x); return x; } template <typename T> istream &operator>>(istream &in, vector<T> &vec) { for (int i = 0; i < vec.size(); ++i) in >> vec[i]; return in; } template <typename T> ostream &operator<<(ostre... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; const int mod = 998244353; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { int n, x; cin >> n >> x; vector<int... |
#include <bits/stdc++.h> using namespace std; vector<int> mark[4]; string sins[4]; int cost[5]; int sta[1010]; int dp[1010][0xffff + 1]; int main() { int n; cin >> n; for (int i = 0; i < 4; i++) cin >> cost[i]; for (int i = 0; i < 4; i++) cin >> sins[i]; for (int j = 0; j < n; j++) { ... |
#include <bits/stdc++.h> using namespace std; enum { DUNNO = -1, AB, BA }; vector<pair<int, int> > E[200010]; map<pair<int, int>, int> edge_id; int dir[200010]; int val[200010]; bool vis[200010]; int main() { int N, M; cin >> N >> M; memset(val, 0, sizeof(val)); memset(vis, 0, sizeof(vis... |
#include <bits/stdc++.h> int main() { int n, a, b, c, t, i, m, ans = 0; scanf( %d%d%d%d%d , &n, &a, &b, &c, &t); ans = n * a; for (i = 0; i < n; i++) { scanf( %d , &m); ans += (t - m) * (c - b); } if (b >= c) printf( %d , n * a); else printf( %d , ans); return 0... |
#include <bits/stdc++.h> using namespace std; template <typename... T> void read(T &...args) { ((cin >> args), ...); } template <typename... T> void write(T... args) { ((cout << args << ), ...); } const long long MOD = 1000000007; const long long INF = 1000000050; const long long BIG = (l... |
#include <bits/stdc++.h> using namespace std; vector<int> v[200010]; bool vis[200010]; int amid[200010]; int n, m; int a[200010]; vector<int> vv; vector<pair<int, int> > t; void dfs(int node) { vis[node] = 1; t.push_back({a[node], node}); int sz = v[node].size(); for (int i = 0; i < sz... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; int d[201][201]; pair<pair<int, int>, int> E[20000]; vector<std::pair<int, int> > Intervals; int n, m; bool check(int idx, int x) { int u = E[idx].first.first, v = E[idx].first.second, w = E[idx].second; Intervals.clear(); ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e3 + 10; int n; pair<string, int> a[N]; string ans[N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { char c; cin >> c >> c >> c >> c; cin >> a[i].first; a[i].second = i; if (a[i].first == 9 ) ans[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 1e6 + 10; struct node { int a, b, w; } e[M]; int fa[N]; bool cmp(node a, node b) { return a.w < b.w; } int find(int x) { if (fa[x] != x) fa[x] = find(fa[x]); return fa[x]; } int du[N]; int main() { int n, m; ... |
#include <bits/stdc++.h> using namespace std; long long n, k, a[600000], L, R, r, t, l, f; long long s; bool ok(long long x) { long long r = 0; for (long long i = 0; i < n; i++) if (a[i] > x) r += (a[i] - x); if (r <= t) return 1; return 0; } bool ok1(long long x) { long long r = 0... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, s; cin >> n >> k >> s; if (k > s || k * (n - 1) < s) { cout << NO n ; } else { cout << YES n ; long long h = 1; while (k--) { long long d = min(n - 1, s - k); s -= d; if (h - ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; inline int comp(double A, double B = 0) { return (A <= B + EPS) ? (A + EPS < B) ? -1 : 0 : 1; } struct point { double x, y; point(double x = 0, double y = 0) : x(x), y(y) {} bool operator<(const point &other) const { ... |
#include <bits/stdc++.h> using namespace std; bool q[2][1001]; short qf[3][1001], an[1001][1001][50][2]; inline short gt(int l, int r, int p) { return qf[p][r] - qf[p][l - 1]; } int main() { int n, p, k; scanf( %d%d%d , &n, &p, &k); for (int i = 0; i < (int)(2); ++i) { int t; scanf( %d... |
#include <bits/stdc++.h> using namespace std; int n, m, s; long long ans = 0; int main() { int i, j, k; int a1, b1, a2, b2; int x1, y1, x2, y2; int p1, p2; cin >> n >> m >> s; for (i = 0; i <= n / 2; i++) { for (j = 0; j <= m / 2; j++) { for (k = 0; k <= n / 2; k++) { ... |
#include <bits/stdc++.h> using namespace std; long long fib[100005], mod = 1e9 + 7; void pre() { fib[0] = fib[1] = 1; for (int i = 2; i < 100005; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % mod; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); pre(); long long m, n, x... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e2 + 7; long long p[MAXN], dp[MAXN]; pair<long long, long long> fig[MAXN]; int32_t main() { long long n; cin >> n; for (long long i = 0; i < n; ++i) cin >> fig[i].second >> fig[i].first; sort(fig, fig + n); long long t; ... |
#include <bits/stdc++.h> int btf(int n) { static int num[10]; memset(num, 0, sizeof(num)); for (int i = 0; i < 4; i++) { num[n % 10]++; n /= 10; } for (int i = 0; i < 10; i++) if (num[i] > 1) return 0; return 1; } void solve(int n) { for (int i = n + 1; 1; i++) ... |
#include <bits/stdc++.h> using namespace std; int a, b, m; void deal() { for (int i = 0; i <= a && i < m; i++) { if ((m - (long long int)i * 1000000000 % m) % m > b) { printf( 1 %.9d n , i); return; } } printf( 2 n ); } int main() { while (scanf( %d%d%d , &a, &b, &m... |
#include <bits/stdc++.h> using namespace std; string s; long long ans[2200], MOD = 1000003; long long dp[2200][2200], inv[2200], fac[2200], ifac[2200]; void init_math(int N) { inv[1] = 1LL; for (int i = 2; i <= N; i++) inv[i] = (MOD - ((MOD / i) * inv[MOD % i]) % MOD); fac[0] = 1LL; ifac... |
#include <bits/stdc++.h> using namespace std; inline int two(int x) { return 1 << x; } inline long long TWO(int x) { return (long long)1 << x; } template <class T> void Min(T &x, T y) { if (y < x) x = y; } template <class T> void Max(T &x, T y) { if (y > x) x = y; } template <class T> T _a... |
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k, a; cin >> n1 >> n2; vector<int> arr1, arr2; for (int l = 0; l < n1; l++) { cin >> a; arr1.push_back(a); } for (int l = 0; l < n2; l++) { cin >> a; arr2.push_back(a); } sort(arr1.begin(),... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] != a && s[i] != e && s[i] != i && s[i] != o && s[i] != u && s[i] != n ) { if (i != s.length() - 1) { if (s[i + 1] != a && s[i + 1]... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { scanf( %d %d , &n, &m); if (m > n) { printf( -1 ); return 0; } m -= 2; if (n == 1) { printf( a ); return 0; } if (n > 1 && m < 0) { printf( -1 ); return 0; } for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000007; const long long linf = 1000000000000000000LL; const double eps = 0.000001; const double pi = 3.14159265358979323846; template <class T> T abs(T k) { return k >= 0 ? k : -k; } template <class T> T sqr(T n) { return n * ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, vmx; long long seed; struct node { int l, r; mutable long long val; bool operator<(const node &x) const { return l < x.l; } }; set<node> tr; set<node>::iterator split(int pos) { set<node>::iterator iter = tr.l... |
#include <bits/stdc++.h> using namespace std; int n; double a[200005], b[200005]; double l = -10001, r = 10001; const double eps = 2e-12; double solve(double x) { for (int i = 1; i <= n; ++i) b[i] = a[i] - x; double res = 0, tmp = 0; for (int i = 1; i <= n; ++i) { if (tmp < 0) tmp = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c, i; cin >> n >> m; c = 2 * n; i = 1; while (i <= 2 * n) { if (m > c) { c++; cout << c << ; } cout << i << ; i++; if (m < i) break; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long t, sx, sy, ex, ey; int e, s, n, w; string ch; int main() { cin >> t >> sx >> sy >> ex >> ey; if (sx < ex) e = ex - sx; else w = sx - ex; if (sy < ey) n = ey - sy; else s = sy - ey; cin >> ch; long long ... |
#include<bits/stdc++.h> using namespace std; #define read(x) scanf( %d ,&x) const int N=1e5+10; string s; int main() { int t; read(t); while(t--) { cin>>s; for(int i=0;i<s.size();i++) { if(i%2==0) { if(s[i]!= a ) s[i]= a ; else s[i]= b ; } else {... |
#include <bits/stdc++.h> using namespace std; const int N = 123456; void solve() { long long n; cin >> n; if (n % 2 == 0) { cout << (10 + n) << 10 ; } else { cout << (9 + n) << 9 ; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , inline , -ffast-math ) #pragma GCC target( avx,sse2,sse3,sse4,mmx ) inline long long read() { long long s(0); bool w(1); char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; cin >> a; for (int i = 0; i < a; ++i) { cin >> b; if (b == 1) { c = 1; } } if (c == 0) { cout << EASY n ; } else { cout << HARD n ; } } |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 4e3 + 5; const int mod = 1e9 + 7; const double eps = 1e-8; const double pi = asin(1.0) * 2; const double e = 2.718281828459; bool Finish_read; template <class T> inline void read(T &x) { Finish_read = 0; ... |
#include <bits/stdc++.h> using namespace std; vector<int> Q[123]; int stk[123]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int x; scanf( %d , &x); for (int j = 0; j < x; j++) { int u; scanf( %d , &u); Q[i].push_back(u); } } ... |
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { int T; in >> T; for (int _t = 0; _t < (int)(T); ++_t) { int n, s, t; in >> n >> s >> t; int res = n - min(s, t) + 1; out << res << endl; ... |
#include <bits/stdc++.h> using namespace std; int a[2001]; int ou, ji; int main() { int n; scanf( %d , &n); long long ans = 0; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); ans += a[i]; if (a[i] % 2 == 0) ou++; else ji++; } if (ou > ji) ... |
#include <bits/stdc++.h> using namespace std; namespace FGF { const int N = 2e5 + 5; int n, m; long long read() { long long s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) w = -w; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const double PI = acos(-1.0); const double eps = 1e-6; const int INF = 0x3f3f3f3f; const long long SEED = 19260817; const long long MOD = 1e9 + 9; const int maxn = 2e5 + 11; int N, M, T; char a[maxn]; long long cnt[maxn][26], di... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 10; long long tree[MAXN * 4][7][11], s[6][MAXN], a[MAXN]; void Pushup(long long u, long long len) { long long z, i, j; for (z = 2; z <= 6; z++) for (i = 0; i < 2 * (z - 1); i++) tree[u][z][i] = tree[u * ... |
#include <bits/stdc++.h> using namespace std; template <class T> void miz(T &a, T b) { if (b < a) a = b; } template <class T> void maz(T &a, T b) { if (b > a) a = b; } template <class T> void clear(T &x) { T t; x.swap(t); } template <class T> T gcd(T a, T b) { while (b) { ... |
/* 西江月·证明 即得易见平凡,仿照上例显然;留作习题答案略,读者自证不难。 反之亦然同理,推论自然成立;略去过程Q.E.D.,由上可知证毕。 result of thinking: Pure. 主要是非内、外向树的情形容易遗漏. AC: */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ldouble; template<class T> bool chmin(T &x... |
#include <bits/stdc++.h> using namespace std; const int N = 201; set<int> graph[N]; map<pair<int, int>, int> edges; pair<int, int> bfs(int node) { int dist[N] = {0}; int vis[N] = {0}; queue<pair<int, int> > q; q.push({0, node}); while (!q.empty()) { int top = q.front().second; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, n1, n2; scanf( %d%d%d , &n, &n1, &n2); if (n1 > n2) swap(n1, n2); vector<double> X; double x; for (int i = 0; i < n; i++) { scanf( %lf , &x); X.push_back(x); } sort(X.begin(), X.end()); double sum1 = 0,... |
#include <bits/stdc++.h> using namespace std; const long long N = 100100, mod = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 998244353, sq = 450, base = 727, lg = 30; long long n, m, x, y, z, w, ans, t, l[N], r[N]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (in... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (m == 0) { cout << n << n ; return 0; } string hint[m]; getline(cin, hint[0]); vector<vector<string> > h(m); for (int i = 0; i < m; i++) { getline(cin, hint[i]); stringstr... |
#include <bits/stdc++.h> using namespace std; int main() { int a[200], n, i, s = 0; scanf( %d , &n); for (i = 0; i < 2 * n - 1; i++) { scanf( %d , &a[i]); if (a[i] < 0) s -= a[i]; else s += a[i]; } if (n % 2 == 0) { sort(a, a + 2 * n - 1); for (i = 0... |
#include <bits/stdc++.h> using namespace std; char s[300005]; int n, cnt, p[300005], to[600005], nexti[600005]; int fa[300005], son[300005], dep[300005], len[300005], top[300005], dfsx[300005], st[300005]; void dfs(int x, int lasti) { son[x] = 0; len[x] = 1; for (int i = p[x]; i != -1; i = n... |
#include <bits/stdc++.h> using namespace std; int a[200005], b[200005], c[200005]; int num = 0; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]]++; } for (int i = 1; i <= n; i++) { if (b[i] == 0) c[++num] = i; } cout << num << endl; ... |
#include <bits/stdc++.h> using namespace std; long long int a, b; stack<long long int> st; bool dfs(long long int n) { if (n > b) { return false; } if (n == b) { return true; } bool a1, a2; a1 = dfs(n * 2); if (a1) { st.push(n * 2); return true; } a2 =... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void printV(vector<int> &S) { for (int s : S) { cout << s; } cout << endl; } void solve() { int x; cin >> x; string T; cin >> T; vector<int> S; for (int i = 0; i < (int)T.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int a[10010]; int n, cnt; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) if (a[a[i]] == i && a[i] <= i) cnt++; cout << cnt << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double eps = 1E-8; const int FFTSZ = 1 << 20; const double pi = acos(-1.); struct cp { double real, img; cp(double _r = 0.0, double _i = 0.0) : real(_r), img(_i) {} cp operator+(const cp &c) const { return cp(real + ... |
#include <bits/stdc++.h> using namespace std; long long int powOfPositive(long long int n) { long long int pos = floor(log2(n)); return pos; } int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; vector<long long int> arr(n); for (long long... |
#include <bits/stdc++.h> using namespace std; namespace zyt { const int N = 1e6 + 10, CH = 20; int f[1 << CH], n; char s[N]; bool check(const int a, const int p) { return a & (1 << p); } int ctoi(const char c) { return c - a ; } void get_max(int &a, const int b) { a = max(a, b); } int work() { sc... |
#include <bits/stdc++.h> using namespace std; const int nax = 2 * (int)1e5 + 10; const int INF = (int)1e9 + 47; vector<int> g[nax]; int n, k; int lvl[nax], tin[nax], tout[nax]; int cnt = 0; int timer = 0; int ver[nax]; int seen[nax]; int par[nax]; int vr[nax]; vector<pair<int, int>> vec; voi... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int n; cin >> n; vector<long long> v; for (int i = 1; i <= n; i++) { int x; cin >> x; v.push_back(x); } sort(v.begin(), v.end()); long long ans = v[... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; const int INF = 99999999; const double eps = 1e-4; int dp[MAXN]; int main() { int n, m, c0, d0; cin >> n >> m >> c0 >> d0; memset(dp, 0, sizeof(dp)); for (int i = c0; i <= n; i++) dp[i] = i / c0 * d0; for (int i = 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.