func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); unsigned long long c = 0; short p; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> p; c += p; } cout << setprecision(14) << ((double)c / n); } |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, m, n, k, a[1100], b[1100][10], count = 0; cin >> n >> m >> k; for (i = 0; i <= m; i++) a[i] = 10000000; for (i = 1; i <= n; i++) { for (j = 0; j < 2; j++) cin >> b[i][j]; if (a[b[i][0]] > b[i][1]) a[b[i][0]] = b[i][1]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; char c[101][101]; cin >> a >> b; for (int i = 1; i <= a; i++) { for (int j = 1; j <= b; j++) { if (i % 2 != 0) { c[i][j] = # ; } } } for (int i = 2; i <= a; i += 4) { for (int j ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T, class U> using Pa = pair<T, U>; template <class T> using vec = vector<T>; template <class T> using vvec = vector<vec<T>>; bool chmax(int &a, int b) { if (a < b) { a = b; return true; } return... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; vector<long long> vis(n + 1, 0); vector<long long> res(n); vector<long long> v; int b; cin >> b; v.push_back(b); int cur = 1; ... |
#include <bits/stdc++.h> int main() { char a[100010]; scanf( %s , a); long long i = 0, x = 1; while (a[i] != 0 ) { if (a[i] == 0 ) { a[i] = 2 ; x = 0; break; } i++; } if (x) { a[0] = 2 ; } i = 0; while (a[i] != 0 ) { if (... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << { << p.first << , << p.second << } ; return os; } template <class T> ostream& operator<<(ostream& os, const vector<T>& p) { os << [ ; int i = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, k; cin >> n >> k; vector<int> v(n); int itr = 1; for (int& x : v) { cin >> x; } set<int> bag{0}, tmp; map<int, vector<int>> pep; for (int i = 0; i < n && b... |
#include <bits/stdc++.h> using namespace std; char str[1000005]; int ar[1000005]; void solve() { int n = (int)strlen(str + 1), i, j, ans = 0; memset(ar, 0, sizeof(ar)); str[0] = 0 ; for (i = n; i >= 0; i--) { if (str[i] == 1 ) { j = i; while (str[j] == 1 ) --j; i... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; reverse(t.begin(), t.end()); for (int i = 0; i < s.size(); i++) { if (s[i] != t[i]) { cout << NO ; return 0; } } cout << YES ; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, sum1 = 0; int x; cin >> n; for (int i = 0; i < (int)n - 1; ++i) { cin >> x; sum += x; } for (int i = 1; i <= n; i++) sum1 += i; cout << sum1 - sum << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int A[26]; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) s[i] = tolower(s[i]); for (int i = 0; i < n; i++) { if (!A[s[i] - a ]) { A[s[i] - a ] = 1; ++cnt; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, gn1 = 0, gj1 = 0, gn2 = 0, gj2 = 0; cin >> n >> m; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) gn1++; else gj... |
#include <bits/stdc++.h> using namespace std; ifstream fin( universal.in ); ofstream fout( ); int n, m; set<int> on; int main() { cin >> n >> m; for (int i = 1; i <= n; ++i) { int aux; cin >> aux; for (int j = 1, bb; j <= aux; ++j) { cin >> bb; on.insert(bb); ... |
#include <bits/stdc++.h> using namespace std; int main() { int p, i, j; scanf( %d , &p); int n = 1 << (p + 1); vector<int> a(n); for (i = 2; i < n; i++) scanf( %d , &a[i]); vector<int> up(n), mx(n); for (i = 1; i < n; i++) { int sum = 0; for (j = i; j > 1; j /= 2) sum += a[j]... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long n, k; long long POW(long long a, long long n) { if (!n) return 1; long long ans = 1; while (n) { if (n & 1) ans = ans * a % mod; n >>= 1; a = a * a % mod; } return ans; } int main() {... |
#include <bits/stdc++.h> using namespace std; long long check, tn, tm, maxn; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long exgcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1, y = 0; return a; } long long d = exgcd(b, a ... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e5 + 10; inline long long po(long long a, long long p, long long mod) { long long r = 1; for (; p; p >>= 1, a = a * a % mod) if (p & 1) r = r * a % mod; return r; } const long long mod1 = 1e9 + 7; const long long mod2 = 1e9 +... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3f; long long dx[] = {0, 1, 1, 1, 0, -1, -1, -1}; long long dy[] = {1, 1, 0, -1, -1, -1, 0, 1}; struct BipartiteMatcher { vector<vector<long long>> G; vector<long long> L, R, Viz; BipartiteMatcher(long long n, long... |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define fill0(a) memset(a,0,sizeof(a)) #define fill1(a) memset(a,-1,sizeof(a)) #define fillbig(a) memset(a,63,sizeof(a)) #define pb push_back #define ppb pop_back #define mp make_pair #define mt make_tuple #define epr... |
#include <bits/stdc++.h> using namespace std; template <typename T> struct fenwick_tree { int tree_n = 0; T tree_sum = 0; vector<T> tree; fenwick_tree(int n = -1) { if (n >= 0) init(n); } void init(int n) { tree_n = n; tree_sum = 0; tree.assign(tree_n + 1, 0); }... |
#include <bits/stdc++.h> using namespace std; int dp[105][2005]; int main() { memset(dp, -1, sizeof(dp)); int v1, v2, t, d; cin >> v1 >> v2 >> t >> d; dp[1][v1] = v1; for (int i = 1; i < t; i++) for (int j = 0; j < 2005; j++) if (dp[i][j] != -1) for (int k = -d; k <= d;... |
#include <bits/stdc++.h> using namespace std; const long long INF = 9223372036854775807ll; const long long dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, inf = 2147483647, nmax = 300005; struct trip { long long a, b, c; }; long long n, m, s[nmax]; vector<pair<long long, long long> > neg... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vii = vector<int>; using pii = pair<int, int>; template <typename T = vii> using vec = vector<T>; const ll INF = 1e18, MOD = 998244353; const int MAX = 1e6; ll ft[MAX + 1]; void cf() { ft[0] = 1; ... |
#include <bits/stdc++.h> int main() { int n, m; scanf( %d%d , &n, &m); if (n % 2 == 0) printf( %d n , n / 2 * m); else printf( %d n , n / 2 * m + m / 2); return 0; } |
#include <bits/stdc++.h> using namespace std; long long T, n, tempur; int t[105], l[105], h[105]; int main() { cin >> T; while (T--) { memset(t, 0, sizeof t); memset(h, 0, sizeof h); memset(l, 0, sizeof l); cin >> n >> tempur; int maxn = tempur, minn = tempur; for (in... |
#include <bits/stdc++.h> using namespace std; signed main() { long long N, B; cin >> N >> B; vector<long long> res(N, -1); queue<pair<long long, long long> > Q; long long endTime = -1; for (long long i = 0; i < N; i++) { long long t, d; cin >> t >> d; while (endTime <= t) {... |
#include <bits/stdc++.h> using namespace std; int N; int A[100005]; int psm[100005]; int DP[100005][20]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; psm[i] = (psm[i - 1] + A[i]) % 10; } for (int d = 1; d <= 1... |
#include <bits/stdc++.h> using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; const int N = 2002, NN = 502, mod = 1e9 + 7, mod1 = 1e9 + 9, Base = 317, Base1 = 371; int n, K, pw[NN], pw1[NN], lcp[N], mn[N][11], id[N]; string s[N]; struct Hash { ... |
#include <bits/stdc++.h> using namespace std; int n; int k; int main() { cin >> n >> k; int l = (n - 1) / k * 2 + ((n - 1) % k != 0) + ((n - 1) % k >= 2); cout << l << endl; for (int i = 1; i < n; i++) { if (i <= k) cout << i + 1 << << 1 << endl; else cout << i + ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5, mod = 1e9 + 7, inf = 1e18; long long n, q, a[maxn], mx[2ll][maxn]; pair<long long, long long> dp[2ll][maxn]; void cal_mx0(long long x) { long long l = n - 1ll, sum = a[n]; for (long long i = n; i > 0; i--) { if (l == 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char a[2 * n - 1][2 * n - 1]; int v = 0, k = n; for (int i = 0; i < n; i++, k--, v++) { for (int j = 0; j < k; j++) printf( ); for (int j = 0; j < v; j++) printf( %d , j); printf( %d , v); for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, m, k, ans = 0; cin >> n >> m >> k; vector<int> a(n + 1), b(n + 1), c(k + 1); for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= k; i++) ci... |
#include <bits/stdc++.h> using namespace std; uint64_t mat[5][5] = {{0, 0, 1, 0, 0}, {1, 0, 1, 0, 0}, {0, 1, 1, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 1, 1}}; uint64_t ex[5][5] = {{0, 0, 0, 0, 0}, {0,... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAXN = 205; const int infint = 1e9; const long long inf = 1e18; const int K = 26; long long n, l, a[MAXN], nxt[MAXN][K], used[MAXN]; string s[MAXN]; struct Vertex { int next[K]; bool leaf = false; long long va... |
#include <bits/stdc++.h> using namespace std; int low(int a) { if (a == 1) { return 0; } return 1; } int main() { int t; cin >> t; string s; cin >> s; stack<char> st; st.push(s[0]); int c = 0; for (int i = 1; i < t; i++) { if (st.top() == s[i]) { c... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; int from[N], to[N]; int main() { cin.tie(NULL); ios_base::sync_with_stdio(0); int n, m; cin >> n >> m; vector<pair<int, int> > mst; set<pair<int, int> > freeEdges; for (int i = 0; i < (int)(m); ++i) { int w, isMST... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k; scanf( %d , &t); while (t-- && scanf( %d %d , &n, &k)) { if ((k & 1) == (n & 1) && (long long)(k)*k <= n && n >= k) printf( YES n ); else printf( NO n ); } return 0; } |
#include <bits/stdc++.h> using namespace std; int dp[128][128][15]; int board[128][128]; int dy[] = {-1, 1}; int N, M, K; int solve(int x, int y, int k) { if (dp[x][y][k] != -2) return dp[x][y][k]; if (x == 0) { if (board[x][y] % K == k) return dp[x][y][k] = board[x][y]; else ... |
#include <bits/stdc++.h> using namespace std; int gr[110][110]; int main() { int n, m, a[110], b[100]; cin >> n >> m; int nn = 0; int mm = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); nn ^= a[i]; } for (int i = 0; i < m; i++) { scanf( %d , &b[i]); mm ^= ... |
#include <bits/stdc++.h> using namespace std; inline int Get() { int res = 0, q = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) q = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) res = res * 10 + ch - 0 , ch = getchar(); return res * ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; vector<long long> fib = {1, 2}; map<pair<long long, long long>, long long> dp; long long f(long long n, int j) { if (fib[j] > n) return 0; if (fib[j] == n) return 1; long long tot = 0; for (int j2 = 0; j2 < j; j2++) { ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n; scanf( %d , &n); vector<vector<int> > p(n); for (int i = 0; i < n; i++) { int sz; scanf( %d , &sz); p[i].resize(sz); for (int j = 0; j < sz; j++) scanf( %d , &p[i][j]); } for (int i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; string s; getline(cin >> ws, s); string one = 1 , two = 1 ; int prevOne = 1, prevTwo = 1; for (i... |
#include<bits/stdc++.h> #define y1 dmytxdy #define pb push_back #define fi first #define se second #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; template <typ... |
#include <bits/stdc++.h> using namespace std; char str1[100 + 10], str2[100 + 10]; int main() { int m, s; while (~scanf( %d%d , &m, &s)) { for (int i = 0; i < m; i++) str1[i] = str2[i] = 0 ; int ss = s; if (m == 1 && s == 0) { printf( 0 0 n ); continue; } if ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int m; cin >> n >> m; vector<vector<bool>> arr(n, vector<bool>(m, 0)); long long int answ = 0; vector<int> hor(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int temp; cin >> temp;... |
#include <bits/stdc++.h> char a[1005], b[1005]; int alen, blen, cnt1, cnt2; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } void work(int t) { int i; for (i = 0; i < t; i++) switch (a[i % alen] - b... |
#include <bits/stdc++.h> using namespace std; using int64 = long long; int main() { string s; cin >> s; int v[26] = {}; for (auto &c : s) v[c - a ]++; deque<int> odd; for (int i = 0; i < 26; i++) { if (v[i] % 2 == 1) odd.emplace_back(i); } while (odd.size() >= 2) { int... |
#include <bits/stdc++.h> using namespace ::std; const long double PI = acos(-1); const long long MOD = 1000000000 + 7; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long add(long long a, long long b, long long m = MOD) { return (a % m + b % m + 2 * m) % m; } long ... |
#include <bits/stdc++.h> int debugnum = 0; using namespace std; const long long MOD = 998244353; inline long long add(long long a, long long b) { return (a + b) % MOD; } int toint(bitset<10> bs) { int ret = 0; for (int i = 9; i >= 0; i--) { ret = (ret << 1) | bs[i]; } return ret; } l... |
#include <bits/stdc++.h> using namespace std; int n, ans1 = 0, ans2 = 0, x, y; char s[1100], m[1100]; int main() { scanf( %d , &n); scanf( %s%s , s, m); sort(s, s + n); sort(m, m + n); x = y = 0; while (x < n && y < n) { if (m[y] >= s[x]) { x++; y++; } else ... |
#include <bits/stdc++.h> using namespace std; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void minus1(string &s) { long long i = (long long)s.size() - 1; while (i >= 0 && s[i] == 0 ) { s[i] = 9 ; --i; } --s[i]; if (i == 0 && s[i] ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } template <typename T> T gcd(const T a, const T b) { return b ? gcd(b, a % b) : a; } templa... |
#include <bits/stdc++.h> using namespace std; const int N = 15e4 + 5; const int M = 3e2 + 5; const long long NINF = -1e12 + 5; long long dp[2][N], a[M], b[M], t[M], n, m, d, interval, curr, nxt; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> d; for (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d%d , &n, &k); if ((n * (n - 1)) / 2 < k * n) { printf( -1 n ); return 0; } printf( %d n , n * k); for (int i = 0; i < n; ++i) { for (int j = i + 1, q = 0; q < k; ++q, ++j) { if (j == n) j ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; a[i] += i; } sort(a.begin(), a.end()); for (int i = 0; i < n; i++) { a[i] -= i; if (i && a[i] < a[i - 1]) { cout << :(... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == W && s[i + 1] == U && s[i + 2] == B ) { s.erase(i, 3); i--; cout << ;... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; } int main() { ios::sync_with_stdio(false); cin.tie(0); string s... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXK = 55, MAXN = 111; int K, X, N, M; int second[MAXK], F[MAXK]; long long tmemo[MAXK]; long long times(int k) { if (k < 2) return tmemo[k]; times(k - 1); if (tmemo[k - 1] > X) return tmemo[k] = tmemo[k - 1]; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long rowNum[] = {-1, 0, 0, 1}; long long colNum[] = {0, -1, 1, 0}; int main() { int n, d, h; cin >> n >> d >> h; if (d > n - 1 || d < h || d > 2 * h || (n > 2 && h < 2 && d == h)) { cout << -1 n ; ret... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int M = 1e5 + 10; int n, m, vis[M * 12], ans[M * 12], tot; vector<int> vt[10][M * 12], tmp; vector<vector<int> > now, nxt; void add(int x, int y, int id) { while (id / 10) vt[id % 10][++tot].push_back(y), y = tot, id /= 10; ... |
#include <bits/stdc++.h> using namespace std; int N, M, C; vector<pair<int, pair<int, int> > > V; int A[505][505], R[505]; int main() { int x, y, t; scanf( %d %d , &N, &M); memset(A, 40, sizeof A); for (int i = 1; i <= M; i++) { scanf( %d %d %d , &x, &y, &t); A[x][y] = A[y][x] = t;... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; long long int dp[5001][5001]; long long int f[5001]; long long int power(long long int x, long long int b) { long long int res = 1; while (b) { if (b & 1) res = res * x % mod; x = x * x % mod; b >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s; cin >> s; set<char> S; int ans = 0; for (int i = 0; i <= s.size(); ++i) { if (i == s.size() || isupper(s[i])) { ans = max(ans, (int... |
#include <bits/stdc++.h> using namespace std; int a[100000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int cnt = 0; if (a[0] != 0) cnt = 1; for (int i = 1; i < n; i++) { if (a[i] != 0) { if (a[i] != a[i - 1]) cnt++; } ... |
#include <bits/stdc++.h> using ll = int; const ll mod = 1e15 + 7; const ll N = 1e5 + 5; const int base = 400; using ull = unsigned long long; using namespace std; ll n, m, t, k, T, a[N], dp[N], lab[N], u, v, b[N], d[N], tong, cnt, q, fe[N], f[N][20], g[N][20], h[N], P[N][20]; ll ans; vector<ll> ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a, b, c, d; cin >> t; while (t--) { cin >> n >> a >> b >> c >> d; int diff = n * (a - b), sum = n * (a + b); if ((diff > c + d) || (sum < c - d)) cout << No << endl; else cout << Yes << endl;... |
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long p, q; cin >> p >> q; if (p % q != 0) cout << p << endl; else { long long x = q; long long ans = 1; for (long long i... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 200005, INF = 1000000009; struct ban { int x, y; }; bool operator<(const ban& a, const ban& b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long arr[N], dp[N], n; long long go(int indx) { if (indx == n) return 0; long long &ret = dp[indx]; if (~ret) return ret; long long sum = arr[indx], j = indx + 1; while (j != n && arr[j] == arr[indx]) sum += arr[j++]; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; long long n, m, q; int main() { scanf( %lld%lld , &n, &q); while (q--) { long long x; scanf( %lld , &x); while (1) { if (x & 1) break; x = x + (n - x / 2); } cout << x / 2 + 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e8 - 3; struct Data { int a, i; bool operator<(const Data& d) const { if (a == d.a) { return i < d.i; } return a < d.a; } }; const int N = 1e5 + 10; int C[N]; int lowbit(int first) { return first & -first;... |
#include <bits/stdc++.h> using namespace std; const int MN = 1000111; int n; pair<int, int> a[MN], b[MN]; int main() { ios ::sync_with_stdio(0); cin.tie(0); while (scanf( %d , &n) == 1) { for (int i = (1), _b = (n); i <= _b; ++i) { scanf( %d , &a[i].first); a[i].second = i; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 10; const long double EPS = 1e-9; double a[MAXN][MAXN]; double x[MAXN]; int answer[MAXN], X[MAXN]; int ans; int n, m; int main() { for (int i = 1; i < 8; i++) { int v[4]; for (int j = 0; j < 4; j++) v[j] = (i & (1 << (3 - j... |
#include <bits/stdc++.h> using namespace std; int n, v0, f[200012], nu = 0; struct eve { int x, v, l; inline bool operator<(const eve &b) const { return (x < b.x) || ((x == b.x) && (v < b.v)); } }; multiset<eve> s; inline void cha(int x, int v) { f[x] = v; if (v + v0 <= 1e9) s.inse... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long modpow(long long x, long long y, long long m) { long long z = 1; while (y) { if (y & 1) z = (z * x) % m; x = (x * x) % m; y >>= 1; } return z; } int egcd(int a, int b, int& x, int& y) { if (a... |
#include <bits/stdc++.h> void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int max(int a, int b) { return (a > b) ? a : b; } int main() { int t, n, k, a[1005], b[1005]; scanf( %d , &t); while (t--) { int total = 0; scanf( %d %d , &n, &k); for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; long long int j, k, n; int main() { long long int q; string x, y; map<string, string> m; map<string, string>::iterator it; cin >> q; while (q--) { cin >> x >> y; if (m.count(x)) { string z; z = m[x]; m.erase(... |
#include <bits/stdc++.h> using namespace std; int arr[200010]; string s; int main() { int t, n; cin >> t; while (t--) { cin >> n; cin >> s; for (int i = 0; i < n; i++) { arr[i] = s[i] - 0 ; } int cur1, cur2, ans, ind; for (int i = 0; i <= 10; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, dif, l; int a[N], f[N], g[N]; deque<int> dmax, dmin, df; void Push(int x) { while (!dmax.empty() && a[dmax.back()] <= a[x]) dmax.pop_back(); dmax.push_back(x); while (!dmin.empty() && a[dmin.back()] >= a[x]) dmin.pop_back... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( avx,avx2 ) using namespace std; const long double eps = 1e-6; long double inf = 0; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { ... |
#include <bits/stdc++.h> using namespace std; long long A[50]; int main() { long long n; A[0] = A[1] = 1; scanf( %lld , &n); for (long long i = 1; i <= 50; ++i) { A[i] = A[i - 1] * i; } long long ans = A[n] / A[n / 2] / A[n / 2] / 2; ans *= A[n / 2 - 1] * A[n / 2 - 1]; printf... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0; char ch = getchar(); bool f = 0; for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = 1; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; return f ? -x : x; } void write(long long ... |
#include <bits/stdc++.h> using namespace std; int N; string S; void precompute() { int cur = 1; while ((int)S.size() <= 1000) { int x = cur++; string tmp; while (x > 0) { tmp.push_back(x % 10 + 0 ); x /= 10; } for (int i = (int)tmp.size() - 1; i >= 0; i--) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; const long long mod = 1000000000 + 7; struct node { int l, r; mutable long long v; node(int L, int R = -1, long long v = 0) : l(L), r(R), v(v){}; bool operator<(const node &x) const { return l < x.l; } }; long long q... |
#include <bits/stdc++.h> using namespace std; int n; long double V; long double vx[111111], vy[111111]; int m, N; struct point { long double x, y; bool operator<(const point &b) const { return (x != b.x) ? (x < b.x) : (y > b.y); } } ans[111111], a[111111]; pair<long double, int> k[1111... |
#include <bits/stdc++.h> using namespace std; void OJ() {} void solve() { string s; cin >> s; string temp = ; int alice = 0, flag = 0, l; while (1) { int cnt = 0, mx_cnt = 0, mx_l = -1, mx_r = -1, d_l = -1; l = s.size(); for (int i = 0; i < l; i++) { if (s[i] == 0 ... |
#include <bits/stdc++.h> using namespace std; using cat = long long; struct edge { int u, v, id; }; int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int N, M, K; cin >> N >> M >> K; vector<int> W(N), D(N, 0); for (int i = 0; i < N; i++) cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); for (int i = 0; i <= s.length() - 1; i++) { if (s[i] == . && s[i - 1] == 9 ) { cout << GOTO Vasilisa. ; return 0; } if (s[i] == . && s[i + 1] < 5 ) { for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; struct node { int ch[27], len, fa; } dian[N]; struct edge { int v, nxt; } e[N]; int n, q, head[N], cnt, las = 1, tot = 1, fl[N], pos[N], ot, x, m, ans; char s[N], t[N]; void ad(int u, int v) { e[++cnt].v = v; e[cnt].nx... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long MOD = 998244353; template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); } template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); } template <typen... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; const int M = 2e6 + 7; long long g[M], q[M]; int n, a[N]; void push(int v, int lr, int rl) { g[v << 1] += q[v]; g[v << 1 | 1] += q[v]; q[v << 1] += q[v]; q[v << 1 | 1] += q[v]; q[v] = 0; } void upd1(int v, int lr, i... |
/*─────────▄▄▄▄▄▄▄▄▄▄▄▄▄ ────────▄▀▀─────────────▀▀▄ ───────█───────────────────█ ──────█─────────────────────█ ─────█───▄▄▄▄▄▄▄───▄▄▄▄▄▄▄───█ ────█───█████████─█████████───█ ────█──██▀────▀█████▀────▀██──█ ───██████───█▀█─███───█▀█─██████ ───██████───▀▀▀─███───▀▀▀─██████ ────█──▀█▄────▄██─██▄────▄█▀─... |
#include <bits/stdc++.h> using namespace std; int N; pair<int, int> a[200002 + 1]; int min(int a, int b) { return a > b ? b : a; } int abs(int a) { return a < 0 ? -a : a; } int main() { cin >> N; N *= 2; int b; for (int i = 0; i < N; i++) { cin >> b; a[i] = {b, i}; } sort... |
#include <bits/stdc++.h> using namespace std; vector<char> a; int x, y, n; void update(pair<int, int> &pos, int i, int d) { if (a[i] == U ) pos.second += d; else if (a[i] == D ) pos.second -= d; else if (a[i] == R ) pos.first += d; else pos.first -= d; } bool ok(pa... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmin(T &a, T b) { if (a > b) a = b; } template <class T> inline void chkmax(T &a, T b) { if (a < b) a = b; } int main() { int N, x, M, y, d, len1, len2, len, r1, r2, r, i; long long ans; scanf( %d%d%d%d , ... |
#include <bits/stdc++.h> const int N = 1e5 + 5; const int M = 1e3 + 10; const int mod = 9973; using namespace std; long long m, n, x, y, l, r, t, a1, r1, a2, r2; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } void e_gcd(long long a, long long b, long long &g, long long &x, long ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.