func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; inline int in() { int res = 0; char c; int f = 1; while ((c = getchar()) < 0 || c > 9 ) if (c == - ) f = -1; while (c >= 0 && c <= 9 ) res = res * 10 + c - 0 , c = getchar(); return res * f; } const int N = 100010; long long n... |
#include <bits/stdc++.h> using namespace std; long long Cross(int x1, int y1, int x2, int y2) { return 1ll * x1 * y2 - 1ll * x2 * y1; } int main() { int xa, xb, xc, ya, yb, yc; scanf( %d%d%d%d%d%d , &xa, &ya, &xb, &yb, &xc, &yc); long long cross = Cross(xb - xa, yb - ya, xc - xa, yc - ya); i... |
#include <bits/stdc++.h> using namespace std; bool SR(int &_x) { return scanf( %d , &_x) == 1; } bool SR(long long &_x) { return scanf( %lld , &_x) == 1; } bool SR(double &_x) { return scanf( %lf , &_x) == 1; } bool SR(char *_s) { return scanf( %s , _s) == 1; } bool RI() { return true; } template <typenam... |
#include <bits/stdc++.h> using namespace std; vector<int> V; vector<int> E[200005]; int d[200005]; int p[200005]; int find(int x) { while (p[x] != x) p[x] = p[p[x]], x = p[x]; return x; } int rnk[200005]; void meld(int x, int y) { x = find(x), y = find(y); if (rnk[x] > rnk[y]) swap(x, ... |
#include <bits/stdc++.h> using namespace std; inline void R(int &x) { char ch = getchar(); x = 0; for (; ch < 0 ; ch = getchar()) ; for (; ch >= 0 ; ch = getchar()) x = x * 10 + ch - 0 ; } const int N = 100005; double x, y, ans; int n; int main() { scanf( %d , &n); for (in... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a(k); for (int h = 0; h < a.size(); h++) { cin >> a[h]; }; int gg = max_element(a.begin(), a.end()) - a.begin(); for (int i = k - 1; i > gg; i--) { if (a[i] > a[i - 1]) { cou... |
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; cout << max(abs(y2 - y1), abs(x2 - x1)); return 0; } |
#include <bits/stdc++.h> int main() { int n, k, i; double t, z, a, b, d = 0; scanf( %d %d , &n, &k); int x[n], y[n]; for (i = 0; i < n; i++) { scanf( %d %d , &x[i], &y[i]); } for (i = 1; i < n; i++) { a = x[i - 1] - x[i]; b = y[i - 1] - y[i]; a = pow(a, 2); b ... |
#include <bits/stdc++.h> using namespace std; int main(void) { srand(time(0)); cout << fixed << setprecision(7); cerr << fixed << setprecision(7); int n, q; scanf( %d%d , &n, &q); static long long s[1 << 23]; for (int i = 1; i <= n; ++i) scanf( %I64d , &s[i]), s[i + n] = s[i + n + ... |
#include <bits/stdc++.h> using namespace std; int n, h; double p; double memexpected[2001][2001][2][2]; int calculado[2001][2001][2][2]; int ri[2001], le[2001]; int v[2001]; double expected(int i1, int i2, int l1, int l2) { if (i1 > i2) return 0; double &mem = memexpected[i1][i2][l1][l2]; if... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const int inf = 1e9; const int N = 2e5; void solve() { long long int d, m; cin >> d >> m; long long int mx; for (long long int i = 32; i >= 0; i--) { if ((1LL << i) & d) { mx = i; break; ... |
#include <bits/stdc++.h> using namespace std; map<int, int> m; pair<bool, char> check(int a, string s) { int flag = 0; char x = s[a], e; for (long long int i = 1 + (x - a ); i < 26; i++) { if (m.count(i)) { return {true, char(i + a )}; } } return {false, f }; } int m... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int c1 = 0; int c2 = 0; int a[1000]; for (int i = 1;; i++) { if (i % 2 == 0) { a[i] = (i * i) / 2; } else { a[i] = (i / 2) * (i / 2) + ceil(i / 2.0) * ceil(i / 2.0); } if (a[i]... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, L, a; int t[N], l[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL)); cin >> n >> L >> a; int res = 0; for (int i = 1; i <= n; i++) { cin >> t[i] >> l[i]; ... |
#include <bits/stdc++.h> using namespace std; const int kMaxN = 100010; const int kMaxA = 1000000010; int a[kMaxN]; signed main() { cin.tie(0); ios::sync_with_stdio(false); long long n; cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 50; const int INF = 0x3f3f3f3f; void bf(int A, int B) { for (long long a = 1; a <= A; a++) for (long long b = 1; b <= B; b++) { if ((a * b + a + b) == stol(to_string(a) + to_string(b))) co... |
#include <bits/stdc++.h> using namespace std; template <typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using max_pq = priority_queue<T>; const int inf = 2e9 + 5; const long long l_inf = 2e18 + 5; const int mod_v = 1e9 + 7; const int max_n = 1e5 + 5; const ... |
#include <bits/stdc++.h> using namespace std; int m, n, rowStart[1010], rowEnd[1010], colStart[1010], colEnd[1010], sum[1010][1010]; int startX = -1, startY; string a[1010]; void quit() { cout << -1 << endl; exit(0); } int getSum(int x, int y, int row, int col) { return sum[x][y] + sum[x... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename T1> T amax(T a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T a, T1 b) { if (b < a) a = b; return a; } template <typename T> T amod(T a) { if (a < 0) a = -a; return ... |
#include <bits/stdc++.h> using namespace std; int ans[21][21]; int cnt[1100]; int n; vector<int> fang, four; void output() { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { cout << ans[i][j] << ; } cout << endl; } } bool check() { int sum = 0; f... |
#include <bits/stdc++.h> const int mod = 1000000007; const int modx = 998244353; using namespace std; void thunder() { long long n; cin >> n; vector<long long> a(n), b(n); long long i, j; for (i = 0; i < n; i++) cin >> a[i]; map<long long, long long> m; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long sums[30000], dp[25][3000][25], can[3000], n, i, j, k, x, y, a[300]; int main() { cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); for (i = 0; i < n; i++) if (a[i] == 1) { k = i; break... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int mod = 1e9 + 7; int n, a[N]; vector<int> get_divisors(int u) { vector<int> res; for (int i = 1; i * i <= u; ++i) { if (u % i == 0) { res.push_back(i); if (i != u / i) res.push_back(u / i); } }... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long int mod = 1e9 + 7; long int i, j, n, t, m, k; vector<pair<long int, long int> > a, b; set<long int> c; bool cmp(const pair<long int, long int> &l, const pair<long int, long int> &r) { return l.first < r.first; } int m... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 1e5 + 10; const ll LG = log2(N) + 1; struct LCA { vector<vector<ll>> G, parent; vector<ll> tin, tout, depth; ll timer; ll n; ll LG; LCA(vector<vector<ll>> G, ll R... |
#include <bits/stdc++.h> using namespace std; const int N = 154321; int n, m, r, k, row[N], col[N]; long long ans = 0; struct node { int a, b; long long val; bool operator<(const node &rhs) const { return val < rhs.val; } }; priority_queue<node> pq; int main() { cin >> n >> m >> r >> k; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const long long inf = 0x3f3f3f3f3f3f3f3fLL; const long long N = 1e5 + 10; const long long MOD = 1e9 + 7; long long n, m, s; vector<vector<long long>> g(N); bool vis[N][2]; long long par[N][2], mark[N]; void dfs(long long u, long lon... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; int n, t, h, s; char road[500001]; int H[500001], S[500001]; bool time(int k) { vector<pair<int, int> > step; step.push_back(make_pair(-1, -1)); for (int i = 0, j = 0; i < h; i++) { if (k) { k--; step.pu... |
#include <bits/stdc++.h> using namespace std; const int M = 1000500; int n, m; bool vis[M]; int fa[M], deg[M], in[M]; inline int read() { int x = 0; char ch = getchar(); while (ch > 9 || ch < 0 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); ret... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x = 0, y = 0, z = 0, a, b, c; for (int i = 0; i < n; i++) { cin >> a >> b >> c; x += a; y += b; z += c; } if (x == 0 and y == 0 and z == 0) cout << YES << endl; else cout... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int a, b, c, d, i, j, n, m, k, g, s; long long ans; pair<pair<int, int>, pair<int, int> > edges[50001]; vector<int> sm[201]; int cs[201][201]; pair<int, int> cur[201]; bool found; bool used[201]; inline void r... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; scanf( %lld , &t); string s; while (t--) { map<char, long long> mp, mpp; string str, txt; cin >> s; long long cur = 50, flag = 0, mn = 50, mrk = 1, mx = 50, i; for (i = 0; i < s.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; int ans = 0; int l1min = 1e9, l1max = 0, r1min = 1e9, r1max = 0; for (int i = 1; i <= n; i++) { int l, r; cin >> l >> r; l1min = min(l1min, l); l1max = max(l1max, l); r1max = max(r1max, r... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, t; cin >> n >> t; vector<int> a(n); for (int& ai : a) cin >> ai; auto build = [&](int t) { vector<int> ret; while (t--) { ret.insert(end(ret), begin(a), end(a));... |
#include <bits/stdc++.h> using namespace std; int ceil(int a, int b) { return a / b + (a % b ? (a % b > 0 ? 1 : -1) : 0); } int dr(int a, int b) { int t = a % b; return t ? t : b; } int main() { int n, m, c; cin >> n >> m >> c; cout << (long long)ceil(n, c) * ceil(m, c) * dr(n, c) * dr(m, ... |
#include <bits/stdc++.h> using namespace std; template <class T> T gi() { T x = 0; bool f = 0; char c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - ) f = 1, c = getchar(); while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f ? -x... |
#include <bits/stdc++.h> using namespace std; int main() { int r = 0; int m, n, z, a[100]; cin >> m >> n >> z; int y = z; for (int i = 0; i < m; i++) cin >> a[i]; for (int j = 0; j < m; j++) { for (int i = 0; i < m - 1; i++) if (a[i] < a[i + 1]) swap(a[i], a[i + 1]); } ... |
#include <bits/stdc++.h> using namespace std; long long n, k, res, ans[1010101]; queue<long long> q; stack<long long> st; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (long long i = 1; i <= n; ++i) { st.push(i); q.push(i); k -... |
#include <bits/stdc++.h> using namespace std; vector<int> v1, v2, v3; int main() { int n, ans = 0, sum = 0; cin >> n; int a[n + 1]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { v1.push_back(a[i] - a[i + 1]); } for (int i = 0; i < v1.siz... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n, f[N]; long long a[N], b[N], c[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) { scanf( %I64d , a + i); a[n + 1] = 1; long long t = a[i]; while (t % 2 == 0) t /= 2, b[i]++; c[i] = t; } ... |
#include <bits/stdc++.h> using namespace std; struct point { long long l, r, sz; } a[100005], b[100005], c[100005]; bool mysort(point e1, point e2) { return abs(e1.l - e1.r) > abs(e2.l - e2.r); } int main() { int n1 = 0, n2 = 0, n3 = 0, n, s, x, y, z; cin >> n >> s; long long tot1 = 0, tot2 = ... |
#include <bits/stdc++.h> using namespace std; int main(void) { float a; cin >> a; float root = pow(a, 0.5); int w = ceil(root); float z = a / w; int h = ceil(z); cout << (2 * (h + w)); return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 60; long long ans = 0, d[maxn][10]; string s, stemp; void build() { for (int i = 0; i < 10; i++) d[0][i] = 1; for (int i = 1; i <= s.size() - 2; i++) for (int j = 0; j < 10; j++) if ((s[i] + j) % 2 == 1) d[i][j] = d... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, m; cin >> x >> y >> m; if (x >= m || y >= m) { cout << 0; return 0; } if (x <= 0 && y <= 0) { cout << -1; return 0; } long long ans = 0; if (x < 0 && y > 0) { long long c = x; ... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned int n, a, b; cin >> n >> a >> b; if (a * b < n) cout << -1 << endl; else { for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { if (i % 2) { if (i * b + (b - j - 1) + 1 > n) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { long long f = 0, g = 1; int n; cin >> n; for (int i = 2; i <= n; i++) { long long k = f; f = 3 * g % mod; g = (k + 2 * g) % mod; } printf( %lld , f); return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; 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 && ch <= 9 ) { x = x * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[200010]; int price[200010]; bool vist[200010][2]; long long int dp[200010][2], sum[200010], ans[200010]; long long int gcd(long long int a, long long int b) { if (b == 0) return a; a %= b; return gcd(b, a); } long long int lcm(long ... |
//################ //# ------------ # //# NoName270805 # //# ------------ # //################ //#pragma GCC optimize( Ofast ) //#pragma GCC optimize( unroll-loops ) //#pragma GCC target( avx,avx2,fma ) //GNU G++17 7.3.0: No long long for faster code //GNU G++17 9.2.0 (64 bit, msys 2): Long long only... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; int tt, n; string s, t; int main() { cin >> tt; while (tt--) { cin >> n >> s >> t; bool ok = 1; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { if (s[i] == t[i]) continue; bool naso = ... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e5 + 5; const long long mod = 1e18 + 5; struct makeEdge { long long weight; long long left; long long right; long long vertex; }; struct makeEdge piece; vector<makeEdge> query2; vector<makeEdge> query3; long long sta... |
#include <bits/stdc++.h> using namespace std; const long long int INF = LLONG_MAX; vector<long long int> v1; vector<pair<long long int, long long int> > v2; string s1, s2, s3; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, b, c, d, e, f, i, j, k, cnt1 = ... |
#include <bits/stdc++.h> using namespace std; bitset<2005> a[2005]; int pos[2005]; int ans[2005]; bool gause(int n, int m) { int d = 1; for (int i = 1; i <= n; i++) { if (!a[d][i]) { for (int j = d + 1; j <= m; j++) if (a[j][i]) { swap(a[d], a[j]); break... |
#include <bits/stdc++.h> using namespace std; int nr, nr1, nr2, n, i, dif; char s[2 * 1000005], t[2 * 1000005]; int main() { cin >> n; scanf( %s , s + 1); scanf( %s , t + 1); for (i = 1; i <= 2 * n; i++) if (s[i] == 1 && t[i] == 1 ) { nr++; s[i] = 0 ; t[i] = 0 ... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, v = 0, c = 0; cin >> x; for (int i = 0; i < x; i++) { cin >> y; if (y == -1 && c == 0) { v++; } else if (y == -1 && c != 0) { c--; } else { c += y; } } cout << v; } |
#include <bits/stdc++.h> using namespace std; inline int read(int x = 0, int f = 1, char ch = 0 ) { while (!isdigit(ch = getchar())) if (ch == - ) f = -1; while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f * x; } const int N = 1e5 + 5; int head[N], ver[N], nxt[N], edge[N];... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const int maxn = 5e5; struct line { double x, y; } A[maxn]; long long X, Y, R; double x0, Y0, v, T, d, x, y, r, M, D; double a, b, now, ans, th, l, Max; int i, n, la; double sqr(double x) { return x * x; } double dist(do... |
#include <bits/stdc++.h> using namespace std; char A[21], B[21]; long i, N, d, t, j, lg; map<string, vector<pair<string, long> > > lista; map<string, vector<pair<string, long> > >::const_iterator iter; vector<pair<string, string> > rez; string a, b; inline int modul(long x) { return (x < 0) ? -x : ((x =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 7; const int mod = 998244353; const long long INF = 1e18; long long jc[maxn]; long long n, k; long long inv2 = 499122177; void init() { jc[0] = 1; for (long long i = 1; i < maxn; i++) jc[i] = jc[i - 1] * i % mod; } long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; long long temp, ans; cin >> t; while (t--) { cin >> n; long long ary[n]; for (int i = 0; i < n; i++) { cin >> ary[i]; } ans = ary[0]; for (int i = 1; i < n; i++) { ans = ans & ary... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; long long xabs(long long a) { return a < 0 ? -a : +a; } bool check(long long p, long long q, long long x, long long y, long long a, long long b) { if (a * x + b * y == p && a * y - b * x == q) return true; els... |
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(1505); vector<int> a[MAXN]; int b[MAXN], ans[MAXN]; struct pt { int x, y, idx; double r; } d[MAXN]; pt o; bool compare(const pt &p, const pt &q) { long long u1 = p.x - o.... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <type... |
#include <bits/stdc++.h> using namespace std; const int N = 200 * 1000 + 5; vector<pair<int, int> > adj[N]; int w[N]; int d[N]; bool mark[N]; set<pair<int, int> > s; vector<int> ans; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> w[i]; } for (int ... |
#include <bits/stdc++.h> char zebra[100005]; int max; int main() { scanf( %s , zebra + 1); max = 0; int n = strlen(zebra + 1); int t = 0; int ans = 0; for (int i = 1; i <= n; i++) { int k = 1; while (zebra[i] != zebra[i + 1] && i + 1 <= n) { k++; i++; } ... |
#include <bits/stdc++.h> using namespace std; bool exceed(long long x, long long y, long long m) { return x >= m / y + 1; } struct SegTree { int size; vector<pair<long long, long long> > seg; SegTree() {} SegTree(int size) { this->size = size; seg.resize(1 << (size + 1)); } pai... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200007; const int mod = 998244353; long long fast_pow(long long b, int k) { long long s = 1; while (k) { if (k & 1) (s *= b) %= mod; (b *= b) %= mod; k >>= 1; } return s; } long long fact[maxn]; int N; int A... |
#include <bits/stdc++.h> using namespace std; int FASTBUFFER; const int N = 1005; const int INF = 1000000000; char str[N][N]; int n, m, l[N], r[N]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %s , str[i] + 1); } for (int i = 1; i <= n; i++) { int ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { int n, i, j; cin >> n; vector<int> icons(n); for (i = 0; i < n; i++) { cin >> icons[i]; } vector<int> num; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = numeric_limits<int>::max(); const long long LINF = numeric_limits<long long>::max() / 2; const double DINF = numeric_limits<double>::max(); const int ITER = 3000; const double EPS = 1e-9; const int MAXN = 1005; struct addr { int x, ... |
#include <bits/stdc++.h> using namespace std; void print() { int n; cin >> n; int arr[n], mx = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; sum += arr[i]; mx = max(mx, arr[i]); } if (mx * 2 > sum || (sum & 1)) cout << T << endl; else cout << H... |
#include <bits/stdc++.h> using namespace std; template <typename T> std::ostream &operator<<(std::ostream &out, vector<T> &v) { for (typename vector<T>::size_type i = 0; i < v.size(); ++i) out << v[i] << ; out << n ; return out; } template <typename T> std::ostream &operator<<(std::os... |
#include <bits/stdc++.h> int dx[] = {+0, +0, -1, +1, +1, +1, -1, -1}; int dy[] = {+1, -1, +0, +0, +1, -1, +1, -1}; using namespace std; int n, mod = 1000000000 + 7; long long res; bool f1[20], f2[20]; int r[8] = {1, 18, 1800, 670320, 734832000, 890786230, 695720788, 150347555}; void attempt(int i) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100001]; int dist[100001]; int n, m; void bfs(int x) { queue<int> q; int cur, i; memset(dist, -1, sizeof(dist)); dist[x] = 0; q.push(x); while (!q.empty()) { cur = q.front(); q.pop(); for (i = 0; i < (int)g[c... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); char board[9][9]; char trash; for (long r = 0; r < 3; ++r) { for (long x = 0; x < 3; ++x) { for (long c = 0; c < 3; ++c) { for (long y = 0; y < 3; ++y) cin >> board[3 * r + x][3 * c + y]; ... |
#include <bits/stdc++.h> using namespace std; int n, p; int main() { map<int, int> mp; cin >> n; for (int i = 1; i <= 2 * n + 1; i++) { if (p % n == 0) { mp[n]++; } mp[p % n]++; p += i - 1; } for (int i = 1; i <= n; i++) { if (mp[i] == 0) { cout <<... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e2 + 5; int N, T; int pref[MAXN]; int ask(int l, int r) { printf( ? %d %d n , l, r); fflush(stdout); int res; scanf( %d , &res); if (res == -1) exit(0); return res; } int main() { scanf( %d%d , &N, &T); if (N =... |
#include <bits/stdc++.h> using namespace std; int main() { int a[3]; for (int i = 0; i < 3; i++) cin >> a[i]; sort(a, a + 3); cout << a[2] - a[0]; return 0; } |
#include <bits/stdc++.h> using namespace std; clock_t start; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); struct MaxFlow { struct Edge { long long f; long long u; Edge* nex; Edge* rev; Edge(long long _u, long long _f, Edge* _nex) : f(_f), u(_u), nex(_... |
#include <bits/stdc++.h> using namespace std; const int M = 1 << 13; const int N = 13; long long dp[M][N][2][2]; bool used[M][N][2][2]; vector<int> digits_hour, digits_minuts; long long solve(int mask, int pos, bool flag1, bool flag2) { int h = digits_hour.size(); int min = digits_minuts.size(); ... |
#include <bits/stdc++.h> using std::map; long long n; long long p2[100005 * 2] = {1}; long long fa[100005 * 2], size[100005 * 2], p[100005 * 2]; long long vis[100005 * 2]; map<long long, long long> mx, my; long long cnt; long long ans = 1; long long getfa(long long x) { return fa[x] == x ? x : fa[x] =... |
//愿你和你重要的人能够重逢! #include<bits/stdc++.h> using namespace std; template<typename T>inline void read(T &x) { x=0;char c=getchar(),f=0; for(;c<48||c>57;c=getchar()) if(!(c^45)) f=1; for(;c>=48&&c<=57;c=getchar()) x=(x<<1)+(x<<3)+(c^48); f?x=-x:0; } long long l,r,st,t,x,y;set<long long>s; int main(... |
#include <bits/stdc++.h> using namespace std; int n, x, maxi; string s = ABRACADABRA ; int main() { cin >> n; maxi = 0; while (n--) { cin >> x; maxi = max(maxi, x); } cout << (maxi ^ x) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, w[200200], h[200200], W, a[200200], maxH, maxH2, id; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d%d , &w[i], &h[i]); if (h[i] > maxH) { maxH = h[i]; id = i; } W += w[i]; } for (in... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; string s; cin >> n >> k >> s; for (int i = 0; i < s.size(); i++) { if (!k) break; if (i + 2 < s.size() && s[i] == 4 && s[i + 1] == 7 && s[i + 2] == 7 && i % 2 == 0) { if (k % 2) s[i + 1] = 4 ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[4], i, j, min = 1000, x, y; for (i = 0; i < 4; i++) { cin >> a[i]; if (min > a[i]) min = a[i]; } cin >> x >> y; if (x >= min) { cout << 0; return 0; } else if (y < min) { cout << y - x + 1; } e... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { long long int one = 1; if (!y) return one; else if (y == 1) return x; else { long long int y1 = power(x, y >> 1); long long int y2 = y1 * y1; if (y & 1) return ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int MAX = 2e5 + 5; const long long MAX2 = 11; const long long MOD = 998244353; const long long MOD2 = 1000000006; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, 0, -1, 1... |
#include <iostream> #include <cmath> using namespace std; int t, n, a[105]; int main(){ cin>>t; while(t--){ cin>>n; int suc = 0; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++){ int k = (int)sqrt((double)a[i]); if(k*k != a[i]){ suc = 1; break; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2600, MAXL = 10000 * 5 + 10, MAXALP = 26; int n, f[MAXN][MAXN], cnt[MAXALP], p[MAXN][MAXN]; char str[MAXL]; pair<int, int> Tohka; string Houki; void Print(const pair<int, int> &a, int res) { if (res <= 0) return; if (p[a.first][a.secon... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int ls[N << 2], rs[N << 2], rt[N << 2], sum[N << 2]; int rcnt; void update(int &rt, int l, int r, int pos) { if (rt == 0) rt = ++rcnt; if (l == r) { sum[rt]++; return; } int mid = (l + r) >> 1; if (pos <= mid)... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-12; const int N = 100000 + 10; long double sqr(long double x) { return x * x; } struct PT { long double x, y; PT(long double x = 0, long double y = 0) : x(x), y(y) {} void in() { double xx, yy; scanf( %lf%lf , &xx... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-12; const int inf = 2000000000; const long long int infLL = (long long int)2e18; long long int MOD = 1000000007; int MOD1 = 1000000007; int MOD2 = 1000000009; inline bool checkBit(long long int n, long long... |
#include <bits/stdc++.h> int main() { int num = 0; int a[100]; int i = 0; int m = 0; int yushu; char hex[16] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , A , B , C , D , E , F }; scanf( %d , &num); if (num == 0) { printf( 1 n ); return 0; ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); int n, ind = -1; int a[100100], b[100100]; pair<int, int> c[100100]; int v[100100], pos[100100]; vector<pair<int, int> > ans; bool is_happy(int x)... |
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010], ja[100010]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; ja[a[i]] = i; } for (int i = 2; i <= n; i++) { if (ja[i] > ja[i - 1]) b[i] = 1; else b[i] = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 80005, maxe = 3000005, maxs = 80005, INF = 0x3f3f3f3f; int n, q, N, m, S, T, a[maxn]; struct event { int x, l, r, f; event(int _x = 0, int _l = 0, int _r = 0, int _f = 0) : x(_x), l(_l), r(_r), f(_f) {} bool operator<(const event... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-8; const int N = 1e5 + 10; int n, q; int sgn(long double x) { return x < -EPS ? -1 : x > EPS; } struct Point { Point() {} long double x, y; Point(long double x, long double y) : x(x), y(y) {} void read() { cin >> x >> y... |
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; while (test--) { int i, n, k; string s; cin >> n; cin >> s; vector<pair<string, int> > ans; for (i = 0; i < n; i++) { string sl = s.substr(0, i); string sr = s.substr(i, ... |
#include <bits/stdc++.h> using namespace std; int main() { string n, m; int w = 0, b[10000]; cin >> n; for (int i = 0; i < n.length(); i++) { if (n.substr(i, 1) == r ) cout << i + 1 << endl; } for (int i = n.length() - 1; i >= 0; i--) { if (n.substr(i, 1) == l ) cout << i + 1 <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.