func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, k; char arr[2 * 1000 + 5]; int cum[2 * 1000 + 5]; void read_input() { cin >> n; cum[0] = 0, k = 0; for (int i = 1; i <= n; i++) { cin >> arr[i]; arr[i + n] = arr[i]; cum[i] = cum[i - 1]; if (arr[i] == T ) cum[i] ... |
#include <bits/stdc++.h> using namespace std; set<pair<long long, long long> > s1; long long a[212345], ans[212345]; long long b[212345]; signed main() { std::ios::sync_with_stdio(false); long long n, m; cin >> n >> m; for (long long i = 1; i <= n; i++) cin >> a[i]; for (long long i = 1; i... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:256000000 ) template <typename T> int size(T& a) { return (int)a.size(); } template <typename T> T sqr(T a) { return a * a; } int main() { int a, b, mod; cin >> a >> b >> mod; int ta = a, tb = b; a %=... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<int, int>; const int mod = 998244353; const int inf = 1 << 30; const int maxn = 100000 + 5; int n, k, alive[maxn]; int query(int x) { cout << ? << x << endl; string s; cin >> s; if (s == Y ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; int nLund0 = 0; int nRund0 = 0; int n00 = 0; int nL = 0; int nR = 0; auto zaehle = [&](char c1, char c2) -> void { if ((c1 == > && c2 == - ) || (c2 == > ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5, INF = 1e9; const double PI = 3.141592653589793238462643383279502884197, eps = 1e-9; int sum; void getstring(int st, int ed, int n, bool val) { string s; sum = 0; cout << ? ; for (int i = 0; i < st; i++) cout << 0; for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; if (n & 1) { cout << 0; } else { int res = n / 4; if (n % 4 == 0) { res--; } cout << res; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 5, M = 205, INF = 1e9, MOD2 = 1e9 + 7; int n, k, y, x[N], mem[N][3], freq[N]; int cur = 0, last = -1; vector<int> vec; int solve(int idx, int rem) { if (!rem) return 0; if (idx > cur) return 0; int& ret = mem[idx][rem]; if (~r... |
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { T r; while (b != 0) { r = a % b; a = b; b = r; } return a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> int getbit(T s, int i) { return ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long a, b; cin >> a >> b; long long count = 0; while (b >= a) { ostringstream str1; str1 << a; string str2 = str1.str(); for (long long i = 0; i < str2.length(); i... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; set<long long int> s; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > 0) { s.insert(a[i]); } } long long int len1 = s.size(); cout << len1 << endl... |
#include <bits/stdc++.h> using namespace std; struct Q { int r1, r2, c1, c2, idx; }; int n, m, k, q; Q qs[200001]; vector<int> qAtRow[100001]; vector<int> qAtCol[100001]; vector<int> atCol[100001]; vector<int> atRow[100001]; bool must[200000]; bool res[200000]; int v[100001]; int Z = 40000... |
#include <bits/stdc++.h> using namespace std; vector<long long int> glen(100001); long long int M = 1000000007; long long int n1, n2 = 0, sum = 0; long long int gcd(long long int a, long long int b) { return (b == 0) ? a : gcd(b, a % b); } long long int lcm(long long int a, long long int b) { long... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; const int maxn = 2e5 + 100; const int mod = 998244353; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll fact[maxn], inv[maxn]; ll pwr(ll a, ll pw) { ... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); while (n--) { int tenth = 10; int F = 0; char input[15]; char A[15] = { 0, }; scanf( %s , input); for (int i = 4; i < strlen(input); i++) A[i - 4] = input[i]; for (int i = 1; i < strlen(... |
#include <bits/stdc++.h> using namespace std; const int N = (int)3e5 + 1; int n, m, a[N][10], p1 = 1, p2 = 1; int ok[(1 << 8) + 1]; bool check(int x) { memset(ok, 0, sizeof(ok)); for (int i = 1; i <= n; ++i) { int mask = 0; for (int j = 0; j < m; ++j) { if (a[i][j] >= x) mask |= (1... |
#include <bits/stdc++.h> using namespace std; int main(void) { int num[102]; int a, i, sum = 0, flag = 1; scanf( %d , &a); for (i = 0; i < a; i++) { scanf( %d , &num[i]); } if (a < 3) { printf( -1 n ); } else { for (i = a - 1; i >= 0; i--) { if (i == a - 1 && i ... |
#include <bits/stdc++.h> #define F(i,j,k) for(int i=(j);i<=(k);++i) #define D(i,j,k) for(int i=(j);i>=(k);--i) #define rep(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();++it) #define Rep(a,s) for(auto a:s) #define PB push_back #define MP make_pair #define FF first #define SS second typedef lo... |
#include <bits/stdc++.h> const long long INF32 = 1e9; const long long INF64 = 1e17; const int RANGE = 1e6 + 5; using namespace std; template <class T> void read(T &Val) { T tmp = 0; char ch = getchar(); int flag = 1; while (!(ch >= 0 && ch <= 9 )) { if (ch == - ) flag = -1; c... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string s; while (t--) { cin >> s; vector<int> E, O; int io = 0, ie = 0, prev = -1; for (int i = 0; i < s.size(); ++i) { if ((s[i] - 48) % 2 == 0) { if (io < O.size() && ie < E.size()... |
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &item) { out << ( << item.fi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int du[maxn]; set<int> g[maxn]; int b1[maxn], b2[maxn], ans[maxn], vis[maxn]; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); set<pair<int, int> > s; for (int i = 0; i < m; i++) { int x, y; scanf( %d%... |
#include <bits/stdc++.h> using namespace std; int main() { long long t = 0; cin >> t; long long a = 0, b = 0; for (int i = 0; i < t; i++) { cin >> a >> b; long long dif = abs(a - b); long long res = dif / 5; dif = dif % 5; res += dif / 2; dif %= 2; res += di... |
#include <bits/stdc++.h> using namespace std; const int lala = 2e9 + 1; int max(int a, int b) { return a > b ? a : b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; pair<int, int> arr[100005]; int dp[3][100005]; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i].firs... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; double eps = 1e-10; const int maxn = 30005; char s[105][105]; int num[105][105], ans[105]; int main() { ios::sync_with_stdio; cin.tie(0); double a, b, c, d; cin >> a >> b >> c >> d; doub... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp[15]; long long k, a[200010]; int n, l[200010], r[200010]; long long ans = 0; int itos(long long x) { int now = 0; while (x) { now++; x /= 10; } return now; } void add(int p) { long long now = a[p];... |
#include <bits/stdc++.h> #pragma GCC optimize( unroll-loops , omit-frame-pointer , inline ) #pragma GCC option( arch=native , tune=native , no-zero-upper ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) #pragma GCC optimize( Ofast ) using namespace std; const ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007, MAX = 100003; const long long INF = 1LL << 60; int par[MAX]; long long mini[MAX], cost[MAX]; void init(int n) { for (int i = 0; i < n; i++) { par[i] = i; mini[i] = cost[i]; } } int root(int a) { if (par[a] ... |
#include <bits/stdc++.h> using namespace std; int k, a[1001], i, j, poz, submisii_interesante, f[1001]; double ecran, fully_tested, n, timp = 1; struct coada { int x, y, z; }; vector<coada> v; int main() { cin >> n >> k; for (i = 1; i <= n; ++i) { cin >> a[i]; if (k) { v.pu... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const int tam = 100010; const int MOD = 1000000007; const int MOD1 = 998244353; const double DINF = 1e100; const double EPS = 1e-9; const double PI = acos(... |
#include <bits/stdc++.h> using namespace std; int mv = pow(10, 5) + 1; void pfn() { char x[mv], y[mv]; cin >> x >> y; int ly = strlen(y) - 1, i; i = ly; while (i >= 0 && y[i] != 1 ) i--; int lx = strlen(x) - 1 - ly + i; i = lx; while (i >= 0 && x[i] != 1 ) i--; cout << lx - i... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; long long int mod = 1000000007; long long int maxn = 200001; long long int binpow(long long int a, long long int b, long long int mod) { long long int res = 1; while (b > 0) { if (b %... |
#include <bits/stdc++.h> using namespace std; struct node { int wh, a, b, c, cst; node(int WH, int A, int B, int C, int CST) { wh = WH; a = A; b = B; c = C; cst = CST; } bool operator<(const node &t) const { return cst < t.cst; } }; vector<node> v1, v2; int main()... |
#include <bits/stdc++.h> using namespace std; const int MOD(1000000009); const int INF((1 << 30) - 1); const int MAXN(100005); int a[MAXN], na = 0; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int x; scanf( %d , &x); int low = 0, high = na - 1, mid, pos = ... |
#include <bits/stdc++.h> using namespace std; long long v[100005]; long long st[400005]; void init(int idx, int a, int b) { if (a == b) { st[idx] = v[a]; } else { int m = (a + b) / 2; init(idx * 2 + 1, a, m); init(idx * 2 + 2, m + 1, b); st[idx] = max(st[idx * 2 + 1], st[id... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int t; cin >> t; for (int tc=1; tc<=t; tc++) { int n, x; cin >> n >> x; vector<int> v(n); for (int i=0; i<n; i++) { cin >> v[i]; } ... |
#include <bits/stdc++.h> using namespace std; int n, i, j, k, m; char ss[111], c; bool a[111]; string s[111], t; bool eq(string a, string b) { for (int i = 0; i < a.length(); i++) if (a[i] <= Z ) a[i] = a[i] - A + a ; for (int i = 0; i < b.length(); i++) if (b[i] <= Z ) b[i] = b[i] ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-12; const int INF = 999999999; const int kMod = 1000000007; const int kMaxN = 100010; char a[kMaxN], b[kMaxN]; int p10[kMaxN], p2[kMaxN], seq[kMaxN]; int F[kMaxN], S[kMaxN]; int P10(int n) { int &res = p10[n]; if (res != -1) r... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, i, j, r = 1; cin >> n; int a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (i % 2 == 0) { a[i][j] = r; r++;... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void Int(T &n) { n = 0; int f = 1; int ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -1; for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - 0 ; n = n * f; } templ... |
#include <bits/stdc++.h> using namespace std; int a[10000], i, t, n, j, x; int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; if (x <= 2048) a[x]++; } j = 1; while (j < 2048) { a[j * 2] += a[j] / 2; a[j] = 0... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int r, c; int diff = 1000000; for (int a = 1; a * a <= n; a++) for (int b = a; a * b <= n; b++) if (a * b == n && b - a < diff) ... |
#include <bits/stdc++.h> const long long oo = 1e16; using namespace std; const int N = 1000005; long long n, dp[N]; long long num(long long n) { if (n == 0) return 0; if (dp[n] != -1) return dp[n]; string s = to_string(n); long long res = oo; for (int i = 0; i < s.size(); i++) if (s[... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m; cin >> n >> m; long long start = 0, end = 6 * (n + m); while (start <= end) { long long mid = (start + end) / 2; long long val1 = (mid / 2) - (mid / 6); long long val2 = (mid / 3) - (mid / 6); if ((m... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; int flag = 1; int st; char c = s[0]; for (int i = 1; i < n; i++) { if (s[i] == c) contin... |
#include <bits/stdc++.h> using namespace std; namespace Solve { const int MAXN = 3005; inline int mymin(int a, int b) { return a < b ? a : b; } inline int mymax(int a, int b) { return a > b ? a : b; } int Log[MAXN], maxid[MAXN][20]; void getLog() { Log[1] = 0; for (int i = 2; i <= 3000; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, K = 105, P = 998244353; using ll = long long; ll dp[N][K], sum[N], cnt[N][K]; inline bool cmp(int a, int b) { return a == -1 || b == -1 || a == b; } int n, kk, len, a[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); c... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1000 + 5; const int mod = 1000 * 1000 * 1000 + 7; int a[65], b[65]; int main() { ios_base::sync_with_stdio(false); long long l, r; cin >> l >> r; for (int i = 0; l > 0; l /= 2, i++) a[i] = l % 2; for (int i = 0; r > 0; r /= 2, ... |
#include <bits/stdc++.h> using namespace std; struct seg { vector<int> id; map<pair<int, int>, int> st; int getid(int l, int r) { int L = lower_bound(id.begin(), id.end(), l) - id.begin(); int R = upper_bound(id.begin(), id.end(), r) - id.begin() - 1; if (L > R) return -1; return... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> tst[100005]; int rep[100005]; int idx[100005]; int arr[100005]; pair<int, int> sw[1000000]; int ns; int num, id; int islucky(int x) { for (; x > 0; x /= 10) if (x % 10 != 4 and x % 10 != 7) return 0; return 1; } int main() ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<pair<int, int> > v; string a; cin >> a; int balance_max = 0; int balance_min = 0; v.push_back(pair<int, int>(0, 0)); for (int i = 0; i < n ... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const long long maxn = (long long)1e6 + 5; const long long mod = 998244353; const long long inf = 0x3f3f3f3f; long long T = 1; struct edg... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000000; const long long longinf = 1000000000000000000; const double PI = 3.141592653589793; const long long mod = 1000000007; long long d[100][2]; void solve() { int n; cin >> n; vector<long long> v(n); for (int i = 0; i < n... |
#include <bits/stdc++.h> using namespace std; long long Mul(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; b >>= 1; } return res; } int A[200005]; long long F[200005], NF[200005], sum[200005], Two[2000... |
#include <bits/stdc++.h> using namespace std; const int mx=2e5+10; const int INF=0x3f3f3f; long long tes[mx][2][2]; bool flg[mx][2][2]; int hd[mx],nx[mx*2],t[mx*2],vl[mx*2]; int sum; struct Node { int x,y,z; long long jud; bool operator < (const Node &nd) const { r... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 5; pair<long long, long long> a[MAXN]; long long s; long long n; bool check(long long x) { long long sum = 0, cnt = 0; vector<long long> nums; for (long long i = 0; i < n; i++) { if (a[i].first >= x) { sum +... |
#include <bits/stdc++.h> using namespace std; int n, k, res, tmp, m; vector<int> v; bool check(int val) { int m = n - val; return m % (2 * k + 1) <= k; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; int i = min(n, k + 1); while ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 300 + 5; int n, m, p; int grid[MAX][MAX]; int dp[MAX][MAX]; vector<pair<int, int> > pos[MAX * MAX]; vector<int> col[MAX]; int main() { scanf( %d %d %d , &n, &m, &p); for (int i = int(0); i < int(n); i++) { for (int j = int(0); j... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<int> vll; typedef pair<int, int> pii; #define F first #define S second #define PB push_back #define MP make_pair #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #defi... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; int n; cin >> n; cin >> a >> b; int ans = 0; for (int i = 0; i < n - 1; i++) { if (a[i] != b[i]) { ans++; if (a[i + 1] != b[i + 1] && a[i] != a[i + 1]) { swap(a[i], a[i + 1]); } el... |
#include <bits/stdc++.h> using namespace std; typedef int matrix[140][140]; const int modp = 12345; int k, N, mod[30], base[30], cnt[30], num[30][30]; int legal[140], ans; long long n; matrix a, b; void mul(matrix a, matrix b) { matrix c; for (int i = 0; i < N; i++) for (int j = 0; j < N; ... |
#include <bits/stdc++.h> using namespace std; int main() { cout.precision(30); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<pair<long long, long long>> ps(n); for (int i = 0; i < n; i++) { cin >> ps[i].first >> ps[i].second; } sort(ps.b... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; while (k > 0) { if (n % 10 != 0 && k >= n % 10) { k -= n % 10; n -= n % 10; } else if (n % 10 != 0 && k < n % 10) { n -= k; k -= k; } else if (n % 10 == 0) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == - ) { ng = true; ch = getchar(); break; } if (ch >= 0 && ch <= 9 ) break; } while (1) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) double eps = 1e-10; using namespace std; long long m, h1, a1, x_1, y_1, h2, a2, x_2, y_2, len1, len2, l1, l2, i1 = -1, i2 = -1; int idx1[1000006], idx2[1000006], cycle1[10... |
#include <bits/stdc++.h> using namespace std; bool debug = true; template <typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> ptt) { os << ptt.first << , << ptt.second; return os; } template <typename T> ostream& operator<<(ostream& os, vector<T> vt) { os << { ; for... |
#include <bits/stdc++.h> long long n, k, m; long long dp[1010][110][2], pw[1010], PW[1010]; long long Solve(long long p, long long r, int f) { if (p <= 0) return f; if (~dp[p][r][f]) return dp[p][r][f]; if (f) return (9LL * PW[p - 1]) % m; long long res = 0; for (int i = ((p == 1) ? 1 : 0); i ... |
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e, i, j, ii, jj, zx, xc, p[10009], ji, F[10009], G[10009]; pair<int, int> k[10009]; vector<int> v; vector<int>::iterator it; int ask(int q, int w) { int qw = 0; cout << ? << q << << w << endl; cin >> qw; return qw; } in... |
#include <bits/stdc++.h> using namespace std; int n; struct Node { int u, w, next; }; struct Node node[300010]; int p; int f[100010], g[100010], num[100010], isgo[100010]; int judge(int n) { while (n) { if (n % 10 != 4 && n % 10 != 7) return 0; n /= 10; } return 1; } void... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5 + 10; const long long mod = 998244353; const long long base = 1e9; mt19937_64 rnd; struct Hashing { vector<vector<vector<long long>>> f; vector<long long> mod; vector<vector<long long>> mu; vector<long long> chr; lo... |
#include <bits/stdc++.h> using namespace std; bool row[1100], col[1100]; int main() { int n, m; while (scanf( %d %d , &n, &m) != EOF) { memset(row, true, sizeof(row)); memset(col, true, sizeof(col)); while (m--) { int x, y; scanf( %d %d , &x, &y); row[x] = false; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, s; long long row, col; long long sr, sc; long long tr, tc; int main() { scanf( %I64d %I64d %I64d , &n, &m, &s); row = n / s + 1; if (n % s == 0) row--; col = m / s + 1; if (m % s == 0) col--; sr = n - ((row - 1) * s + 1); ... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, x; scanf( %d%d , &n, &x); int sum = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); sum += a[i]; } if (n == 1) { if (a[0] == x) printf( YES n ); else printf( NO n )... |
#include <bits/stdc++.h> using namespace std; int x[5011], a, b, c, n; int main() { cin >> n; printf( ? 1 2 n ); fflush(stdout); scanf( %d , &a); printf( ? 1 3 n ); fflush(stdout); scanf( %d , &b); printf( ? 2 3 n ); fflush(stdout); scanf( %d , &c); int q = a - c; x... |
#include <bits/stdc++.h> using namespace std; auto start = std::chrono::system_clock::now(); inline void skj() { std::chrono::time_point<std::chrono::system_clock> end; end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end - start; std::time_t end_time = std::... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 300000; const long long inf = 1LL << 60; struct edge { long long from, to, dist; edge(long long u, long long v, long long d) : from(u), to(v), dist(d) {} }; struct HeapNode { long long d; long long u; HeapNode(long long... |
#include <bits/stdc++.h> int pr[100002]; int lv[100002]; int st[100002], head; int P(int x) { head = 0; while (pr[x] != -1) { st[head++] = x; x = pr[x]; } while (head > 0) { pr[st[--head]] = x; } return x; } void Union(int x, int y) { x = P(x); y = P(y); ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; cin >> a >> b >> n; a = a * 10; int f = 0; for (int i = 0; i < 10; i++) { if ((a + i) % b == 0) { cout << a + i; string s(n - 1, 0 ); cout << s << endl; f = 1; break; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 10000; const long long INFFLUJO = 1e14; const double INFCOSTO = 1e14; struct edge { int u, v; long long cap, flow; double cost; long long rem() { return cap - flow; } }; int nodes; vector<int> G[MAXN]; vector<edge> e; voi... |
#include <bits/stdc++.h> using namespace std; struct inf { long long v; long long b; }; bool cmp(struct inf a, struct inf c) { return a.b > c.b; } int main() { struct inf a[300005]; long long n, k, i, j, sum = 0, ans = -1, temp; cin >> n >> k; for (i = 0; i < n; i++) { cin >> a[i... |
#include <bits/stdc++.h> using namespace std; void count() {} int ans[1000001], h = 0; int main() { count(); int n; cin >> n; int a[301], b[301]; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { cin >> b[i]; } for (int i = 1; i <= n; ++... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int count = 1; bool res = false; for (int i = 0; i < s.length() - 1; i++) { if (s.at(i) == s.at(i + 1)) { count++; if (count > 6) { res = true; break; } } else {... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; long long white, black; cin >> n; cin >> x >> y; white = (x - 1) + (y - 1); black = (n - x) + (n - y); if (white == black) { cout << White ; } else { white > black ? cout << Black : cout << ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) using namespace std; const int N = 1000 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; const double eps = 1e-8; const double PI = acos(-1); templa... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 15; int prime[maxn]; bool visit[maxn] = {false}; vector<int> prim; vector<int> nu; void init() { int pos = 0; for (int i = 2; i < maxn; i++) { if (visit[i] == false) { prime[pos++] = i; } for (int j = 0;... |
#include <bits/stdc++.h> int n; int a[100001]; typedef struct { int len; } segment; int main(void) { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); if (n <= 2) { printf( %d , n); return 0; } segment max; max.len = 2; segment temp; temp.len = 2;... |
#include <bits/stdc++.h> using namespace std; int lowbit(int a) { return a & (-a); } int getans(char c, int l, int r, string &s) { if (l == r) { return s[l] != c; } int len = r - l + 1; int cnt = 0; for (int i = l; i < l + len / 2; i++) { if (s[i] != c) cnt++; } int ans = c... |
#include <cstdio> #include <algorithm> #include <vector> typedef long long LL; const int Inf = 0x3f3f3f3f; const int Mod = 998244353; const int MN = 405; int N, M; std::vector<int> G[MN]; int Dis[MN][MN]; int Calc(int x, int y) { for (int i = 2; i <= N; ++i) if ((Dis[x][i] ^ Dis[y][i... |
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; long long modPow(long long n, long long k) { long long res = 1; for (n %= mod; k; k >>= 1) { if (k & 1) res = res * n % mod; n = n * n % mod; } return res; } long long modInv(const long long x) { return mod... |
#include <bits/stdc++.h> using namespace std; struct segnode { int l, r, mid, s, h; segnode *ls, *rs; segnode(void) { l = r = mid = s = h = 0; } segnode(int x, int y) { l = x, r = y, mid = (l + r) >> 1, s = h = 0; } void build(void) { if (l == r) return; ls = new segnode(l, mid); ... |
#include <bits/stdc++.h> using namespace std; int n; struct node { int a, k; bool operator<(const node& e) const { return k < e.k; } } a[300100]; int main() { while (scanf( %d , &n) != EOF) { for (int i = 0; i < n; i++) scanf( %d %d , &a[i].k, &a[i].a); sort(a, a + n); int ans = ... |
#include <bits/stdc++.h> using namespace std; const long long int MAXN = 1e18 + 7; const long long int MAXNN = 300005; long long int int_pow(long long int base, long long int exp) { long long int result = 1; while (exp) { if (exp & 1) result *= base; exp /= 2; base *= base; } r... |
#include <bits/stdc++.h> using namespace std; long long a[10000000]; int main() { long long n, i, j, m, l, r, cnt = 0; string s, s2, s3 = , s4 = , s5 = ; cin >> s >> s2; n = s.size(); for (i = 0; i < n - 1; i++) { if (s[i] == s2[i]) s3 += s[i]; else break; ... |
#include <bits/stdc++.h> using namespace std; long long dp[2][300000]; long long dfs(int previous,bool previousMax,int N, vector<vector<int> > & adj, vector<pair<long long,long long> > &vals) { if(dp[previousMax][N]!=-1) return dp[previousMax][N]; long long res1 = 0; long long res2 = 0; if(pr... |
#include <bits/stdc++.h> using namespace std; int n; char a[1000]; int mp[105][150]; int jishu[105][5]; int flag; int main() { scanf( %d , &n); memset(mp, 0, sizeof(mp)); getchar(); for (int i = 1; i <= n; i++) { memset(a, 0, sizeof(a)); gets(a); flag = 0; for (unsi... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int main(void) { int t; long long n, k, o; cin >> t; while (t--) { cin >> n >> k; for (o = 0; n;) { if (n % k) { o += n % k; n -= n % k; } else { o++; n /= k... |
#include <bits/stdc++.h> using namespace std; // Template {{{ #define MOD 1000000007 #define MAX 1e9 #define MIN -1e9 #define PI acos(-1.0) #define mid(s,e) (s+(e-s)/2) #define clz(n) __builtin_clzll(n) #define all(x) (x).begin(), (x).end() #define pb... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 4e6; const long double SADAT = 7.84e-17; const long long INF = 1e9; const long long mod = 1e9 + 7; const long double PI = 4 * atan((long double)1); long long pw(long long a, long long b) { return (!b ? 1 : (b & 1 ? a *... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; struct info { int x, y, z; }; vector<info> ans; int dep[N], n, m, fa[N]; vector<int> g[N], edge[N]; void dfs(int x) { dep[x] = dep[fa[x]] + 1; for (int v : g[x]) { if (!dep[v]) { fa[v] = x; dfs(v); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.