func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { long long q1, q2; cin >> q1 >> q2; long long w1, w2; cin >> w1 >> w2; long long e1, e2; cin >> e1 >> e2; long long l1 = (q2 - w2) * (w1 - e1); long long l2 = (q1 - w1) * (w2 - e2); if (l2 > l1) return cout << LEFT , 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int N; cin >> N; if (N == 1) { cout << 1 << endl; return 0; } cout << ((N + 1) * N / 2) % 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int inline read() { int num = 0, neg = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) neg = -1; c = getchar(); } while (isdigit(c)) { num = (num << 3) + (num << 1) + c - 0 ; c = getchar(); } return num * n... |
#include <bits/stdc++.h> using namespace std; int n, m, a[500005], l = 1, r, b[500005]; queue<int> Q; bool flag = false; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) a[i] = i & -i; for (int i = 1; i <= n; ++i) b[i] = 1; r = n; while (m--) { int opt, x, y; sc... |
#include <bits/stdc++.h> using namespace std; int a[500010]; pair<int, int> b[500010]; int c[500010]; int T, n, tot; int main(void) { T = 1; while (T--) { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); b[i] = {a[i], -i}; } sort(b + 1, b + ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); template <typename T> void chmin(T &x, const T &y) { if (x > y) x = y; } template <typename T> void chmax(T &x, const T &y) { if (x < y) x = y; } template <typename T> T gcd(T x, T y) { return y ? gcd(y, x % y) : x... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n = 0; cin >> n; int a[n], res[n]; for (int i = 0; i < n; i++) { cin >> a[i]; res[i] = 0; } for (int i = 0; i < n - 1; i++) { if (i) res[i] = res[i -... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; cin >> n >> str; int p = 0; if (n % 2 == 1) { p = 3; cout << str.substr(0, 3); if (n != 3) cout << - ; } for (int i = p; i < str.length(); i += 2) { cout << str.substr(i, 2); if (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3030; struct dsu { int par[MAXN]; void clear() { for (int i = 0; i < MAXN; ++i) par[i] = i; } int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } bool join(int u, int v) { if ((u = find(u)) == (v = find(... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; const int MAXK = 17; int X[MAXN]; long long Y[MAXN]; int N, M; int par[MAXN][MAXK]; int dpth[MAXN]; int Q[MAXN]; int ql = 0, qr = 0; int main() { ios_base::sync_with_stdio(0); cin >> N; for (int i = 1; i <= N; ++i) ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; mt19937 rng; ll MAX = 1e18; const int MN = 1e3 + 100; int get_rand(int x) { return static_cast<int>(static_cast<ll>(rng()) * x / (static_cast<ll>(rng.max()) - rng.min() + 1)); } int N; ll L, E; array<... |
#include <bits/stdc++.h> using namespace std; int n, u, r; int a[31], b[31], k[31], p[31]; long long int s = -333; void calc(vector<int> &v) { int f[31]; for (int j = 0; j < n; j++) { f[j] = a[j]; } for (int j = 0; j < v.size(); j++) { if (v[j]) { for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010, oo = 1e9; int n; char s[maxn][maxn]; int f[maxn][maxn], fuck[maxn]; pair<int, int> pre[maxn][maxn]; vector<pair<int, int> > all, foo; int main() { scanf( %d , &n); int m; scanf( %d , &m); for (int i = 1; i <= n; ++i) sc... |
#include <bits/stdc++.h> using namespace std; priority_queue<int, vector<int>, greater<int> > pq; int dp[11][11]; void ini() { int i, j; for (int i = 0; i < 11; i++) for (j = 0; j <= max(i, 10); j++) { if (i == 0) dp[i][j] = 0; else if (i == j || j == 0) dp[i][j... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; int N, C; vector<int> c[6]; vector<pair<int, int> > cl; int seq[100008]; bool seen[100008]; struct Action { int len; int b[5]; int c[5]; }; vector<Action> act; void cycle2action(int c, i... |
#include <bits/stdc++.h> using namespace std; string ko(int k, int y) { string g = ; while (y > 0) { g = char(y % k + 48) + g; y = y / k; } return g; } int main() { int k; cin >> k; int i, j; for (i = 1; i <= k - 1; i++) { for (j = 1; j <= k - 1; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; if (a == d || b == e || c == f) cout << YES ; else cout << NO ; return 0; } |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-6; const long long oo = 1LL << 60; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int N = 100005; struct segTree { int num; long long sum[5]; } node[N << 2]; struct Query { int t... |
#include <bits/stdc++.h> using namespace std; int n; int a[100100], b[100100]; int id[100100], p[100100]; int main() { int T = 1; while (T--) { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); id[a[i]] = i; } for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dx[] = {-1, 0, 1, 0}; long long dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<long long> v(n); vector<long long> a; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> struct Point { T x, y; Point() {} Point(T x_, T y_) : x(x_), y(y_) {} using pair = std::pair<T, T>; explicit operator pair() const { return pair(x, y); } friend bool operator==(const Point& a, const Point& b) { retur... |
#include <bits/stdc++.h> const double PI = 3.141592653589793238; using namespace std; long long takeTurn(long long n) { if (n % 2 == 1) return n - 1; if (n % 4 == 0 && n > 4) return n - 1; return n / 2; } void solve() { long long n, res = 0; cin >> n; while (n > 0) { long long t1... |
#include <bits/stdc++.h> using namespace std; int a[110][110]; int main() { int n, m, i, j; while (~scanf( %d %d , &n, &m)) { for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf( %d , &a[i]); if (n & 1) { cout << n << endl; continue; } int vis; for (... |
#include <bits/stdc++.h> using namespace std; int main() { int k = 0; int a, b, c; string s1, s2, s3; cin >> s1 >> s2 >> s3; a = s1.size(); b = s2.size(); c = s3.size(); if ((a + b) != c) { cout << NO ; return 0; } s1 = s1 + s2; for (int i = 0; i < c; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 2) cout << 1 << endl << 1; else if (n == 3) cout << 2 << endl << 1 3 ; else { cout << n << endl; for (int i = 2; i <= n; i += 2) cout << i << ; for (int i = 1; i <= n; i += 2) c... |
#include <bits/stdc++.h> using std::cin; using std::cout; int dist(int from, int to, int count) { if (from <= to) { return to - from; } else { return dist(from, count - 1, count) + dist(0, to, count) + 1; } } void output(const std::vector<int64_t>& boxes); std::vector<int64_t> recove... |
#include <bits/stdc++.h> using namespace std; int t, a, b; void fn() { cin >> a >> b; if (a < b) swap(a, b); a -= b; int ans = a / 5; a %= 5; if (a == 1 || a == 2) ans++; else if (a == 3 || a == 4) ans += 2; cout << ans << endl; } int main() { cin >> t; whil... |
#include <bits/stdc++.h> using namespace std; int ans[300005]; void input() { int i, l, r, x, cur, n, ne; set<int> alive; set<int>::iterator ite; vector<int> xoa; scanf( %d %d , &n, &ne); for ((i) = (1); (i) <= (n); (i)++) alive.insert(i); for ((i) = 0; (i) < (ne); (i)++) { scanf... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; int a[MAX]; int main() { ios::sync_with_stdio(false); int n, k; cin >> n >> k; n = 2 * n + 1; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n - 1 && k; i++) if (a[i - 1] + 1 < a[i] && a[i] > a[i + ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n], b[n + 1]; vector<pair<int, int>> c; for (int i = 0; i < n; i++) cin >> a[i]; unordered_map<long long, long long> mp, mp1; vector<vector<int>> v; v.assign(n + 1, vector<int>()); for (... |
#include <bits/stdc++.h> int f[105][25][25], g[25][25], n, k, u, v; std::vector<int> ch[105]; using ll = long long; const int mod = 1e9 + 7; void dfs(int u, int fa) { f[u][0][1] = f[u][k][0] = 1; for (int v : ch[u]) { if (v == fa) continue; dfs(v, u); std::memcpy(g, f[u], sizeof(f[u]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 520; int dp[maxn][maxn]; char mp[maxn][maxn]; int h, w, q; int main() { cin >> h >> w; for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> mp[i][j]; for (int i = 2; i <= w; i++) { if (mp[1][i] == . && mp[1]... |
#include <bits/stdc++.h> int a[30][2 * 100000 + 5], cnt[30]; char s[2 * 100000 + 5], t[2 * 100000 + 5]; long long max(long long a, long long b) { if (a > b) return a; else return b; } int main() { long long i, j, n, len, m, maxn; scanf( %lld , &n); scanf( %s , s); for (i = ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, a, b, c, d, t, input; vector<int> vi; for (i = 1; i <= 370; i++) { t = i; if (t <= 9) { vi.push_back(t); } else if (t >= 10 && t < 100) { a = t % 10; t = t / 10; b = t; vi.push_bac... |
#include <bits/stdc++.h> using namespace std; class DFS { int N_, R_; vector<vector<int> > G_; vector<int> par_, dep_, dep_sub_; void DFS_internal(int v) { dep_sub_[v] = 0; for (auto u : G_[v]) if (par_[u] == -1) { par_[u] = v; dep_[u] = dep_[v] + 1; ... |
#include <bits/stdc++.h> #define ll long long #define INF INT_MAX #define pii pair<int,int> using namespace std; const int maxn=1e3+10; const int mod=998244353; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll N,K; cin>>N>>K; vector<vector<ll>> p(maxn); ... |
#include <bits/stdc++.h> using namespace std; const int N = 5010; struct T { int a, b, i; T() {} T(int a, int b, int i) : a(a), b(b), i(i) {} bool operator<(const T &other) const { return a > other.a; } }; const int inf = 1e9; int n, m, k, dp[N][N], f[N][N]; T a[N]; vector<int> ga, gb; ... |
#include <bits/stdc++.h> using namespace std; int a[1001][3] = {0}; int b[1001] = {0}; int c[1001] = {0}; vector<int> a1, a2, a3; int main() { int n, m, i, x, y, z; int ans, t = 0; scanf( %d%d , &n, &m); for (i = 0; i < m; i++) { scanf( %d%d%d , &x, &y, &z); a[x][0] = y; a[... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, i, j, total, cnt; cin >> n >> k; double r, g, b; r = ceil((n * 2.0) / k); g = ceil((n * 5.0) / k); b = ceil((n * 8.0) / k); cout << int(r + g + b) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 0x6fffffff; const int MINF = 0x80000000; const int mod = 1000000007; const int cons = 100001; const double pi = 3.141592653589793; int dy2[2] = {1, 0}; int dx2[2] = {0, -1}; int dy1[2] = {0, 1}; int dx1[2] = {1, 0}; int n, m; int main... |
#include <bits/stdc++.h> using namespace std; const long long dx[4] = {-1, 0, 1, 0}; const long long dy[4] = {0, -1, 0, 1}; const long long dxx[] = {1, 1, 0, -1, -1, -1, 0, 1}; const long long dyy[] = {0, 1, 1, 1, 0, -1, -1, -1}; void err(istream_iterator<string> it) {} template <typename T, typename... A... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); long long n, x, k, mult = 1; cin >> n >> k >> x; while (k--) { mult *= x; } vector<long long> pre(n + 1, 0), suf(n + 2, 0), v(n + 1, 0); for (long long i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int lp[MAXN]; vector<int> pr; int ans[MAXN]; int main() { for (int i = 2; i < MAXN; ++i) { ans[i] = 0; if (lp[i] == 0) { lp[i] = i; pr.push_back(i); } for (int j = 0; j < (int)pr.size() && pr... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v; int c; for (int i = 0; i < n; i++) { cin >> c; v.push_back(c); } if (n == 1) { if (v[0] == 1) { cout << YES ; return 0; } } sort(v.begin(), v.end())... |
#include <bits/stdc++.h> using namespace std; long long n, k, x; long long eval(long long x) { long long ret = 0; if (x % 4 == 0) { return x / 4; } else { if (x % 4 == 3) { x -= 15; ret++; ret++; } else if (x % 4 == 2) { x -= 6; ret++; } ... |
#include <bits/stdc++.h> const int N = 1000; int n, k; struct point { int x, y; point operator-(const point &rhs) const { return (point){x - rhs.x, y - rhs.y}; } } a[7], b[N]; bool same_sgn(int x, int y) { return !x || !y || (x > 0) == (y > 0); } bool collinear(point a, point b) { retu... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << (n / 2) - (n % 2) * n << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c, m; int flag = 0; int c1 = 0, c2 = 0, c3 = 0; int t; cin >> a >> b >> c >> m; t = 0; for (int i = min(c, m); i <= 2 * c && i <= 2 * m; i++) ... |
#include <bits/stdc++.h> const int N = 1e5 + 10; 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 - 0 , ch = getchar(); return f ? -x : x; } std::vector<int> vec[N]; inline int calc(int n, i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 2; const long long N = 1e6 + 1; long long n; set<int> Q; int main() { scanf( %d , &n); int ans = 1; while (n--) { int x; scanf( %d , &x); while (!Q.insert(x).second) { Q.erase(x); x++; } ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; while (cin >> a) { bool f = false; if (a.length() < 3) { cout << No << endl; continue; } for (int i = 0; i <= a.length() - 3; i++) { b = a.substr(i, 3); if (b[0] != . && b[1] !... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, k; cin >> n >> k; if (k == 1 || k == n) { cout << (3 * n); } else { cout << min(2 + 3 * (k - 1) + k + 3 + 3 * (n - k - 1), 6 +... |
#include <bits/stdc++.h> using namespace std; int main() { long long int h, l; scanf( %lld %lld , &h, &l); printf( %.9f n , (l * l - h * h + 0.0) / (2 * h)); return 0; } |
#include <bits/stdc++.h> using namespace std; char str[110]; int n, ans, len; bool arr[110][220][55][2]; int main() { scanf( %s%d , str + 1, &n); len = strlen(str + 1); arr[0][100][0][0] = true; for (int i = 1; str[i]; ++i) for (int j = 100 - i; j <= 100 + i; ++j) for (int k = 0;... |
#include <bits/stdc++.h> using namespace std; const int N = 4010; const int T = 20010; int n, p, q, c[N], h[N], t[N], cs[T], cd[T], b[T], rez[T]; int d[10010][N]; vector<int> v[T], v2[T], v3[T]; void sol(int pozs) { int pozd = min(T - 1, pozs + 2 * p), mid = pozs + p; vector<int>::iterator it; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n; cin >> n; long long a[n]; long long maxi = LONG_LONG_MIN, mini = LONG_LONG_MAX; map<long long, stack<long long> > ma; for (long long i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> const int mod = 1000000007; long long f[2005][2005], g[2005][2005]; int main() { for (int n, m; scanf( %d%d , &n, &m) != EOF;) { memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g)); for (int i = 1; i <= n; i++) { long long sum = 0; for (int j = 2; j <= m... |
#include <bits/stdc++.h> using namespace std; long long int _xor(long long int a, long long int b) { return a ^ b; } long long int _and(long long int a, long long int b) { return a & b; } long long int _or(long long int a, long long int b) { return a | b; } long long int _not(long long int a) { return ~a; } ... |
#include <bits/stdc++.h> using namespace std; void affiche(int t[], int n) { for (int i = 0; i < n; i++) cout << t[i] << ; cout << n ; } void afficheV(vector<int> t) { for (int i = 0; i < t.size(); i++) cout << t[i] << ; } vector<vector<int> > adj(50005); vector<bool> visited(50005, fa... |
#include <bits/stdc++.h> using namespace std; namespace FGF { int n, m; const int N = 2e5 + 5; const double eps = 1e-10; struct Node { double x, t; } a[N]; double sum, ans; bool cmp(Node u, Node v) { return u.t < v.t; } void work() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) sc... |
#include <bits/stdc++.h> using namespace std; inline long long read() { char c = getchar(); long long x = 0; bool f = 0; for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); if (f) x = -x; return x; } struct modint {... |
#include <bits/stdc++.h> using namespace std; bitset<510> reach[510]; int n, p[510], use[510], i, j, wz[510]; char s[510]; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &p[i]), wz[p[i]] = i; for (i = 1; i <= n; i++) { scanf( %s , s + 1); reach[i][i] = 1; for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a, flag = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a; if (a == 1) flag = 1; } if (flag == 1) cout << HARD << endl; else cout << EASY << endl; } |
#include <bits/stdc++.h> using namespace std; int n, m, q, u, v; pair<int, vector<int> > P[100011][25]; vector<int> residents[100011]; vector<int> adj[100001]; int parent[100001]; int L[100001]; int checker; vector<int> mergevec(vector<int>& A, vector<int>& B, int sz) { vector<int> sol; int ap... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int cnt[maxn], a[maxn], n, q; signed main() { scanf( %d , &q); while (q--) { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); cnt[i] = 0; } vector<int> res; for (int ... |
#include <bits/stdc++.h> using namespace std; char c[1003]; char s[1003]; int sign[1003]; int fi[1003]; int main() { int n, m; cin >> n >> m; getchar(); int num = 0; int ans = 1001; for (int i = 0; i < n; i++) { scanf( %c , &c[i]); } getchar(); for (int i = 0; i < m... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const int MAXN = 1e5 + 10; int v[MAXN]; int lis[MAXN]; int main() { int n; scanf( %d , &n); for (int a = 0; a < n; ++a) scanf( %d , &v[a]); memset(lis, INF, sizeof(lis)); ... |
#include <bits/stdc++.h> using namespace std; struct road { int x, next; } r[100005 * 2]; int N, M, D, ans; int vis[100005], p[100005]; int down[100005], up[100005]; int st[100005], w; void add(int x, int y) { r[++w].x = y, r[w].next = st[x]; st[x] = w; } void Make_Down(int x, int fr) { ... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(0); int cases, caseno = 0, n, i, j, k, cnt, sum; cin >> n >> j >> k; for (i = 1; i <= 10000; i++) { if (n == 2) { cout << Final! ; return 0; } if ((j + 1) / 2 == (k + 1) / 2) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int t; t = 1; while (t--) { int n; cin >> n; int tot = 0; vector<int> v; for (int i = 1; i < n + 1; i++) { if (tot + i > n) { v.... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; int n, m; int main(void) { while (cin >> n >> m && n && m) { priority_queue<long long, vector<long long>, greater<long long> > que; for (int i = 0; i < n; i++) { long long a; que.push((cin >> a, a)); } ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e7 + 7; const long long mo = 1e9 + 7; long long n, m, k, p, q, r, mod, i, j, d = 0, ans; long long wz; int main() { scanf( %lld %lld %lld , &n, &m, &k); r = n - 1; ans = r * m; wz = 1; if (ans < k || m > k) print... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 9; long long pow_mod(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % mod; n >>= 1; x = x * x % mod; } return res; } long long inv(long long x) { return pow_mod(x, m... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int find(vector<int>& par, int x) { if (x != par[x]) return find(par, par[x]); return x; } bool same(vector<int>& par, int x, int y) { return find(par, x) == find(par, y); } void merge(vector<int>& par, vector<int>& sz... |
#include <bits/stdc++.h> using namespace std; const int mxn = 200000; int n; int a[mxn], b[mxn], first[mxn], ff[mxn]; vector<int> v[mxn]; auto cmp = [](int x, int y) { return b[x] > b[y]; }; priority_queue<int, vector<int>, decltype(cmp)> pq(cmp); map<int, int> second; int main() { ios::sync_with_... |
#include <bits/stdc++.h> const long long MOD = 998244353; const int N = 6000; std::vector<long long> fact(N), revfact(N); long long Pow(long long a, long long b) { long long rt = 1; while (b) { if (b & 1) rt = (rt * a) % MOD; a = (a * a) % MOD; b /= 2; } return rt; } long l... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> g[n + 1]; for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } vector<vector<... |
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool uax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ios::sync... |
#include <bits/stdc++.h> const long long mod = 1e9 + 7; using namespace std; vector<int> par, rnk; void make_set(int n) { par[n] = n; rnk[n] = 0; } int find_set(int a) { if (par[a] == a) return a; return par[a] = find_set(par[a]); } void union_set(int a, int b) { a = find_set(a); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; vector<int> v[maxn]; stack<int> s; int low[maxn], dfn[maxn], vis[maxn], clk = 0; int belong[maxn], tot = 0; vector<int> Ws[maxn]; void tarjan(int x) { s.push(x), vis[x] = 1; low[x] = dfn[x] = ++clk; for (auto &u : v[x]... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int i, a[n]; map<int, pair<int, int> > m; for (i = 0; i < n; i++) { cin >> a[i]; } int vis[n + 1]; memset(vis, -1, sizeof(vis)); for (i... |
#include <bits/stdc++.h> using namespace std; int a[300001]; long long an[300001], dp[300001]; struct data { int x, y, No; void scan() { scanf( %d%d , &x, &y); } bool operator<(data b) const { if (y < b.y) return 0; if (y > b.y) return 1; int r1 = x % y, r2 = b.x % y; if (r1 ... |
#include <bits/stdc++.h> using namespace std; int a[100000], b, c, n, m, x, y, z, s; int main() { cin >> a[0] >> a[1] >> n; if (n <= 1) cout << a[n]; else { for (int i = 2; i <= n; i++) { a[i] = a[i - 1] + a[i - 2]; } cout << a[n]; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long cnt[105]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long ans = 0; while (m--) { long long l,... |
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int dcmp(long double x) { return x < -1e-12 ? -1 : (x > 1e-12); } template <class T> ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == - ) { ng = true; ch = getchar(); break; } if (ch >= 0 && ch <= 9 ) break; } while (1) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> e[100005]; int used[100005]; void bfs(int x) { queue<int> q; while (!q.empty()) q.pop(); q.push(x); used[x] = 1; while (!q.empty()) { int p = q.front(); q.pop(); for (int i = 0; i < e[p].size(); i++) { if (e[... |
#include <bits/stdc++.h> int main() { char a[8][8]; char x, y; int i, j, b = 0; for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) a[i][j] = 1; scanf( %c%c , &x, &y); x -= a ; y -= 1 ; a[x][y] = 0; for (i = 0; i < 8; i++) { a[x][i] = 0; a[i][y] = 0; } if (x... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int a, b, c, d; cin >> a >> b >> c >> d; if (a + b <= max(c, d)) cout << Polycarp ; else if (a <= c && b <= d) cout << Polycarp ; else cout << Vasiliy ; return 0; } |
#include <bits/stdc++.h> int main() { int n; int a[105]; scanf( %d , &n); int B, C; B = 0; C = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] < 0) C += a[i]; else B += a[i]; } printf( %d n , B - C); } |
#include <bits/stdc++.h> using namespace std; long long n, r, l[210000], t[210000], ans, a[110000], b, x, y, c; int main() { scanf( %I64d%I64d , &n, &r); for (int i = 1; i <= n; i++) scanf( %I64d , &l[i]); for (int i = 1; i <= n; i++) scanf( %I64d , &t[i]); for (int i = 1; i <= n; i++) if (t... |
#include <bits/stdc++.h> using namespace std; int s[1005]; int main() { int n, m, h; scanf( %d%d%d , &n, &m, &h); int sum = 0; for (int i = 1; i <= m; i++) { scanf( %d , &s[i]); sum += s[i]; } if (sum < n) { printf( -1 n ); return 0; } long double ans = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<long long> h(n + 5); vector<long long> deg(n + 5, 0), a(n + 5, 0); for (long long i = 1; i <= n; i++) cin >> h[i]; for (long long i = 1;... |
#include <bits/stdc++.h> using namespace std; const int mxs = 2e5 + 7; int n; int a[mxs]; int l[mxs]; int r[mxs]; int ans[mxs]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = n; i; i--) { l[i] = i; while (a[i] <= a[l[i] + 1]) l[i] = l[... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:64000000 ) const int maxn = 200200; const int inf = 1000000007; const int mod = 1000000007; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, 1, -1}; double pr[maxn]; double pw(double x, int k) { if (k == 1) retu... |
#include <bits/stdc++.h> using namespace std; vector<int> nums; int mod[100]; char in[1000010]; int cnt[100]; int main() { int i, j, k; nums.push_back(1); nums.push_back(6); nums.push_back(8); nums.push_back(9); sort(nums.begin(), nums.end()); do { int sum = 0; for (i... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; const long long mod = 998244353; long long a[N]; long long n, m, k; long long pw(long long n, long long k) { if (!k) return 1; long long res = pw(n, k >> 1); res = res * res % mod; if (k & 1) return res * n % mod; ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; long long c = a ^ b; a = a & c; b = b & c; cout << a + b << n ; ... |
#include <bits/stdc++.h> using namespace std; vector<string> a; int n, j; string s; map<long long, int> f; long long h(string s) { long long res = 0; for (int i = 0; i < s.length(); i++) res = res * 28 + (s[i] - a ) + 1; return res; } int main() { scanf( %d , &n); for (int i = 1; i ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.