func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; const int N = 200111; struct node { int i, j; long long mn, ad = 0; node *l, *r; node(long long *a, int i, int j) : i(i), j(j) { if (j - i == 1) { l = r = NULL; mn = a[i]; } else { int k = ... |
#include <bits/stdc++.h> using namespace std; const int N = 2501; mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count()); int n, p[2 * N], a[N][N], cur; void no() { puts( NOT MAGIC ); exit(0); } struct edge { int u, v, w; edge(int a = 0, int b = 0, int c = 0) { u = ... |
#include <bits/stdc++.h> using ll = long long; const ll maxn = 1234; const ll inf = 1e9 + 7; int main(int argc, char *argv[]) { ll n, m, a[maxn]; std::cin >> n >> m; ll cur = 0, maxx = 0, minn = 0; for (int i = 0; i < n; i++) { std::cin >> a[i]; cur += a[i]; maxx = std::max(max... |
/* Author: QAQAutoMaton Lang: C++ Code: F.cpp Mail: lk@qaq-am.com Blog: https://www.qaq-am.com/ */ #include<bits/stdc++.h> #define int long long #define debug(qaq...) fprintf(stderr,qaq) #define DEBUG printf( Passing [%s] in LINE %d n ,__FUNCTION__,__LINE__) #define Debug debug( Passing [%s] in LI... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; struct BIT { vector<int> tree; BIT(int sz) { tree = vector<int>(sz + 1, 0); } void upd(int idx, int v) { for (idx++; idx < tree.size(); idx ... |
#include <bits/stdc++.h> using namespace std; void A() { cout << tokitsukaze << endl; exit(0); } void B() { cout << quailty << endl; exit(0); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; string s; cin >> s; ... |
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int f = 0, x = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) x = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { f = (f << 1) + (f << 3) + ch - 0 ; ch = getchar(); } return ... |
#include <bits/stdc++.h> const int MAXN = 100100; char S[MAXN]; char T[MAXN]; int aS[MAXN], aT[MAXN]; int bS[MAXN], bT[MAXN]; bool go() { int leftS, rightS, leftT, rightT; scanf( %d %d %d %d , &leftS, &rightS, &leftT, &rightT); int lengthS = rightS - leftS + 1; int lengthT = rightT - leftT +... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); cout << 2 << endl; int prev = (n + n - 1) / 2; if ((n + n - 1) % 2 != 0) prev++; cout << n << << n - 1 << endl; for (int i = n ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long int l, r; cin >> l >> r; long long int p = 1; long long int sum = 0; for (long long int i = 0; i < 32; i++) { for (long long int j = 0; j < 32; j++)... |
#include <bits/stdc++.h> using namespace std; template <class T> struct rge { T b, e; }; template <class T> rge<T> range(T i, T j) { return rge<T>{i, j}; } template <class T> auto dud(T *x) -> decltype(cerr << *x, 0); template <class T> char dud(...); struct debug { template <class T... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int lcm(int a, int b) { return (a * b) / gcd(a, b); } int fact(int n) { if (n == 0 || n == 1) return 1; else return n * fact(n - 1); } int main() { ios_base::... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, st[N], fn[N], timer, ans[N]; vector<int> adj[N], vec[N]; struct node { long long sum, lazy, sz, one; node() { sum = one = sz = lazy = 0; } } seg[N << 2]; void dfs1(int v, int p = -1) { st[v] = timer++; for (auto... |
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define P push #define B break #define C continue #define R return #define gcd(x,y) __gcd(x,y) #define be(a) a.begin(),a.end() #define lb(a,x) (lower_bound(be(a),x)-a.begin()) #define ub(a,x) (upp... |
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 9; const int inf = 1e9 + 9; const int N = 1e3 + 9; int n, m, c[N], d[N], a[N], b[N], dp[N][N], ans; int main() { cin >> n >> m >> c[0] >> d[0]; for (int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> c[i] >> d[i]; for (int i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (size_t i = 0; i < v.size(); ++i) { os << v[i]; if (i + 1 != v.size()) { os << ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int INF = 1e9; const double inf = 1e15; const double eps = 1e-9; const long long MOD = 1e9 + 7; long long toNum(string s) { stringstream ss(s); long long ret; ss >> ret; return ret; } string toString(long l... |
#include <bits/stdc++.h> using namespace std; const long long iinf = 1 << 29; const long long inf = 1ll << 60; const long long mod = 1e9 + 7; void GG() { cout << No n ; exit(0); } long long mpow(long long a, long long n) { long long re = 1; while (n > 0) { if (n & 1) re = re * a % m... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) const double PI = acos(-1.0); using namespace std; const int N = 509, M = 1000000; int n, m, dis[N][N], in[N][N], ans[N][N], t[N][N]; vector<int> adj[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; cin >> n >> m; int u, v... |
#include <bits/stdc++.h> int main() { int tux; scanf( %d , &tux); int foo = 0, bar = 0, baz = 0, quz = 1; for (int i = 0; i < tux; i++) { int pur; scanf( %d , &pur); foo += pur; bar++; if (foo * quz >= bar * baz) { baz = foo; quz = bar; } } p... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i < n; i++) arr[i] -= 1; for (int i = 0; i < n; i++) { int count = 1; int ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; long long n, a[maxn], aa[maxn], bb[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { aa[i] = aa[i - 1] + a[i]; } long long b[maxn]; for (int i =... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; using pii = pair<int, int>; using vi = vector<int>; mt19937 mrand(time(0)); ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; } ll get(ll l, ll r) { return get(r - l + 1) + l; } int t, T, n, m, L, R = 1e9, ... |
#include <bits/stdc++.h> using namespace std; void Read(int &n) { int sign = 1; n = 0; char c; do { c = getchar(); } while (!isdigit(c) && c != - ); if (c == - ) { c = getchar(); sign = -1; } do { n = n * 10 + c - 48; c = getchar(); } while (isdigi... |
#include <bits/stdc++.h> using namespace std; set<int> remaining; set<pair<long long int, long long int> > edge; int cur = 1; int cmp[300011]; int bfs(int v) { int cnt = 0; queue<int> q; q.push(v); vector<int> second; while (q.size()) { cnt++; v = q.front(); q.pop(); ... |
#include <bits/stdc++.h> using namespace std; int main() { int x, a, b; cin >> a >> b >> x; if (a >= b) { cout << 0 ; if (x % 2 == 0) { for (int i = 1; i < x / 2; i++) cout << 10 ; for (int i = 0; i <= b - x / 2; i++) cout << 1 ; for (int i = 1; i <= a - x / 2; i++... |
#include <bits/stdc++.h> using namespace std; int n, a[1005] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15... |
#include <bits/stdc++.h> constexpr int MAXN = 1e2 + 2; constexpr int MAXE = 1e4 + 4; using namespace std; int n; vector<double> choc, prefixSum, suffixSum, cpy; int main() { std::ios::sync_with_stdio(false); cin >> n; choc.resize(n), prefixSum.resize(n), suffixSum.resize(n); for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const long double PI = 3.14159265358979323846; const long long MOD = 998244353; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int n; cin >> n; vector<int> a(n); map<int, deque<... |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; const int maxn = 200005; long long a[maxn], b[maxn]; int n; int ans, base; std::map<std::pair<long long, long long>, int> mmp; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } int main() { ci... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = 1e3 + 5, OO = 0x3f3f3f3f, MOD = 1000000007, M = 200000 + 5; const double EPS = 0.000000001; int n, x, y; char str[N]; int main() { scanf( %d %s , &n, str); for (int i = 0; i < n; ++i) { x += str[i] == R ... |
#include <bits/stdc++.h> using namespace std; int a, q, w, t; int main() { cin >> a; cout << (a + 1) / 36 << << (a + 1) % 36 / 3; } |
#include <bits/stdc++.h> using namespace std; long long n, ans, val[3001000]; priority_queue<int> q; int main() { scanf( %lld , &n); for (int i = 1; i <= n; i++) scanf( %lld , &val[i]); for (int i = 1; i <= n; i++) { q.push(-val[i]); q.push(-val[i]); ans += val[i] + q.top(); ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; int p[N + 10], a[N + 10], pos[N + 10]; struct seg { int l, r, min; } t[N * 4 + 10]; int nxt[N + 10][20]; int get(int x, int n) { int ans = x, cnt = 0; while (n) { if (n & 1) ans = nxt[ans][cnt]; if (ans >= 0x7f7f7f7f)... |
#include <bits/stdc++.h> using namespace std; int main() { long long T, n; cin >> T; while (T--) { cin >> n; double x = (3.141592653589793238) / (2 * n); cout << fixed << setprecision(10) << cos(x) / sin(x) << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; inline void out(int a) { printf( %d n , a); } inline void out(int a, int b) { printf( %d %d n , a, b); } inline void outf(double a) { printf( %3.lf n , a); } inline void outf(double a, double b) { printf( %3.lf %3.lf n , a, b); } inline void base() { ios_bas... |
#include <bits/stdc++.h> using namespace std; string a, b, c, s; const long long mod = 1000000007; long long res[310000], sum; int N, ar[310000], srt[310000], dad[310000]; int where[310000], lcp[310000], F[310000], S[310000], T[310000]; pair<int, int> as[310000]; vector<pair<int, int> > q; int comp(co... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 20; long long sum; int k, p, n, a[N + 1], i, b[N + 1], left_tree[N + 1], right_tree[N + 1]; vector<long long> leftv, rightv; void update(int index, int value, int tree[]) { while (index < N + 1) { tree[index] += value; index +=... |
#include <bits/stdc++.h> using namespace std; int n, a[100001], b[100001]; long long int k, SS; int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; SS = SS + a[i]; } if... |
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } int main() { int N; scanf( %d , &N); int cnt[3] = {}; for (int i = 0; i < (int)(N); ++i) { int a; scanf( %d , &a); ++cnt[... |
#include <bits/stdc++.h> using namespace std; template <class C> constexpr int sz(const C &c) { return int(c.size()); } using ll = long long; using ld = long double; constexpr const char nl = n , sp = ; using T = long double; constexpr const T EPS = 1e-9; bool lt(T a, T b) { return a + EPS ... |
#include <bits/stdc++.h> using namespace std; int a, b, c, k, k1, ans; int main() { cin >> a >> b >> c; if (b > c) swap(b, c); if (b <= a / 2 && c > a / 2) { cout << Final! << endl; return 0; } while (c != b) { b++; c++; b /= 2; c /= 2; ans++; } ... |
#include <bits/stdc++.h> using namespace std; template <class T> using vc = vector<T>; template <class T> using vvc = vc<vc<T>>; template <class T> void mkuni(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); } long long rand_int(long long l, long long r) ... |
#include <bits/stdc++.h> using namespace std; vector<vector<char>> g; map<long long, bool> dp; void brute(int n, vector<int> &p) { int x = find(p.begin(), p.end(), -1) - p.begin(); if (x == int(p.size())) { vector<vector<char>> dp2(1 << n, vector<char>(n)); vector<int> pos1(n), pos2(n); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const long long mod = 1e9 + 7; int prime[500], judge[500], lcm[500][40], cnt, tol; int tree[100][maxn << 2], root[maxn], ls[maxn << 6], rs[maxn << 6], sum[maxn << 6], last[maxn << 1]; int a[maxn], ba = 1 << (int)ceil(log2(1e5 + 1)... |
#include <bits/stdc++.h> using namespace std; vector<int> p; vector<int> t; int main() { int n, c, a, ans1 = 0, ans2 = 0, t1 = 0, t2 = 0; cin >> n >> c; for (int i = 0; i < n * 2; i++) { cin >> a; if (i < n) { p.push_back(a); } else { t.push_back(a); } } ... |
#include <bits/stdc++.h> using namespace std; int const N = 3e5 + 5; int const NN = 20; int const MAX = 1e9 + 1; int n, a[N]; struct ITMAX { pair<int, int> tree[4 * N]; pair<int, int> get_interval(pair<int, int> p, pair<int, int> q) { return make_pair(min(p.first, q.first), max(p.second, q.sec... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int main() { ios::sync_with_stdio(false); long long n; cin >> n; string s; cin >> s; if (s[0] == s[n - 1]) { char a = s[0]; char b = s[n - 1]; long long x = 0, y = 0; for (int i = 0; s[i] == a;... |
#include <bits/stdc++.h> using namespace std; long long int pow(long long int a, long long int b) { long long int ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b >>= 1; } return ans; } long long int powmod(long long int a, long long int b) { long long int ans = 1; w... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; struct node { int x, d; }; vector<int> adj[100005]; vector<int> good[105]; int vis[100005]; int a[100005]; int d[100005][105]; void bfs(int s) { queue<node> q; for (int i = 0; i < good[s].size(); i++) { int v = ... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n, a[N], s1[N], s2[N], ans = 0; void judge(int x, int y, int mid) { int tmp = 0; if (x == y) tmp = s1[mid] + s2[n] - s2[mid]; else tmp = s1[x - 1] + s2[n] - s2[y] + s2[mid] - s2[x - 1] + s1[y] - s1[mid]; ans = max(... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) using namespace std; long long read() { long long 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 ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > q[500005]; int n, m, tot, nms, ans[500005], dep[500005], ms[500005], sz[500005], t[500005][30], a[500005], hd[500005], to[500005], nxt[500005]; char ch[500005]; int read() { int x = 0, fl = 1; char ch = getchar(); while (c... |
#include <bits/stdc++.h> const int SIZE = 5e5 + 5; using namespace std; vector<pair<int, int> > v; set<pair<int, int> > H; bool used[SIZE]; int b[SIZE]; int main() { int(n); scanf( %d , &n); for (int i = 0; i < (n); ++i) { int(x); scanf( %d , &x); v.push_back(make_pair(x, i))... |
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pi; const int MAXN = 250005; const int mod = 998244353; //1e9 + 7;//998244353; template<typename T> T gcd(const T &a, const T &b) { return b == T(0) ? a : gcd(b, a % b); } struct mint { in... |
#include <bits/stdc++.h> using namespace std; string s; long long k, n; int index_1[(int)(1e6 + 5)], num = 0; void solve() { cin >> k >> s; n = s.size(); if (k == 0) { long long last = 0, ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 0 ) last++; else { ... |
#include <bits/stdc++.h> using namespace std; int in() { int n; scanf( %d , &n); return n; } long long Lin() { long long n; scanf( %lld , &n); return n; } double Din() { double n; scanf( %lf , &n); return n; } const long long inf = (long long)1e17; const long long m... |
#include <bits/stdc++.h> using namespace std; long long a[200005]; long long cum[200005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long tc; cin >> tc; while (tc--) { long long n, p, k; cin >> n >> p >> k; for (int i = 0; i < n; i++) c... |
#include <bits/stdc++.h> using namespace std; using lint = long long; const lint linf = 1e18 + 7; const lint inf = 1e9 + 7; const int MOD = 1000000007; void press(vector<long long>& x) { map<int, int> memo; int n = x.size(); for (int i = 0; i < n; ++i) { memo[x[i]] += 1; } int cur ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 10007; const long long INF = 1e18 + 1234; int setbit(int n, int pos) { return n = n | (1 << pos); } int resetbit(int n, int pos) { return n = n & ~(1 << pos); } bool checkbit(int n, int pos) { return (bool)(n & (1 <<... |
#include <bits/stdc++.h> using namespace std; const int N = 2020; int prv[N], nxt[N], n; long long h, x[N]; int px[N], nx[N], pxa[N], nxa[N]; bool mark[N][N][4]; double p, dp[N][N][4]; void prep() { for (int i = n - 1; i >= 0; i--) { if (i + 1 == n || x[i + 1] - x[i] >= h) { nxa[i] = h... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 3 * 100000 + 1; vector<int> v(n); v[0] = 0; for (int i = 1; i < n; i++) { v[i] = i ^ v[i - 1]; } int a, b, t, ans; cin >> t; while (t--) { cin >> a >> b; if (v[a - 1] == b) { ans = a; }... |
#include <bits/stdc++.h> using namespace std; int n, a, b, i, p = 2e9; int main() { for (cin >> n; i < n; i++) { cin >> a >> b; if (max(a, b) <= p) p = max(a, b); else if (a <= p) p = a; else if (b <= p) p = b; else return cout << NO , 0; } ... |
#include <bits/stdc++.h> using namespace std; inline int re_ad() { int x = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + (ch ^ 48), ch = getchar(); return x * f; } int a, b, m... |
#include <bits/stdc++.h> using namespace std; long long x[1000006] = {}, y[1000006] = {}, a[1000006] = {}, b[1000006] = {}, x2[1000006][3], y2[1000006][3]; long long dfs(int i, long long xx, long long yy, long long px[4][2]) { int k = i % 4; for (int jj = 0; jj < k - 1; jj++) { if (xx ==... |
#include <bits/stdc++.h> using namespace std; int main() { int count = 0, sum = 0; int n; cin >> n; int arr[101]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n; i++) { sum += arr[i]; } for (int i = 0; i < n; i++) { if ((sum - arr[i]) % 2 =... |
#include <bits/stdc++.h> int cnt[1001][1001], que[1000001][2], head = -1, tail; char map[1001][1001]; int n, m; int main() { int i, j, a, go[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}, print; scanf( %d %d , &n, &m); for (i = 0; i < n; i++) { scanf( %s , map[i]); for (j = 0; j < m; j++) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int maxN = 80; long long f[maxN]; int d[maxN]; const int maxD = 1000; const int K = 13; int dp[maxD][maxD]; bool filled = false; pair<int, int> get(int order, long long x) { if (order == K && filled) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, m, r = 0, t; cin >> n; for (i = 0; i < n; i++) { cin >> m; while ((m) && (r)) { if (m > r) m %= r; else r %= m; } r += m; } cout << r * n << endl; } |
#include <bits/stdc++.h> using namespace std; const int N = 8; const int M = 100010; const int INF = 1 << 30; int n, q; map<int, int> sum, val; void init() { sum.clear(); val.clear(); } void add(int p, int v) { if (val.find(p) == val.end()) val[p] = 0; val[p] += v; while (p) { ... |
#include <bits/stdc++.h> using namespace std; const int M = 220000; vector<int> e1[M], e2[M]; int p[M], dis[M]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; e1[u].push_back(v); e2[v].push_back(u); } int k; cin >> k... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int nums[n]; for (int i = 0; i < n; i++) { cin >> nums[i]; } if ((nums[0] % 2 == 0)) { cout << No ; return 0; } if ((nums[n - 1] % 2 == 0)) { cout << No ; return 0; } i... |
#include <bits/stdc++.h> using namespace std; int treeNo[111111]; vector<vector<int> > BIT; vector<pair<int, int> > E[111111]; int in[111111]; int base[111111]; int P[111111], depth[111111]; void update(int x, int val, int id) { for (; x < BIT[id].size(); x += (x & -x)) BIT[id][x] += val; } int ... |
#include <bits/stdc++.h> long long exp(long long x, long long p) { long long ret = 1; while (p > 0) { if (p & 1) { ret = (ret * x) % 1000000007; } p >>= 1; x = (x * x) % 1000000007; } return ret; } signed main() { std::ios::sync_with_stdio(false); std::cin.t... |
#include <bits/stdc++.h> using namespace std; const long long INF = 99999999; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; if (n == 1) { cout << 1; return 0; } vector<int> a(n); ; for (int i = 0; i < (n); ++i) cin >> a[i]; ; vector... |
#include <bits/stdc++.h> using namespace std; const int LIM = 3e5 + 7; int T[LIM][10], n, m, ans1, ans2; bool spr(int x) { vector<int> V[1 << m]; for (int i = 0; i < (n); ++i) { int l = 0; for (int j = 0; j < (m); ++j) { if (T[i][j] >= x) l += 1 << j; } V[l].push_back(i);... |
#include <bits/stdc++.h> using namespace std; int minimumStones(string s, int n) { int i = 0, counts = 0; while (s[i] == - ) { counts++; i++; } for (int i = 0; i < n; i++) { if (s[i] == - ) counts--; else counts++; if (counts == 0) { int j = i ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-3; const int SZ = 4000050, INF = 0x7FFFFFFF; const double PI = acos(-1); struct nd { double a, b, c, d, e; nd(double _a = 0, double _b = 0, double _c = 0, double _d = 0, double _e = 0) : a(_a), b(_b), c(_c), d(_d), e(_e) {} ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, K = 300; int n, mx, ct, ans, a[N], buc[N], lst[N * 2], tp[N], cnt; inline void Add(int x, int k) { cnt -= (tp[x] == ct), tp[x] += k, cnt += (tp[x] == ct); } int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d ,... |
#include <bits/stdc++.h> using namespace std; inline long long getnum() { char c = getchar(); long long num, sign = 1; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) sign = -1; for (num = 0; c >= 0 && c <= 9 ;) { c -= 0 ; num = num * 10 + c; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a; b = a; reverse(b.begin(), b.end()); printf( %s%s n , a.c_str(), b.c_str()); return 0; } |
#include <bits/stdc++.h> using namespace std; long long tree[400005]; int n; long long r[100005], h[100005], v[100005]; pair<long long, int> p[100005]; int mp[100005]; void update(int nd, int bb, int ee, int ii, long long vv) { if (bb == ee && bb == ii) { tree[nd] = vv; return; } i... |
#include <bits/stdc++.h> using namespace std; long long a[200020]; long long va[200020]; long long b[200020]; long long c[200020]; char ans[200020]; char ansstring[200020]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); long long n, k; cin >> n >> k; for (int i = 1; i <= n... |
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n <= 1) return false; for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n; cin >> n; vector<int> v; ... |
#include <bits/stdc++.h> using namespace std; const int N = 120; int a[N][N], n, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; if (k > n * n) { cout << -1 n ; } else { for (int i = 0; i < n && k > 0; i++) { a[i][i] = 1, k--; for ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const int MAXN = 200010; const double EPS = 1e-7; inline int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) ... |
#include <bits/stdc++.h> using namespace std; long long gen(int order) { long long sum = 0; while (order != 0) { sum = (sum * 10) + 9; order--; } return sum; } int main() { long long l, r; cin >> l >> r; long long p = l, k = r; int order = 0, sorder = 0; while (k ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return a ? gcd(b % a, a) : b; } template <typename T> T lcm(T a, T b) { return (a / gcd(a, b)) * b; } string int_to_str_easy(long long n) { return n ? : int_to_str_easy(n / 10) + (char)( 0 + n % 10); ... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; const int MAXN = 1e6 + 10; const long long MOD = 1e9 + 7; const long long MOD2 = 998244353; const long long INF = 8e18; const int LOG = 22; long long pw(long long a, long long b, long long mod) { return (!b ? 1 :... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const int MAXN = 1e5 + 10; const long long mod = (1ll << 32); const long long inf = 1e16; const int N = 1e7 + 1; struct Query { int l, r, id; }; Query q[MAXN]; long long a[MAXN], p[MAXN], cntl[N], cntr[N], res[MAXN], ... |
#include <bits/stdc++.h> using namespace std; int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); int a, ta, b, tb; string t; cin >> a >> ta >> b >> tb >> t; int p = 600 * (t[0] - 0 ) + 60 * (t[1] - 0 ) + 10 * (t[3] - 0 ) + t[4] - 0 ; int q = p + ta; int ans = ... |
#include <bits/stdc++.h> using namespace std; using namespace std; long long ara[205]; long long dp[205][205][205]; int n, k, x; long long rec(int pos, int last, int left) { if (last > k) return -1e17; if (pos == n + 1) { if (!left) return 0; return (-1e17); } if (left < 0) retur... |
#include <bits/stdc++.h> using namespace std; long long num[300010]; long long sum[300010]; int n; bool cmp(int a, int b) { return a > b; } int main() { while (~scanf( %d , &n)) { for (int i = 0; i < n; i++) cin >> num[i]; sort(num, num + n, cmp); sum[0] = num[0]; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; double n, m, k, a, b, c; string s; vector<double> v; int main() { scanf( %lf %lf %lf , &a, &b, &c); if (a == 0 && b == 0 && c == 0) { printf( -1 n ); return 0; } if (a == 0 && b == 0 && c != 0) { printf( 0 n ); return 0; ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1E-15; const int inf = int(1e9) + 7; const int maxN = 1000 + 5; int in[maxN], to[maxN], cs[maxN]; int n, m; int main() { scanf( %d%d , &n, &m); int a, b, c; for (int(i) = 0; (i) < (m); ++(i)) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 6001; int n, m, k, a, b, x[N], y[N], z[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &x[i]); scanf( %d , &m); for (int i = 1; i <= m; i++) scanf( %d , &y[i]); scanf( %d , &k); for (int i = 1; i <= k;... |
#include <bits/stdc++.h> using namespace std; int n, a[52][52], d[52], dd[52], c[52], b[52][52]; bool check(int pos) { int t[n + 2]; for (int i = 1; i <= n; i++) t[i] = d[i]; for (int i = 1; i <= n; i++) if (t[i] == n && i != pos) t[i] = n - 1; for (int i = 1; i <= n; i++) for (int j =... |
#include <bits/stdc++.h> using namespace std; int const MAX_N = 1e5 + 10; int n, p, l[MAX_N], r[MAX_N]; int get_count(int l, int r) { int ans = 0; if (l % p == 0) ++ans; l -= l % p; r -= r % p; ans += (r - l) / p; return ans; } double get_prob(int a, int b) { long long count = 0;... |
#include <bits/stdc++.h> #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( Ofast ) using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; long double u; cin >> n >> u; vector<long double> e(n); for (int i = 0; i < n; i++) c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.