func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; struct Node { int pos, id; Node(int p = 0, int i = 0) : pos(p), id(i) {} bool operator<(const Node& rhs) const { return pos < rhs.pos; } } a[MAXN], b[MAXN]; int m, n; long long c[3 * MAXN]; int ans[MAXN]; void add(int x, ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1e5 + 1, Mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long n, k; cin >> n >> k; std::vector<int> v(n); for (auto &x : v) cin >> x; multiset<int> s; int pos ... |
#include <bits/stdc++.h> const unsigned int Mod1 = 1000000009, Mod2 = 1000000007; const unsigned int Bas1 = 12232, Bas2 = 14124; struct mybit { unsigned long long b[16]; mybit() { memset(b, 0, sizeof b); } void clear() { memset(b, 0, sizeof b); } void flip(int z) { b[z >> 6] ^= 1llu << (z & 63); }... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007LL; const long long mod2 = 998244353LL; int n; int a[100005], b[100005]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); } for (int i = 1; i <= n; ++i) { scanf( %d , &b[i]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, k, dist, min_count, num; vector<int> len_jumps, mosqs, mosq_count, result; cin >> n >> m >> k; len_jumps.resize(m); mosqs.resize(k); mosq_count.resize(m); for (i = 0; i < m; i++) { cin >> len_jumps[i]; ... |
#include <bits/stdc++.h> const int mod = 1051131, inv2 = (mod + 1) / 2, phi = 700752; using namespace std; int n, T, s; long long w; int a[33554440]; void qmo(int &x) { x += (x >> 31) & mod; } int ksm(int a, int k) { int res = 1; for (; k; k >>= 1, a = 1ll * a * a % mod) if (k & 1) res = 1ll... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i = i + 6) { if (n % i == 0 || n % (i + 2) == 0) return false; } return true; } ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 5; const long long MOD = 1e9 + 7; const long long INF = 1e18; mt19937 rnd(time(0)); signed main() { long long q; cin >> q; while (q--) { long long d, mod; cin >> d >> mod; long long c = 1; long lon... |
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int h = 0, t = 1; while ((ch > 9 || ch < 0 ) && ch != - ) ch = getchar(); if (ch == - ) t = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) h = h * 10 + ch - 0 , ch = getchar(); return h * t; } const... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; cout << min(n, m) + 1 << endl; for (int i = 0; i < min(n, m) + 1; i++) { cout << i << << min(n, m) - i << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int a[100]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m = a[0]; for (int i = 1; i < n; i++) { if (a[i] > m) { m = a[i]; } } int o = 0; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500005, maxd = 20; int jump[maxd][maxn], range[maxd][maxn]; int a[maxn], L[maxn], lmin[maxd][maxn]; int n; int getminL(int a, int b) { return L[a] < L[b] ? a : b; } int getmin(int a, int b) { int k = b - a + 1 ? 31 - __builtin_clz(b - a + ... |
#include <bits/stdc++.h> using namespace std; const int OO = 1e9; const long long INF = 1e18; const int irand(int lo, int hi) { return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo; } const long long lrand(long long lo, long long hi) { return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long Inf = 1e18; const int N = 2e5 + 10; const int mod = 0; long long gi() { long long x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getc... |
#include <bits/stdc++.h> using namespace std; int sum, n, m, i, j, ans, a[1000001], v[1000001], cnt[1000001]; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d , &a[i]); for (i = 1; i <= n; i++) for (j = i + 1; j <= n; j++) cnt[abs(a[i] - a[j])]++; for (i = 1; i <= 1e6; ... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6, mod = 1e9 + 7, inf = 1e10; long long int a[N], dp[N]; int main() { long long int n, mn = 0, mx = -1, ans_1 = 0, ans_2 = 0, cnt, clk, clr; cin >> n; for (long long int i = 1; i * i * i <= n; i++) { if (n % i == 0) { ... |
#include <bits/stdc++.h> int arr[150]; int temp[150]; int main() { int n, m; std::cin >> n >> m; for (int i = 0; i < n; ++i) { int a, b; std::cin >> a >> b; for (int j = a; j <= b; ++j) arr[j]++; } int cnt = 0; for (int i = 1; i <= m; ++i) { if (!arr[i]) temp[cnt++]... |
#include <bits/stdc++.h> using namespace std; const int N = 6000; int dp[N][N], len[N], dep[N], sz[N], n, k, val[N]; char S[N * 300]; char *s[N]; struct Edge { int L, len; int to; Edge(int L = 0, int len = 0, int to = 0) : L(L), len(len), to(to) {} } d[N][26]; inline int idx(int c) { return ... |
#include <bits/stdc++.h> using namespace std; long long i, j = 0, k = 0, l = 0, m = 0, n, t = 0, sum = 0, r = 0, q = 0, p = 0, z = 0; int a[2000005]; vector<int> v; int main() { ios_base::sync_with_stdio(false); string s, f, g; cin >> m >> f >> g; n = g.size(); if (g[n - 1] ... |
#include <bits/stdc++.h> using namespace std; long long a, b, n; short ans = 0; int main() { cin >> a >> b; while (b > 0) { if (b == 1) { ans = 0; break; } if (b % a != 0) { ans = 1; break; } ++n; b = b / a; } if (ans == 0) { ... |
#include <bits/stdc++.h> using namespace std; const int Nmax = 2e5 + 17; inline int sqr(int x) { return x * x; } int main(void) { int a[6]; for (int i = 0; i < 6; i++) cin >> a[i]; cout << sqr(a[0] + a[1] + a[2]) - sqr(a[0]) - sqr(a[2]) - sqr(a[4]); } |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::ios; using std::sort; const int MAX = 1e3 + 2; int a[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); int n = 0; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n ... |
#include <bits/stdc++.h> using namespace std; int N, K; int hardcode[11] = {0, 1, 0, 1, 2, 0, 2, 0, 1, 0, 1}; int get_sprague_1(int val) { int tmp = val; while (tmp % 4 == 0) { tmp /= 4; } if (val <= 10) { return hardcode[val]; } else if (tmp == 6 || (val % 4 == 0 && tmp % 2 == 1... |
#include <bits/stdc++.h> using namespace std; namespace zzc { inline int read() { int 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; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[5][101][101]; int sd[5][3]; int main() { scanf( %d , &n); for (int t = 1; t <= 4; t++) { char ss[101]; for (int i = 1; i <= n; i++) { scanf( %s , ss + 1); for (int j = 1; j <= n; j++) { int f = ss[j] - 0 ... |
#include <bits/stdc++.h> using namespace std; double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } bool have(long long x1, long long y1, long long x2, long long y2, long long x, long long y) { long long A = y1 - y2; long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int ct = 0, i, j; map<char, int> mp1; int len = s.length(); int bc, rc, gc; gc = rc = bc = 0; for (i = 0; i < len; i++) { if (s[i] == R ) rc++; if (s[i] == G ) gc++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, M = 1000000007; int n, i, a, b, n1, n2; struct str { int a, b, t; } s1[300005], s2[300005]; bool cmp1(str a, str b) { return a.a > b.a; } bool cmp2(str a, str b) { return a.a < b.a; } int main() { scanf( %d , &n); for (i = 1... |
#include <bits/stdc++.h> using namespace std; vector<int> v; void solve(int n) { int m = 1; while (n > 0) { if (n & 1) v.push_back(m); n >>= 1; m++; } reverse(v.begin(), v.end()); } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MAXN = 100; struct mtx { int d[MAXN][MAXN]; int r, c; }; mtx operator*(const mtx l, const mtx r) { mtx res; res.r = l.r; res.c = r.c; assert(l.c == r.r); for (int i = 0; i < res.r; i++) for (in... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; long double s; cin >> n >> s; vector<long long> cnt(n); for (long long i = 0; i < n - 1; ++i) { long long u, v; cin >> u >> v; --u; --v... |
#include <bits/stdc++.h> int main() { char n[10005]; scanf( %[^ n] , n); int len = strlen(n); char temp[len + 1]; int j = 0; for (int i = 0; i < len; i++) { if (n[i] >= a && n[i] <= z ) { temp[j] = n[i]; j++; } else if (n[i] == ) { if (n[i - 1] == )... |
#include <bits/stdc++.h> using namespace std; void print(vector<int> s) { for (int i = 0; i < s.size(); i++) cout << s[i] << ; cout << endl; } const int INF = 1e9 + 7; char next(char v) { if (v == R ) return L ; if (v == L ) return R ; if (v == U ) return D ; if (v == D ) ret... |
#include <bits/stdc++.h> using namespace std; int a, b, n; const int MOD = 1e9 + 7; long long fac[1111111]; bool ok(int x) { while (x) { if (x % 10 == a || x % 10 == b) { x /= 10; } else return 0; } return 1; } void init() { fac[0] = fac[1] = 1; for (int i =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; bool vis[10005][10005], rev[10005]; struct E { int nxt, to; } e[MAXN]; int tot, head[MAXN]; inline void add(int x, int y) { e[++tot] = (E){head[x], y}; head[x] = tot; } int opt[MAXN], X[MAXN], Y[MAXN], s[MAXN], m, n, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; int u = 1e9; for (int a = 0; a <= 2; a++) { for (int b = 0; b <= 2; b+... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9 + 5; const long long INF64 = 1e18; template <typename T> string to_string(const vector<T>& v) { string ret = < ; for (auto it : v) { ret += to_string(it) + , ; } ret.pop_back(); ret.pop_ba... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<pair<int, int> > v(n); multiset<int> l, r; for (int i = 0; i < n; i++) { scanf( %d%d , &v[i].first, &v[i].second); l.insert(v[i].first); r.insert(v[i].second); } int ans = 0; f... |
#include <bits/stdc++.h> using namespace std; int r[305]; int main() { int p, n; cin >> p >> n; int a[n + 5]; for (int i = 1; i <= n; i++) { cin >> a[i]; } int sum = 0, c = 0, f = -1; for (int i = 1; i <= n; i++) { c = a[i] % p; if (r[c] == 0) { f = -1; ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 123; const long long INF = (long long)1e18 + 123; const int inf = (int)1e9 + 123; const int MOD = (int)1e9 + 7; void megaRandom() { unsigned int FOR; asm( rdtsc : =A (FOR)); srand(FOR); } int n; vector<int> g[N]; lo... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int N = 2010; int f[N][N], g[N], dp[N]; int p[N], ip[N]; int power(int x, int y) { int ret = 1; for (; y; y >>= 1, x = 1ll * x * x % mod) { if (y & 1) ret = 1ll * ret * x % mod; } return ret; } int main(... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; const int MOD = int(1E9) + 7; int pow_mod(int b, int p) { int ret = 1; while (p) { if (p & 1) ret = 1LL * ret * b % MOD; b = 1LL * b * b % MOD; p >>= 1; } return ret; } int P[MAXN + 5], S[MAXN + 5]; in... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n, m, x[N], y[N], xx[N], yy[N], num[N][N], vis[N * N], cur, pre[N * N]; vector<int> v[N * N]; using pii = pair<int, int>; vector<pair<int, pii>> process(vector<pair<int, pii>> q) { sort(q.begin(), q.end()); vector<pair<int, pii>> ... |
#include <bits/stdc++.h> using namespace std; using namespace placeholders; template <class T> void mini(T &l, T r) { l = min(l, r); } template <class T> void maxi(T &l, T r) { l = max(l, r); } template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << = << h << n ; } ... |
#include <bits/stdc++.h> using namespace std; struct temp { unordered_map<long long, int> mp; }; int main() { ios_base::sync_with_stdio(false); long long sum = 0, ans = 0; vector<int> val(26); string str; temp mpc[26]; for (int i = 0; i < 26; i++) cin >> val[i]; cin >> str; f... |
#include <bits/stdc++.h> using namespace std; string tos(int a) { ostringstream os( ); os << a; return os.str(); } const int MAXN = 1000000; bool isp[MAXN + 100]; int main() { ios_base::sync_with_stdio(0); for (int i = 0; i <= MAXN; ++i) isp[i] = 1; isp[0] = isp[1] = 1; for (int... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<int> a(n + 1); vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 4... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int x, y; while (cin >> x >> y) { while (true) { bool ok = false; if (x >= 2 && y >= 2) { x -= 2; y -= 2; ok = true; } else if (x >= 1 && y >= 12) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void next_int(T &x) { x = 0; char c; bool neg = false; while (!isdigit(c = getchar())) if (c == - ) neg = true; do x = x * 10 + c - 48; while (isdigit(c = getchar())); if (neg) x = -x; } template <typ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; } struct StrInt { StrInt(const string& ref) : ref(... |
#include <bits/stdc++.h> using namespace std; int main() { int i, n; string s; cin >> s; vector<int> freq(27, 0); for (i = 0; i < s.length(); ++i) { if (s[i] == B ) freq[26]++; else if (s[i] >= a && s[i] <= z ) freq[s[i] - a ]++; } cout << (min(freq[26], ... |
#include <bits/stdc++.h> using namespace std; int n, a[4], b[4]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); sort(a, a + n); if (!n) puts( YES n1 n1 n3 n3 ); else if (n == 1) printf( YES n%d n%d n%d n , a[0] << 1, a[0] << 1, a[0] + (a[0] << 1)); ... |
#include <bits/stdc++.h> int edge[110][110]; int main() { memset(edge, 0, sizeof(edge)); int n, u, v, w; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &w); edge[i % n][(i + 1) % n] = edge[(i + 1) % n][i % n] = w; } scanf( %d%d , &u, &v); for (int i = 0; i < n; ++... |
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int m, n; scanf( %d %d , &n, &m); char s[n][m]; for (int i = 0; i < n; i++) { scanf( %s , s[i]); } int ans = 0; for (int i = 0; i < n; i++) if (s[i][m - 1] == R ) ans++; ... |
#include <bits/stdc++.h> using namespace std; const long long mx = 105; const long long mx1 = 1000001; const long long mod = 1000000007; vector<vector<long long> > edges; void adds(long long &a, long long b) { a += b; if (a >= mod) a -= mod; } long long mul(long long a, long long b) { return (lo... |
#include <bits/stdc++.h> using namespace std; int main() { string s, s1; vector<string> vc; cin >> s; for (int i = 0; i < s.size(); i++) { s1 = s[i]; vc.push_back(s1); for (int j = i + 1; j < s.size(); j++) { s1 = s[i]; s1 += s[j]; vc.push_back(s1); ... |
#include <bits/stdc++.h> using namespace std; double f(double z, double first) { int k = 0; double w; while (first > 2 * z) { w = z; while (2 * w < first) w *= 2, k += 2; first -= w; } if (first <= z) return first; else return 2 * z - first; } int main() { ... |
#include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/trie_policy.hpp> //using namespace __gnu_pbds; using namespace std; #define ll long long int #define ld long double #define mod 1000000007 #define inf ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long double... |
#include <bits/stdc++.h> using namespace std; int n, m, k; char s[2010][1010]; int a[1010][1010]; int main() { scanf( %d%d%d n , &n, &m, &k); if (k == 1) { int cnt = 0; int tot = 0; for (int i = 0; i < 2 * n - 1; ++i) { gets(s[0]); for (int j = 0; j < m - ((i + 1) & 1... |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y, z; }; double len[10000]; double sum[10000]; int n; Point point[10001], potter; double vp, vs; double getDist(Point &a, Point &b) { double x = a.x - b.x; double y = a.y - b.y; double z = a.z - b.z; return sqrt... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; unsigned long long ans = 0; for (int i = 0; i < s.size(); i++) { int x = s[i] - 0 ; if (x % 4 == 0) ans++; if (i > 0) { x += 10 * (s[i - 1] - 0 ); if (x % 4 == 0) ans += i; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, k; cin >> n >> k; string s, s1; cin >> s; if (k == 0) { cout << s; } else if (n == 1) { cout << 0 << n ; } else { if (s[0] != 1 ) { ... |
#include <bits/stdc++.h> using namespace std; #define ll long long #define f(i,n) for(int i=0;i<n;i++) #define endl ( n ) #define pb push_back #define mp make_pair #define pl pair<ll, ll> #define vl vector<ll> #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL); #define M 1000000007 ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 3; const double EPS = (1e-7); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } long long gcd(long long a, long long b) { if (b == 0) return a; ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 3e5; int n; int a[maxN]; int diff[maxN]; int ans[maxN]; vector<int> pos[maxN]; int main() { int t; while (scanf( %d , &t) != EOF) for (int tt = 1; tt <= t; tt++) { scanf( %d , &n); for (int i = 0; i < n; i++) po... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[2000]; memset(arr, 0, sizeof(arr)); string s; cin >> s; for (int i = 0; i < n; i++) arr[s[i]]++; int m = 10000000; for (int i = 65; i < 65 + k; i++) m = min(arr[i], m); cout << m * k; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e1 + 5; map<int, int> mp; long long n, arr[MAXN], brr[MAXN], crr[MAXN]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; brr[i] = arr[i]; } sort(arr, arr + n); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> const int N = 1e5 + 1, B = 128; int i, j, n, m, r, a[N], f[N][B]; int main() { for (scanf( %d , &n); ++i <= n; scanf( %d , a + i)) ; for (j = 1; j < B; ++j) for (i = n; i; --i) f[i][j] = i + j + a[i] > n ? 1 : f[i + j + a[i]][j] + 1; for (scanf( %d , &m); m--;) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (auto &ai : a) cin >> ai; vector<pair<int, int>> v; vector<bool> b(n); for (int i = 0; i < n; i++) { if (a[i] == 0) { sort(begin(v), end(v)); for (int k = 0; k < 3; k++... |
#include <bits/stdc++.h> using namespace std; int n, kezd[200002], veg[200002], pos[200002], inv[200002], x, csa, csb; vector<pair<pair<int, int>, int> > sz; vector<int> v; priority_queue<pair<int, int> > q; void p() { for (int i = 1; i <= n; i++) inv[pos[i]] = i; for (int i = 1; i <= n; i++) cout <... |
#include <bits/stdc++.h> using namespace std; inline int read() { bool ok = 0; int res = 0; char c; while (((c = getchar()) < 0 || c > 9 ) && c != - ) ; if (c == - ) ok = 1; else res = c - 48; while ((c = getchar()) >= 0 && c <= 9 ) res = (res << 3) + (res... |
#include <bits/stdc++.h> using namespace std; auto SEED = chrono::steady_clock::now().time_since_epoch().count(); mt19937 rng(SEED); int main() { int n, k; cin >> n >> k; int dist[n][n]; for (int i = (0); i < (n); i++) { for (int j = (0); j < (n); j++) { cin >> dist[i][j]; } ... |
#include <bits/stdc++.h> using namespace std; vector<long long> q1; vector<long long> q2; long long n, x, y, a, b, k; long long l = 1, r = n; long long ans = 0; long long mid; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } bool cmp(long long a, long long b) { return a > b; }... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string tmp; map<string, vector<vector<string> > > m; for (int i = 0; i < n; i++) { cin >> tmp; getline(cin, tmp); bool f = false; string name; vector<string> v; for (int j = 0; j < tmp... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2 || y1 == y2) cout << abs(x1 - x2) + abs(y1 - y2) << endl; else cout << abs(x1 - x2) + abs(y1 - y2) + 2 << endl; ... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char c = getchar(); x = 0; while (!isdigit(c) && !isalpha(c)) c = getchar(); if (isalpha(c)) return void(x = c - a ); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); } const int N = 5e5 + 5, SZ = 22; int n, v... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, t, i, j, ii, a; while (scanf( %d%d%d , &n, &k, &t) != EOF) { for (i = 1; i <= n; i++) { if ((i * k + 1) * 100 > t * n * k) break; } for (j = 0; j <= k; j++) { a = (i - 1) * k + j; if (n * k * t >= ... |
#include <bits/stdc++.h> using namespace std; long long fat[200005]; void gerafat() { fat[0] = 1; for (long long i = 1; i < 200005; i++) { fat[i] = (fat[i - 1] * i) % 1000000007; } } long long modInv(long long a) { long long v = 1; long long e = 1000000007 - 2; while (e) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, r; long long a; map<int, long long> d; int ans[300010]; int k = 0; ans[0] = 1; cin >> n; for (int i = 1; i <= n; ++i) { scanf( %I64d , &a); if (d[a] > r) { ans[++k] = i; r = i; } else ... |
#include <bits/stdc++.h> using namespace std; signed long long n, m, answer; signed long long calc(signed long long n, signed long long m) { signed long long answer; if (m - n >= 1) { answer = n; } else { answer = m + (signed long long)ceil((sqrt(1.0L + 8.0L * (n - m)) - 1.0L) / ... |
#include <bits/stdc++.h> using namespace std; int n, vis[4001], children, ans[4001]; long long v[4001], abcdefghijklmnopqrstuvwxyz[4001], d[4001]; int main() { while (~scanf( %d , &n)) { memset(vis, 0, sizeof(vis)); children = 0; for (register int i = 1; i <= n; i++) { scanf( %lld%... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; const ll INF = 100000000000ll; const int N = 200005; const int prime = 31; const ll mod = 1000000007; const ld eps = 1e-5; mt1... |
#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; int a, b; int ans = 0; bool ok = true; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } void solve(int a) { while (a % 2 == 0) { a /= 2; ans++; } while (a % 3 == 0) { a /= 3; ans... |
#include <bits/stdc++.h> using namespace std; vector<int> g; int n; int a = 0; int b = 0; int ans = 0; bool used[200][200]; void dfs(int a, int b) { used[a][b] = 1; for (int i = max(0, n - a); i <= min(n, b); i++) { if (!used[a + i - (n - i)][b - i + (n - i)]) { dfs(a + i - n + i, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> inline bool Min(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool Max(T &a, T b) { re... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200; const int oo = 1000000007; int n, k, m, a[10], lik[10], head[10], adj[10]; long long res; bool fre[10], ok; void make(int u, int v) { m++; adj[m] = v; lik[m] = head[u]; head[u] = m; } void dfs(int u) { fre[u] = fal... |
#include <bits/stdc++.h> using namespace std; int main() { int r = 0, c = 0; string str; cin >> str; if (str.length() > 2) { for (int i = 0; i < str.length() - 2; i++) { if (str[i] == Q ) { for (int j = i + 1; j < str.length() - 1; j++) { if (str[j] == A ) r++; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; static constexpr ll oo = numeric_limits<ll>::max() / 2; struct Node { ll sm, mx; Node() : sm{0}, mx{-oo} {} Node(ll sm_, ll mx_) : sm{sm_}, mx{mx_} {} }; struct LazySegmentTree { vector<Node> tree; vector<ll> mark; i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long ca; cin >> ca; while (ca--) { long long n, i, j, k, l, r, m; cin >> l >> r >> m; for (i = l; i <= r; i++) { long long x1, x2; x1 = m / i; if (m % i != 0) ... |
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; bool ck(int k) { double ss = (double)k * m, cnt = 1; double C = 1, A = k, B = 1; for (long long lp = 1; cnt < n && ss > 0 && A >= 0; lp++) { C = C * A / B; A... |
#include <bits/stdc++.h> using namespace std; int n, sz[1005], lab[1005], cur = 1, cur2, f = 1; vector<int> v[1005]; int getsz(int node, int p) { sz[node] = 1; for (int u : v[node]) { if (u != p) sz[node] += getsz(u, node); } return sz[node]; } int find(int node, int p) { for (int ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; struct CHT { vector<long long> m, c; bool decSlope, askMin; CHT(bool slopeType, bool queryType) { decSlope = slopeType; askMin = queryType; } bool throwLine(long long l1, long long l2, long long l3) { i... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long int fp(long long int a, long long int b) { long long int res = 1; while (b) { if (b & 1) (res *= a) %= (1000000000 + 7); b /= 2; (a *= a) %= (1000000000 + 7); } return res; } int n, k, cr, l, last; l... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const long long mod = 998244353; inline long long add(long long v1, long long v2) { v1 += v2; if (v1 >= mod) v1 -= mod; if (v1 < 0) v1 += mod; return v1; } inline long long mul(long long v1, long long v2) { return v1 *... |
#include <bits/stdc++.h> using namespace std; char s[200000], t[200000]; int equi(int a, int b, int c, int d) { bool x = 1; for (int i = 0; i <= b - a; i++) { x &= (s[i + a] == t[i + c]); } if (x) return 1; if (b <= a) return 0; int n = b - a + 1; if (n % 2 == 1) return 0; if... |
#include <bits/stdc++.h> using namespace std; vector<int> all; vector<int> zu; vector<int> de; int main() { string x; cin >> x; int y = x.size() / 2; cout << x; for (size_t i = 0; i < y; i++) { swap(x[i], x[x.size() - i - 1]); } cout << x << endl; return 0; } |
/* ----@sagittarius_k2----- Created by Ritesh Ranjan -> */ #define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #include <bits/stdc++.h> #include <iostream> #include <set> #include <algori... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T abs(T t) { return t < 0 ? -t : t; } const long long modn = 1000000007; inline long long mod(long long x) { return x % modn; } const int MAXN = 100010, INF = 0x3f3f3f3f; int n, m, deg, s[MAXN], p[MAXN]; int main() { sc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.