func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MAXN = (int)1003; const int LOG = (int)11; const int infint = (int)1e9 + 3; const long long inf = (long long)1e12; string A, B[MAXN]; int cost[MAXN], dp[MAXN][MAXN], last[MAXN], n, mx, sza; pair<int, int> radix[MAXN]... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int a, b, c, i, j, cnt = 0; cin >> a >> b >> c; for (i = 0; i <= c; i++) { for (j = c; j >= 0; j--) { if ((j * a + i * b) == c) { cout << Yes << endl; cnt = 1; break;... |
#include <bits/stdc++.h> using namespace std; const long long N = (long long)(1e6) + 322; const long long MAXN = (long long)(1e7) + 100; const long long inf = (long long)(3e18) + 322; const long long mod = (long long)(1e9) + 7; const double eps = 1e-6; inline void upd(long long &mn, long long x, long long... |
#include <bits/stdc++.h> using namespace std; template <class T> int chkmax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; } template <class T> int chkmin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; } template <class iterator> void out... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; const long long mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string str; cin >> str; long long n = str.length(); vector<pair<long long, long long> > arr; arr.push_back(make_pair... |
#include <bits/stdc++.h> using namespace std; class Graph { public: vector<vector<int> > adjList; vector<int> indegree; Graph(int v) { adjList.resize(v); indegree.resize(v, 0); } void add(int u, int v) { adjList[u].push_back(v); indegree[v]++; } }; struct subse... |
#include <bits/stdc++.h> using namespace std; int main() { char trash[100]; int n; cin >> n; cin.getline(trash, 10); for (int i = 0; i < n; ++i) { string s; getline(cin, s); bool fredas = (s.find( lala. , s.length() - 5) == s.length() - 5); bool rainbows = (s.find( miao. ... |
#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); } bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); } template <typename T> inline T __lcm(T a, T b) { return (a * b) / __gcd(a, b); } ... |
#include <bits/stdc++.h> using namespace std; const double long EPS = 1e-7; vector<vector<long long>> precost(long long n, vector<long long> &p, vector<long long> &id) { vector<vector<long long>> res(n, vector<long long>(n)); for (int i = 0; i < n; i++) { vector<l... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long mpow(long long x, long long y) { long long res = 1; x = x % 1000000007; while (y) { if (y & 1) { res *= x; res = res % 1000000007; } x *= x; x %= 1000000007; y >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) { if ... |
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; n -= 10; if (n <= 0) cout << 0 << endl; else if (n <= 9) cout << 4 << endl; else if (n == 10) cout << 15 << endl; else if (n == 11) cout << 4 << endl; else cout << 0 << endl; } ... |
#include <bits/stdc++.h> using namespace std; int p[100005], cnt, h[100005], cnth, l[100005], cntl, cntquery; int query(int x, int y) { printf( 0 %d %d n , x, y); fflush(stdout); int ret; scanf( %d , &ret); cntquery++; if (cntquery > 300000) while (1) ; return ret; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 150001; struct BIT { int bit[maxn]; BIT() { memset(bit, 0, sizeof(bit)); } void add(int x, int v) { for (x++; x < maxn; x += x & -x) bit[x] += v; } void add(int a, int b, int v) { add(a, 1), add(b + 1, -1); } int qry(int ... |
#include <bits/stdc++.h> using namespace std; int mod(int val) { return val > 0 ? val : -val; } int main() { int g[2], b[2]; cin >> g[0] >> g[1] >> b[0] >> b[1]; bool pass = false; if (((g[1] + 1) * 2 >= b[0]) && (b[0] - g[1]) > -2) { pass = true; } if ((g[0] + 1) * 2 >= b[1] && (b[1... |
#include <bits/stdc++.h> int main() { int i, n, k; scanf( %d %d , &n, &k); int a[n]; int count = 0, j = 0; for (i = 0; i < n; i++) { scanf( %d , &a[i]); } for (i = 0; i < n; i++) { if (a[i] <= k) count++; else { j = 1; break; } } if (... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; int n, m, a[1005][1005]; vector<int> row[1005]; vector<int> col[1005]; int ans[1005][1005]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { scanf( %d , &a[i][j]); ... |
#include <bits/stdc++.h> using namespace std; #define INF 200000000000000000LL typedef long long int ll; typedef pair<ll,ll> ii; typedef pair<ii,ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; #define getbit(n,i) (((n)&(1LL<<(i)))!=0) #define setbit0(n,i) ((n)&(~(1LL<<(i)))) #define setbit1(... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long qpow(long long x, long long tms) { long long tmp = 1; while (tms) { if (tms & 1) tmp = tmp * x % mod; tms >>= 1; x = x * x % mod; } return tmp; } int n, m, T; bool chk(int k) { if (n == ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); for (int i = 0; i < t; i++) { int cont = 0; int tamano; scanf( %d , &tamano); string x; cin >> x; for (int j = 0; j < tamano / 2; j++) { if (x[j] == x[tamano - j - 1]) { ... |
#include <bits/stdc++.h> using namespace std; int n, a[109], d; void nhap() { scanf( %d n , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); } void qs(int l, int r) { int x = a[(l + r) / 2]; int i = l; int j = r; while (i <= j) { while (a[i] < x) i++; while (a[j] > x)... |
#include <bits/stdc++.h> int max(int x, int y) { return (x > y ? x : y); } int geGcd(int a, int b) { if (a == 0 || b == 0) return 0; for (int i = max(a, b); i >= 1; i--) if (a % i == 0 && b % i == 0) return i; } using namespace std; int main() { int a, b, n; cin >> a >> b >> n; int c... |
#include <bits/stdc++.h> using namespace std; long long lv[100001], lf[100001], par[100001], n; vector<long long> con[100001], cld[100001]; long long get_leaf(long long id) { if (cld[id].size() == 0) { lf[1]++; return 1; } long long x = 0, i; for (i = 0; i <= cld[id].size() - 1; i++)... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int c = 0, f = 0; for (int i = 0; i < n; i++) { if (s[i] == x ) c++; else if (s[i] != x && c < 3) c = 0; if (c > 2) { while (1) { f++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int k, d; cin >> k >> d; if (d == 9) { cout << 9; for (int i = 1; i < k; i++) cout << 0; } else if (d == 0 && k > 1) { cout << No solution ; } else { cout << d; for (int i = 1; i < k; i++) cout << 9; } ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return b / gcd(a, b) * a; } int n, g[5001]; int s; int l[5000][5001]; int best = 1 << 30, freq; int SWAP(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; int ucln(int a, int b) { int r; while (b > 0) { r = a % b; a = b; b = r; } return a; } int main() { int x, y, a, b, bc; cin >> x >> y >> a >> b; bc = x * y / ucln(x, y); int l = a, r = b; while (l % bc != 0) l++;... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, y, index; point(long long x, long long y, long long index) : x(x), y(y), index(index) {} long long operator*(const point p) { return x * p.x + y * p.y; } long long operator^(const point p) { return x * p.y - y * p.x; } boo... |
#include <bits/stdc++.h> using namespace std; using u64 = unsigned long long; const int mod = 1e9 + 7, N = 2e3 + 10; char mp[N][N]; int f[N][N]; bool st[N][N]; unordered_map<char, pair<int, int>> mv = { { L , {0, -1}}, { R , {0, 1}}, { U , {-1, 0}}, { D , {1, 0}}}; int main(void) { int t; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:36777216 ) using namespace std; const int INF = ~(1 << 31); const double EPS = 1; const double PI = 3.141592653589793; int main() { int n, m; cin >> n >> m; if (m == 3 && n >= 5) { cout << -1 n ; return 0; } for (int i... |
#include <bits/stdc++.h> using namespace std; int m, x, p[100005], h[100005], cnt; long long n; int ksm(int a, long long k) { if (!k) return 1; int p = ksm(a, k / 2); if (k & 1) return (long long)p * p % 1000000007 * a % 1000000007; return (long long)p * p % 1000000007; } int Getval(long lon... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x0f0f0f0f; template <class S, class T> inline pair<S, T> MP(S a, T b) { return make_pair(a, b); } template <class T> inline auto LX(T &X) -> decltype((X.first)) { return X.first; } template <class T> inline auto LX(const T &X) ->... |
#include <bits/stdc++.h> using namespace std; int it = 0; int find(int l, int r, int k) { if (l == r) return l; int ras = (r - l + 1) / 2; int ll, rr; if (k == 0) { ll = l + ras - 1; rr = l + ras; } else { ll = r - ras; rr = ll + 1; } if (k == 0) { assert(... |
#include <bits/stdc++.h> unsigned long long int p[64][2][2], m, pi[64]; void mul_matrix(int size, unsigned long long int (*a)[2], unsigned long long int (*b)[2], unsigned long long int (*dest)[2]) { int i, j, k; for (i = 0; i < size; i++) for (j = 0; j < 2; j++) { ... |
#include <bits/stdc++.h> int inp() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum; } char s[1000010], l[1000010], r[1000010]; long long f[1000010], sum[1000010];... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; t = 1; while (t--) { int n; cin >> n; long long arr[n], c4 = 0, c2 = 0; long long i; map<long long, long long> make_pair; for (i = 0; i < n; i++) { c... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 505; int l[MAXN], r[MAXN], s[MAXN], w[MAXN], v[MAXN]; int dp[2 * MAXN][MAXN]; vector<int> wr[2 * MAXN]; int calc(int str, int i) { if (dp[str][i] != -1) return dp[str][i]; int L = l[i], R = r[i]; vector<int> prf(2 * MAXN); prf[L]... |
#include <bits/stdc++.h> using namespace std; void read(long long &x) { x = 0; long long f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -f; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; x *= f; } void print(long long x) { if (x ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long INF = 1e17; vector<vector<long long>> g; vector<long long> used; void dfs(long long v) { used[v] = 1; for (auto u : g[v]) { if (!used[u]) { dfs(u); } } } void solve() { long... |
#include <bits/stdc++.h> using namespace std; int main(void) { int t; cin >> t; for (int z = 0; z < t; ++z) { int n; string s; cin >> n >> s; string ans = ; for (int i = 0; i < n; ++i) { if ((s[i] - 0 ) % 2 == 1) ans += s[i]; if (ans.size() == 2) break; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 100; vector<int> g[maxn], G[maxn]; int type[maxn]; int cntIn[maxn]; void no() { printf( No ); exit(0); } void yes() { printf( Yes ); exit(0); } void dfsG(int v, int par = -1) { if ((int)G[v].size() > 2) no(... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 77; int main() { int a, b; cin >> a >> b; int ans = 0; while (1) { if (a <= 0 || b <= 0) break; if (a < b) { a++; b -= 2; } else { b++; a -= 2; } if (a < 0 || b < 0) brea... |
#include <bits/stdc++.h> using namespace std; int arr[1000005]; int main() { int n, q, a, b, x = 0, xPar = 0; scanf( %d %d , &n, &q); while (q--) { scanf( %d , &a); if (a == 1) { scanf( %d , &b); x += b; if (x >= n) { x = x % n; } else if (x < 0) {... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; struct query { long long k, pos, ind; }; struct fenwick { long long n; vector<long long> f; fenwick(long long _n) { n = _n; f.resize(n, 0); } void add(long long val, long long i) { for (; i < n;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string x, y; cin >> x >> y; int n, m; n = x.size(), m = y.size(); if (n != m) { cout << NO ; return 0; } if (n == 1) { if (x == y) cout... |
#include <bits/stdc++.h> using namespace std; int dp[2][316 + 1][316 + 2]; int addmod(int x, int y) { int sum = x + y; if (sum >= 1000000007) sum -= 1000000007; return sum; } int mulmod(int x, int y, int p) { long long prod = x; prod = (prod * y) % p; return (int)prod; } void add_t... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> data(n + 1); int ans = 1e9; for (int i = 1; i <= n; i++) { cin >> data[i]; ans = min(ans, data[i] / max(i - 1, n - i)); } cout << ans << endl; } int main() { cin.sync_with_stdio(... |
#include <bits/stdc++.h> int n, k, m, t, l; int a, b; int main() { scanf( %d %d %d %d , &n, &k, &m, &t); l = n; for (int i = 1; i <= t; i++) { scanf( %d %d , &a, &b); if (a == 1) { if (b <= k) l++, k++; else l++; } else { if (b < k) ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int Graph[1025][1025], f[1025][1025]; int Tj(int x) { int tot = 0; while (x) tot++, x -= x & (-x); return tot; } void read(int &x) { x = 0; char c = getchar(); int f = 1; while (c < 0 || c > 9 ) { if (c == - ) f... |
#include <bits/stdc++.h> using namespace std; int gl, gr, bl, br; bool check(int g, int b) { if (g - 1 <= b && b <= 2 * (g + 1)) return true; else return false; } int main() { scanf( %d %d %d %d , &gl, &gr, &bl, &br); if (check(gl, br) || check(gr, bl)) cout << YES << endl;... |
#include <bits/stdc++.h> using namespace std; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; const int inf = 0x7f7f7f7f; const int mod = 1000000007; const double eps = 1e-8; int n, m; set<int> v; vector<pair<int, int> > ans; vector<int> vc[100007]; bool isok(int u, int v) { for (size_t ... |
#include <bits/stdc++.h> using namespace std; int main() { long long b, c, d, e, f, g, h, i, j = 0, k = 2, l, o = 0, m = 0, n = 0, q = 1, r = 1, s, t, u, v, x = 1, y = 1, z = 1111111; string a; cin >> a; b = a.size(); fo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<vector<int> > pre; vector<int> starts; vector<int> coproc; vector<int> cnts; vector<int> nexts; void dfs(int v, int co) { for (int p : pre[v]) { cnts[p]--; if (cnts[p] == 0) { if (coproc[p] == co) { ... |
#include <bits/stdc++.h> using namespace std; vector<long long> z_function(string s) { long long n = (long long)s.length(); vector<long long> z(n); for (long long i = 1, l = 0, r = 0; i < n; ++i) { if (i <= r) z[i] = min(r - i + 1, z[i - l]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; vector<char> used; vector<long long> distArr, fArr, sArr; long long A, B, diameter; long long answer = 0; struct step { int a, b, d; friend ostream& operator<<(ostream& s, const step& v); }; ostream& operator<<(ostream& s, c... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; long long a, b, f, k; int cnt() { int c = 0; int n = v.size(); long long now = 0; for (int i = 0; i < n; i++) { if (now + b < v[i]) return -1; while (i < n && now + b >= v[i]) i++; i--; c++; now = v[... |
#include <bits/stdc++.h> using namespace std; int dp[2][1005][55][55], a[1005], b[1005]; int mx(int x) { return max(0, x); }; int main() { int n, p, k; scanf( %d %d %d , &n, &p, &k); if (p > 2 * (n + k - 1) / k) { p = 2 * (n + k - 1) / k; } int z1; scanf( %d , &z1); for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long q; cin >> q; while (q--) { long long l1, r1, l2, r2; cin >> l1 >> r1 >> l2 >> r2; if (l1 == l2) { cout << l1 << << r2 << n ; continue; } if (l1 == r2)... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 9; int n, m, a, b, k; char s[100005]; long long ans, q; inline long long f(char a) { return a == - ? -1 : 1; } inline long long fpow(long long a, long long b) { long long r = 1; for (; b; b >>= 1, a = (a * a) % M) if (... |
#include <bits/stdc++.h> int n, a[105], ans; int comp(const void* elem1, const void* elem2) { int f = *((int*)elem1); int s = *((int*)elem2); if (f > s) return 1; if (f < s) return -1; return 0; } int main(int argc, char* argv[]) { scanf( %d , &n); int i; for (i = 0; i < n; ++i) ... |
#include <bits/stdc++.h> const int maxn = 100100; const int bl = 512; static const int N = 600; int n, k, q; int s[maxn]; struct block { int pop[N], c0; int push[N], c1; int ok; } o[maxn / bl + 10]; inline int eql(const int *a, const int *b, const int len) { for (int i = 0; i < len; ++i)... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; int main() { int n, k; cin >> n >> k; set<char> st; string s; cin >> s; for (int i = 0; i < n; ++i) st.insert(s[i]); int res = 0; char lastc = 0; int i; for (i = 0; i < k && !st.empty(); ++i) { au... |
#include <bits/stdc++.h> const int N = 1000001; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<pair<int, int>> a[n + 1]; int ans = 0; for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; ... |
#include <bits/stdc++.h> using namespace std; int n, m; struct column { int a[13]; int x; }; column c[2001]; bool cmp(column p, column q) { return p.x > q.x; } int s[13][4096], f[13][4096]; int mian() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << { << p.first << , << p.second << } ; return os; } co... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INF = 1 << 30; const long long LINF = 1ll << 60; const int BUFFER_SZ = 1 << 15; const int MOD = 1000 * 1000 * 1000 + 7; char BUFFER[BUFFER_SZ]; int gi() { int x; scanf( %d , &x); return x; } double gd() { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using P = pair<ll, ll>; const int INF = 1001001001; const ll mod = 998244353; const ll INFL = 1000000001000000000; int M = 100005; int main() { int n, q; cin >> n >> q; vector<ll> v(n); for (int i = 0; i < (n); i++) ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; else if (b == 0) return a; else { a = a % b; return gcd(b, a); } } int main() { int n; int sum = 0, odd = 0; scanf( %d , &n); int t; for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; char arr1[n][m]; char arr2[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char a; cin >> a; arr1[i][j] = a; arr2[j][i] = a; } } string ans =... |
#include <bits/stdc++.h> static const int INF = std::numeric_limits<int>::max(); int main() { int n; std::cin >> n; std::vector<int> a(n + 1), b(n + 1); for (int i = 1; i <= n; ++i) { std::cin >> a[i]; } for (int i = 1; i <= n; ++i) { std::cin >> b[i]; } std::vector<int> ... |
#include <bits/stdc++.h> using namespace std; int n, m; char c[109][109]; bool ja = 1; bool useless = 1; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> c[i][j]; if (c[i][j] == . ) { if (i % 2 == 0 && j % 2 == 0 || i % 2... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e2 + 10; int main() { mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i, in, last, ans = 0, prelast = -1; cin >> n; cin >> las... |
#include <bits/stdc++.h> using namespace std; const long long e = 1e5 + 110; bool zs[e]; long long num[e]; void sai() { for (long long i = 2; i <= e - 99; i++) { if (zs[i]) continue; for (long long j = i + i; j <= e - 99; j += i) { zs[j] = true; } } for (long long tot = 0... |
#include <bits/stdc++.h> using namespace std; stack<int> s; priority_queue<int> pq; long long maxm = numeric_limits<long long>::max(); const int maxn = 10005; struct node { int l, r; } q[1001]; bool cmp(node a, node b) { return a.l < b.l; } int main() { int n, sum = 0; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; bool b[4][n][n]; for (int i = 0; i < 4; i++) { for (int j = 0; j < n; j++) { char c[n + 1]; scanf( %s , &c); for (int k = 0; k < n; k++) b[i][j][k] = c[k] == 1 ? 1 : 0; } } int s... |
#include <bits/stdc++.h> using namespace std; int N, M; int A[50050], X[50500]; int L[50050], R[50500]; int XX[1010101]; int ma[50505]; int ret[50505]; signed long long xorxor(signed long long val) { int i; signed long long ret = ((val + 1) / 2) % 2; for (i = 0; i <= 29; i++) if ((val ... |
#include <bits/stdc++.h> using namespace std; int n; string a; int f[1005][5]; int main() { cin >> n >> a; string t = , s = ; char cur = 0 ; for (int i = 0; i <= n - 1; i++) { t += cur; s += 1 - cur + 0 ; cur = 1 - cur + 0 ; } int ans = (int)2e9; int re... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; string s; int MOD = 1e9 + 7; const int INF = 1e9; const long long INF64 = 2e18; const double PI = 3.141592653589793238463; long long ar[1000004], ar1[1000004], vis[1000004], pre[1000004], dp[3004][3004]; vector<long long> gr[1000004], pa... |
#include <bits/stdc++.h> using namespace std; const int N = 7005; const int M = 200000; struct state { int l, r, val; state() {} state(int l, int r, int val) { this->l = l; this->r = r; this->val = val; } }; int n, m, dl[M], dr[M]; vector<state> v[N]; int solve(int d, i... |
#include <bits/stdc++.h> using namespace std; long long modpow(long long base, long long exp, long long modulus) { base %= modulus; long long result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return resul... |
#include <bits/stdc++.h> const long long inf = 0x3f3f3f3f; using namespace std; const long long maxn = 2e5 + 100; long long n, k; long long a[maxn]; int32_t main() { long long q; scanf( %lld , &(q)); while (q--) { scanf( %lld%lld , &(n), &(k)); long long maxx = 0, minn = 0x3f3f3f3f; ... |
#include <bits/stdc++.h> using namespace std; 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 ) { x = x * 10 + c - 0 ; c = getchar(); } return x * f; } co... |
#include <bits/stdc++.h> int max(int a, int b) { return a < b ? b : a; } int min(int a, int b) { return a < b ? a : b; } void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; } int can(int x, int y, int a, int b) { if ((x <= a && y <= b) || (x <= b && y <= a)) return 1; return 0; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 300000; int x[N][2]; int ans[N]; bool hear[N]; vector<pair<int, int> > G[N]; int color[N]; void dfs1(int s) { color[s] = 1; for (int i = 0; i < (int)G[s].size(); i++) { int v = G[s][i].first; if (color[v] == 0) { if ... |
#include <bits/stdc++.h> using namespace std; const int bits = 10; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<string, int> > commands; for (int i = 0; i < n; ++i) { string tp; int x; cin >> tp >> x; commands.emplace_ba... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<pair<int, int>> times; for (int i = 0; i < m; i++) { int s, e; cin >> s >> e; times.push_back(make_pair(s, e)); } sort(times.begin(), times.end(), [](pair<int, int> a, pair<int, int> ... |
#include <bits/stdc++.h> using namespace std; vector<long long> adj[100001]; long long vis[100001] = {0}; long long n; long long nodecolor[100001]; long long treecolor[100001]; long long cc[100001]; map<long long, long long> colorcnt; long long dfs(long long root, long long col) { long long cnt = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; long long dp[N], f[N], ok[N], p[N]; vector<long long> node[N]; long long cur, now; void dfs(long long u, long long p) { for (auto j : node[u]) { if (j == p) continue; dfs(j, u); if (f[j]) { dp[u] += dp[j] + 1;... |
#include <bits/stdc++.h> using namespace std; long long Set(long long N, int pos) { return N = N | (1LL << pos); } long long reset(long long N, int pos) { return N = N & ~(1LL << pos); } bool check(long long N, int pos) { return (bool)(N & (1LL << pos)); } struct node { bool endmark; node *next[2]; ... |
#include <bits/stdc++.h> using namespace std; string to_string(string c) { return string(c); } string to_string(char ch) { return string(1, ch); } template <size_t N> string to_string(bitset<N> B) { string second = ; for (long long i = 0; i < (long long)N; i++) second += (char) 0 + B[i]; return... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; char s[maxn], t[maxn], st[maxn]; long long cnts[maxn], cntt[maxn]; long long Next[maxn]; int n, m; long long ans; long long lent, lens; long long f, e; void init() { ans = 0; lent = lens = 0; s[0] = t[0] = 0; ch... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, a[N], b[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + 1 + n); for (int i = 1; i <= n / 2; i++) { b[i * 2 - 1] = a[i]; b[i * 2] = a[n - i + 1]; } if (n... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> q[9]; char s[2]; int main() { long long n, x0, y0; scanf( %lld , &n); scanf( %lld%lld , &x0, &y0); for (long long m = 0; m < 9; m++) q[m] = make_pair(1E10, INT_MAX); while (n--) { long long x, y, i, j, k, g, m, d;... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n, k; cin >> n >> k; vector<long long> a(n); for (auto& i : a) cin >> i; while (a.back() <= k) a.pop_back(); reverse(a.begin(), a.end()); while (a.back() <= k) a.pop_back(); cout << n - a.size() << n ; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 30; signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); string s; cin >> s; int n = s.size(); int pref = 0, suf = n - 1; while (pref < n - 1 && s[pref] != s[pref + 1]) pref++; while (suf > 0 && s[su... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000007; const long long INF = 1e18; int mod = 998244353; template <typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline... |
#include <bits/stdc++.h> using namespace std; int len = 0, coun = 0; bool visited[1000006]; vector<int> check; vector<int> grid[1000006]; void dfs(int v) { visited[v] = true; for (int i = 0; i < grid[v].size(); i++) { if (!visited[grid[v][i]]) { dfs(grid[v][i]); } } check... |
#include <bits/stdc++.h> using namespace std; int n, x, y; vector<vector<int> > adjList(100009, vector<int>()); bool vis[100009]; vector<int> ans; bool check_valid_edges(vector<vector<int> > &a, int n) { for (size_t i = 1; i <= n; i++) if (a[i].size() != 4) return false; return true; } int... |
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y = 0; cin >> x >> y; int z = abs(x) + abs(y); if ((x > 0) && (y > 0)) cout << 0 << << z << << z << << 0; else if ((x < 0) && (y > 0)) cout << -z << << 0 << << 0 << << z; else if ((x > 0... |
#include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; using ll = long long int; using vi = vector<int>; using graph = vector<vi>; const int INF = 0x3f3f3f3f; const ll INFL = 0x3f3f3f3f3f3f3f3f; const int MAXN = 200005; int fq[4]; int main() { int n, m, k; string s; cin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.