func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s1; cin >> s1; for (int i = 0; i < s1.size() - 1; i++) { while ((s1[i] == a || s1[i] == o || s1[i] == y || s1[i] == e || s1[i] == u || s1[i] == i ) && (s1[i + 1] == a ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 3; int n, l; double ans, a[N]; int main() { scanf( %d %d , &n, &l); for (int i = 0; i < n; ++i) scanf( %lf , a + i); sort(a, a + n); if (a[0] != 0) ans = a[0]; if (a[n - 1] != l) ans = max(ans, l - a[n - 1]); for (int i ... |
#include <bits/stdc++.h> using namespace std; int CC; long long f[109]; int v[109]; long long d0[109], d1[109]; int main() { f[1] = 1; f[2] = 2; CC = 2; while (f[CC - 1] + f[CC] < 1000 * 1000 * 1000LL * 1000LL * 1000 * 1000) { f[CC + 1] = f[CC] + f[CC - 1]; CC++; } int T;... |
#include <bits/stdc++.h> int main() { char str[100], i, a; scanf( %s , str); a = strlen(str); if (a % 2 == 0) { printf( %c , str[(a - 1) / 2]); for (i = 1; i < ((a - 1) / 2) + 1; i++) { printf( %c , str[((a - 1) / 2) + i]); printf( %c , str[((a - 1) / 2) - i]); } ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-14; int a[MAXN]; void solve() { int n; cin >> n; for (int i = 1; i <= 9; i++) { cin >> a[i]; } int mn = a[1], ciph = 1; for (int i = 2; ... |
#include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; double vmax, t0, vx, vy, wx, wy; cin >> vmax >> t0 >> vx >> vy >> wx >> wy; double dx = (x2 - x1); double dy = (y2 - y1); double l = 0, r = 1e16; double ans = 1e16; for ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 10, MOD = 1e9 + 7; int n, x[MAX_N], y[MAX_N], ordered_x[MAX_N], ordered_y[MAX_N], x_n, y_n, ans = 1; int fa[MAX_N * 2], node_cnt[MAX_N * 2], edge_cnt[MAX_N * 2]; void init() { scanf( %d , &n); for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000001; template <class T, class U> ostream &operator<<(ostream &out, const pair<T, U> &p) { return out << p.first << << p.second; } template <class T> ostream &operator<<(ostream &out, const vector<T> &v) { for (typeof((v).begi... |
#include <bits/stdc++.h> using namespace std; int n, m; const int MAXN = 1e6 + 10; pair<int, pair<int, int> > A[MAXN]; int HX[MAXN], HY[MAXN]; int fa[MAXN]; int X[MAXN], Y[MAXN]; int ans[MAXN]; int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); } void uni(int x, int y) { int fx = Fin... |
#include <bits/stdc++.h> using namespace std; int n, i; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (i = 2; i <= n; i++) cout << i << ; cout << 1 << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int p2[203]; int p5[203]; int dpcur[203][5003][2]; int dpnxt[203][5003][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { long long int x; cin... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; const long long mod = 998244353; long long binpow(long long a, long long n) { if (n == 0) return 1; if (n % 2 == 1) { return (binpow(a, n - 1) * a) % mod; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, a[1000001], mx[1000001], cnt, maxi, ans; int main() { cin >> n; for (long long i = 1; i <= n; ++i) { cin >> a[i]; mx[i] = -1; for (long long j = 1; j <= a[i]; ++j) { long long k; cin >> k; mx[i] = max(m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long int n, i, x; cin >> n; long long int a[2 * n]; for (i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); x = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[... |
#include <bits/stdc++.h> using namespace std; char a[300099]; char ans[300099]; int c[200000]; int b; int main() { while (~scanf( %s , a)) { memset(c, 0, sizeof(c)); scanf( %d , &b); int len = strlen(a); for (int i = 0; i < b; i++) { int pt; scanf( %d , &pt); ... |
#include <bits/stdc++.h> const int P = 998244353; using namespace std; template <typename T> inline void ckmax(T &a, T b) { (a < b) && (a = b); } template <typename T> inline void ckmin(T &a, T b) { (a > b) && (a = b); } inline int mul(int a, int b) { return 1ll * a * b % P; } inline int add... |
#include <bits/stdc++.h> long long int a, b; int main() { scanf( %lld %lld , &a, &b); if (a % 2 == 0) { if (2 * b - 1 < a) { printf( %lld , 2 * b - 1); } else { printf( %lld , (b - a / 2) * 2); } } else { if (2 * b - 1 <= a) { printf( %lld , 2 * b - 1); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300100; int n, m, a[maxn], ans = -1; int f[maxn][30], du[maxn], Time; char s[maxn]; int dfn[maxn], low[maxn]; vector<int> g[maxn]; vector<int>::iterator it; bool loop = 0, in[maxn]; stack<int> q; void dfs(int x) { dfn[x] = low[x] =... |
#include <bits/stdc++.h> using namespace std; int n, m, cnt, ans[200009], sum[200009], dp[200009][26], s1[200009], s2[200009], f[200009]; char a[200009], b[200009]; void solve(int u, int v) { int i; for (i = 1; i <= n; i++) s1[i] = (a[i] == a + u); for (i = 1; i <= m; i++) { s2[i] = (b... |
#include <bits/stdc++.h> using namespace std; long long int P; long long int a[501]; long long int dp[501][501]; void solve() { long long int n, m, b, P, i, j, k; cin >> n >> m >> b >> P; for (i = 1; i <= n; i++) { cin >> a[i]; } memset(dp, 0, sizeof(dp)); long long int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxp = 22; const long double EPS = 1e-18; const long long INF = 2e18; const int MOD = 1e9 + 7; const int N = 2e5 + 1; string s, t = hard ; long long dp[N][4]; long long arr[N]; int n; long long solve(int x, int idx) { if (idx == 4) retur... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; int mod = 1e9 + 7; int qpow(int a, int b) { int ans = 1; for (; b >= 1; b >>= 1, a = (long long)a * a % mod) if (b & 1) ans = (long long)ans * a % mod; return ans; } long long ans[32]; int main() { int t; scanf... |
#include <bits/stdc++.h> using namespace std; int main() { long long r, g, b; cin >> r >> g >> b; long long ans = min(r, min(g, b)); long long mini = ans; if (r <= 3 && g <= 3 && b <= 3) { cout << ans << endl; return 0; } long long count = 0; r = r - ans; g = g - ans;... |
#include <bits/stdc++.h> using namespace std; int const M = 4e5 + 20; int a[M], ans[M], l[M], r[M], ty[M], cnt[M], sv[M]; vector<pair<int, int> > qu[M]; int main() { int n, q; cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= q; i++) { int ind, nu; cin >... |
#include <bits/stdc++.h> using namespace std; int v[4005], d[14005]; long long int p[4005]; bool done[4005]; vector<int> vec; int main() { int n, val, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> v[i] >> d[i] >> p[i]; } for (int i = 0; i < n; i++) { if (done[i]) co... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; int total = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s == ++X || s == X++ ) { total++; } else { total--; } } cout << total; } |
#include <bits/stdc++.h> using namespace std; long long cnt[200010]; void f(long long x) { while (x) { cnt[x]++; x /= 2; } cnt[0]++; } long long count(long long x, long long y) { long long sol = INT32_MAX, cnt = 0; while (x != y) { if (!x) break; ++cnt; x /= 2... |
#include <bits/stdc++.h> using namespace std; struct comp { bool operator()(const vector<int>& lhs, const vector<int>& rhs) const { return lhs.size() > rhs.size(); } }; struct comps { bool operator()(const string& lhs, const string& rhs) const { return lhs > rhs; } }; bool ff(pai... |
#include <bits/stdc++.h> using namespace std; vector<int> edge[20]; int n, t; string a, b; bitset<20> used; void DFS(int h) { used[h] = true; for (auto &i : edge[h]) if (!used[i]) DFS(i); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; ... |
#include<bits/stdc++.h> #define rep(i,st,en) for(int i=st;i<=en;i++) using namespace std; typedef long long ll; int t,x,y,i,n; int main() { scanf( %d ,&t); while(t--) { scanf( %d ,&n); rep(i,1,n)scanf( %d ,&x); printf( %d n ,3*n); rep(i,1,n/2) { x=2*i-1; y=2*i; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int n, sz; vector<int> vec[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; cout << n - 1 << n ; for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--, b--; vec... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<char> a; char x; for (int i = 0; i < n; i++) { cin >> x; a.push_back(x); } for (int i = 0; i < a.size(); i++) { if (a[i] == U && a[i + 1] == R ) { a.erase(a.begin() + i); ... |
#include <bits/stdc++.h> using namespace std; long long p[1100000], r[1100000], cnt; int main() { long long n, bac; cin >> n; if (n == 1) { printf( 1 n ); return 0; } bac = n; long long i; for (i = 2; i * i <= n; i++) { if (bac % i == 0) { cnt++; p[cnt... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; const int LOGN = 15; struct TreeGraph { vector<int> *graph; vector<int> heights; vector<int> *d; vector<int> weights; vector<int> mapNodes; int n, nAritculationPoints; ; TreeGraph(){}; TreeGraph(int nArtiPoin... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> r(7, 0); string den; for (int i = 0; i < n; i++) { cin >> den; for (int j = 0; den[j] != 0 ; j++) { r[j] += den[j] == 1 ; } } int m = 0; for (int i = 0; i < 7; ... |
#include <bits/stdc++.h> using namespace std; static const int len = 1000010; struct event { int t, x, y, tip, num; event() {} event(int _t, int _x, int _y, int _tip, int _num) : t(_t), x(_x), y(_y), tip(_tip), num(_num) {} }; bool compar(event one, event two) { return ((one.x < two.x)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, res = 0, j, mid, a[6] = {}, b[6] = {}; cin >> n; for (i = 0; i < n; i++) { cin >> j; a[j]++; } for (i = 0; i < n; i++) { cin >> j; b[j]++; } for (i = 1; i < 6; i++) { mid = a[i] + b[i]; ... |
#include <bits/stdc++.h> using namespace std; const int INFint = 2147483647; const long long INF = 9223372036854775807ll; const long long MOD = 1000000007ll; const long double EPS = 1e-9; int p[1000]; int a[1000]; int b[1000]; int cnt; void dfs(int v) { p[v] = 1; for (int i = 1; i <= cnt; i+... |
#include <bits/stdc++.h> using namespace std; double dp[100002]; int main() { double res = 0, prob = 0; int n; cin >> n; dp[0] = 0; for (int i = 0; i < n; i++) { double p; cin >> p; dp[i] = dp[i - 1] * p; res = res + p + dp[i] * 2.0; dp[i] += p; } printf( ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n), b(n), c(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; int ans = INT_MAX; sort(a.begin(), a.end()); sort(b.begin(), b.end()); for (int i = ... |
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; using namespace std; const double eps = 1e-6; const long long mod = 1e9 + 7; const int maxn = 1e5 + 100; const int maxe = 1e6 + 100; struct node { int to; int next; }; bool dp[maxn][2], cir; v... |
#include <bits/stdc++.h> using namespace std; using db = long double; using pll = pair<long long, long long>; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t, i, x, j, y, z, k, n; long long tt; cin >> tt; for (long long _tt = 0; _tt < tt; _tt++) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16000000 ) using namespace std; const int inf = 0x3f3f3f3f; const long long inf2 = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; namespace fastio { char in[100000]; int itr = 0, llen = 0; char get() { if (itr == ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3fLL; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 ... |
#include <bits/stdc++.h> using namespace std; long long dp[5050][505]; pair<long long, long long> pre[5050][505]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long d, s; cin >> d >> s; queue<pair<long long, long long>> q; for (long long i = 1;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; struct Modify { bool add; int a, b; }; int n, m, t; vector<int> x[MAXN]; map<int, int> h; vector<int> s; vector<Modify> ans; int losestate[1 << 20]; int winstate[1 << 20]; void BuildBase() { int out[MAXN]; vecto... |
#include <bits/stdc++.h> using namespace std; template <int MOD, int RT> struct Mint { static const int mod = MOD; static constexpr Mint rt() { return RT; } int v; explicit operator int() const { return v; } Mint() { v = 0; } Mint(long long _v) { v = int((-MOD < _v && _v < MOD) ? _v ... |
#include <bits/stdc++.h> using namespace std; int n, a, am, duong, zero; unsigned long long t; int main() { scanf( %d n , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a); if (a < 0) am++; else if (a > 0) duong++; else zero++; t += abs(abs(a) - 1)... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0, a; for (int i = 0; i < n; i++) { cin >> a; sum += a; } int m; cin >> m; vector<char> good(1e5 + 1, false); int l, r; for (int i = 0; i < m; i++) { cin >> l >> r; f... |
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int i, flag = 0; for (i = 1; i < a.size(); i++) { if (a[i] == 1 ) { flag = 1; break; } } i = (a.size()) / 2; if (flag == 1 && a.size() % 2 == 1) i++; cout << i; } |
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x < 0 ? -x : x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int MAXN = 8009; const int MAXX = (int)1e+6 + 7; ... |
#include <bits/stdc++.h> int n; int sum = 0; int a[16]; int mat[4][4]; int rows[4], cols[4]; int gotx[4], goty[4], gotd[2]; int x[16], y[16]; int diag[2]; bool dfs(int state, int mask) { for (int i = 0; i < 2; i++) { if (gotd[i] == n && diag[i] != sum) { return false; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int c = 0; for (int i = 0; i < n; i++) { if (i == 0 && a[0] > 0) { c++; } if (i > 0 && a[i] != 0 && a[i] ... |
#include <bits/stdc++.h> using namespace std; int main() { long l; cin >> l; int div = 0; for (int i = 5; i < 1 + pow(l, 0.5); i++) { if (l % i == 0) { div = i; break; } } if (div == 0 || (l / div) < 5) { cout << -1 << endl; } else { char a[div][in... |
#include <bits/stdc++.h> using namespace std; int arr[98]; int main() { string s; vector<long long> v(4); for (int i = 0; i < 4; i++) cin >> v[i]; sort(v.begin(), v.end()); char c1, c2, c3; cin >> c1 >> c2 >> c3; if (c1 == * && c2 == * && c3 == * ) cout << v[0] * v[1] * v[2]... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> a(n), b(n); for (long long i = 0; i < n; ++i) cin >> a[i]; for (long long i = 0; i < n; ++i) cin >> b[i]; map<long long, vector<long long> > mp; long long m; cin >> m; for (long lo... |
#include <bits/stdc++.h> using namespace std; int t, n, doc[100010], doc1[100010], p[100010]; vector<vector<int> > g; vector<pair<int, pair<int, int> > > q; vector<int> tin, tout; int par(int u) { if (p[u] == u) return u; return p[u] = par(p[u]); } void dfs(int u) { tin[u] = t; for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int counter = 0, a, b, t; cin >> a >> b; while (true) { if (b > a) { t = a; a = b; b = t; } counter = counter + (a / b); a = (a % b); if (a == 0) break; } cout << c... |
#include <bits/stdc++.h> using namespace std; const int N = 1000; int ans[N], l[N], r[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> l[i]; } for (int i = 0; i < n; ++i) { cin >> r[i]; } fo... |
#include <bits/stdc++.h> using namespace std; bool boy[1000], girl[1000]; int n, m, b, g, x, y, q[1000][2], h, t; int main() { memset(boy, false, sizeof(boy)); scanf( %d%d%d , &n, &m, &b); for (int i = 1; i <= b; i++) { scanf( %d , &x); boy[x] = true; } memset(girl, false, sizeof... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[1000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (!(a[i] & 1)) --a[i]; } for (int i = 0; i < n; i++) { cout << a[i] << ; } cout << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int n; string a; constexpr char t[4] = { A , C , T , G }; int best = INT_MAX; int main() { cin >> n; cin >> a; for (int i = 0; i < n - 3; ++i) { int cur = 0; for (int j = 0; j < 4; ++j) { int temp = min(abs(t[j] - a[i + j]), ab... |
#include <bits/stdc++.h> using namespace std; template <typename T> void prn(T first) { cout << first << n ; } int main() { int a[4]; cin >> a[0] >> a[1] >> a[2] >> a[3]; sort(a, a + 4); if (a[0] + a[3] == a[1] + a[2] || a[3] == a[0] + a[1] + a[2]) { cout << YES ; } else { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, h, v[1100]; multiset<long long> s; cin >> n >> h; for (int i = 0; i < n; i++) cin >> v[i]; long long k, ht; for (int i = 0; i < n; i++) { s.insert(v[i]); k = 0; ht = 0; for (multiset<long long>::r... |
#include <bits/stdc++.h> using namespace std; string s; pair<int, int> st[3000002]; void build(int v, int l, int r) { if (l == r) { st[v] = make_pair(s[l] == ( , s[l] == ) ); return; } int lv, rv, mid; lv = 2 * v; rv = 2 * v + 1; mid = (l + r) / 2; build(lv, l, mid); ... |
#include <bits/stdc++.h> using namespace std; long double k, d, t, g, c, p, ilec, ilep, cp, zos; long long dzielup(long long x, long long y) { if (x % y == 0) return x / y; return x / y + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> k >> d >> t;... |
#include <iostream> using namespace std; const int MOD = 1e9+7, N = 1e5+5; long long inv(long long a) { long long b = 1; int k = MOD-2; while(k) { if(k%2) b = b * a % MOD; a = a * a % MOD; k /= 2; } return b; } long long fact[N], ifact[N]; ... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <class T> ostream& prnt(ostream& out, T v) { out << v.size() << n ; for (auto e : v) out << e << ; return out; } template <class T> ostream& operator<<(ostream& out, vector<T> v) { return prnt(ou... |
#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)); } inline int addmod(int x, int y) { return (x % 1000000007 + y % 1000000007) % 10000000... |
#include <bits/stdc++.h> using namespace std; int t, zero, cur; long long ans; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> s; ans = zero = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 0 )... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; string sign[n]; long long x[n]; char ans[n]; long long low = -2e9, up = 2e9; for (int i = 0; i < n; i++) { cin >> sign[i] >> x[i] >> ans[i]; if (sign[i] == >= ) ... |
#include <bits/stdc++.h> using namespace std; int n, m, l, r; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { scanf( %d%d , &l, &r); } for (int i = 0; i < n; i++) { if (i & 1) printf( 0 ); else printf( 1 ); } puts( ); } |
#include <bits/stdc++.h> using namespace std; int fir[200010], to[200010 << 1], nxt[200010 << 1], cnt; long long f[200010], fac[200010]; void add(int u, int v) { nxt[++cnt] = fir[u]; fir[u] = cnt; to[cnt] = v; } void dfs(int x, int fa) { f[x] = 1; int i, s = (x != 1); for (i = fir[x]... |
#include <bits/stdc++.h> using namespace std; int main() { int a[1000]; int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int res = 0; int sum = 10; int ress = 0; for (int i = 0; i < n; i++) { sum += a[i]; if (sum <= 720) { res++; ... |
#include <bits/stdc++.h> using namespace std; const int M = (119 << 23) + 1; int add(int a, int b) { return (a += b) < M ? a : a - M; } int sub(int a, int b) { return (a -= b) < 0 ? a + M : a; } int mul(int a, int b) { return 1LL * a * b % M; } int mod_pow(int a, int b) { int res = 1; while (b) { ... |
#include <bits/stdc++.h> using namespace std; inline long long read(void) { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } ... |
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::string name; std::cin >> name; bool atFlag = false; std::string result = ; result += name[0]; for (int i = 1; i < name.length(); i++) { if (!atFlag && name.substr(i, 2) == at ) { result += @ ; ... |
#include <bits/stdc++.h> using namespace std; int n, mm, s, it; int a[200005], r[200005], so[200005], ne[200005]; bool u[200005]; string ss, na[200005]; vector<int> v[200005]; queue<int> q; map<string, int> m; inline string sb(string v) { for (int i = 0; i < v.size(); i++) if (v[i] < a ) v[... |
#include <bits/stdc++.h> using namespace std; const int maxN(1e3 + 10); int N, M, P[maxN], A[maxN][maxN], C; void dfs(const int u) { C++; for (int v = 1; v <= N; v++) if (A[u][v] && !P[v]) { P[v] = u; dfs(v); } } int main() { cin >> N >> M; if (M != N - 1) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long a, x, y; cin >> a >> x >> y; if (y % a == 0) cout << -1; else { long long ratio = (long long)(y / a); if (ratio > 0) { if (((long long)(y / a)) ... |
#include <bits/stdc++.h> using namespace std; int tmp; string s; char a[3][10] = {{ q , w , e , r , t , y , u , i , o , p }, { a , s , d , f , g , h , j , k , l , ; }, { z , x , c , v , b , n , m , , , . , / }}; char Tinh(char c) { for (int ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e4 + 100; int n, k; struct node { int sz; int mn[15], mx[15]; void init(int a) { sz = 0; for (int i = 1; i <= k; i++) { mx[i] = mn[i] = a; } } void unit(node a) { sz += a.sz; for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { int n; cin >> n; int a[n], f[1005] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; f[a[i]]++; } ... |
#include <bits/stdc++.h> const int S = 200003; int n, m, h[S], nx[S], v[S], eg = 1, s[S], e[S], _ = 0, t[S], fa[S], dep[S], f[S], rk[S], root, a[S]; inline void egadd(int uu, int vv) { nx[++eg] = h[uu]; h[uu] = eg; v[eg] = vv; } void dfs_1(int x) { s[x] = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, k; string s; pair<int, int> fff(const string &s, char x) { pair<int, int> res; int cc = 0; for (int i = 0; i < s.length(); i++) if (s[i] == x) cc++; if (cc >= k) { res.first = 0; res.second = 0; return res; } in... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using v = vector<T>; const ll K = 1000; const ll N = 1e5; const ll B = N / K + 1; ll n; ll arr[N + 1]; ll cnt[N + 1]; ll bin[B + 1]; ll greedy(ll k) { fill(begin(cnt), end(cnt), 0); v<ll> dif; l... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const long long mod = 1e9 + 7; const int inf = 1 << 30; const int maxn = 600500; const double EPS = 1e-7; void solve() { int q; scanf( %d , &q); while (q--) { long long n; scanf( %lld , &n); int a, b; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print_array(T arr[], int size_arr) { for (int i = (0); i < (size_arr); i++) { cout << arr[i]; if (i == size_arr - 1) cout << endl; else cout << ; } } template <typename T> void print_vector(... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const double EPS = 1e-8; const double PI = 2 * acos(0); const int MAXN = 2006; struct Node { int x, y; bool operator<(Node b) const { if (x != b.x) return x < b.x; return y < b.y; } }; struct Math { int... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x = 0, y = 0, z = 0; int ar[4]; for (int i = 0; i < 4; i++) { cin >> ar[i]; } x = ar[1]; y = ar[2]; z = ar[2]; cout << x << << y << << z << endl; ... |
#include <bits/stdc++.h> const int N = (int)3e5 + 2; int n; bool a[N << 1]; int ans, ansl, ansr; inline long long read() { long long x = 0; char ch = getchar(); for (; ch > 9 || ch < 0 ; ch = getchar()) ; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = (x << 1) + (x << 3) + (... |
#include <bits/stdc++.h> using namespace std; template <typename A> ostream &operator<<(ostream &cout, vector<A> const &v); template <typename A, typename B> ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << ( << p.first << , << p.second << ) ; } template <typename A> os... |
#include <bits/stdc++.h> using namespace std; int n, maxim, a; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a; if (a > maxim) maxim = a; } cout << (maxim ^ a); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, b, t; cin >> t; int arr[t]; for (int i = 0; i < t; i++) { cin >> a >> b; arr[i] = a + b; } for (int i = 0; i < t; i++) { cout << arr[i] << endl; } } |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; string a1(b.size(), 0 ); string b1(a.size(), 0 ); a1 = a1 + a; b1 = b1 + b; if (a1 > b1) cout << > << endl; if (a1 == b1) cout << = << endl; if (a1 < b1) cout << < << endl; return 0... |
#include <iostream> #include <vector> using namespace std; const int MAXN = 2e5 + 5; struct Info { int maxPref, maxSuff; Info(){} Info(int x) : maxPref(x), maxSuff(x) {} Info(int maxPref, int maxSuff) { this->maxPref = maxPref; this->maxSuff = maxS... |
#include <bits/stdc++.h> namespace algo { using namespace std; const long double PI = 3.141592653589793238462643383279502884L; const long double E = 2.718281828459045235360287471352662498L; const long double EPS = 1e-12L; template <typename T1, typename T2> T1 bin_pow(T1 a, T2 n) { T1 r = 1; while... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000009; map<pair<int, int>, int> in, id; set<int> S; int X[100010], Y[100010]; bool check(pair<int, int> P) { int x = P.first, y = P.second + 1; for (int dx = x - 1; dx <= x + 1; dx++) { if (in.count(make_pair(dx, y)) && in[make... |
#include<bits/stdc++.h> #include<algorithm> #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<stack> #include<queue> using namespace std; typedef long long ll; const ll INF=0x7f7f7f7f; const int maxn=2e5+7; const ll mod=1e9+7; ll read(){ ll f=0,x=0;char ch=ge... |
#include <bits/stdc++.h> const int N = 1e5 + 5, M = 2e5 + 5, logN = 17 + 1; int n, m, root, idx, a[N], f[N][logN], dfn[N], seq[N], sz[N], dep[N]; int tot, lnk[N], ter[M], nxt[M]; long long seg[N << 2], tag[N << 2]; void pushup(int rt) { seg[rt] = seg[rt << 1] + seg[rt << 1 | 1]; } void build(int rt, int l, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.