func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int n, x, trie[2][31 * maxn], cnt[31 * maxn], a[maxn], tot = 1; inline void insert(int x) { int p = 1, t; for (int i = 31; i >= 0; i--) { t = (1 << i) & x ? 1 : 0; if (!trie[t][p]) trie[t][p] = ++tot; p = trie[t][... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b, s; cin >> s; vector<string> g; for (long long i = 0; i < s.length(); i++) { a += s[i]; if (s[i] != a ) { b += s[i]; } if (a.length() + b.length() == s.length()) { break; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n % 2 == 0) { cout << 2; } else cout << 1; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; inline int read() { int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == - ; ch = getchar(); } while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar(); return w ? -X : X; } int n... |
#include <bits/stdc++.h> 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 debug { template <class c... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265359; template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } const long long mod = 1000000007; struct matr { int maxn; int n; long long a[1 << 7][... |
#include <bits/stdc++.h> using namespace std; const long long Inf = 1000000000000000000ll; const int inf = 1000000000; vector<long long> pri, fac; long long m, x, ans; void getpri(long long t, vector<long long>& v) { v.clear(); for (long long i = 2; i * i <= t; ++i) { if (t % i) continue; ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { long long n, k; cin >> n >> k; long long altura = ceil((long double)k / n); cout << altura; return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T, class V> ostream& operator<<(ostream& s, pair<T, V> a) { s << a.first << << a.second; return s; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long int T = 1; cin >> T; for (long long int qq = 1; ... |
#include<bits/stdc++.h> using namespace std; #define int long long #define f(i,n) for(int i=0;i<(n);++i) #define fa(i,a,n) for(int i=a;i<=(n);++i) #define fd(i,a,n) for(int i=a;i>=(n);--i) #define tc int t;cin>>t;f(testcase,t) #define ld long double #define pii ... |
#include <bits/stdc++.h> using namespace std; void c() { int n; cin >> n; vector<long long> a(n); for (int(i) = (0); (i) < (n); ++(i)) cin >> a[i]; vector<long long> pf(n, a[0]); for (int(i) = (1); (i) < (n); ++(i)) pf[i] = pf[i - 1] ^ a[i]; map<long long, vector<pair<long long, long lon... |
#include <bits/stdc++.h> using namespace std; double mar[100000]; int main() { double ml, rl; cin >> ml >> rl; double m = ml, r = rl; double save = 0; if (ml >= 3) save += 2 * m * (m - 3) + 2 * (m - 2) + 6; else if (ml == 2) save += 2; save *= (sqrt(2) - 2); double ans ... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n, x; cin >> n; vector<vector<int>> adj(n); for (int i = 1; i < n; i++) cin >> x, x--, adj[x].push_back(i), adj[i].push_back(x); queue<int> q; q.push(0); ... |
#include <bits/stdc++.h> int main() { int i, j, n, k; while (scanf( %d %d , &n, &k) == 2) { int f, t, max = -2000000000; for (i = 0; i < n; i++) { scanf( %d %d , &f, &t); if (t > k) { if ((f - t + k) > max) max = f - t + k; } else { if (f > max) max = f;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int i = 1; i <= t; i++) { int n, k, d; cin >> n >> k >> d; int mn = n; int a[n + 10]; for (int j = 1; j <= n; j++) cin >> a[j]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, numa, numb, ans; bool f = 0; cin >> n >> a >> b; for (int i = 2, cnt = 1; i <= n; i *= 2) { numa = a / i; if (a % i != 0) numa++; numb = b / i; if (b % i != 0) numb++; if (numa == numb) { if... |
#include <bits/stdc++.h> using namespace std; long long x[100005], y[112345]; set<long long> stx, sty; int main() { long long n, m, a, b; scanf( %lld %lld , &n, &m); long long total = n * n; while (m--) { scanf( %lld %lld , &a, &b); if (x[a] == 0 && y[b] == 0) { total = total... |
#include <bits/stdc++.h> using namespace std; int n; double a[22][22], p[20][(1 << 18) + 10], pc[(1 << 18) + 10], sm[20][(1 << 18) + 10]; int main() { while (scanf( %d , &n) != EOF) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { scanf( %lf , &a[i][j]); } ... |
#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; const int N = 5005; const long long INF = 1e18; struct node { int u, v, w; node(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {} } a[2 * N]; int fst[N], nxt[2 * N], tot, n, size[N]; bool vis[N]; long long ans, sum[N], ans0, mn; void build(int... |
#include <bits/stdc++.h> using namespace std; class DSU { public: vector<long long> p; DSU() {} DSU(long long n) { p.resize(n + 1); for (long long i = 1; i <= n; i++) p[i] = i; } void join(long long a, long long b) { p[find(b)] = find(a); } long long find(long long a) { return... |
#include <bits/stdc++.h> using namespace std; const int N = 500004; int a[N], m, k, s, t, n, sz = 0; map<int, int> mp, mq; void add(int n, int val) { if (n == -1) return; if (val == 1) { ++mq[n]; if (mq[n] == mp[n]) ++sz; } else { if (mq[n] == mp[n]) --sz; --mq[n]; } ... |
#include <bits/stdc++.h> using namespace std; string s[] = { ABSINTH , BEER , BRANDY , CHAMPAGNE , GIN , RUM , SAKE , TEQUILA , VODKA , WHISKEY , WINE }; int main() { int n; scanf( %d , &n); string ss; int sol = 0; for (int i = 0; i < n; i++) { cin >> s... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) const int N = 100005; long long ans; int n, a[N], pi; vector<int> G[N]; int s[2], flag, cnt[2]; map<int, int> mp[2]; void upd(int u, int dep) { if ((dep % 2) != (flag % 2)) { s[flag ^ 1] ^= a[... |
#include <bits/stdc++.h> using namespace std; class data { public: long long k, b; bool operator<(const data a) const { if (k * a.k < 0) return (b * a.k < a.b * k); else return (b * a.k > a.b * k); } bool operator==(const data a) const { return b * a.k == a.b * k; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) { cout << -1 << endl; } else { cout << 2 1 ; for (int i = 3; i < n; i += 2) { cout << << i + 1 << << i; } cout << endl; } return 0; } |
#include <bits/stdc++.h> int a[15][200000][15]; int b[15] = {0}; int main() { a[1][0][0] = 0; b[1] = 1; int n; scanf( %d , &n); for (int i = 0; i < n; i++) { for (int j = 0; j < b[i]; j++) { int m = 0; for (int k = 0; k <= i; k++) if (a[i][j][k] > m) m = a[i][j]... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T qmin(const T &a, const T &b) { return a < b ? a : b; } template <typename T> inline T qmax(const T &a, const T &b) { return a > b ? a : b; } template <typename T> inline void getmin(T &a, const T &b) { if (a > b) ... |
#include <bits/stdc++.h> using namespace std; const int inf = (1 << 29); const int maxn = 300005; const int mod = 1000007; vector<pair<int, int> > color[maxn]; int q1[maxn], q2[maxn], ans[maxn], qq; int n, m, num[maxn], top = 0, q[maxn], tot = 0, stk[maxn]; vector<int> edge[maxn]; bool vis[maxn]; lo... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, k; cin >> t; while (t--) { cin >> k >> n; cout << n + (9 * (k - 1)) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; map<string, int> name, name2; const int maxn = 1e3 + 10; string s[maxn]; int A[maxn]; int main() { int n; cin >> n; int maxx = -999999999; for (int i = 0; i < n; i++) { cin >> s[i] >> A[i]; name[s[i]] += A[i]; } for (int i = 0... |
#include <bits/stdc++.h> const double EPS = 1e-9; const int INT_INF = 1 << 31 - 1; const long long I64_INF = 1ll << 63 - 1ll; const double PI = acos(-1.0); using namespace std; struct person { int c, first; person(int _c = 0, int _f = 0) { c = _c; first = _f; } friend bool operat... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k = 1; scanf( %d%d , &n, &m); while (1) { if (m < k) break; m -= k; k = k % n + 1; } printf( %d n , m); return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int main() { int n; scanf( %d , &n); vector<int> a(n), cum(n + 1); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); cum[i + 1] = a[i] + cum[i]; } int bits = 32 - __builtin_clz(n); vector<vector<int>> dp(b... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 5, MOD = 1e9 + 7; long long n; long long par[MAXN]; long long cnt1[MAXN]; long long cnt2[MAXN]; long long dp1[MAXN]; long long dp2[MAXN]; long long color[MAXN]; bool subtree[MAXN]; vector<long long> G[MAXN]; void dfs_up1(... |
#include <bits/stdc++.h> using namespace std; long long s, x, a, ans = 1; void setup() { cin >> s >> x; a = s - x; if (a & 1) { cout << 0; exit(0); } a >>= 1; } void xuly() { long long k = a; while (x) { if (x & 1) { if (a & 1) { cout << 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int n = a.size(); int f = 0, s = 0; for (int i = 0; i < n; ++i) if (a[i] != b[i]) { if (a[i] == 4 ) f++; else s++; } int ans = min(f, s); ans += (f - an... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 5; int n, par[N], mx1[N], mx2[N], ans[N]; int main() { scanf( %d , &n); par[1] = mx1[1] = mx2[1] = ans[1] = 0; for (int i = 2; i <= n + 1; i++) { scanf( %d , &par[i]); int v = i, val; ans[i] = mx1[i] = mx2[i] = 0... |
#include <bits/stdc++.h> using namespace std; int N, a, b, Q; long long W[(500000)], S[(500000)], O[(500000)]; map<pair<int, int>, vector<pair<int, int> > > M; void pro(int t, int b, long long* g, int& l) { *g = 0, l = 1; while (b < N) { long long S = W[b] + g[l - 1]; g[l++] = S, b += t; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 256; const char nxt = n ; inline void in(string Q) { Q += .in ; freopen(Q.c_str(), r , stdin); } inline void out(string Q) { Q += .out ; freopen(Q.c_str(), w , stdout); } inline void open_file(string Q) { in(Q... |
#include <bits/stdc++.h> using namespace std; struct rec { int w, h; }; vector<rec> v; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int w, h; scanf( %d %d , &w, &h); v.push_back({w, h}); } int last = -0x3f3f3f3f; for (int i = n; i > 0; i--) {... |
#include <bits/stdc++.h> using namespace std; int n, m, a[100001], v[100001], posa[100001], posv[100001], x, y; int inx[100001]; inline void kspxa(int s, int t) { if (s < t) { int i = s, j = t, k = (i + j) >> 1; int l = a[i]; a[i] = a[k]; a[k] = l; l = posa[i]; posa[i] = ... |
#include <bits/stdc++.h> using namespace std; template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &a) { return out << ( << a.first << , << a.second << ) ; } template <class A> ostream &operator<<(ostream &out, const vector<A> &a) { for (const A &it : a) out << it << ... |
#include <bits/stdc++.h> using namespace std; long long a[2005]; vector<long long> Z; vector<long long> F; int main() { long long n, i, S = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; S += a[i]; } sort(a, a + n); reverse(a, a + n); for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> long long t[105], s[105]; long long a[105]; int getNumber(long long add) { if (add == 0) return 1; else { int res = -1; for (int i = 2; i <= 101; i++) { long long last = i * (i - 1) * (i - 2) / 6, next = i * (i - 1) * (i + 1) / 6; ... |
#include <bits/stdc++.h> using namespace std; long long n; long long ans[100100 << 1]; long long ksm(long long p, long long q) { long long res = 1; while (q) { if (q & 1) res = res * p % 1000000007; p = p * p % 1000000007; q >>= 1; } return res; } signed main() { cin >>... |
#include <bits/stdc++.h> using namespace std; long long n, a, b, t, p, i; int main() { cin >> n >> a >> b; p = b * n; while (n > 1) { t += 2 * a + 1; n--; } cout << t << << p; return 0; } |
#include <bits/stdc++.h> using namespace std; string s1, s2; bool eq(int a1, int b1, int a2, int b2) { if ((b1 - a1) & 1) { while (a1 < b1) { if (s1[a1] != s2[a2]) return 0; ++a1; ++a2; } return 1; } int m1 = (a1 + b1) / 2; int m2 = (a2 + b2) / 2; retu... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m, k; cin >> n >> m >> k; vector<int> dp1(m, 0); vector<int> pref_max(m, 0); vector<int> suf_max(m, 0); vector<vector<int> > a(n); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int x; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; s = s + x ; int dol = 0; int cent = 0; int td = 0; int tc = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] >= a && s[i] <= z ) { dol += td; cent += tc; td = 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; bool v[N]; int n, m, x, y, k, q[N], t, d[N], A[N], c; vector<int> a[N]; void D(int x) { q[++t] = x, d[x] = t; for (int i = 0; i < a[x].size(); i++) if (!d[a[x][i]]) D(a[x][i]); else if (d[x] - d[a[x][i]] + 1 >= ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, t, cur = 1, pre, s; cin >> n >> pre; s = n; n--; for (int i = 0; i < (int)(n); ++i) { cin >> t; if (t == pre) cur++; else if (t != pre && cur > 1) { s += (cur * (cur - 1) / 2); cur =... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; string s; cin >> s; int n = s.size(); int ps[n + 5]; ps[0] = s[0] - 0 ; for (int i = 1; i < n; i++) ps[i] = ps[i - 1] + s[i] - 0 ; long long ans = 0; for (int i = 0; i < n; i++) { int it1 = lo... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long int x; long long int k; long long int res; long long int curr; long long int exponentiation(long long int base, long long int power) { long long int ans = 1; while (power > 0) { if (power % 2) ans = (ans * base)... |
#include <bits/stdc++.h> using namespace std; signed main() { long long N; cin >> N; long long frend[N + 1][N + 1]; long long i, j, k; for (i = 1; i <= N; i++) { for (j = 1; j <= N; j++) { cin >> frend[i][j]; } } long long alex[N + 1]; long long liking[N + 1]; ... |
#include <bits/stdc++.h> using namespace std; int count_inversions(vector<int> v) { int t = 0; for (int i = 0; i < (int)v.size(); ++i) for (int j = i + 1; j < (int)v.size(); ++j) if (v[i] > v[j]) t++; return t; } int main() { int n; scanf( %d , &n); vector<int> v(n); fo... |
#include <bits/stdc++.h> long long mod; long long solve(int dep, long long idx, long long left, long long right, long long l, long long r, long long u, long long v) { if (right < l) return 0; if (left > r) return 0; if (left >= l && right <= r) { long long delta = (1LL << dep); ... |
#include <bits/stdc++.h> using namespace std; struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); } } _; const int MAXN = -1; int n, m; int main() { int a, b; cin >> a >> b; int n = a + b + 1; for (int i = n - a; i <= n; ++i) cout << i << ; f... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, s = 0; scanf( %I64d%I64d , &a, &b); while (b != 0) { s = s + a / b; c = b; b = a % b; a = c; } printf( %I64d n , s); return 0; } |
#include<bits/stdc++.h> #define X first #define Y second #define sz(a) (int)a.size() #define ll long long //#define int long long using namespace std; const int mod = 1e9 + 7; const int N = 3e5; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, k, tot, root; int ak[30]; int son[20000005][2], g[20000005]; long long ans; void calc(int v, int *a) { memset(a, 0, 120); int i = 0; while (v) { a[i++] = v & 1; v >>= 1; } return; } int mak... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; vector<int> T; int l, size; void Stworz(int n) { int p = 1; while (p < n) p *= 2; l = p; size = 2 * p - 1; for (int i = 0; i <= size; ++i) T.push_back(INF); } void Ustaw(int a, int x) { a += l; T[a] = x; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, y, x, h, n; cin >> a >> b >> c >> d; y = (a * 3) / 10, x = (a - ((a / 250) * c)), h = (b * 3) / 10, n = (b - ((b / 250) * d)); if (max(y, x) > max(n, h)) cout << Misha ; else if (max(y, x) < max(n, h)) co... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; using Pl = pair<ll, int>; const int mod = 1e9 + 7, INF = 1 << 30; const double EPS = 1e-12, PI = 3.1415926535897932384626; const ll LINF = 1LL << 60, lmod = 1e9 + 7; const int MAX_N = 102; vector<P> graph[MAX... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { long long a, b; cin >> a >> b; v.push_back(make_pair(a, b)); } int c = 0; for (int i = 0; i < n; i++) { int up = 0, lo = 0... |
#include <bits/stdc++.h> using namespace std; const short int N = 1000; short int n, m, ax[] = {0, 0, 1, -1}, ay[] = {1, -1, 0, 0}, man_dis[N][N]; bool vis[N][N], v[N][N], g[N][N]; void good() { for (short int i = 0; i < n; i++) { for (short int j = 0; j < m; j++) { bool f = 0; if (i... |
#include <bits/stdc++.h> using namespace std; bool oppSign(double a, double b) { if (a == 0 || b == 0) return false; if (a > 0 && b < 0) return true; if (a < 0 && b > 0) return true; return false; } void parr(vector<double>& a) { for (int i = 0; i < a.size(); ++i) { cout << a[i] << ... |
#include <bits/stdc++.h> using namespace std; int n; long long ans; int a[150000 + 1]; int main() { scanf( %d , &n); for (register int i = 1; i <= n; ++i) { scanf( %d , &a[i]); ans += 1LL * a[i] * (n - a[i] + 1); } for (register int i = 1; i <= n; ++i) ans -= 1LL * min(a[i], ... |
#include <bits/stdc++.h> using namespace std; const int inf = ~0u >> 1, N = 1000005; int n, r, x, ans, fr; char o[N]; void output(int x, int y) { for (int i = n; i; --i) if (x >= y) o[i - 1] = T , x -= y; else o[i - 1] = B , y -= x; } int evaluate(int x, int y) { int ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int n, k, a, b; vector<int> v; int ret(int lt, int rt) { int id2 = upper_bound(v.begin(), v.end(), rt) - v.begin(); int id1 = lower_bound(v.begin(), v.end(), lt) - v.begin(); return id2 - id1; } long long dfs(int lt, int rt) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; int a[2 * n], ans = 0; for (int i = 0; i <= 2 * n - 1; i++) cin >> a[i]; for (int i = 0; i < 2 * n; i += 2) { int j = i + 1; while (a[j] != a[i]) j++; ans += j - i - 1; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = 1e9 + 9; const long long MOD = 1e9 + 696969; const long long INF = 1e18; int n, m, k, a, b, c, w, h; char s[1000100]; int dp[1000100][26], last[1000100][26]; pair<int, int> SECOND, MIN; inline pair<int, int> minex... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; const long long INF64 = (long long)1e18; const long double eps = 1e-9; const long double pi = 3.14159265358979323846; int dp[20][50]; int frmP[20][50], frmQ[20][50], frmE[20][50]; long long ten[20]; char str[60]; vector<long lon... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; const long long llinf = 1e18 + 7; const double eps = 1e-15; const int N = 2e5 + 5; int cnt0[N], cnt1[N]; long long sum(int cnt[N], int l, int r) { long long ret = cnt[r]; if (l) ret -= cnt[l - 1]; return ret; } int main... |
#include <bits/stdc++.h> using namespace std; int main() { int n, r1, r2; cin >> n >> r1 >> r2; int a[n + 2]; for (int i = 1; i <= n; i++) if (i != r1) cin >> a[i]; else a[i] = 0; int v = r2, x = a[r2]; do { int y = a[x]; a[x] = v; v = x; x... |
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; #ifdef eclipse #define debug(...) do{ fprintf(stderr, LINE %d: (%s) = ,__LINE__, #__VA_ARGS__ ); _do(__VA_ARGS__); }while(0) template<typename T> void _do(T &&_x) {cerr << _x ... |
#include <bits/stdc++.h> using namespace std; long long n; int resp; int ask(long long x) { printf( ? %lld n , x); fflush(stdout); scanf( %d , &resp); return resp; } void ans(long long x) { printf( = %lld n , x); fflush(stdout); } void solve() { scanf( %lld , &n); if (n =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, m; cin >> n >> m; vector<long long int> v; long long int s = (m + 1) / 2; v.push_back(s); long long int i = 1; if (m % 2) { while (1) { ... |
#include <bits/stdc++.h> const int INF = 1 << 29; int cmp(const void* a, const void* b); long long maxv(long long a, long long b); long long minv(long long a, long long b); long long gcd(long long u, long long v); int main() { long long t = 1, i = 0; while (t--) { long long r, d, n; scan... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, -1, 1}; void arquivo() { freopen( , r , stdin); freopen( , w , stdout); } const int N = 505050; struct no { int l, r; int op; no(){}; no(int a, int b, int c) { op = a; l = b; ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long f[305][305][5]; struct point { int x, y; point(int x = 0, int y = 0) : x(x), y(y) {} } a[305]; struct edge { int u, v; double w; edge(int u = 0, int v = 0, double w = 0) : u(u), v(v), w(w) {} bool operator<(const edge ... |
#include <bits/stdc++.h> using namespace std; int in[30]; int out[1050000][2]; int oc; int n; int pre[30]; int cnt[30][2]; inline int cntf(int np, int b) { if (cnt[np][b] != -1) return cnt[np][b]; if (np == n) return cnt[np][b] = 0; if (!b) return cnt[np][b] = cntf(pre[np] + 1, b) * 2 ... |
#include <bits/stdc++.h> using namespace std; using std::bitset; const double Pi = acos(-1); inline long long read() { long long x = 0; bool fu = 0; char ch = 0; while (ch > 9 || ch < 0 ) { ch = getchar(); if (ch == - ) fu = 1; } while (ch <= 9 && ch >= 0 ) x = (x * 10... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int maxn = 200; long long x, y, l, r; void solve() { set<long long> a, b, S; a.insert(1); b.insert(1); long long base = x; while (base <= INF) { a.insert(base); if (INF / base < x || x == 1) break; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int m; int a[100005] = {0}; int b[100005] = {0}; cin >> s; s = + s; cin >> m; for (int i = 1; i <= s.length(); i++) { if (s[i] == s[i + 1]) a[i] = 1; } for (int i = 1; i <= s.length(); i++) { ... |
#include <bits/stdc++.h> using namespace std; void test_case() { int n, i, cnt; cin >> n; string str; cin >> str; cnt = 0; vector<int> c(n + 5, 0); vector<int> flag(n + 5, 0); int fl = 0; for (i = n - 1; i >= 0; i--) { if (str[i] == ( ) cnt++; else cn... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 4; char s[maxn]; int a[maxn]; void get(bitset<maxn> &B) { scanf( %s , s); int m = strlen(s); int x = 1, y = -1; for (int i = 0; i < m; i++) a[m - 1 - i] = s[i] - 0 ; m--; x += m + y; ++x; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; ifstream fin; ofstream fout; FILE *outt, *inn; const int N = 100009, M = 70; int k, b[M], d[M], k2, y, yy; unsigned long long m, c[M][M], l, r, cur; void find() { for (int i = 0; i <= 64; i++) { for (int j = 0; j <= 64; j++) { if (i == 0) {... |
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> ord; vector<pair<int, int> > edges; vector<int> adj[200000]; int n; int main() { cin >> n; cout << n - 1 << endl; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; edges.push_back(make_pair(a, b)); ... |
#include <bits/stdc++.h> using namespace std; int Max[100010 * 4], Min[100010 * 4]; int dp_Min[100010 * 4]; int a[100010]; int dp[100010]; int ql, qr, val; void build(int l, int r, int o) { if (l == r) { Max[o] = Min[o] = a[l]; return; } int mid = l + (r - l) / 2; build(l, mid,... |
#include <bits/stdc++.h> using namespace std; int main() { int a[100010]; int b[100010]; while (scanf( %d , &a[0]) != EOF) { getchar(); int n = 1; while (scanf( %d , &a[n]) != EOF) { n++; getchar(); } sort(a, a + n); a[n] = 9999999; int h = 0; ... |
#include <bits/stdc++.h> using namespace std; long long a[1010]; int main() { long long n, k, p; int q; scanf( %I64d%I64d%d , &n, &k, &q); p = n - k; for (int i = 0; i < q; i++) scanf( %I64d , a + i); if (k == 0) { for (int i = 0; i < q; i++) printf( . ); return 0; } fo... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323846; const int MAXN = 1e5 + 3; long long n, a, b, p, q; bool isLeap(int a) { if (a % 400 == 0) return true; if (a % 4 == 0 && a % 100) return true; return false; } void solve() { int y; cin >> y; ... |
#include <bits/stdc++.h> using namespace std; const long long mod1 = 1e9 + 7, mod = 998244353; const long long N = 3e5 + 7; long long ncr[N]; void fact(long long A) { auto binexp = [&](long long a, long long b) { long long res = 1; while (b) { if (b & 1) res *= a; a *= a; ... |
#include <bits/stdc++.h> using namespace std; const double PAI = atan(1.0) * 4; const double EPS = 1e-5; int n; double theta; struct Point { double x, y; Point() {} Point(double _x, double _y) : x(_x), y(_y) {} Point operator+(const Point &r) const { return Point(x + r.x, y + r.y); } Poi... |
#include <bits/stdc++.h> using namespace std; class point { public: int x, ind; point(int dx = 0, int _ind = 0) { x = dx; ind = _ind; } }; int n, k, f[210][210]; point a[210], c[210]; bool cmpx(point A, point B) { return A.x < B.x; } bool cmpi(point A, point B) { return A.ind < ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; double h, d, c, n, mx; int hh, mm; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> hh >> mm; hh = hh * 60 + mm; cin >> h >> d >> c >> n; double nec = ceil(h / n) * c; if (hh >= 1... |
#include <bits/stdc++.h> using namespace std; static int i = 0; int fun(long long n) { i++; if (n % 2 == 1) return 0; else fun(n / 2); } int main() { int n; long long k; scanf( %d %lld , &n, &k); fun(k); printf( %d , i); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, id[105], m, i, j; unsigned long long cant[105], c[105], T[105], total, sol, factor, x, llevo; bool cmp(const int i, const int j) { return c[i] < c[j]; } int main() { scanf( %d , &n); for (i = 0; i < n; i++) { cin >> cant[i] >> c[i]; tota... |
#include <bits/stdc++.h> using namespace std; struct segment { int l, r, p; } seg[300005]; struct PS { int l, r, val; } P[300005 * 20]; int n, m, k, a, b, l, r, tot; int suf[300005]; int get(int node, int bas, int son, int x, int y) { if (bas >= x && son <= y) return P[node].val; bool l ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.