func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x; cin >> n; int s1 = 0, s2 = 0; for (int i = 0; i < n; i++) { cin >> x; s1 += x; } for (int i = 0; i < n; i++) { cin >> x; s2 += x; } co... |
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) s = s * 10 + ch - 0 , ch = getchar(); return s; } const int N = 1e5 + 5; int n, m, k, p; long long h[N], a[N], c[N]; inline bool c... |
#include <bits/stdc++.h> using namespace std; int main() { map<char, int> mp; string s; int i, j, n, off; cin >> n >> s; for (i = 0; i < s.size(); i++) { mp[s[i]] = 1; } int max = mp.size(); if (n > max) { cout << NO ; } else { int c = 0; cout << YES <<... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 2e5 + 5; const int MAX = 0x7fffffff; const int MIN = 0x80000000; int n, k; struct node { int num, index; bool friend operator<(node a, node b) { return a.num > b.num; } }; node a[N]; char ch[N]; int pos[N]... |
#include <bits/stdc++.h> using namespace std; vector<int> a[30005]; int main() { int n, m, p, q, i, j; vector<int> v; cin >> n >> m; for (i = 0; i < m; i++) { scanf( %d%d , &p, &q); a[p].push_back(q); } for (i = 1; i < n; i++) sort(a[i].begin(), a[i].end()); for (i = 1; i <... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long xx = 0, yy = 0; for (int i = 0; i < 2 * n; i++) { int x, y; cin >> x >> y; xx += x; yy += y; } cout << xx / n << << yy / n; return 0; } |
#pragma GCC optimize( O3 ) #include <bits/stdc++.h> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; //template<... |
#include <bits/stdc++.h> using namespace std; int solve(int n, int k, vector<int> &arr, int mn) { int MX = int(1e6); if (k >= mn - 1) return mn; int i, j; for (i = mn; i >= k + 1; i--) { int tot = 0; for (j = 0; j <= MX; j += i) { int mx = min(j + k, MX); tot += (arr[mx] ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a, m, x, tk, i, tr, tl, r, l; scanf( %d %d %d , &n, &k, &a); scanf( %d , &m); tk = (n + 1) / (a + 1); set<int> ceils; map<int, pair<int, int> > intv; ceils.insert(n); intv[n] = pair<int, int>(1, tk); for (i = 1;... |
#include <bits/stdc++.h> using namespace std; bool dp[20][10]; int dp4[20][10], dp7[20][10], dpj[20][10]; long long n; int bit = 1; long long ten[20]; long long r[6]; int w[20]; int main() { int tcase; scanf( %d , &tcase); ten[0] = 1; for (int i = 1; i <= 18; i++) ten[i] = ten[i - 1] *... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; long long n, T, a[maxn], x, y, t1, t2, k; long long b[maxn]; long long cmp(long long x, long long y) { return x > y; } long long cmp1(long long x, long long y) { return x > y; } long long check(long long len) { for (long long ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000 * 1000 * 1000 + 7; const int INF = 1e9 + 100; const long long LINF = 1e18 + 100; long long x, k; const int n = 1e5; vector<long long> divs; vector<long long> ddv[7010]; vector<long long> fk[7010]; void getnxt(const vector<long long> ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353, INF = 1e18; vector<int> f; int n; int getsum(int i) { int sum = 0; i += 1; while (i > 0) { sum += f[i]; i -= (i & (-i)); } return sum; } void update(int i, int val) { i += 1; while (i <= ... |
#include <bits/stdc++.h> using namespace std; inline void read_string_to_vector(vector<string> &vec) { string str; getline(cin, str); vec.push_back(str); } template <typename T> inline void read_digit_to_vector(vector<T> &vec) { T t; cin >> t; vec.push_back(t); } template <typename... |
#pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) #include <bits/stdc++.h> using namespace std; typedef long long ll; #define S second #define v vector #define dbg(x) cout<<#x<< = <<(x)<<endl; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; string s; cin >> s; vector<char> base(k, ? ); for (long long i = 0; i < n; i++) { if (s[i] == 1 ) { if (base[i % k] == 1 ) { continue; } if (base[i % k] == ... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, y; bool operator<(const point& t) const { if (x == t.x) return y < t.y; return x < t.x; } bool operator==(const point& t) const { return x == t.x && y == t.y; } }; const long long INF = 1e18; const long long ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long n, m, u, v, st, cnt, a[N], check[N], num[N], low[N]; long long sz[N], val[N], sub[N], good[N]; vector<int> adj[N]; vector<pair<int, int> > edge; map<pair<int, int>, bool> bridge; void dfs(int u, int p) { check[u] = 1; ... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << 1) + (c & 15); ... |
#include <bits/stdc++.h> using namespace std; string str[100]; int func(string s1, string s2) { int i, j, k; int l1 = s1.length(), l2 = s2.length(); if (l1 != l2) return -1; for (i = 0; i < l1; ++i) { for (j = i, k = 0; k < l1; ++k, ++j) { j = j % l1; if (s1[k] != s2[j]) brea... |
#include <bits/stdc++.h> using namespace std; const int N = 4e4 + 10, M = 32, INF = 1e9 + 10; int a, b, n; int dp[N][M]; long long mypw(long long a, int b) { double ans = pow(a, b); if (ans > INF) { return INF; } long long ret = 1; while (b--) ret = ret * a; return ret; } int... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INFMEM = 63; const int INF = 1061109567; const long long LINF = 4557430888798830399LL; const double DINF = numeric_limits<double>::infinity(); const long long MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};... |
#include <bits/stdc++.h> using namespace std; map<int, int> m; vector<int> fr; int v[100100]; int main() { int n; scanf( %d , &n); int mf = 0; for (int i = 0; i < n; i++) { int t; scanf( %d , &t); v[i] = t; m[t]++; mf = max(mf, m[t]); } sort(begin(v), en... |
#include <bits/stdc++.h> using namespace std; long long numC[200011]; long long numQ[200011]; long long numBC[200011]; long long numBQ[200011]; long long numQC[200011]; long long numQQ[200011]; long long triple(int n) { if (n < 0) return 0; if (n == 1) return 3; if (n == 0) return 1; lon... |
#include <bits/stdc++.h> using namespace std; int sol[123123]; int on[123123]; int matrix[142][142]; int matrix_2[142][142]; int main() { int n, m, h; cin >> n >> m >> h; for (int i = 1; i <= m; i++) cin >> on[i]; for (int i = 1; i <= n; i++) cin >> sol[i]; for (int i = 1; i <= n; i++) ... |
#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 int maxn = 155; int f[maxn][maxn * maxn], a[maxn]; int n, K, s, ans = 2e9, cur; void solve() { sort(a + 1, a + n + 1); ans = 0; for (int i = 1; i <= K; i++) ans += a[i]; printf( %d n , ans); } int main() { scanf( %d%d%d , &n, &K, &s);... |
#include <bits/stdc++.h> using namespace std; const long long one = 1; const long long INF = 2e18; const long long MOD = 1e9 + 7; const long long N = 40040 + 10; const long long nul = 0; signed main() { vector<long long> cnt(6); for (long long &i : cnt) cin >> i; vector<pair<pair<long long, lo... |
#include <bits/stdc++.h> using namespace std; inline int IN() { char c; register int first = 0; for (; (c = getchar()) < 48 && c ^ - || c > 57;) ; bool f = c == - ; if (f) (c = getchar()); for (; c > 47 && c < 58; (c = getchar())) first = (first << 3) + (first << 1) + c - 48; ... |
#include <bits/stdc++.h> using namespace std; int main() { int N, tot = 0, i, temp1, temp2, temp3, fin; char inp1[1005], inp2[1005]; scanf( %d%s%s , &N, inp1, inp2); for (i = 0; i < N; i++) { temp1 = abs(inp1[i] - inp2[i]); temp2 = abs( 9 - inp1[i]) + (inp2[i] - 0 ) + 1; temp3 = ... |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int N = 2e3 + 7, Max = 1e6 + 7; int n, m, res; pii a[N], b[N]; int surf[Max]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { res = 1e9; fill(surf, surf + Max,... |
#include <bits/stdc++.h> using namespace std; int a[110]; int b[110]; int main() { int n, m; int maxx; int maxx1; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { maxx = 1; maxx1 = 0; for (int j = 1; j <= n; j++) { scanf( %d , &a[j]); if (a[j] > maxx1) {... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long int n; cin >> n; if (n % 2 == 0) cout << n / 2 << << n / 2 << n ; else { long long int x = -1; ... |
#include <bits/stdc++.h> using namespace std; string a, b; int m, d; long long int memo[2000][2000][2][2]; long long int dp(int i, int rem, bool hf, bool lf) { if (i >= a.length()) { if (rem == 0) { return 1; } return 0; } if (memo[i][rem][hf][lf] != -1) return memo[i][re... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<int> a; int temp = 0, sumb = 0, sumc = 0; for (int i = 0; i < t; i++) { cin >> temp; a.push_back(temp); } for (int i = 0; i < t; i++) { int tem = 0; if (a[0] < a[a.size() - 1]) { ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long double PI = acosl(-1.0); const long double E = 1e-15; mt19937_64 rnd(time(0)); long long n, m, r, pr[100001], dp[100001]; pair<long long, pair<long long, long long> > a[100001]; long long binpow(long long h, long lon... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int maxn = 403; int n, m; int a[maxn][maxn]; void read() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j]; } int min_r[maxn]; long long s[maxn * maxn][7]; int find_fi... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, x; cin >> n >> x >> m; long long a, b; long long mn = 1e9 + 1, mx = 1; bool f = false; while (m--) { cin >> a >> b; if (!f) { if (x >= a && x <= b) { f = true; mn = a; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << = << a << endl; err(++it, args...); } const ll MOD... |
#include <bits/stdc++.h> const int N = 7 + 1e9; using namespace std; const int p = 1e6 + 10; int arr[p]; int power(int x, int y); void pre() { int j = 1; for (int i = 1; i < p; i++) { if (i % 3 != 0) { if (i % 10 != 3) { arr[j] = i; j++; } } } } ... |
#include <bits/stdc++.h> using namespace std; struct S { int c[13], ma; } a[2010]; int b[20][2020]; bool cmp(S a, S b) { return a.ma > b.ma; } int dp[20][(1 << 12) + 10], sum[20][(1 << 12) + 10]; int main() { int T, n, m, i, j, k, l; scanf( %d , &T); while (T--) { memset(dp, 0, sizeo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1234567; const int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s, a, t; cin >> s; vector<string> v; for (int i = 0; i < 10; i++) { cin >> a; v.push_back(a); } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T gi() { T f = 1, x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f * x; } cons... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<string> s(n); for (string &e : s) cin >> e; vector<vector<int> > a(n, vector<int>(m, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf( %d , &a[i][j]); vector<int> d... |
#include <bits/stdc++.h> using namespace std; int dp[2][2005]; int a[2005]; int cnt2[2005]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = n; i >= 1; i--) { cnt2[i] = cnt2[i + 1]; if (a[i] == 2) cnt2[i]++; } for (int i = 0; i <= 2; i++)... |
#include <bits/stdc++.h> using namespace std; using lint = long long; using ulint = unsigned long long; const int T = 10; lint dp[T], nxt[T]; void relax(lint &x, lint y) { x = max(x, y); } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); fill(begin(dp), end(dp), -1); fi... |
#include <bits/stdc++.h> int n, m, mo; int sz[111111], ace[111111]; int ancestor(int x) { return x - ace[x] ? ace[x] = ancestor(ace[x]) : x; } int mul(int x, int y) { return (int)((long long int)x * y % mo); } int main() { scanf( %d%d%d , &n, &m, &mo); if (mo == 1) { puts( 0 ); return 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; const int mod = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } void exgcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1,... |
#include <bits/stdc++.h> const unsigned long long mod = 1e9 + 7; using namespace std; const int N = 1e3 + 5; const double esp = 1e-5; int n, x, pos, lsum = -1, rsum; unsigned long long f[N], a[N]; unsigned long long qpow(unsigned long long a, unsigned long long b) { unsigned long long ans = 1, base = ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long long INF = 1e18; const int MAXN = 1e5 + 5; long long i, j, m, n, k, t, d; long long ans; long long x[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> d; for (i ... |
#include <bits/stdc++.h> using namespace std; int h[100010], res[100010]; int main() { int n, i; while (scanf( %d , &n) != EOF) { memset(h, 0, sizeof(h)); memset(res, 0, sizeof(res)); for (i = 1; i <= n; i++) { scanf( %d , &h[i]); } int temp = 0; for (i = 1; i <... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; while (k--) { int n; cin >> n; vector<int> h(n); for (int i = 0; i < n; i++) cin >> h[i]; sort(h.begin(), h.end()); reverse(h.begin(), h.end()); int ans = 0; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; int n, a[505]; int m, b[505]; int sumA[505]; int sumB[505]; int dp[505][505]; struct Answer { int p; char c; Answer(void){}; Answer(int x, char y) { p = x; c = y; } } stk[505]; int tot = 0; int tree[505]; int lowbit(int ... |
#include <bits/stdc++.h> using namespace std; int cmp(int a, int b) { return a > b; } int main() { int i, j, m, n, sm = 0, sn = 0, num[110], e[110]; string s; map<string, int> mapp; map<string, int>::iterator it; scanf( %d%d , &m, &n); for (i = 0; i < m; i++) { scanf( %d , &num[i]); ... |
#include <bits/stdc++.h> int ans[1000006]; int dij[1000006]; int mmax; void dfs(int now, int num) { dij[num] = now; for (int i = 2; i < now; i++) { if (now % i == 0) { dfs(now / i, num + 1); } } dij[++num] = 1; if (num > mmax) { mmax = num; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; int num[maxn], ans; void Solve() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , num + i); sort(num + 1, num + 1 + n); int nn = unique(num + 1, num + 1 + n) - (num + 1); for (int i = 1; i <= nn... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N == 1) { cout << ! 1 << endl; return 0; } vector<int> res(N); for (;;) { int x = 0, y = 0; for (int i = 0; i < N; ++i) { if (x == 0 && res[i] == 0) { x = i + 1; ... |
#include <bits/stdc++.h> const long long int mod = 1e9 + 7; using namespace std; long long int p, q, r, s; long long int len(long long int x) { long long int count = 0; while (x > 0) { x = x / 10; count++; } return count; } long long int fx(long long int x) { long long int co... |
#include <bits/stdc++.h> using namespace std; int n, m, k, t, a[200010], f[200010]; long long ans; struct nood { int x, id; } b[200010]; int cmp(nood a, nood b) { return a.x > b.x; } int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i].x... |
#include <bits/stdc++.h> using namespace std; long long int tc, n, m, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; cin >> n; long long int k1, k2; cin >> k1; queue<long long int> q1; for (__typeof(k1) i = (0) - ((0) > (k1)); i != (k1) - ((0... |
#include <bits/stdc++.h> using namespace std; long long n, h, a, b, k, s[10001]; int main() { scanf( %lld%lld%lld%lld%lld , &n, &h, &a, &b, &k); for (int i = 1; i <= k; i++) { long long u1, v1, u2, v2; scanf( %lld%lld%lld%lld , &u1, &v1, &u2, &v2); if (u1 == u2) s[i] = abs(v1 - v... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int h[N], e[2 * N], ne[2 * N], w[2 * N], idx; int dist[N][N]; int n, m, k; bool st[N]; pair<int, int> q[N]; void add(int a, int b, int c) { e[idx] = b; ne[idx] = h[a]; w[idx] = c; h[a] = idx++; } priority_queue<pair<in... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const int N = 1e5 + 5; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; long long nem = 0, ans = 0; for (int i = 0; i < n; i++) { cin... |
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; int total = (n * (n - 1)) / 2; if (total >= n * k) { total = n * k; cout << total << n ; int nod1 = 1; int nod2 = nod1 + 1; int cate = 0; while (total > 0) { cate++; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long mx = 1e3 + 4; vector<vector<long long>> dist; vector<vector<bool>> col; queue<pair<long long, long long>> vis; long long n, m, t; long long expo_pow(long long x, long long y) { if (y == 0) return 1; y = ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0); int n; cin >> n; int ats = 0; list<int> kruv; int kur = 1; for (int i = 0; i < 2 * n; i++) { string c; cin >> c; if (c[0] == a ) { int nr; cin >> nr... |
#include <bits/stdc++.h> using namespace std; bool issub(string s, string t) { int cur = 0; for (char c : s) { if (c == t[cur]) cur++; if (cur == t.size()) return true; } return false; } int main() { int q, i; cin >> q; while (q--) { string s, t, p; cin >> s >... |
#include <bits/stdc++.h> using namespace std; long long siv[1000006]; long long prime[1000006]; void seive() { for (long long i = 2; i < 1000006; i++) { prime[i] = prime[i - 1]; if (!siv[i]) { prime[i]++; for (long long j = i + i; j < 1000006; j += i) siv[j] = 1; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long T, x, y, k; cin >> T; while (T--) { cin >> x >> y >> k; long long minSt = (y * k) + k - 1; long long st = 1; long long count = minSt / (x - 1); if (minSt % (x - 1) != 0) { cout << count + k + 1 << ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int par[N], par1[N], T, vis[N], n, m, w[N], x[N], y[N]; bool ans[N]; vector<pair<int, int>> e[N], q[N]; int get(int u) { return u == par[u] ? u : par[u] = get(par[u]); } int gett(int u) { return (vis[u] != T ? vis[u] = T, par1[u] = p... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline int in() { int x; scanf( %d , &x); return x; } inline long long inl() { long long x; scanf( %I64d , &x); ... |
#include <bits/stdc++.h> using namespace std; const int N = 110; int n, m, a, b, cnt, Newid, Size[N], id[N], nid[N], ans[N]; struct edge { int x, y, z; bool operator<(const edge &rhs) const { return z < rhs.z; } } e[N << 2]; int tot = 0, head[N], to[N << 2], nxt[N << 2], len[N << 2]; void add_edge... |
#include <bits/stdc++.h> using namespace std; long long int k1, k2; long long int dp[101][101][11][11]; long long int rec(long long int n1, long long int n2, long long int x, long long int y) { if (n1 == 0 && n2 == 0) return 1; if (dp[n1][n2][x][y] != -1) return dp[n1][n2][x][y]; ... |
#include <bits/stdc++.h> #define all(v) (v).begin(), (v).end() #define sortv(v) sort(all(v)) #define uniqv(v) (v).erase(unique(all(v)), (v).end()) #define pb push_back #define FI first #define SE second #define lb lower_bound #define ub upper_bound #define mp make_pair #define test 1 #define TE... |
#include <bits/stdc++.h> using namespace std; int f(int n, vector<int> &a); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i <= n - 1; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; int oo = (int)1e9; int get(string str) { int f = 0; for (int i = 0; i < (int)str.size(); ++i) { if (str[i] != - ) { if (str[i] != str[0]) f = 1; } } if (f == 0) return f; for (int i = 1; i < (int)str.size(); ++i) { if (st... |
#include <bits/stdc++.h> int n, m, a, b, c; int ans[110][110]; int find(int i, int j) { for (int k = 1; k <= 10; k++) { if (k != ans[i][j - 1] && k != ans[i - 1][j] && k != ans[i + 1][j - 1] && k != ans[i - 1][j + 1]) return k; } } void output() { for (int i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; string a, b; bool ok(string s) { if (s == ) return false; if (s.length() == 1 && s[0] == 0 ) return true; if (s[0] == 0 ) return false; for (char c : s) { if (c < 0 || c > 9 ) return false; } return true; } void cal(string s) {... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int getRand(int l, int r) { uniform_int_distribution<int> uid(l, r); return uid(rng); } unordered_map<string, int> X; long long get_sum(long long n) { if (n == 1) { return 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long int inf = 1e18; vector<long long int> v, arr; void pf() {} long long int sqrtfun(long long int num) { long long int lo = 0, hi = (long long int)2e9, mid; if (num == 1) return num; while (lo + 1 < hi) { mid = l... |
#include <bits/stdc++.h> using namespace std; long long call(long long n) { if (n == 1) return 1; else return n + call(n / 2); } void fun() { long long n; cin >> n; cout << call(n); } int main() { long long t; cin >> t; while (t--) { fun(); cout << end... |
#include <bits/stdc++.h> using namespace std; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; long long gcd(long long a, long long b) { for (; b; a %= b, swap(a, b)) ; return a; } int main(void) { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int t; cin >> t; whil... |
#include <bits/stdc++.h> using namespace std; int main() { int x, n, m; cin >> n >> m; if (n < m) { cout << -1 n ; return 0; } if (n % 2 == 0) x = n / 2; else x = (n / 2) + 1; while (x % m != 0) { x++; } cout << x << n ; } |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << n ; err(++it, args...); } long long powMod(long long x, long long y) { long lon... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fastio(); int n, m, temp; cin >> n >> m; vector<int> boys(n); vector<int> girls(m); int hb; cin >> hb; ... |
#include <bits/stdc++.h> using namespace std; bool check(int x, pair<int, int> a) { return a.first <= x && x <= a.second; } signed main() { int n; scanf( %d , &n); vector<pair<int, pair<int, int>>> vert; vector<pair<int, pair<int, int>>> hor; while (n--) { int x1, y1, x2, y2; scanf... |
#include <bits/stdc++.h> using namespace std; long long int f(long long int a, long long int b) { long long int z = b, x = 0; while (z > 1) { z /= 2; x++; } long long int y = pow(2, x); if (a == b) return a; else if (y <= a) return f(a - y, b - y) + y; else if (po... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, a, cnt = 0, tmp; scanf( %lld%lld%lld , &n, &m, &a); cnt = (m / a) * (n / a); if (n % a != 0) cnt += (m / a); if (m % a != 0) cnt += (n / a); if (m % a != 0 && n % a != 0) cnt += 1; printf( %lld n , cnt); retur... |
#include <bits/stdc++.h> using namespace std; int number[120], prime[120], primecounter = 0; void sieve() { for (int i = 0; i <= 100; i++) number[i] = 1; number[0] = 0; number[1] = 0; for (int i = 4; i <= 100; i = i + 2) number[i] = 0; for (int i = 3; i * i <= 100; i = i + 2) { for (int ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; template <typename first, typename second> ostream& operator<<(ostream& os, const pair<first, second>& p) { return os << ( << p.first << , << p.second << ... |
#include <bits/stdc++.h> using namespace std; vector<pair<char, int> > vec(100); int n; bool check(vector<bool> &bitmask) { bool flag = 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (vec[i].first == vec[j].first) { if (vec[i].second != vec[j].second) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300000; int n, m, q, p[MAXN + 3], rk[MAXN + 3], dia[MAXN + 3], type, x, y, dist[MAXN + 3]; bool flag[MAXN + 3]; vector<int> adj[MAXN + 3]; int ceil(int n) { if (!n) return 0; return (n - 1) / 2 + 1; } int find(int x) { return (... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (T i : v) os << i << , ; return os; } template <class T> ostream &operator<<(ostream &os, const set<T> &v) { for (T i : v) os << i << ; return os; } template <... |
#include <bits/stdc++.h> using namespace std; struct BookInfo { int t; int a; int b; int i; }; struct CombinedBook { int t; BookInfo b1; BookInfo b2; bool isCombined; }; int main() { ios_base::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed <<... |
#include <bits/stdc++.h> template <typename Tp> inline void read(Tp &x) { x = 0; bool f = true; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) f ^= ch == - ; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + (ch ^ 48); x = f ? x : -x; } const int N = 15e4; ... |
#include <bits/stdc++.h> using namespace std; const signed int inf = (signed)((1u << 31) - 1); const signed long long llf = (signed long long)((1ull << 61) - 1); const double eps = 1e-6; const int binary_limit = 128; template <typename T> inline bool readInteger(T& u) { char x; int aFlag = 1; ... |
#include <bits/stdc++.h> using namespace std; const int MAXLEN = 100000; long long have; char s[MAXLEN + 1]; int slen; typedef struct Node { int start, end; int childs[4]; int suffix; Node(int start, int end) : start(start), end(end) { memset(childs, -1, sizeof(childs)); suffix =... |
#include <bits/stdc++.h> using namespace std; int n; int main() { int i; scanf( %d , &n); if (n == 2) { printf( -1 n ); return 0; } else { printf( 6 n10 n15 n ); for (i = 0; i < n - 3; i++) printf( %d n , 15 * (i + 2)); } return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, memo[100001]; vector<long long> a; long long x; long long rek(int pos) { long long &ret = memo[pos]; if (ret != -1) return ret; ret = rek(pos - 1) + 20; x = upper_bound(a.begin(), a.end(), a[pos] - 90) - a.begin(); if (x) ret... |
#include <bits/stdc++.h> using namespace std; void input(vector<long long>& v, long n) { for (long long i = 0; i < n; i++) { long long in; cin >> in; v.push_back(in); } } void output(vector<long long> v) { for (long long i = 0; i < v.size(); i++) cout << v[i] << ; } long lon... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.