func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return abs(a.first) + abs(a.second) < abs(b.first) + abs(b.second); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int>> q1; vector<pair<int, i... |
#include <bits/stdc++.h> using namespace std; const int N = 2007; set<pair<int, int> > E[N]; struct edge { int x, y; } e[N]; int n, rk[N], mxrk, mxid; void adde(int x, int y, int i) { E[x].insert(make_pair(y, i)), E[y].insert(make_pair(x, i)); } void dele(int i) { int x = e[i].x, y = e[i].... |
#include <bits/stdc++.h> using namespace std; long long bin_pow(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 0) { long long t = bin_pow(a, b / 2); return t * t % 1000000007; } else return a * bin_pow(a, b - 1) % 1000000007; } vector<long long> a; int main() { ... |
#include <bits/stdc++.h> using namespace std; vector<int> graph[5001]; bool subset[5001][5001]; set<pair<int, int>> ans_pairs; vector<int> child_nodes(5001, -1); int total_nodes; void insert_into_answer(int network1, int network2) { if (network1 != 0 && network2 != 0) { ans_pairs.insert({network... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int e = max(c, d); if (e > 2 * c || e > 2 * d || e >= b) { cout << -1; return 0; } cout << 2 * a << endl << 2 * b << endl << e; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string str; int n; cin >> n; cin.ignore(); getline(cin, str); int l = 0, r = n - 1; while (l < n && str[l] == 0 ) { l++; } while (r >= 0 && str[r] == ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k, l; cin >> n >> k; vector<int> barrel; for (int i = 0; i < n; i++) { cin >> l; barrel.push_back(l); } sort(barrel.begin(), barrel.end()); long long... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; char buf[100000]; vector<pair<int, string> > vp; int b[maxn], n, m; pair<int, string> me; int getL() { int tx = 0, ret = 1; if (m == n) { me.first -= b[0]; tx = 1; } for (int i = 0; i < (int)vp.size(); i++) ... |
#include <bits/stdc++.h> using namespace std; struct edge { int x, y, d, r; bool operator<(edge const &T) const { return d < T.d; } }; int n, t, ed, x, y; int v[100005], b[100005], p[100005], s[100005], l[100005], qd[100005 + 100005], qn[100005 + 100005], qr[100005 + 100005]; long long int sum... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; int promena[3002]; long long d[3001], s[3002][3002], pom; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int j, n, i, x, p; cin >> n; for (i = 0; i < n; i++) { cin >> x >> p; v... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long int n; cin >> n; long long int a[n]; map<long long int, long long int> mp; for (long long int i = 0; i < n; i++) { cin >> a[i]; mp[a[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; inline int setBit(int N, int pos) { return N = N | (1 << pos); } inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); } inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); } int A[400000 + 10]; vector<int> nxt[400000 + 10]; int i... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100 + 3; int n, m, k, ns[MAX]; long long dp[MAX][MAX][MAX], cs[MAX][MAX]; long long solve(int cur = 0, int pre = 0, int rem = k) { if (cur == n && rem == 0) return 0; if (rem < 0 || (cur == n && rem != 0)) return 1e18; long long &ret = ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, i, count = 0; vector<long long int> v; string s1, s2, s3, reverses1, reverses2, reverses3; cin >> s1 >> s2 >> s3; reverses1 = s1; reverses2 = s2; reverses3 = s3; reverse(s1.begin(), s1.end()); reverse(s... |
#include <bits/stdc++.h> using namespace std; const long long INF = 3e18 + 100; const int MOD = 1e9 + 7; const int N = 100; int32_t main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); int n; cin >> n; set<int> s, tot; vector<int> a(n + 5, 0), cnt(n + 5, 0), la... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, cnt; string s; map<int, pair<int, int> > mapp; cin >> n; cin >> s; cnt = 0; int maxm = 0; for (i = 0; i < n; i++) { if (s[i] == 0 ) cnt--; else cnt++; if (mapp.find(cnt) == mapp.en... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const vector<int> mods = {998244353, 1000000007, 1000000009}; const long long inf = 3e18; const double pi = acos(-1.0); const double eps = 0.0000001; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <c... |
#include <bits/stdc++.h> using namespace std; const int N = 2200000; int chk[N]; int main() { ios_base::sync_with_stdio(0); int cnt = 0, n, m; cin >> n >> m; for (int i = 0; i < n; i++) if (!chk[i]) { for (int j = i; (j < n && chk[j] < 2) || (j >= n && chk[n + n - 2 - ... |
#include <bits/stdc++.h> using namespace std; int a[55][55]; const int MAX = 1e3 + 5; const int INF = 0x3f3f3f3f; int color; int A[MAX][MAX]; int A1[MAX][MAX], A2[MAX][MAX]; int N; int DX[2] = {0, 1}, DY[2] = {1, 0}; int NOW1[4], NOW2[4]; int X1, Y1, X2, Y2; bool FLAG = false; bool VIS[MAX][MA... |
#include <bits/stdc++.h> int main() { int n, i, b; while (scanf( %d , &n) != EOF) { int j = 0, str[10001] = {0}, total = 0; for (i = 0; i < n; i++) { scanf( %d , &b); if (str[b] == 0) ++total; ++str[b]; if (str[b] > j) j = str[b]; } printf( %d %d n , j, ... |
#include <bits/stdc++.h> using namespace std; double eps = 1e-6; double pi = acos(0.0) * 2; double dinf = 1e250; long long INF = static_cast<long long>(2e18); long long inf = static_cast<long long>(1e9 + 7); long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <class T> v... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long n, x, y, a, b, c, t, q; string s; while (cin >> n >> q) { if ((n / q) % 2 == 0) { cout << NO << endl; } else cout << YES ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[100001], l = 1; for (int i = 1; i <= n; i++) { int c, t; cin >> c >> t; int x = c * t; a[l] = c * t; l++; } int d = 1, s = 0; for (int i = 0; i < m; i++) { int k;... |
#include <bits/stdc++.h> using namespace std; void OJ() {} long long n, m, x, k, y; long long a[200000 + 5], b[200000 + 5]; void imp() { cout << -1 << n , exit(0); } long long remove(long long start, long long end) { if (start > end) return 0; long long sz = end - start + 1; long long maxneb =... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } const int N = 100005; void solve() { long long n; cin >> n; long long ans = 1; for (long long i =... |
#include <bits/stdc++.h> using namespace std; struct ton { vector<pair<long long, long long> > v[1919810 + 3]; long long& operator()(long long a, int b, int c, int d) { a = ((a * 4000ll + b) * 4000ll + c) * 3ll + (d == 1); int k = a % 1919810; for (auto u = v[k].begin(); u != v[k].end(); u... |
#include <bits/stdc++.h> using namespace std; char dirs[100001]; int todo[4]; int main() { int n, fx, fy, tx, ty; string wind; cin >> n >> fx >> fy >> tx >> ty >> wind; memcpy(dirs, wind.c_str(), n); memset(todo, 0, sizeof(todo)); if (fx < tx) todo[0] = tx - fx; if (fy < ty) todo[3] ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, p; cin >> t; for (; t > 0; t--) { cin >> n >> p; int br = 0; for (int r = 1; r <= n; r++) { for (int i = 1; i <= n; i++) { cout << i << << (i + r - 1) % n + 1 << endl; br++; i... |
#include <bits/stdc++.h> using namespace std; long long int div_floor(const long long int &a, const long long int &b) { return a / b - (((a ^ b) < 0) and a % b); } long long int div_ceil(const long long int &a, const long long int &b) { return a / b + (((a ^ b) >= 0) and a % b); } long long int diff... |
#include <bits/stdc++.h> using namespace std; int n; int a[111]; int vv(int k) { int i, j; j = 0; for (i = 1; i < k; i++) if (a[i] == 0) j++; for (i = k; i <= n; i++) if (a[i] == 1) j++; return j; } int main() { cin >> n; int i, j, k; for (i = 1; i <= n; i++) cin ... |
#include <bits/stdc++.h> using namespace std; int n; long long a[30]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long now = a[n - 1]; long long ans = 0; for (int i = n - 1; i >= 0; i--) { now = min(now, a[i]); ans += now... |
#include <bits/stdc++.h> using namespace std; string s; int num_e = 1e9 + 10, num_m, ans, w, q; string answer; void read_input() { cin >> s; } void solve() { for (int i = 0; i < s.size(); i++) { if (s[i] == e ) num_e = i; if (s[i] == . ) num_m = i; } string s2 = ; for (int i ... |
#include <bits/stdc++.h> using namespace std; long long n, a, b; long long arr[1000002]; long long dp[1000002][3]; set<int> prime; int main() { ios::sync_with_stdio(false); cin >> n >> a >> b; for (int i = 0; i < n; ++i) cin >> arr[i]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < ... |
#include <bits/stdc++.h> using namespace std; const bool online_judge = true; const long long inf = 1LL << 60; long long toInt(string s) { long long res; stringstream ss; ss << s; ss >> res; return res; } string toString(long long n) { stringstream ss; ss << n; return ss.str(... |
#include <bits/stdc++.h> int const M = 1010000; int const N = 10100; int n; int len[N]; int x[N]; int y[N]; int sq[M]; int perm[N]; double angle[N]; int resx[N]; int resy[N]; void filllens() { std::fill(sq, sq + M, -1); for (int i = 0; i * i < M; ++i) { sq[i * i] = i; } int... |
#include <bits/stdc++.h> using namespace std; int _; long long a1, a2, b1, b2, c1, c2; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2; if ((c2 - b2) * (c1 - a1) == (c2 - a2) * (c1 - b1)) { cout << No ; } else if ((a1 - b1) * (a1 - b1) + (... |
#include <bits/stdc++.h> using namespace std; const int oo = ~0u >> 1; int n, m, a, ans; int b[100015], p[100015]; bool check(int x) { int sum = 0; ans = 0; for (int i = 0; i < x; i++) { sum += max(p[x - i - 1] - b[i], 0), ans += p[x - i - 1]; if (sum > a) break; } if (sum <= a... |
#if !defined(ONLINE_JUDGE) #include prettyprint.hpp #include debug.h #else #include <bits/stdc++.h> using namespace std; #define deb(...) 1729 #define dbg(...) 29 #define cer(x) 13 #endif const bool testcase = 1; typedef long long int ll; const ll mod1 = 10000000... |
#include <bits/stdc++.h> using namespace std; int question, r, speed, st, en, len, did; double lft, rht, middle, dist, p; inline double euclid_dist(double a, double b) { return sqrt(a * a + b * b); } inline bool check(double dis) { p = 1.0 * dis / r; return r * euclid_dist(1 - cos(p), sin(p)) >= len -... |
#include <bits/stdc++.h> using namespace std; const int MAXP = 18; const int MAXN = 1000001; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, p; string cad; int freq[MAXP]; int val[1 << MAXP]; int vis[1 << MAXP]; vector<pair<int, int> > lista[1 << MAXP]; bool mat[MAXP][MAXP]; bool ... |
#include <bits/stdc++.h> using namespace std; int ch[101]; int main() { int n, pos; cin >> n; for (int i = 0; i < n / 2; i++) { cin >> ch[i]; } sort(ch, ch + (n / 2)); int black = 0; pos = 1; for (int i = 0; i < n / 2; i++) { black += abs(ch[i] - pos); pos += 2; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; char s[200000], c[200000]; cin >> s; int x = k / 2, r = k / 2; if (k == n) { cout << s; return 0; } for (int i = 0, j = 0; i < n; ++i) { if (s[i] == ( ) { if (x > 0) c[j++] ... |
#include <bits/stdc++.h> using namespace std; long long re() { long long x; scanf( %lld , &x); return x; } int main() { long long y1 = re(), x1 = re(), y2 = re(), x2 = re(); long long h = (x2 - x1) / 2 + 1; cout << h * (((y2 - y1 + 1) + 1) / 2) + (h - 1) * ((y2 - y1 + 1) / 2) << endl; ... |
#include <bits/stdc++.h> using namespace std; using li = long long; int get_num(string s) { istringstream is(s); int x; if ((is >> x) && to_string(x) == s) return x; return -1; } void solve(bool read) { int n; cin >> n; vector<pair<string, int>> s(n); int n_e = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; long long tot, n, q, u, v, z, a, b, c, p, k; long long dep[200005], f[200005][25], fa[200005], va[200005]; struct edge { long long from, head, nxt, val, go; } e[200005 * 4]; long long find(long long x) { long long o = x; while (x != fa[x]) x = fa[x] ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, p, c = 0; cin >> n >> k; vector<int> v; map<int, int> m; for (int i = 1; i <= n; i++) { cin >> p; v.push_back(p); m[p]++; } if (m[k] == 0) v.push_back(k), c++, n++; sort(v.begin(), v.end()); wh... |
#include <bits/stdc++.h> using namespace std; int grid[500][500]; int srow[500][500]; int scircle[500][500]; int rmaxcircle[500][500 + 1]; int cmaxcircle[500][500 + 1]; int width[((500 - 1) / 2) + 1]; int separation[2 * ((500 - 1) / 2) + 1]; int skip_whitespace() { int ch; while (true) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; int n, l[N], t[N]; long long r, dv, res, tcur; vector<long long> ans; void solve(int l, int t) { if (2 * l <= t) { tcur += 2 * l; return; } long long x = t - l; long long tmp = (1ll * l - x + r - 1) / r; res ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 228; const int big = 2e9; const int md = 1e9 + 7; struct node { int l, r, s; }; int n, m, a[N], pr[N], root[N], k, tex, jj; node t[N * 40]; bool ok; void build(int v, int l, int r) { if (l == r) return; t[v].l = ++k; t... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int test; cin >> test; while (test--) { int n; cin >> n; for (int i = 2 * n, j = 0; j < n; i += 2, ++j) { cout << i << ; } cout << endl; } return 0... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 10; int le[MAXN], ri[MAXN]; int a[MAXN]; struct num { int val, pos; }; num data[MAXN]; bool cmp(num a, num b) { return a.val < b.val; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int SZ = 1000010; const long long INF = 1e18 + 10; const int mod = 1e9 + 7; const long double eps = 1e-12; long long read() { long long n = 0; char a = getchar(); bool flag = 0; while (a > 9 || a < 0 ) { if (a == - ) flag = 1; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (b) { ... |
#include <bits/stdc++.h> const int MXN = 100010; bool alive[MXN * 5]; int L[MXN], R[MXN], T[MXN]; struct heap_t { int idx; heap_t(int nidx) : idx(nidx) {} bool operator<(const heap_t& cmp) const { return T[idx] > T[cmp.idx]; } }; struct ele_t { int idx, val; bool operator<(const ele_t& c... |
#include <bits/stdc++.h> const long long INF = (long long)1e18 + 18; const long long maxn = (long long)1e6 + 6; using namespace std; long long n; signed main() { cin >> n; long long a[n], c[n], b[maxn]; for (long long i = 0; i < n; i++) { cin >> a[i]; } for (long long i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; template <typename T> using minheap = priority_queue<T, vector<T>, greater<T>>; template <typename T> using maxheap = priority_queue<T>; template <typename T> using dpair = pair<T, T>; template <class T1, class T2> istream &operator>>(istream &is, pair<T1,... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 10010; int f[2][N], g[2][N], a[N], ans[N], b[N], pr[N]; inline int qpow(long long a, int b, const int p) { int ret = 1; a %= p; while (b) { ret = ret * 1ll * (b & 1 ? a : 1) % p; a = a * a % p, b >>= 1... |
#include <bits/stdc++.h> const int INF = 1e9 + 1; const int MOD = 1e9 + 7; const int N = 1e6 + 1; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, m; cin >> n >> m; if (m == 1) { cout << 100003 100003 << endl; cout << ... |
#include <bits/stdc++.h> using namespace std; double memo[2002][2002]; double p; int main() { int n, t; cin >> n >> p >> t; double ans = 0; memo[0][0] = 1.0; for (int per = 1; per <= n; per++) for (int s = 1; s <= t; s++) memo[per][s] = memo[per - 1][s - 1] * p + memo[per][s - ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; void *wmem; char memarr[10485760]; template <class T> inline void walloc1d(T **arr, int x, void **mem = &wmem) { static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void *)(((char *)(*mem)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, val; int arr[3] = {0}, count = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> val; arr[val]++; } if (arr[2] <= arr[1]) { count += arr[2]; arr[1] -= arr[2]; count += (arr[1] / 3); } else { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; cin >> t; while (t--) { int n; cin >> n; set<int> se; for (int i = 0; i < n; i++) { int va; cin >> va; se.insert(va & 1); } if (se.size() == 1) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010, mod = 998244353; inline long long read() { char ch = getchar(); long long x = 0, f = 0; while (ch < 0 || ch > 9 ) f |= ch == - , ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); retu... |
#include<bits/stdc++.h> using namespace std; const int N=1e5+5; int tot; int head[N],to[N*2],next1[N*2]; void lian(int x,int y) { to[++tot]=y; next1[tot]=head[x]; head[x]=tot; } int d[N],k; struct qw{ int a,b,c,d; }e[N]; struct er{ int a,b; }jie[N]; void dfs(int x... |
#include <bits/stdc++.h> using namespace std; long long n, k, a[100100]; int main() { scanf( %lld %lld , &n, &k); int temp = 0, t = 0; vector<int> v; for (int i = 1; i <= n; i++) { long long x; scanf( %lld , &x); if (temp + (i - n) * x * 1ll * (i - t - 1) < k) { v.push_ba... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[1001]; int b[1001] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]] = 1; } sort(a, a + n); int ans = 0; int sum = a[n - 1] - a[0] + 1; cout << sum - n << endl; return 0;... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010; int n, m, k, u, v, x, y, t, a, b, ans; string A[5]; string s; int ma... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int n, a, b, c, ans = 0; int main() { cin >> n >> a >> b >> c; for (int i = 0; i <= a; i += 2) for (int j = 0; j < (int)(b + 1); j++) { int k = n - (i * 0.5 + j); if (k < 0) break; if (... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int M = 1e6 + 10; const long long INF = 0x3f3f3f3f3f3f3f; const int inf = 0x3f3f3f; const double esp = 1e-6; long long read() { long long x = 0; long long k = 1; char c = getchar(); while (c < 0 || c > 9 ) { ... |
#include <bits/stdc++.h> using namespace std; int Ask(int x, int y) { printf( ? %d %d n , x, y); fflush(stdout); int t; scanf( %d , &t); return t; } int vis[105], t[105], n; struct bt { bitset<105> A; int id; int operator[](int x) { return A[x]; } friend bool operator<(bt x... |
#include <bits/stdc++.h> using namespace std; template <typename... T> inline void inp(T &...args) { ((cin >> args), ...); } template <typename T> inline istream &operator>>(istream &in, vector<T> &a) { for (auto &x : a) in >> x; return in; } template <typename T, typename U> inline istrea... |
#include <bits/stdc++.h> using namespace std; int n, m; long long a[100005]; long long sum1[100005], sum2[100005]; int main() { memset(sum1, 0, sizeof(sum1)); memset(sum2, 0, sizeof(sum2)); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; sum1[i] = sum1[i - 1] + a[i]; } ... |
#include <bits/stdc++.h> bool fun(long long a); using namespace std; int main() { long long num, num1, num2; cin >> num; if (num % 2 == 0) { num1 = num / 2; num2 = num / 2; while (!fun(num1) || !fun(num2)) { num1 -= 1; num2 += 1; } } else { num1 = num ... |
#include <bits/stdc++.h> using namespace std; int n, tab[1000001]; void draw() { for (int i = 0; i < n; i++) { cout << tab[i] << ; } cout << endl; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> tab[i]; } sort(tab, tab + n); if (n % 2 == 1) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read(T& x) { x = 0; int f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= (ch == - ), ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x = f ? -x : x; } ... |
#include <bits/stdc++.h> using namespace std; bool debug = 1; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; vector<int> mp[100005]; int r1, r2, fa[100005], s[100005], no[100005], cnt, d[100005], w[100005]; bool vis[100005]; int bfs(int x) { queue<int> q; ... |
#include <bits/stdc++.h> using namespace std; namespace fio { streambuf* in = cin.rdbuf(); char bb[1000000], *s = bb, *t = bb; inline long long read() { long long x = 0; char ch = (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF : *s++); while (ch < 48) ch = (s == t &... |
#include <bits/stdc++.h> using namespace std; vector<vector<set<int> > > setgrid; vector<string> grid; int k; int ro[4] = {1, -1, 0, 0}; int co[4] = {0, 0, -1, 1}; struct s { s() : r(-1), c(-1), set(-1), path( ), let( A ), d(0) {} s(int nr, int nc, unsigned int nset, string npath, char nlet, int ... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y; bool a[401][401]; bool viz[401]; int dist[401]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cerr.tie(0); cout.tie(0); cin >> n >> m; while (m--) { cin >> x >> y; a[x][y] = a[y][x] = 1; } ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { char s[3][3]; bool is = false; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cin >> s[i][j]; if (s[i][j] == X ) is = true; } } int i = 0, j = 0; bool isY = true; for... |
#include <bits/stdc++.h> using namespace std; double p1, p2; double fastPow(double b, int n) { if (n == 0) return 1.0; double po = fastPow(b, n / 2); po = po * po; if (n & 1) return po * b; return po; } double proba(int turno) { double ans = 1; ans = ans * fastPow(1 - p1, turno / 2... |
#include <bits/stdc++.h> using namespace std; const int maxN = 3e5 + 5; map<pair<int, int>, int> mp; int counts[maxN]; set<int> s[maxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, P; cin >> N >> P; for (int i = 0; i < N; i++) { pair<int... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string second, a = 1968 ; string rem[10]; cin >> second; int zero = 0; bool one = 0, six = 0, eight = 0, nine = 0; string alt = ; for (int i = 0; i < second.si... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5, OO = 1e14; const int di[] = {1, -1, 0, 0}; const int dj[] = {0, 0, 1, -1}; long long TC, n, m, k, a, b, c, cnt, u, mx, mn, ans, arr[N]; bool f, vis[N], mark[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> TC; ... |
#pragma GCC optimize( O3 ) #pragma GCC target( avx2 ) #include<bits/stdc++.h> using namespace std; #define int long long signed main() { int t; cin >> t; for (int u = 0; u < t; ++u) { string s; cin >> s; int b1 = 0, b2 = 0; int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; string toString(long long n) { string str = ; while (n) { str += n % 10 + 0 ; n /= 10; } reverse(str.begin(), str.end()); return str; } int main() { string s = ; for (auto i = (1); i <= (10000); ++i) { string t = to... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, b; cin >> n >> b; long long int a[n], i, j, k, l, t1, t2, sum = 0, ad[n]; for (i = 0; i < n; i++) { cin >> a[i]; ad[i] = a[i]; } vector<pair<long long int, long long int>> v; map<long long int, long l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; double p[maxn], dp[maxn]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lf , &p[i]); double sol = 0.; dp[0] = 0; for (int i = 1; i < n; i++) { dp[i] = (dp[i - 1] + p[i - 1]) * p[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int numTest; cin >> numTest; for (int num = 0; num < numTest; ++num) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr, arr + n); int temp = arr[0], temp2 = 0... |
#include <bits/stdc++.h> using namespace std; int getInt() { int x; scanf( %d , &x); return x; } long long getLongLong() { long long x; scanf( %I64d , &x); return x; } double getDouble() { double x; scanf( %lf , &x); return x; } char getChar() { char x; scanf(... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000; const int dx[4] = {1, 1, -1, -1}; const int dy[4] = {1, -1, -1, 1}; int n, m; int t[MAXN + 2][MAXN + 2]; int dp[4][MAXN + 2][MAXN + 2]; int sol; int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n;... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N]; int n; int res[N]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } void solve() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } if (n... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 9; struct Node { double st, ed, dir; } p[N]; struct flag { double num, id; } q[N]; bool cmp(flag a, flag b) { return a.num < b.num; } int main() { int n, m, i, j, k; while (~scanf( %d , &n)) { for (i = 0; i < n; ++i)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200020; long long a; int main() { cin >> a; long long l = 1, r = 1e18; long long ans = (((9 * (5 * (9 * (2 * (long long)1e17) % a) % a) % a) % a) + 1) % a; cout << l + (a - ans) << << r + (a - ans) << endl; return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int task; scanf( %d , &task); while (task--) { int n, p; scanf( %d%d , &n, &p); int rest(2 * n + p); for (int i = 1; (i <= n) && rest; i++) for (int j = i + 1; (j <= n) && rest; j++) printf( %d %d n , i,... |
#include <bits/stdc++.h> const long long max9 = 10 + 1e9, max6 = 10 + 1e6, max12 = 10 + 1e12, max15 = 10 + 1e15; const long long min6 = -1 * max6, min9 = -1 * max9, min12 = -1 * max12, min15 = -1 * max15; const long long R = 7 + 1e9, NN = 10 + 1e5; using namespace std; int ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:167772160 ) int comp(const void* a, const void* b) { return (*(long long*)a) - (*(long long*)b); } int main() { int n; long long mas[300000], ans(0); scanf( %d , &n); for (int i(0); i < n; ++i) scanf( %I64d , &ma... |
#include <bits/stdc++.h> using namespace std; char s[105]; int main() { int n, m, i, l, r; char ch1, ch2; cin >> n >> m; cin >> (s + 1); while (m--) { cin >> l >> r >> ch1 >> ch2; for (i = l; i <= r; i++) if (s[i] == ch1) s[i] = ch2; } cout << (s + 1); return 0;... |
#include <bits/stdc++.h> using namespace std; string a[100], b[100]; map<string, int> m; int n, s; int main(void) { scanf( %d , &n); for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; } for (int i = 0; i < n; i++) { cin >> b[i]; m[b[i]]--; } s += abs(m[ S ]);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.