func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; if (t % 2 == 0) { cout << Mahmoud << endl; } else { cout << Ehab << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; cin >> a >> b; n = a + b + 1; for (int i = 0; i < a; i++) cout << i + 1 << ; for (int i = 0; i <= b; i++) cout << a + b + 1 - i << ; cout << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; inline int read() { register int x = 0, f = 1; register char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = x * 10 + c - 48, c = getchar(); return x * f; } names... |
#include <bits/stdc++.h> using namespace std; int n; int a[200000 + 9]; long long com[200000 + 9]; double f1(int i, int k) { long long sum1 = a[i] + com[n] - com[n - k] + com[i - 1] - com[i - 1 - k]; double av1 = (double)sum1 / (2 * k + 1); return av1; } double f2(int i, int k) { long long... |
#include <bits/stdc++.h> using namespace std; double n, m, k; int main() { while (scanf( %lf %lf %lf , &n, &m, &k) != EOF) { if (m > n + k) { printf( %.6lf n , 0.0); continue; } double resp = 1.0; for (int i = 0; i <= k; i++) { resp *= ((m - i) / (n + k + 1 - i)... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 9, M = 3e5 + 9, OO = 0x3f3f3f3f; const double EPS = 0.00000000001; const int mod = 1000003; int n, m, d[3005]; bool flage = 1; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; ++i) { scanf( %d , d + i); if (d[i... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; bool a[100100]; void go() { long long int n; cin >> n; memset(a, true, sizeof(a)); for (int i = 2; i <= n; i++) { for (int j = i + 1; i * j <= n; j++) { if (j % i == 0) continue; a[j * i] = false; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; const int inf = 0x3f3f3f3f; int a[maxn]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= k; ++i) scanf( %d , &a[i]); int x = 2 * n, y = n; for (int i = 1; i <= k; ++i) { if (a[i] >= 4 && y > 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; vector<int> checkpt; for (int i = 0; i < n; i++) { int t; cin >> t; checkpt.push_back(t); } sort(checkpt.begin(), checkpt.end()); long long distance = 0; if (n == 1) { cout << ... |
#include <bits/stdc++.h> int main() { int x, y, x1 = 0, y1 = 0, n, k = 0; do { scanf( %d%d , &x, &n); } while (x < 1 || n < 1 || n > 100000 || x > 100000); y = x; if ((x == 4 && n == 2) || (x > 5 && n < 4) || x <= n || n < 4) { printf( %d n , (x == n && x != 1) ... |
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, bool> fuck; int n, m; char s[5]; int x, y; long long ans; int dx, dy; int main() { scanf( %d%d , &n, &m); scanf( %d%d , &x, &y); scanf( %s , s + 1); if (s[1] == U ) dx = -1; else dx = 1; if (s[2] == L... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string c; cin >> c; for (int i = 1; i <= n; i++) if (n % i == 0) reverse(c.begin(), c.begin() + i); cout << c; } |
#include <bits/stdc++.h> using namespace std; long long int cost(long long int h[], long long int n, long long int a, long long int r, long long int m, long long int x) { long long int plus = 0, minus = 0; for (int i = 0; i < n; i++) { if (h[i] > x) { minus += h[i] - x; ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9, PI = acos(-1.); const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int N = 2e5 + 5, SQ = 500; int n, q, a[N], l[N], r[N], p[N]; long long ans[N], c[1000005], s; void add(int x) { int v = a[x]; s -= c[v] * c[v] * v; c[v]+... |
#include <bits/stdc++.h> using namespace std; template <class T> void check_max(T& a, T b) { if (a < b) a = b; } template <class T> void check_min(T& a, T b) { if (a > b) a = b; } const int MAXN = 10100; int n, k; double per; double a[MAXN]; int main() { cin >> n >> k; per = (dou... |
#include <bits/stdc++.h> using namespace std; void solve() { long long i, j, k, x, y, z, n, mi = 1e16, sum = 0; cin >> n; long long a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); if (n == 1 || n == 2) { cout << a[0] - 1; return; } z = (long long)... |
#include <bits/stdc++.h> using namespace std; int a[2005], b[2005]; int main() { std::ios::sync_with_stdio(false); int n, k, p; long long minn = (1000 * 1000 * 1000 + 5); minn *= (1000 * 1000 * 1000 + 7); long long ans; int j, val, i; cin >> n >> k >> p; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { map<string, bool> vis; int n; scanf( %d , &n); while (n--) { string s; cin >> s; if (vis[s]) puts( YES ); else puts( NO ); vis[s] = 1; } return 0; } |
#include <bits/stdc++.h> using namespace std; double n, r; signed main() { scanf( %lf%lf , &n, &r); printf( %.10f n , 2.0 * n * 0.5 * r * r * sin(acos(-1.0) / (2.0 * n)) / sin(acos(-1.0) - (acos(-1.0) / (2.0 * n)) * 3) * sin(2 * acos(-1.0) / (2.0 * n)));... |
#include <bits/stdc++.h> using namespace std; int n; double p[1000]; const int cc = 2; double a[201][cc * 101][cc * 101]; double get(int IT) { for (int it = 0; it <= IT; it++) for (int i = 0; i <= cc * n; i++) for (int j = 0; j <= cc * n; j++) a[it][i][j] = -100; for (int i = 0; i <= c... |
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, q, a; cin >> n >> k >> q; int t[150005] = {0}; for (int i = 1; i <= n; i++) { cin >> a; t[i] = a; } set<pair<int, int> > s; set<pair<int, int> >::iterator it; for (int i = 1; i <= q; i++) { int fla... |
#include <bits/stdc++.h> using namespace std; const int N = 4e3 + 10, mod = 1e9 + 7; char a[N]; int n, k; long long dp[N][N], dp2[N][N]; int main() { cin >> n >> k; cin >> (a + 1); dp[0][0] = dp2[0][0] = 1; for (int i = 1; i <= n; i++) for (int j = 0; j <= k; j++) { dp[i][j] = ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using vll = vector<ll>; using vpll = vector<pll>; struct d_ { template <typename T> d_& operator,(const T& x) { cerr << << x; return *this; } } d_t; int mix... |
#include <bits/stdc++.h> using namespace std; char v[2100][2100]; int n, m; int sumx[2100][2100]; int sumy[2100][2100]; long long ans1, ans2, ans3, cima, baixo; int main() { bool ok; scanf( %d %d , &n, &m); for (int i = 0; i < n; ++i) scanf( %s , v[i]); for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, -1, 0, 1, -1, 1, 1, -1}; template <class T> inline bool get(T& n) { char c, mul = 1; n = 0; while (!isdigit(c = getchar_unlocked()) && (c != EOF) && (c != - )) ; if (c == EOF... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50 + 5; const int maxm = 2500 + 5; const int inf = 1 << 29; const long long mod = 1e9 + 7; const double eps = 1e-8; long long read() { long long s = 0, w = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) { if (c == ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int temp; map<int, vector<int>> mpp; for (int i = 2; i <= n; i++) { cin >> temp; mpp[temp].push_back(i); } for (auto itr = mpp.begin(); itr != mpp.end(); ++itr) { vector<int> v = (*itr).second; ... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, l, k; int h[4][2] = {0, 1, 1, 0, 0, -1, -1, 0}, dp, cp, bp; int u[59][59]; char a[59][59]; int r[2509][5]; void dfs(int i, int j, char c) { if (i >= n || i < 0 || j >= m || j < 0) return; if (a[i][j] != c || u[i][j]) return; u[i][j]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; pair<int, int> c = make_pair(1, 0); int dx = 1, cover = 0, inc = 0; while (k != 1) { if (inc == 0) cout << 2 << ; if (dx == 1 && c.second + dx <= m) { c.second += dx; } else i... |
#include <bits/stdc++.h> using namespace std; struct node { long long li, ri; } sum[400000]; long long pmx[400000], nmx[400000]; long long pmi[400000], nmi[400000]; int main() { long long n; memset(pmi, 0x7f7f7f7f, sizeof(pmi)); memset(nmi, 0x7f7f7f7f, sizeof(nmi)); memset(pmx, -0x7f7f7f... |
#include <bits/stdc++.h> using namespace std; int V = 0; struct Node { int id; long long num, sum; Node *l, *r; Node() { num = -1; sum = 0; l = r = nullptr; id = V++; } }; int N; string s; Node* build(int& n) { Node* node = new Node(); if (s[n] == ( ) {... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x, y, n; cin >> x >> y >> n; int a, b; a = n % x; b = n - a; if (b + y <= n) { cout << b + y << endl; } else { cout << b + y - x << endl; } } ... |
#include <bits/stdc++.h> using namespace std; int c[5555], ans[5555]; int main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { memset(c, 0, sizeof(c)); int bc = 0, bt = -1; for (int j = i; j <= n; j++) { int ... |
#include <bits/stdc++.h> using namespace std; int power(int a, int b) { if (b == 0) return 1; else if (b % 2 == 0) return power((a * a) % 1000000007, b / 2); else return (a * power((a * a) % 1000000007, b / 2) % 1000000007); } int main() { std::ios_base::sync_with_stdio(false);... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, rem; cin >> a >> b; long long int count = 0; a = max(a, b); b = min(a, b); while (a != b && b != 0) { count += a / b; a = a % b; a = a + b; b = a - b; a = a - b; } cout << cou... |
#include <bits/stdc++.h> using namespace std; int main() { int l, r, x, y, k; scanf( %d%d%d%d%d , &x, &y, &l, &r, &k); int L = (int)ceil(1.0 * x / k), R = (int)floor(1.0 * y / k); if (R < L || R < l || r < L) puts( NO ); else puts( YES ); return 0; } |
#include <bits/stdc++.h> using namespace std; struct pt { long long x; long long y; }; pt u; bool cmp(pt a, pt b) { return a.x < b.x || (a.x == b.x && a.y < b.y); } bool cw(pt a, pt b, pt c) { return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) < 0; } bool ccw(pt a, pt b, pt c) ... |
#include <bits/stdc++.h> using namespace std; int n; char s[50001]; int last[26][50001]; int best[51][50001]; bool prv[51][50001]; void print(int i, int j, int k) { int len = 2 * i + (k != -1 ? 1 : 0); char ans[101]; ans[len] = 0 ; if (k != -1) ans[i] = s[k]; while (j != 0) { i... |
#include <bits/stdc++.h> using namespace std; const int N = 13 * 16, Mod = 1e9 + 7; struct Matrix { int n, m, A[N][N]; inline Matrix(int _n, int _m) : n(_n), m(_m) { memset(A, 0, sizeof(A)); } inline Matrix operator*(Matrix &X) { Matrix R(n, X.m); for (int i = 0; i < n; i++) for (i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int s, x1, x2, t1, t2, p, d; cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d; swap(t1, t2); int sol = abs(x1 - x2) * t1; int tram = 0; int p1 = p; int p2 = x1; if (d == -1) { if (... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const long long inf = 1e18 + 9; long long ans = inf... |
#include <bits/stdc++.h> using namespace std; struct edge { int t, f, w; bool operator<(const edge& e) const { return w > e.w; } edge(int from, int to, int weight) { t = to; f = from; w = weight; } }; const double EPS = (1e-9); class UnionFind { public: vector<int> p, ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int x, y, l, r; cin >> x >> y >> l >> r; vector<long long int> vec(0); long long int xa = 1; long long int cap = 0; long long int r1 = r; while (r1 > 0) { r1 /= x; ++cap; } for (long long int i = 0; ... |
#include <bits/stdc++.h> const long long LLINF = 0x3f3f3f3f3f3f3f3f; using namespace std; class otr { public: long long len = 0; long long* D = nullptr; otr(long long alen) { len = alen; D = new long long[alen]; } ~otr() { delete[] D; } }; void Flip(long long* left, long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x; vector<pair<int, int>> v; cin >> n; for (int i = 1; i <= n && cin >> x; i++) v.push_back({x, i}); sort(v.begin(), v.end()); cout << v[n - 1].second << << v[n - 2].first; } |
#include <bits/stdc++.h> using namespace std; int z[1005]; string a[1005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) cin >> a[i]; for (int j = 0; j < m; ++j) { for (int i = 1; i < n; ++i) for (int i1 = 0; i1 ... |
#include <bits/stdc++.h> using namespace std; int mark[123456]; int main() { int n, t; scanf( %d , &n); for (int i = 0; i < n - 1; i++) { scanf( %d , &t); mark[t]++; } int ans = 0; for (int i = 1; i <= n; i++) { if (!mark[i]) { ans = i; break; } ... |
#include <bits/stdc++.h> using namespace std; int a[500009], posin[500009]; vector<int> pairs[500009]; int main() { int n, m, x, y, c = 0; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); posin[a[i]] = i; } for (int i = 0; i < m; i++) { scanf( %d %d ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, sum = 0, hours = 0; cin >> a >> b; for (int i = 0; i < a; i++) { hours += 1; sum += 1; if (sum == b) { a += 1; sum = 0; } } cout << hours; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); pair<int, int> a[101]; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } int t; cin >> t; for (int i = n - 1; i >= 0; i--) {... |
#include <bits/stdc++.h> int p, v, n, s, t; int main(int argc, char** argv) { scanf( %d%d%d , &p, &v, &n); int aux = v; s = 0; t = 0; while (aux >= n) { int i; i = (aux / 50) % 475; for (int j = 0; j < 25; j++) { i = (i * 96 + 42) % 475; if (i + 26 == p) { ... |
#include <bits/stdc++.h> using namespace std; int q, n; bool ok(long long edg) { long long b = (edg + 1) >> 1, o = (n - b) * (n - b - 1) >> 1; return (b + min(edg >> 1, o)) == edg && b < n; } long long bs() { long long beg = 0, end = 2LL * n, mid; while (beg < end) { mid = (beg + end + 1... |
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 500054; int n, Z, Hz; int a[N], z[N]; std::vector<int> r[N]; std::pair<int, int> w[N]; std::priority_queue<int, std::vector<int>, std::greater<int>> pq; inline void up(int &x, const int y) { x < y ? x = y : 0; } inline void down... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100010], i, x, val; cin >> n >> x; int cnt[100010] = {0}; int cnt2[100010] = {0}; for (i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; } for (i = 0; i < 100010; i++) { if (cnt[i] > 1) { cout << ... |
#include <bits/stdc++.h> using namespace std; long long n, m, a[20000], p[20000], i, l, j, mx, ans[20000], mxi; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { mx = 0; for (j = i; j < n; j++) { p[a[j]]++; if (p[a[j]] > mx ... |
#include <bits/stdc++.h> using namespace std; int N, A, B, X, Ans = 0, C = 0; int main() { cin >> N >> A >> B; for (int i = 1; i <= N; i++) { cin >> X; if (X == 1) { if (A > 0) A--; else if (B > 0) C++, B--; else if (C > 0) C--; els... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; long long n, m, k, ki[maxn], d[maxn], par[maxn]; long long ans; vector<pair<int, int>> veci[maxn]; bool mark[maxn], fu; set<pair<long long, pair<int, int>>> st; vector<pair<long long, pair<int, int>>> yal; int get(int u) { return... |
#include <bits/stdc++.h> using namespace std; int n, M[2002][2002]; bool V[2002]; vector<int> L, L_; void dfs(int inicial, vector<int> &Li) { Li.push_back(inicial); V[inicial] = 1; for (int i = 0; i < n; ++i) if (!V[i] && M[inicial][i]) dfs(i, Li); } bool Conexo() { dfs(0, L); fo... |
#include <bits/stdc++.h> const int N = 8; int n, x; double p[1 << N]; void fwt(int l, int r) { if (l + 1 == r) return; int mid = (l + r) >> 1; fwt(l, mid); fwt(mid, r); int t = mid - l; for (int i = l; i < mid; ++i) { double x = p[i], y = p[i + t]; p[i] = x + y; p[i + t... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> res(n); for (auto &v : res) cin >> v; int sum = 0, mini = INT_MAX, index = -1, i; for (i = 0; i < n; i++) { if (i < k) { sum += res[i]; continue; } else { if (m... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int prime[100005 + 5000]; int a2[10005]; map<int, int> M; int f[100005]; int Gcd[50005]; int sum[50005]; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int i, j, k = 0; for (i = 2; i <=... |
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } const long long MOD = 1000000007; long long inv[1... |
#include <bits/stdc++.h> using namespace std; const int nax = 2e5 + 10; int first[nax], last[nax], a[nax]; int reach[nax]; int main() { fill_n(first, nax, 1e9); fill_n(last, nax, -1e9); ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> a(n); long long s = 0; long long l = 0; long long r = 1000000000000000; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; l = max(a[i], l); } long long is = r; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; long long n, a[N], sum; vector<long long> v; void fact() { if (sum % 2 == 0) { v.push_back(2); while (sum % 2 == 0) sum /= 2; } for (long long i = 3; i * i <= sum; i += 2) { if (sum % i == 0) { v.push_ba... |
#include <bits/stdc++.h> using namespace std; inline bool cmin(int &x, int y) { return x > y ? x = y, 1 : 0; } inline bool cmax(int &x, int y) { return x < y ? x = y, 1 : 0; } const int _ = 1e5 + 55; int N, x; long long ans(0); priority_queue<int> A, B; int main() { scanf( %d , &N); for (int i(1... |
#include <bits/stdc++.h> using namespace std; inline int read() { int out = 0, fh = 1; char jp = getchar(); while ((jp > 9 || jp < 0 ) && jp != - ) jp = getchar(); if (jp == - ) fh = -1, jp = getchar(); while (jp >= 0 && jp <= 9 ) out = out * 10 + jp - 0 , jp = getchar(); return out... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long q; cin >> q; while (q--) { long long n; cin >> n; vector<long long> vec(n, 0); vector<bool> vis(n, false); vector<pair<long long, long... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0); int n, a, b; cin >> n >> a >> b; int ans = 0; int c[n]; for (int i = 0; i < n; i++) cin >> c[i]; int st = 0; int en = n - 1; while (st <= en) { if (st == en) { i... |
#include <bits/stdc++.h> using namespace std; inline int read() { int 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(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10, inf = 0x3f3f3f3f, mod = 1000000007; const long long INF = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-9; void read() {} template <typename T, typename... T2> inline void read(T &x, T2 &...oth) { x = 0; int ch = getchar(), f = 0... |
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cout << sdbg << = << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != , ) cout << *sdbg++; cout << = << h << , ; _dbg(sdb... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } template <class T> inline void umin(T &a, T b) { if (a > b) a = b; } const int N = 2e5; long long X, Y, x[N], y[N]; long long nx, bx; long long ny, by; long long basx, basy;... |
#include <bits/stdc++.h> const int SZ = 2e5 + 5; using namespace std; int n, p[SZ]; string s, t; bool valid(int idx) { string tmp = s; for (int i = 0; i < idx; i++) { tmp[p[i]] = . ; } string tmp2 = ; for (int i = 0; i < n; i++) { if (tmp[i] != . ) tmp2 += tmp[i]; } ... |
#include <bits/stdc++.h> using namespace std; int v[100005]; stack<pair<int, int> > S; vector<pair<int, int> > Q; int main() { int N; scanf( %d , &N); for (int i = 0; i < N; i++) scanf( %d , &v[i]); ++N; v[N] = 0; for (int i = 0; i < N; i++) { int a = v[i]; if (S.empty() &&... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200100; int N, M; vector<int> edge[MAXN]; int dep[MAXN]; int croute[MAXN]; int par[MAXN]; pair<int, int> cover[MAXN]; bool seen[MAXN]; void run(int cloc, int last, int cdep) { seen[cloc] = true; croute[cdep] = cloc; dep[cloc]... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 10; const int INF = 10000000; int n; struct Number { int L, R, num; } a[N]; const bool comp(const Number &A, const Number &B) { return A.num > B.num; } int main() { scanf( %d , &n); int pos; for (int i = 1; i <= N; ++i... |
#include <bits/stdc++.h> using namespace std; template <typename A> string to_string(A* ptr) { stringstream ss; ss << 0x << std::setw(16) << std::setfill( 0 ) << std::hex << (uint64_t)(uintptr_t)ptr; return ss.str(); } string to_string(char c) { return ((string) + c) + ; } templa... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; int n; pair<long long, int> t[N]; long long tree[4 * N], dp[N], v[N]; int rnk[N]; inline void update(int idx, long long val, int st, int en, int root) { if (idx < st || idx > en) return; if (st == en) { tree[root] = ma... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> bpow = {{1, 1}}; struct HashArr { const long long base = 137137, mod[2] = {(int)1e9 + 7, (int)1e9 + 9}; vector<pair<long long, long long>> h; void init(vector<int>& a) { int n = a.size(); h.resize(n + 1); ... |
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int>> moves_knight(int x, int y) { vector<pair<int, int>> v; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (abs(x - i) + abs(y - j) == 3 && abs(x - i) * abs(y - j) == 2) v.push_back({i, j}); ... |
#include <bits/stdc++.h> using namespace std; char s[100010]; int l[100010], r[100010]; struct node { int val, id; }; struct cmp { bool operator()(node a, node b) { return a.val < b.val; } }; priority_queue<node, vector<node>, cmp> q; int main() { scanf( %s , s); int len = strlen(s); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e8; struct st { int l, r; }; bool cmp(st a, st b) { return a.l < b.l; } int main() { bool a1 = false, b1 = false; int i; st v, q, w; vector<st> v1, v2; string s, a = AB , b = BA ; cin >> s; for (i = 0; i < s.siz... |
#include <bits/stdc++.h> using namespace std; int en[100004]; long long int dp[100004][3]; string x[100004]; int n; long long int sol(int i, int ck) { if (i > n) return 0; if (dp[i][ck] != -1) return dp[i][ck]; string org = x[i]; long long int ans = 0; long long int ans1 = 0; if (!ck... |
#include <bits/stdc++.h> using namespace std; long long N, L, W; vector<long long> neg, pos; long long INF32 = 0x7fffffff; inline long long div_floor(long long a, long long b) { if (b == 0) return (a > 0 ? +INF32 : -INF32); if (a % b < 0) a -= (b + a % b); return a / b; } int main() { cin ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int MOD = 1e9 + 7; int aa[N]; int tree[4 * N]; int query(int v, int l, int r, int L, int R) { if (l > r || l > R || r < L) return 0; if (L <= l && r <= R) return tree[v]; int v1 = 2 * v + 1; int v2 = 2 * v + 2; i... |
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > room_to_switches; vector<vector<pair<long long, long long> > > neighbors; vector<long long> target; void dfs(long long s, long long color, vector<long long>& colors) { if (colors[s] != -1) { if (color != colors[s]) { co... |
//W4P3R /* ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; char s[N]; int main() { scanf( %s , s); int n = strlen(s); int x = 0, y = 0; for (int i = 0; i < n; i++) { if (s[i] == L ) x--; else if (s[i] == R ) x++; else if (s[i] == U ) y++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 5; vector<int> g[N], revg[N], cur; bool used[N], isans[N]; set<int> all; int n, m; int main() { scanf( %d %d , &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf( %d %d , &u, &v); u--, v--; g[u].push_... |
#include <bits/stdc++.h> using namespace std; const int max_n = 5e5 + 10, max_f = 800; struct Rad { int l, r; vector<pair<long long, int> > ar; long long s; Rad() { l = r = -1; s = 0; } }; int n, q; long long num[max_n]; Rad sq[max_n]; bool compare(const pair<long long, i... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } int main() { long long n; vector<long long> a; vector<pair<long long, long long> > b; cin >> n; for (i... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int inf = 0x3f3f3f3f; int n, k, a[510][510]; int main() { while (~scanf( %d%d , &n, &k)) { int top = 1, ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j < k; j++) { a[i][j] = top++; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; vector<long long> a(n); vector<long long> b(n); for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i = 0; i < n; i++) cin >> b[i]; sort(b.begin(), b.end()); long long ans = m - 1; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int M = 20; pair<int, int> dp[M][(1 << 10)]; int a[M], K, ten[M]; int Count(int st) { int rnt = 0; while (st) st &= st - 1, rnt++; return rnt; } pair<int, int> f(int pos, int st, int lead, int limit) { if (pos... |
#include <bits/stdc++.h> using namespace std; const int c = 200002; int sum, n, ans[c], pos; vector<int> sz[c]; bool v[c]; bool dfs(int a) { v[a] = true; int el = a; for (int i = 0; i < sz[a].size(); i++) { int x = sz[a][i]; if (!v[x] && !dfs(x)) ans[el] = x, el = x; } if (el... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, c = 0, f = 0; cin >> n >> k; int y[n]; for (int i = 0; i < n; i++) cin >> y[i]; if (k == 5) { for (int i = 0; i < n; i++) { if (y[i] == 0) c++; } if (c >= 3) { if (c == 6) f = 2; ... |
#include <bits/stdc++.h> using namespace std; struct query { long long t, fi, si; }; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long a[n]; map<long long, long long> f; for (long long i = 0; i < n; i++) { long lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.