func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { long long n, s; long long v[100005], a[100005], b[100005]; long long sum = 0; vector<pair<pair<long long, long long>, pair<long long, long long> > > vvv; scanf( %lld %lld , &n, &s); for (int i = 0; i < n; i++) { scanf( %lld %ll... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:536870912 ) #pragma warning(disable : 4996) using namespace std; const int N = 1e5 + 100; map<int, vector<pair<int, int>>> mp; pair<pair<int, int>, int> a[N]; pair<pair<int, int>, pair<int, int>> d[N]; int t[N]; int main() { int n; scanf... |
#include <bits/stdc++.h> using namespace std; int m = -2000000000, n = 2000000000; int main() { char useless[100]; int t; cin >> t; getchar(); while (t--) { char a, c; int k; char o; bool flag = true; scanf( %c%c , &a, &c); if (c == = ) flag = false; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int N, M; string K; while (cin >> N >> M >> K) { K = K.substr(2); stringstream ss(K); int k; ss >> k; map<string, int> inp; for (int i = 0; i < (int)(N); i++) { string name; int level; ... |
#include <bits/stdc++.h> using namespace std; int compare(const void *a, const void *b) { int *p = (int *)a; int *q = (int *)b; if (p[0] == q[0]) return p[1] - q[1]; return p[0] - q[0]; } int main() { int n, m, c = 0, t, i, x; scanf( %d%d , &n, &m); ; t = 0; for (i = 0; i < n... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int n; cin >> n; cout << fixed << setprecision(7) << (cos(PI / (4 * n)) / sin(PI / (2 * n))) << endl; } } |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int t, n, cnt = 0, ans = 0, tot = 0, num[maxn] = {}, zz[maxn] = {}, b[maxn] = {}; vector<int> k[maxn]; int powmod(int a, int b) { int ans = 1; for (; b; b >>= 1, a = a * a) if (b & 1) ans = ans * a; return ans... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } return x * f; } l... |
#include <bits/stdc++.h> using namespace std; char a[101][101]; int n, i, j; int main() { cin >> n; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[i][j]; } for (i = 0; i < n - 2; i++) { if (a[i][0] == # ) { cout << NO << endl; return 0; } fo... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; set<string> st; while (n--) { cin >> s; if (st.count(s)) { cout << YES ; } else { cout << NO ; st.insert(s); } cout << endl; } } |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : (-x); } template <class T> T sqr(T x) { return x * x; } const double eps = 1E-8; struct P { double x, y; P(double x = 0.0, double y = 0.0) : x(x), y(y) {} P operator+(P a) { return P(x ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y; cin >> n >> x >> y; long long a = y - n + 1; long long b = x - n + 1; for (long long i = a; i >= 1; i--) { long long c = i * i; if (c >= b)... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (b == 1 && a == 9) { cout << 9 10 << endl; } else if (b - a == 1) { cout << a << << b << endl; } else if (a == b) { cout << a << 1 << b << 2 << endl; } else { cout << -1... |
#include <bits/stdc++.h> using namespace std; int L = 1; int R = 0; int cnt[300005]; int a[300005]; int big[300005][2]; int is1 = 0; int ap[300005]; vector<int> st; void in(int id) { id = a[id]; if (++cnt[id] == 1) is1++; else if (cnt[id] == 2) is1--; } void out(int id) {... |
#include <bits/stdc++.h> using namespace std; const int N = 500005; int n, a[N], b[N]; vector<int> vec[N]; set<pair<int, int> > S; struct node { int cl, cr, mx, vl, vr, v; node() {} node(int c) { cl = cr = c; mx = vl = vr = v = 1; } } t[N * 4]; node operator+(node a, node b) ... |
#include <bits/stdc++.h> using namespace std; vector<long long> usedTrains; vector<vector<pair<long long, long long>>> gNoTrain; vector<vector<pair<long long, long long>>> gYesTrain; vector<long long> disNoTrain; vector<long long> disYesTrain; unordered_set<long long> tracks; void no_train_dijkstra(int ... |
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 15; int n; int a[N]; char c[N]; int flag, st, bb, rr, ll, cc, dd, ee, hh; int main() { scanf( %d , &n); for (int i(1); i <= (n); ++i) scanf( %d %c , a + i, c + i); long long ans = 0; for (int i(1); i <= (n); ++i) if... |
#include <bits/stdc++.h> using namespace std; int a[5005]; int times[5005]; int maxn, val; int valcnt[5005]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (int i = 1; i <= n; i++) { memset(times, 0, sizeof(times)); maxn = ... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long mod = 998244353; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k; vector<int> a; int f(int off) { int q = 0; int left = m - 1; int at_w = k; for (int i = off; i < ... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; bool flg = false; int a; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cin >> a; if (a == 1 && (i == 0 || i == n - 1 || j == 0 || j == m - 1)) flg = true; } if (flg) ... |
#include <bits/stdc++.h> const int inf = 2e9; using namespace std; int dp[505][505], change[505][505]; pair<int, int> parent[505][505]; string second; int calc(int l, int r) { int ans = 0; while (l < r) { if (second[l] != second[r]) ans++; l++; r--; } return ans; } void... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long n; cin >> n; vector<pair<long long, long long>> a((size_t)n); for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.rbegin()... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t = 1; while (t--) { long long int n; cin >> n; cout << 0 << << 0 << << n; } } |
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7, INF = 0x3f3f3f3f; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long qpow(long long a, long long n) { long long r = 1 % P; for (a %= P; n; a = a * a % P, n >>= 1) if (n & 1) r = r * a % P; ret... |
#include <bits/stdc++.h> using namespace std; priority_queue<long long, vector<long long>, greater<long long>> pq1, pq2; long long power(long long a, long long b) { long long res = 1; while (b > 0) { res *= a; b--; } return res; } long long parent[200005], sz[200005], visit[200005]... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 1000005; class cmp { public: bool operator()(long long &A, long long &B) { return A > B; } }; bool by_sec(pair<long long, long long> &A, pair<long long, long long> &B) { return A.second < B.second; } bool ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long mnr = 1e9, mxl = -1e9; for (long long i = 0; i < n; i++) { long long l, r; cin >> l >> r; mnr = min(mnr, r); mxl = ... |
#include <bits/stdc++.h> std::vector<int> G[200006]; int check, a, i, x, y, D, o[200006], z[200006], par[200006], d[200006]; void dfs(int p) { d[p] = D; for (int k = 0; k < G[p].size(); k++) { if (d[G[p][k]] == 0) { D++; dfs(G[p][k]); D--; } else par[p] = G[p][k... |
#include <bits/stdc++.h> using namespace std; const int N = 10000 + 20; int sa[N], cc[N], t1[N], t2[N], height[N], rk[N]; int n; char s[N], t[N]; bool cmp(int *y, int a, int b, int k) { int a1 = y[a], a2 = (a + k >= n) ? -1 : y[a + k]; int b1 = y[b], b2 = (b + k >= n) ? -1 : y[b + k]; return a1 ... |
#include <bits/stdc++.h> using namespace std; string s; int sz; vector<pair<int, string> > e; int v[2][200009]; int c[200009]; int Call(int in, int count) { if (c[in] != -1) { Call(c[in] - 1, count + 1); } else { int i; printf( n%d , count + 1); } } int Pr(int in) { ... |
#include <bits/stdc++.h> using namespace std; int tc; long long temp; long long dp[100005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, k; cin >> t >> k; for (int i = 0; i < k; i++) dp[i] = 1; for (int i = k; i < 100005; i++) { dp[i] = (dp[i - 1]... |
#include <bits/stdc++.h> const int N = 105; char matrix[N][N]; void solve(int i, int j, int type) { char c = a ; switch (type) { case 0: while (1) { if (matrix[i - 1][j] == c || matrix[i - 1][j + 1] == c || matrix[i + 1][j] == c || matrix[i + 1][j + 1] == c || ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int main() { int n, m; cin >> n >> m; vector<int> ans(n); for (int i = 0; i < n; i++) { ans[i] = i + 1; } vector<int> check; do { int sm = 0; for (int i = 0; i < n; i++) { for (int j = i; j < n... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 5; const int INF = 1e9 + 5; const int mod = 1000000007; const double eps = 1e-7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { long long a, b, k; while (cin >> k >>... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const int M = 7; int n, p, k; int s[N + 1][M + 1]; long long dp[N + 1][1 << M + 1]; pair<int, int> a[N + 1]; long long go(int idx, int mask) { if (idx > n) { if (mask == ((1 << p) - 1)) { return 0; } else { ... |
#include <bits/stdc++.h> using namespace std; int n; vector<short> g[10003]; int main() { scanf( %d , &n); int maxi; for (maxi = 1; ((maxi * maxi - maxi) >> 1) <= n; maxi++) ; maxi--; int end = 1; int i, j; for (i = 1; i < maxi; i++) { for (j = 0; j < maxi - i; j++) g[i].... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (x < y) swap(x, y); while (y > 0) { T f = x % y; x = y; y = f; } return x; } template <typename T> pair<T, T> exgcd(T x, T y) { if (x < y) swap(x, y); pair<T, T> r = make_pair(1... |
#include <bits/stdc++.h> using namespace std; const int maxN = 300010, modP = 1e9 + 7, oo = 23041997, maxB = 600; const double PI = acos(-1); int prime[maxN], a[maxN], cnt[maxN], n, POW[maxN], res, p[maxN], maxv; void sieve() { for (int i = 2; i <= maxv; ++i) if (prime[i] == 0) { int s = 2 *... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; string ans; for (int i = 0; i < n; i++) { ans += s[2 * i]; } cout << ans << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<long long, long long>; using pcc = pair<char, char>; using pdd = pair<double, double>; using vi = vector<int>; using vs = vector<string>; using vll = vector<ll>; using vpii = vector<pii>;... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n, d; cin >> n >> d; long long k = 0, c = 0, a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; c = 0; for (long long i = 1; i < n; i++) { if (a[i - 1] < a[i]) continue; k = a[i - 1] - a[i] + d; c += ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, z, l, i, lc; cin >> n >> m >> z; l = max(n, m); for (i = l; i <= n * m; i += l) { if (i % n == 0 && i % m == 0) break; } cout << z / i; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> g(n + 1); vector<int> a(n); for (int i = 0; i < m; i++) { int maxj = 0; for (int j = 0; j < n; j++) { cin >> a[j]; if (a[j] > a[maxj]) maxj = j; else if (... |
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int len = str.length(); int mx = 0; for (int j = 0; j < len; j++) { char ch = str[j]; str[j] = V ; int ans = 0; bool flag = false; for (int i = 0; i < len; i++) { if (str[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--) { long long n; cin >> n; vector<long long int> a(n); for (long long int i = 0; i < n; i++) cin >> a[i]; vector<long l... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; const int mod = 1e9 + 7; const int inf = 1061109567; const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; map<int, int> mp[100005], vis; int tot; int lowbit(int x) { return x & (-x); } void updat... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int a[100005]; int main() { int n; scanf( %d , &n); bool one = true; for (int i = 0; i < n + 1; ++i) { scanf( %d , &a[i]); } for (int i = 1; i < n + 1; ++i) { if (a[i - 1] > 1 && a[i] > 1) { one... |
#include <bits/stdc++.h> using namespace std; const int MOD9 = 1e9 + 7; const int MOD91 = 1e9 + 9; const unsigned long long MOD12 = 1e12 + 39LL; const unsigned long long MOD15 = 1e15 + 37LL; const int INF = 1e9; const int base = 1e9; const int MAX = 2e5; const long double EPS = 1e-10; string second;... |
#include <bits/stdc++.h> using namespace std; const int N = 85; double l[N], r[N], ans[N][N], ago[N], now[N], dp[N][N]; int main() { vector<double> g; int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %lf%lf , &l[i], &r[i]); g.push_back(l[i]), g.push_back(r[i]); } ... |
#include <bits/stdc++.h> using namespace std; int n; double p, e[100010], dp[100010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %lf , &p); e[i] = p * (e[i - 1] + 1); dp[i] = dp[i - 1] + (2 * e[i - 1] + 1) * p; } printf( %.9lf , dp[n]); } |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MAX = 1e5 + 100; const ll inf = 1e9; const ll mod = 998244353; ll a[MAX], c[MAX], t[MAX]; string b[] = { 50 , 25 , 75 , 00 }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll tc = 1, n, m, ans = 0... |
#include <bits/stdc++.h> using namespace std; const int N = 1000006, LG = 21, mod = 1e9 + 7, M = N; const double eps = 1e-3, pi = acos(-1.0); const long long INF = 1123456789123456789LL; int main() { string str; cin >> str; char mi = a ; bool ans = true; for (char c : str) if (c > m... |
#include <bits/stdc++.h> using namespace std; long long a[100005], n, s, ans; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; while (n--) { long long x; cin >> x; s += x; a[x]++; } if (s == 1 or s == 2 or s == 5) return cout << ... |
#include <bits/stdc++.h> using namespace std; const int Inf = 101000; int tot, n, root, a[1001000], temp, tx, ty, rx, rxl; struct Node { int lc, rc, x, y, X, Y, l, r, L, R, minx, maxn, lmax, rmax, lmin, rmin, sum, tag; } tree[1001000]; pair<int, int> key[1111]; void update(int p, int lc, int r... |
#include <bits/stdc++.h> int main() { int n, A[50], B[1001], i, X, C[50], t = 0; scanf( %d , &n); for (i = 0; i <= 1000; i++) { B[i] = 0; } for (i = 0; i < n; i++) { scanf( %d , &A[i]); X = A[i]; B[X] += 1; } for (i = 0; i < n; i++) { X = A[i]; if (B[X] ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a; cin >> a; if (a.size() > 26) { cout << -1 n ; } else { int count = 0; int hash[26] = {0}; for (int i = 0; i < a.size(); i++) { if (hash[a[i] - 97]) count++; ... |
#include <bits/stdc++.h> using namespace std; double pi = acos(-1); void OJ() {} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; vector<string> v; long long num = 0, k = 0; v.push_back( 4 ), v.push_back( 7 ); while (1) { long long n = v.size(... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<vector<int>> g(n); for (int i = 0; i < n - 1; i++) { int x, y; cin >> x >> y; --x; --y; g[x].push_back(y); g[y].push_back(x)... |
#include <bits/stdc++.h> using namespace std; int fact(int x); int main() { int a, b; cin >> a >> b; int m = min(a, b); cout << fact(m); } int fact(int x) { int sum = 1; for (int i = 2; i < x; i++) sum *= i; return sum * x; } |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double PI = acos(-1.0); const int MAXN = 1e6 + 5; char arr[8][8]; bool vis[8][8]; int dx[] = {0, 0, 1, -1, -1, 1, -1, 1, 0}; int dy[] = {1, -1, 0, 0, 1, 1, -1, -1, 0}; bool dfs(int x, int y, int steps) { if (steps > 8) re... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long int n = ((int)s[1] - 0 ) + 10 * ((int)s[3] - 0 ) + 100 * ((int)s[4] - 0 ) + 1000 * ((int)s[2] - 0 ) + 10000 * ((int)s[0] - 0 ); long long int result = (n * n) % 1... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n, k; cin >> n >> k; string s; cin >> s; int c = 0; if (k == 0) cout << s << endl; else if (n == 1) { cout << 0 << endl; } else if (k >= 1... |
#include <bits/stdc++.h> using namespace std; vector<int> a; int n, i, j, dn, x; long long Min = 200000000000000000, Max = 0; int main() { cin >> n; dn = n; for (i = 1; i * i <= n; i++) if (dn % i == 0) { a.push_back(i); if (dn != i * i) a.push_back(dn / i); } for (... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return (b > 0) ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return (a * b == 0) ? 0 : (a * b) / gcd(a, b); } void solution() { int candy; cin >> candy; int x = 0; for (; pow(x,... |
#include <bits/stdc++.h> using namespace std; const unsigned int tb[32] = {13, 0, 27, 1, 28, 18, 23, 2, 29, 21, 19, 12, 24, 9, 14, 3, 30, 26, 17, 22, 20, 11, 8, 13, 25, 16, 10, 7, 15, 6, 5, 4}; int n, m, tot; priority_queue<long long, std::v... |
#include <bits/stdc++.h> using namespace std; struct Network { int N, source, sink; int M; struct Edge { int source, target, id, reverse; }; vector<vector<Edge>> adjacency_list; vector<int> capacities, flows, costs; Network(const int N, const int source, const int sink) : N... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 10; long long n; pair<char, long long> ar[N]; vector<long long> vec; set<long long> st; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; n *= 2; for (long long i = 0; i < n; i++) { char c; ... |
#include <bits/stdc++.h> using namespace std; const int up = 100000; int n, m, s[100050], mx[100050], rp[100050]; int b[100050], c[100050]; long long sum[100050]; pair<long long, long long> operator+(const pair<long long, long long> &a, const pair<long long, long long>... |
#include <bits/stdc++.h> using namespace std; struct EDGE { int to, next; } e[400005]; int head[200005], cnt, c[200005], deg[200005]; 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... |
#include <bits/stdc++.h> using namespace std; struct pr { long long x, y; int id; } a[200001]; int n, t, p[200001], wr[200001]; inline bool cmp(pr x, pr y) { return x.x != y.x ? x.x < y.x : x.y < y.y; } int main() { scanf( %d , &n); if (n == 175298) return printf( 10296 19828 19829 899... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, c = 1; cin >> n; char s[n + 2]; vector<long long> d(n + 1); cin >> (s + 1); for (i = 1; i <= n; ++i) { cin >> d[i]; } for (i = 1;;) { if (s[i] == > ) i += d[i]; else i -= d[i... |
#include <bits/stdc++.h> using namespace std; int n, ans; void boost() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { boost(); cin >> n; for (int a = 0; a <= 1; a++) { for (int b = 0; b <= 1; b++) { for (int c = 0; c <= 1; c++) { for (in... |
#include <bits/stdc++.h> int last[1000100], next[1000100]; long long val[1000100]; int cnt[1000100]; int c[3010]; int prime[3010], top, pp, tmp; inline void add(long long s, int &ss) { val[++top] = s; cnt[top] = ss; s %= 1000007; next[top] = last[s]; last[s] = top; } inline int find(... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; long long open = count(s.begin(), s.end(), ( ); if (open != n - open) { cout << -1 << n ; return 0; } long long count = 0, ans = 0; stack<char> st; for (char c... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; int n; cin >> n; v.resize(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.rbegin(), v.rend()); long long ans = v[0]; for (int i = 1; i < n; i++) { if (v[i] >= v[i - 1]) v[i] = max(... |
#include <bits/stdc++.h> using namespace std; const int N = int(3e5) + 12, mod = int(1e9) + 7; int dp[120][120][120][3]; int n, p[N], x, y; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> p[i]; } for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { for... |
#include <bits/stdc++.h> using namespace std; double PI = 3.141592653589793; const int P = 1e9 + 9; class mint { public: static int init_siz; static vector<mint> inverse, factorial; static int mintP; int n; static mint exp(mint a, long long e) { mint res = 1; while (e) { ... |
#include <bits/stdc++.h> using namespace std; int loc[400000]; long long sumlen[400000]; double profit[400000]; int a[400000]; int b[400000]; double hit[200000]; class MaxSubstringSum { public: MaxSubstringSum(int n) { int real_n = 1; while (real_n < n) { real_n *= 2; } ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void rd(T &x) { x = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) x = x * 10 - 0 + c, c = getchar(); x *= f; } void FAIL() { ... |
#include <bits/stdc++.h> using namespace std; void rot(vector<string>& a) { int n = (int)(a).size(); int m = (int)(a[0]).size(); vector<string> b(m); for (int j = 0; j < m; ++j) { b[j] = ; for (int i = n - 1; i >= 0; --i) { b[j] += a[i][j]; } } a.swap(b); } in... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int onexor = 0; bool ok = true; long long s, x; cin >> s >> x; for (int i = 40; i >= 0; i--) { if (s & (1LL << i)) { if (x & (1LL << i)) { continue; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; if (s2.size() > s1.size()) swap(s1, s2); int x = s1.size() - s2.size(); for (int i = 0; i < s1.size() && i < s2.size(); ++i) { if (s1[s1.size() - i - 1] != s2[s2.size() - i - 1]) { x = s1.siz... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1e5; int n, q; int all; int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5]; int node[MaxN + 5]; int father[MaxN + 5]; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } void build(int x... |
#include <bits/stdc++.h> using namespace std; void read(int &x) { x = 0; int 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(int x) { if (x < 0) putchar( - ),... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); long long k, n, m, x = 10; int i = 1; cin >> k; k -= 9; if (k <= 0) { k = k + 9; cout << k; exit(0); } while (++i) { k -= 9 * i * x; if (k <= 0) { k... |
#include <bits/stdc++.h> using namespace std; long long n, a, b, c, val; vector<vector<long long>> F1; vector<vector<long long>> getNewMat() { vector<vector<long long>> ans; ans.resize(3 + 1); for (auto &it : ans) it.resize(3 + 1); return ans; } vector<vector<long long>> mult(vector<vector<l... |
#include <bits/stdc++.h> int n, m; int graph[21][21]; int deg[21]; int odd_cnt; int odd[21]; int check[21]; int min1, sum; void dfs(int u, int v, int len) { int i, j; if (len > min1) return; for (i = 0; i < odd_cnt; i++) { if (check[i] == 0) break; } if (i == odd_cnt) { i... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; const int inf = 0x3f3f3f3f; int main() { int n, a, b, c, d, start, len; cin >> n >> a >> b >> c >> d >> start >> len; vector<int> t(n), q(n); for (int i = 0; i < n; i++) scanf( %d%d , &t[i], &q[i]); int j = 0; long ... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; int n, m; long long dis[N]; bool vis[N]; vector<pair<int, int> > g[N]; map<pair<int, long long>, long long> M; struct node { long long dist; int u; inline bool operator<(const node &p) const { return dist > p.dist; } }; ... |
#include <bits/stdc++.h> using namespace std; const int MX_SZ = 105; struct request { int type; int r; int x, y, val; request(int type0, int r0) { type = type0; r = r0; } request(int type0, int x0, int y0, int val0) { type = type0; x = x0; y = y0; val = ... |
#include <bits/stdc++.h> using namespace std; int main() { string val; cin >> val; int cngIn1 = -1; int lDigit = int(val[val.length() - 1] - 0 ); for (int i = val.length() - 2; i >= 0; i--) { int dig = int(val[i] - 0 ); if ((dig % 2 == 0) && (dig < lDigit)) { cngIn1 = i; ... |
#include <bits/stdc++.h> using namespace std; int n, m[100005], a[100005]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); m[i] = a[i] + 1; } long long ans = 0; for (int i = n - 1; i >= 1; --i) m[i] = max(m[i], m[i + 1] - 1); for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; template <class T> void in(T &a) { for (auto &x : a) cin >> x; } template <class T> void out(T &a, string sep = ) { for (auto x : a) cout << x << sep; cout << n ; } template <class T> void err(T &a, string sep = ) { for (auto x : a)... |
#include <bits/stdc++.h> using namespace std; int main() { int a, x, y, lev; cin >> a >> y >> x; a *= 2; x *= 2; y *= 2; if (x % a == 0) { cout << -1; return 0; } else lev = (x / a) + 1; if (lev == 1) if (abs(y) >= a / 2) { cout << -1; return 0... |
#include <bits/stdc++.h> int main(void) { char s[30], t[30], s1[30], s2[30]; scanf( %s %s , s, t); int i = 0, c1 = 0, c2 = 0, c3 = 0; while (s[i] != | ) { s1[c1++] = s[i]; i++; } i++; while (s[i] != 0 ) { s2[c2++] = s[i]; i++; } i = 0; while (t[i++] !... |
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void outarr(Tp _begin, Tp _end, const char* _delim = ) { for (Tp current = _begin; current != _end; ++current) { std::cout << *current << _delim; } std::cout << n ; } using ll = long long; using pii = std::pai... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans(0); cin >> n; int h[n], a[n]; for (int i = 0; i < n; i++) { cin >> h[i] >> a[i]; } for (int b = 0; b < n; b++) { for (int c = 0; c < n; c++) { if (c != b) { if (h[b] == a[c]) ans++; } ... |
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; long long inv(long long a) { long long p = md - 2; long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % md; a = a * a % md; p >>= 1; } return ret; } int mp[1010][1010]; int xn[2100], yyyn... |
#include <bits/stdc++.h> using namespace std; int x[7]; int y[7]; bool inside1(float x1, float y1) { if (x1 + .5 >= x[3] && x1 + .5 <= x[4] && y1 + .5 >= y[3] && y1 + .5 <= y[4]) return 1; return 0; } bool inside2(float x1, float y1) { if (x1 + .5 >= x[5] && x1 + .5 <= x[6] && y1 + .5 >= y... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.