func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> int main() { int n, v, pre, rotting, a[4005], b[4005], i, j, bag, collect, day, v2; while (scanf( %d%d , &n, &v) != EOF) { day = 0; bag = 0; for (i = 0; i < n; i++) { scanf( %d%d , &a[i], &b[i]); if (a[i] > day) day = a[i]; } rotting = 0; ... |
#include <bits/stdc++.h> using namespace std; string doen() { char c; string waarde; while (cin.get(c) && c != n ) { waarde += c; } int aantal = stoi(waarde); string iets; getline(cin, iets); for (int i = 0; i < iets.length(); i = i + 2) { if (iets[i] == 1 ) { ... |
#include <bits/stdc++.h> using namespace std; int a[110]; int d[110]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d%d , &a[i], &d[i]); } int ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] >= a[j]) { ... |
#include <bits/stdc++.h> struct { inline operator int() { int x; return scanf( %d , &x), x; } inline operator long long() { long long x; return scanf( %lld , &x), x; } template <class T> inline void operator()(T &x) { x = *this; } template <class T, class.... |
#include <bits/stdc++.h> using namespace std; vector<int> E[100005]; int head, tail, A[300], B[300]; int N, M, H, T, marked[100005]; bool ok; void checkHydra(int x) { int heads = 0; for (int i = 0; i < int(E[x].size()); ++i) marked[E[x][i]] = 1, ++heads; if (heads >= H) { for (vector<int>:... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string start; string end; cin >> start; cin >> end; int startInt = (stoi(start.substr(0, 3))) * 60 + (stoi(start.substr(3, 5))); int endInt = (stoi(end.substr(0, 3))) * 60... |
#include <bits/stdc++.h> using namespace std; int v[100005]; int st[100005][22]; bool mark[100005]; long long dp[100005]; int n, k; void build() { int i, j; for (j = 1; 1 << j <= n; j++) { for (i = 0; i + (1 << j) <= n; i++) { st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-loops ) #pragma GCC target( avx2 ) using namespace std; template <class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; } template <class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; } template <cl... |
#include <bits/stdc++.h> using namespace std; int n, a[300005], s[300005], X, Y; long long ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { long long x; scanf( %lld , &x); for (long long j = 0; j < 60; j++) if (x >> j & 1) a[i]++; s[i] = s[i - 1] + a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; int n; cin >> n >> s; int res = 0; long long a = 0, b = 0; for (int i = 0; i < n; i++) { if (s[i] == s[0]) { a++; } else { break... |
#include <bits/stdc++.h> using namespace std; long n, m, h, ts, calc[2000]; double p2, p1; double gc(long n, long m) { if (m > n) return 0; double res = 0; for (int i = n; i > n - m; i--) res = res + log(i + .0), res = res - log(.0 + n - i + 1); return exp(res); } int main() { ios_... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> a, b, g, ar; vector<vector<int> > edg, nxt; vector<long long> d; long long f(int v) { long long res = 0; for (int w : edg[v]) { long long tmp = f(w) + a[w]; if (tmp > 0) { res += tmp; nxt[w].push_back(v); ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9; long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); } long long power(long long a, long long n) { long long p = 1; while (n > 0) { if (n % 2) { p = p * a; } n >>= 1; a *= a; ... |
#include <bits/stdc++.h> using namespace std; long long md(long long a, long long b) { long long ret = 1; a %= 1000000007; while (b) { if (b & 1) { ret = (ret * a) % 1000000007; } a = (a * a) % 1000000007; b >>= 1; } return ret; } int mp[41] = {2, 3, ... |
#include <bits/stdc++.h> using namespace std; int main() { int a; string s; cin >> a; for (int i = 1; i <= a + 5; i++) { stringstream sa; string ssa; sa << i; sa >> ssa; s.append(ssa); } cout << s[a - 1]; return 0; } |
#include <bits/stdc++.h> using namespace std; bool cutPaper(int n, int x, int y) { int count = 1; while ( x % 2 == 0 || y % 2 == 0 ) { if ( x % 2 == 0 ){ x /= 2; count *= 2; }else if ( y % 2 == 0 ) { y /= 2; ... |
#include <bits/stdc++.h> using namespace std; int a[3509]; int n, t, m, k; deque<int> d; vector<int> v; int main() { scanf( %d , &t); for (int i = 0; i < t; i++) { scanf( %d%d%d , &n, &m, &k); for (int j = 0; j < n; j++) scanf( %d , &a[j]); int g = n - m + 1; v.clear(); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000004; int a[N], arr[N], nxt[N], big[N], len[N]; int main() { int n; scanf( %d , &n); int i, idx; int mx1 = 0, mx2 = -1; for (i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] > mx1) { mx2 = mx1; mx1 = ... |
#include <bits/stdc++.h> const int maxn = 5e5 + 5; std::vector<std::pair<int, int>> G[maxn]; std::vector<std::tuple<int, int, int>> q[maxn]; int in[maxn], out[maxn], id[maxn], tot, n, m; long long dis[maxn], ans[maxn]; struct SegTree { long long sum[maxn << 2], lazy[maxn << 2]; void pushdown(int o) ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } int p[100009]; int main() { int ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300010, maxlg = 18; struct edge { int to, nxt; long long val; }; edge G[maxn << 1], G2[maxn]; int head[maxn], cnt; int head2[maxn], cnt2; struct node { int u; long long d; inline bool operator<(const node &rhs) const { re... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v1, v2; for (int i = 0; i < n; i++) { int a; cin >> a; if (a) v1.push_back(a); } for (int i = 0; i < n; i++) { int a; cin >> a; if (a) v2.push_back(a); } for (i... |
#include <bits/stdc++.h> using namespace std; int main() { long k, m; string s; vector<int> rooms; cin >> k >> m; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == 0 ) { rooms.push_back(i); } } long select = k; k = 0; while (k + m < rooms.size(... |
#include <bits/stdc++.h> using namespace std; const int sieve_size = 15000002; bool sieve[sieve_size + 1]; vector<long long> prime; void Sieve() { prime.push_back(2); for (int i = 3; i * i <= sieve_size; i += 2) { if (!sieve[i]) { long long p = i * 2; for (int j = i * i; j <= sie... |
#include <bits/stdc++.h> namespace IO { inline char gc() { static const int Rlen = 1 << 22 | 1; static char buf[Rlen], *p1, *p2; return (p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, Rlen, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> T get_integer() { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, q; cin >> n >> q; long long int ans[q]; for (long long int i = 0; i < q; i++) { long long int x, y, k = 0, cto = 0; ; cin >> x >> y; if (n % 2 == 0) { k = (n / 2) * (x - 1) + ((y / 2) + (y % 2... |
#include <bits/stdc++.h> using namespace std; long long arr[200022]; long long b[200022]; vector<vector<long long> > vect(4 * 200022); void merge(long long i, long long a, long long j, long long b1, long long pos) { long long s = i; long long e = b1; while (i <= a && j <= b1) { if (b[i] < b[... |
#include <bits/stdc++.h> using namespace std; int dfs(int n) {} int main() { int n, k, x, y, a[200200], b[200200]; cin >> n >> k; vector<vector<int> > v(n, vector<int>()); for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } for (int i = 0; i < k; i++) { cin >> x >> ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000; const int MAX = 1000; const int inf = 999999999; const int p1 = 104393321, p2 = 104393329; int a[MAX], adj[MAX][MAX], ans = inf; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = (0); i < int(n);... |
#include <bits/stdc++.h> using namespace std; int n, cnt = 0; map<int, int> mp; int main() { cin >> n; mp[n]++; cnt++; while (n) { n++; while (!(n % 10)) n /= 10; if (mp[n]) break; mp[n]++; cnt++; } cout << cnt << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(int i, T X) { return (X & (1 << (i - 1))); } template <class T> T onbit(int i, T X) { return (X | (1 << (i - 1))); } template <class T> T offbit(int i, T X) { return (X | (1 << (i - 1)) - (1 << (i - 1))); } tem... |
#include <bits/stdc++.h> using namespace std; int SET(int n, int pos) { return n = n | (1 << pos); } int RESET(int n, int pos) { return n = n & ~(1 << pos); } int CHECK(int n, int pos) { return (bool)(n & (1 << pos)); } int str2int(string s) { stringstream ss(s); int x; ss >> x; return x; } ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { string s; cin >> s; string ans; bool found{false}; for (int i = 0; i < (int)s.size(); i++) { if ((i == (int)s.size() - 1) && !found) continue; if (s[i] == 1 || found) ans += s[i]; ... |
#include <bits/stdc++.h> using namespace std; set<int> st; int arr[1000005]; bool taken[1000005]; map<int, int> mp; int main() { int n; (scanf( %d , &n)); for (int i = 1; i <= n; i++) { (scanf( %d , &arr[i])); mp[arr[i]]++; st.insert(i); } for (int i = 1; i <= n; i++) s... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int neginf = 0xc0c0c0c0; const int mod = 1000000007; bool cmp(const double& a, const double& b, const double TOL = 1e-9) { return (a + TOL > b) ? (b + TOL > a) ? 0 : 1 : -1; } long long powmod(long long a, long long b) { ... |
#include <bits/stdc++.h> using namespace std; bool done[123][123]; char s[123][123]; vector<pair<pair<long long, long long>, long long int> > v; int main() { long long int n, m; scanf( %lld%lld , &n, &m); for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { done[i][j] = false; ... |
#include <bits/stdc++.h> using namespace std; int n, m, len[400], cnt, Block, pos[100010]; long long c[100010], sum[400], v[100010], cov[400], dlt[400]; bool mak[400]; void BuildBlocks() { int tail; for (int i = 1; i <= n; i = tail + 1) { tail = min(i + Block - 1, n); ++cnt; len[cnt]... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k; cin >> t; while (t > 0) { cin >> n >> k; if (n < k) { cout << k - n << endl; } else if (n % 2 == k % 2) { cout << 0 << endl; } else { cout << 1 << endl; } t--; } re... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long a[N], b[N], x[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, t; cin >> n >> t; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) cin >> x[i]; for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; using li = long long; using ld = long double; void solve(bool); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); solve(true); return 0; } const int maxn = (int)1e5 + 5; int n, a[maxn]; ... |
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T& x) { return x * x; } template <class _T> inline string tostr(const _T& a) { ostringstream os( ); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795; const long d... |
#include <bits/stdc++.h> using namespace std; long long int n; string m = abacaba ; long long int bal(string s) { long long int bl = 0; for (long long int i = 0; i < n - 6; i++) { bool b = true; for (long long int j = 0; j < m.size(); j++) { if (s[i + j] != m[j]) { b = fal... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int n = (int)s.size(); vector<int> nxt(n); int pos = -1; for (int i = 0; i < n; i++) { if (s[i] == 1 ) pos = i; ... |
#include <bits/stdc++.h> using namespace std; int n, p[200001], bl, cnt, cntbl, visited[200001], flag; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i]; } for (int i = 1; i <= n; i++) { if (!visited[i]) { int j = i, tmp = j; while (!visited[j]) { ... |
#include <bits/stdc++.h> using namespace std; const int NMax = 110000; int N; long long A[NMax], B[NMax], dp[NMax]; int Q[NMax], L, R; int main() { scanf( %d , &N); for (int i = 1; i <= N; i++) scanf( %I64d , A + i); for (int i = 1; i <= N; i++) scanf( %I64d , B + i); L = 0; R = 0; Q... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; string p(s.size(), 0 ); int dif = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != t[i]) dif++; } if (dif % 2 != 0) return cout << impossible , 0; int a(0), b(0); for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; long long aa[258], bb[258]; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0), cerr << ; string a, b; long long n; cin >> n; cin >> a >> b; long double s = 0; for (int i = 1; i <= n; ++i) aa[b[i - 1]] += i, ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int tt = 0; tt < t; tt++) { int n, flag = 0; cin >> n; vector<int> q(n + 1); vector<int> p(n + 1, -1); vector<int> use(n + ... |
#include <bits/stdc++.h> using namespace std; double dist(double x1, double y1, double x2, double y2) { double dx = x1 - x2; double dy = y1 - y2; return sqrt(dx * dx + dy * dy); } double catet(double a, int b) { double z = a * a - b * b; if (z < 1e-12) z = 0; return sqrt(z); } int ma... |
#include <bits/stdc++.h> using namespace std; namespace ioput { template <typename T> T read() { T x = 0, f = 1; char c = getchar_unlocked(); while ((c < 0 ) || (c > 9 )) { if (c == - ) f = -1; c = getchar_unlocked(); } while ((c >= 0 ) && (c <= 9 )) x = (x << 1) + (x ... |
#include <bits/stdc++.h> using namespace std; int ipow(int base, int exp) { int result = 1; for (;;) { if (exp & 1) result *= base; exp >>= 1; if (!exp) break; base *= base; } return result; } void show(int a[], int array_size) { for (int i = 0; i < array_size; ++i) c... |
#include <bits/stdc++.h> using namespace std; int main() { int tt = 1; while (tt--) { int n, a, b, c; cin >> n >> a >> b >> c; int mv = min(min(a, b), c); int q = n / mv, ans = 0; for (int x = 0; x <= q; x++) { for (int y = 0; y <= q - x; y++) { float z = ((n ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a, b, t, points[100000]; int n; double d[100000]; pair<double, int> s1[100000], s2[100000]; double dist(pair<int, int> first, pair<int, int> second) { long long x = first.first - second.first; long long y = first.second - second.second; ... |
#include <bits/stdc++.h> using namespace std; int a[102]; int b[102]; int main() { int n, m; cin >> n >> m; int num = 0; for (int i = 1; i <= m; i++) { int q = 0; for (int j = 1; j <= n; j++) { cin >> a[j]; q = max(q, a[j]); } for (int l = 1; l <= n; l++) ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 300005; int n, m; int p[max_n]; int rk[max_n]; bool vis[max_n]; vector<int> G[max_n]; set<int> s; void dfs(int u) { for (auto v : G[u]) s.erase(rk[v]); vector<int> can; for (auto v : s) { if (v < rk[u]) { v = p[v... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, a, b; cin >> n >> a >> b; if (abs(a - b) > 1 || (a + b) > n - 2) { cout << -1 << endl; return; } int l = 1, r = n; int arr[n + 5]; for (int i = 1; i <= n; i++) arr[i] = i; if (a > b) for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m], b[m]; for (int i = 0; i < m; i++) { cin >> a[i]; b[i] = a[i]; } int min = 0; for (int i = 0; i < n; i++) { int t1 = INT_MAX; int loc = -1; for (int j = 0; j < m; j+... |
#include <bits/stdc++.h> using namespace std; const int inf(1010101010); const long long P(29); long long pp[100005]; long long ch[100005]; inline bool eq(int start1, int start2, int le) { long long h1(ch[start1 + le] - ch[start1]); long long h2(ch[start2 + le] - ch[start2]); return h1 * pp[star... |
#include <bits/stdc++.h> using namespace std; char a[10][10]; int main(void) { for (int i = 0; i < 8; i++) { cin >> a[i]; } int b = 10, w = 10; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (a[i][j] == B ) { int f = 0; for (int k = i + 1; k... |
#include <bits/stdc++.h> using namespace std; int e, s, n, m, st, q[4][200000 + 10]; pair<int, int> a[200000 * 2 + 10], f[200000 * 2 + 10], ans[200000 + 10]; int main() { int i, front[4], rear[4], j; memset(f, 0xff, sizeof f); memset(ans, 0xff, sizeof ans); scanf( %d%d%d%d , &e, &s, &n, &m); ... |
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define x first #define y second typedef pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; template <typename T> void chkmax(T &x,T y){x<y?x=y:T();} template <typename T> void chkmin(T &x,T... |
#include <bits/stdc++.h> using namespace std; int price[100005]; int sum[100005]; vector<int> tempo; int main() { int n, t; scanf( %d , &n); tempo.push_back(0); for (int i = 1; i <= n; i++) { scanf( %d , &t); if (i == 1) { price[i] = 20; sum[i] = 20; tempo.p... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { long long ax, ay, bx, by, cx, cy, ab, bc; double slopeAB, slopeBC; cin >> ax >> ay >> bx >> by >> cx >> cy; if (ax == cx && ay == cy) { cout << Yes n ; } else { ab = (ax - bx) * (ax - bx) + (ay - by) * ... |
#include <bits/stdc++.h> using namespace std; long long bigmod(long long b, long long p, long long m) { if (p == 0) return 1; if (p % 2 == 0) { long long temp = bigmod(b, p / 2, m); return (temp * temp) % m; } return (bigmod(b, p - 1, m) * (b % m)) % m; } int main() { string s; ... |
#include <bits/stdc++.h> using namespace std; vector<bool> was; vector<vector<int> > es; vector<int> cst; vector<int> cols; vector<vector<int> > cycs; void dfs(int v, int par = -1) { was[v] = true; cst.push_back(v); for (int i = 0; i < ((int)(es[v]).size()); i++) { int b = es[v][i]; ... |
#include <bits/stdc++.h> using namespace std; const int T = 7; int prosti[] = {114689, 163841, 147457, 188417, 151553, 270337, 286721}; int proots[] = {3, 3, 10, 3, 3, 10, 11}; int pows[7][300000]; void fft_trivial(vector<int>& a, int id) { int n = a.size(); int mod = prosti[id]; int step = (mod... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:536870912 ) #pragma warning(disable : 4996) using namespace std; const int N = 5e5 + 100; int q[N], a[N], b[N], w[N], used[N], in[N]; bool ok[N]; vector<int> tr[N], d[N]; vector<pair<int, vector<int>>> gr[N]; vector<pair<int, int>> ed; int col... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string str; for (int i = 1; i <= t; i++) { cin >> str; string str1; str1.append(str, 0, 1); int j = 1, l = str.length(); while (j < l) { str1.append(str, j, 1); j += 2; } ... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) int a[100010], cnt[100010]; int queries[100010][2]; bool res[100010]; bool xpeHb[100010]; int main() { int t; scanf( %d , &t); for (int y = 0; y < t; y++) { int m, k; scanf( %d %d , &m, &k); for (in... |
#include <bits/stdc++.h> using namespace std; namespace fast { inline char nc() { static char buf[100000], *L = buf, *R = buf; return L == R && (R = (L = buf) + fread(buf, 1, 100000, stdin), L == R) ? EOF : *L++; } template <class orz> inline void qread(orz &x) { x ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int sum = 0; int i = 0; while (i < n) { int x; cin >> x; sum += x; ++i; } cout << fixed << setprecision(12); cout << (long... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; unsigned long long c; for (int i = 0; i < q; i++) { cin >> c; if ((c < 4) | (c % 2 != 0 & c < 13 & c != 9)) cout << -1 << endl; else { if (c % 2 != 0) cout << (c - 9) / 4 + 1 << en... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int tc; cin >> tc; while (tc--) { int arr[103][103]; long long cnt = 0; int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, hours_digit = 1, minutes_digit = 1; cin >> n >> m; long long int temp = 0; for (long long int a = 7; a < n; a *= 7) hours_digit += 1; for (long long int b = 7; b < m; b *= 7) minutes_digit += 1; if (hours_digit + ... |
#include <bits/stdc++.h> using namespace std; long long size, seg1[2 * 200005], seg2[2 * 200005], a[200005], b[200005], seg3[2 * 200005], seg4[2 * 200005]; long long temp = 0; long long f(long long u, long long v) { return min(u, v); } long long query(long long l, long long r, long long u, long long v, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; vector<int> a(n); --s; for (int i = 0; i < n; ++i) cin >> a[i]; int ans = 0; if (a[s] != 0) { a[s] = 0; ++ans; } for (int i = 0; i < n; ++i) if ((i != s) && (a[i] == 0)) a[i] = n... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; char ibuf[4096]; int ipt = 4096; int readUInt() { while (ipt < 4096 && ibuf[ipt] < 0 ) ipt++; if (ipt == 4096) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { register int res = 0; register char c = getchar(), f = 1; while (c < 48 || c > 57) { if (c == - ) f = 0; c = getchar(); } while (c >= 48 && c <= 57) res = (res << 3) + (res << 1) + (c & 15), c = getchar(); r... |
#include <bits/stdc++.h> using namespace std; long long a, b, k, t, maxi, l, r, i, ans; long long dp0[200005]; long long dp1[200005]; long long s[200005]; int main() { cin >> a >> b >> k >> t; maxi = k * t; dp1[maxi] = 1; while (t) { t--; for (i = 0; i <= 2 * maxi; i++) { ... |
#include <bits/stdc++.h> int main(int argc, char** argv) { int32_t num_queries; std::cin >> num_queries; for (int32_t i = 0; i < num_queries; i++) { int32_t num_sticks; std::cin >> num_sticks; if (num_sticks == 2) std::cout << 2 << std::endl; else if (num_sticks % 2 == 0) ... |
#include <bits/stdc++.h> using namespace std; void read(long long a = 0) { freopen( in , r , stdin); if (a) freopen( out , w , stdout); } vector<vector<pair<long long, long long> > > ad; long long over; long long dfs(long long a) { over = a; if (ad[a].size() == 0) return 1000000007; re... |
#include <bits/stdc++.h> using namespace std; template <typename U, typename V> void Min(U &a, const V &b) { if (a > b) a = b; } template <typename U, typename V> void Max(U &a, const V &b) { if (a < b) a = b; } template <typename U, typename V> void add(U &a, const V &b) { a = (a + b) % 1... |
#include <bits/stdc++.h> using namespace std; struct __timestamper {}; const int MAXN = 100100; int val[MAXN]; long long dp[MAXN][4]; vector<int> g[MAXN]; void dfs(int v, int p) { for (int u : g[v]) if (u != p) dfs(u, v); long long max0 = 0, smax0 = 0, tmax0 = 0; int max0v = -1, smax0v =... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 7e4; const int INF = 1e9; struct d { int ad, xr; } a[N]; stack<int> s; vector<pair<int, int>> v; int n; int main() { ios::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> n; int A, B; ... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& out, const pair<T1, T2>& p) { return (out << p.first << << p.second << endl); } const int INF = 1000000017; const long long LLINF = 1000000000000000017LL; const long double inf = 1.0 / 0.0; c... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3, MOD = 1e9 + 7, UNDEF = -1; int readInt() { bool minus = false; int result = 0; char ch; ch = getchar(); while (true) { if (ch == - ) break; if (ch >= 0 && ch <= 9 ) break; ch = getchar(); } if (ch ==... |
#include <bits/stdc++.h> using namespace std; int main() { stringstream ss; string x, s1, s2, s3; long long int a1 = 0, a2 = 0, a3 = 0, sum = -1, q = 0; cin >> x; int z = x.size(); for (int i = 1; i < (z - 1); i++) { for (int j = 1; j < (z - i); j++) { q = 0; stringstre... |
#include <bits/stdc++.h> const int MOD = 998244353; int prefix[505]; int dp[505]; void addmod(int& x, int y) { x = (x + y) % MOD; } int main() { int N, K; scanf( %d %d , &N, &K); dp[0] = 1; for (int k = 1; k <= N; k++) { for (int i = 1; i <= N; i++) { dp[i] = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; int i, n, l, miao, lala; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; cin.ignore(); while (n--) { char s[105]; miao = 0; lala = 0; cin.getline(s, 105); int l = strlen(s); if (l > 4 && s[0]... |
#include <bits/stdc++.h> using namespace std; int kval(int a) { if (a == 0) return 10; int kvala = a; if (kvala % 10) kvala = 10 + ((kvala / 10) * 10) - kvala; else kvala = 0; return kvala; } int compare(int a, int b) { if (kval(a) >= kval(b)) return 0; else r... |
#include <bits/stdc++.h> using namespace std; int z; struct pi { bool operator()(const pair<int, int>& p, const pair<int, int>& q) { if (0) { } else if (abs(p.first - z) < abs(q.first - z)) { return 1; } else if (abs(p.first - z) > abs(q.first - z)) { return 0; } else {... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n], b[n]; for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i... |
#include <bits/stdc++.h> using namespace std; long long n, x, y; long long c; string s; long long ans = 1e16; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> x >> y; cin >> s; s = 1 + s; for (long long i = 1; i <= n; i++) if (s[i] == 0 and s[i - 1] == 1 )... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; const long long N = 2005, inf = 1e15; long long dp[N][N], suffix1[N][26], suffix2[N][26]; long long n; string s, t; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; bool dmy[MAXN][MAXN][MAXN]; void dfs(int d, int m, int y, int bd, int bm, int by) { if (dmy[bd][bm][by]) return; dmy[bd][bm][by] = true; if (bm > 12) return; if (bd > 31) return; if (!(by % 4) && bm == 2 && bd > 29) return; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; long long n, sum, arr[N], cnt; int main() { scanf( %lld , &n); for (int i = 0; i < n; ++i) { scanf( %lld , &arr[i]); sum += arr[i]; } sort(arr, arr + n); for (int i = 0; i < n - 1; ++i) { if (arr[i] == a... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; scanf( %d%d%d , &a, &b, &c); if (a > b) swap(a, b); if (b - a >= c) { printf( %d n , (a + c) * 2); return 0; } if (b - a < c) { c -= b - a; printf( %d n , b * 2 + (c / 2) * 2); return 0; ... |
#include <bits/stdc++.h> using namespace std; int a[200050]; int b[200050]; int c[200050]; int now[200050]; int tot[200050]; int ans[200050]; int n, m, cnt, p; int main() { int i, j; while (scanf( %d %d %d , &n, &m, &p) != EOF) { for (i = 0; i < n; i++) scanf( %d , a + i); for (i =... |
#include <bits/stdc++.h> const int Maxn = 500010; using namespace std; multiset<long long> S; int n, m; long long t[Maxn]; void add(int pos, int x) { for (; pos <= m; pos += pos & -pos) { t[pos] += x; } } long long query(int pos) { long long ans = 0; for (; pos; pos ^= pos & -pos) ... |
#include <bits/stdc++.h> using namespace std; vector<int> vec, ves; int main() { int n, m, f = 0, w = 0; bool p = false, t = false; cin >> n; for (int i = 0; i < n; i++) { cin >> m; if (m == 0) t = true; for (int j = 0; j < vec.size(); j++) { p = false; if (m == v... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.