func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct ad { int l, r, i; bool operator<(const ad a) const { if (l != a.l) return l < a.l; return r > a.r; } }; const int INF = 1000000000; const int MAXN = 200005; const int SZ = 1 << 18; int N, M, A, B; long long res, resi, resj, C; ... |
#include <bits/stdc++.h> using namespace std; int fastio() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(nullptr); return 0; } int __fastio = fastio(); void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr <... |
#include <bits/stdc++.h> const long long N = 2e5 + 5, MOD = 1e9 + 7; using namespace std; int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; long long n, m, a[N], cnt, ans; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >... |
#include <bits/stdc++.h> using namespace std; enum { MAXN = 100010 }; pair<long long, long long> d[MAXN]; int x[MAXN], t[MAXN]; long long minv[MAXN]; int solveB(int n) { int mans = 0; for (int i = 0; i < n; i++) { int f = upper_bound(minv, minv + mans, d[i].second) - minv + 1; if (f > ma... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long n; cin >> n; long long arr[n]; for (long long i = 0; i < n; ++i) { cin >> arr[i]; } if (n == 1) { cout << 1 << << 1 << n ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int a; for (int i = 0; i < t; i++) { int n, m; cin >> n >> m; if (n == 1 && m == 1) { cout << 1 << endl; } else if ((n == 1 && m != 1) || (m == 1 && n != 1)) { if ((n * m) % 2 == 0) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int TMXN = 1e6 * 4 + 1; const int INF = 1e9 + 7; const long long INFL = 1e18; int n, k; char a[N]; int mink = INF; int pref[N]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (... |
#include <bits/stdc++.h> using namespace std; int32_t main() { int64_t t; cin >> t; for (int64_t i = 0; i < t; i++) { int64_t a, b; cin >> a >> b; if (a == b) { cout << 0 << endl; continue; } int64_t k = abs(b - a); int64_t ans = k / 5; k %= 5; ... |
#include <bits/stdc++.h> using namespace std; vector<int> all[2010]; int dist(pair<int, int> a, pair<int, int> b) { return abs(a.first - b.first) + abs(a.second - b.second); } int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j+... |
#include <bits/stdc++.h> using namespace std; int i, i0, n, m, a[105]; bool vis[100]; vector<int> ans; int main() { while (scanf( %d , &n) != EOF) { for (i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] == 0) { ans.push_back(a[i]... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; string second; cin >> second; for (int i = 0; i < (int)n; i++) { if (i < n - 2 && second[i] == o && second[i + 1] == g && second[i + 2] == o ) { cout << *** ; ... |
#include <bits/stdc++.h> int f[1000001]; int main() { int n; scanf( %d , &n); f[0] = 0; f[1] = 1; f[2] = 1; int i, j, k; for (i = 3;; i++) { f[i] = f[i - 1] + f[i - 2]; if (f[i] > 1000000000) break; } int idx = i; int no = 0; for (i = 0; i < idx; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, nn, sz[133333], p; vector<int> g[133333], V; void dfs_sz(int x, int par) { sz[x] = 1; for (int to : g[x]) { if (to != par) { dfs_sz(to, x); sz[x] += sz[to]; } } if (sz[x] == n / 2 || sz... |
#include <bits/stdc++.h> using namespace std; int main() { string a, s = ; int b; cin >> b; for (int i = -1; i < b; i++) { getline(cin, a); int len = a.length(); if (len >= 2 and a.substr(len - 2, 2) == po ) { s += FILIPINO ; s += n ; } else if (len >= 4... |
#include <bits/stdc++.h> int xx[4][5] = { {0, 0, 0, 1, 2}, {0, 1, 1, 1, 2}, {0, 1, 2, 2, 2}, {0, 1, 1, 1, 2}}; int yy[4][5] = { {0, 1, 2, 1, 1}, {2, 0, 1, 2, 2}, {1, 1, 0, 1, 2}, {0, 0, 1, 2, 0}}; struct num { int x, y, z; }; int l[(20 * 20 * 25)], r[(20 * 20 * 25)], d[(20 * 20 * 25)], u[(20 *... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; int type0, type1; void dfs(int s, bool visited[], vector<int> adj[], int type[], int ctr) { if (visited[s]) retur... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:16777216 ) const double EPS = 1e-7; double iabs(const double a) { return (a < -EPS) ? -a : a; } double imin(const double a, const double b) { return (a - b > EPS) ? b : a; } double imax(const double a, const double b) { return (a ... |
#include <bits/stdc++.h> using namespace std; vector<int> l[1000000]; int main() { int n; cin >> n; int a[n], b[n], c[n]; for (int i = 0; i < n; i++) { cin >> a[i]; l[a[i]].push_back(i + 1); } int q = 0; for (int i = 0; i < n; i++) { int j = a[i]; if (a[j - 1] !... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; long long mxmx = -1, mnmx = -1; while (n--) { long long x, y, h, w; char c; cin >> c; if (c == + ) { cin >> x ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } long long lcm(long long a, long long b) { return (a * b) / (gcd(a, b)); } void solve() { long long n; cin >> n; vector<long lon... |
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #define rep(i, a, n) for(int i = a; i <= n; ++ i) #define per(i, a, n) for(int i = n; i >= a; -- i) //#define ONLINE_JUDGE using namespace std; typedef long long ll; const int mod=1e9+7; template<type... |
#include <bits/stdc++.h> using namespace std; long long i, j, n, m, f1, f2, t, k, a, b, x1, x2, w; long long ans = -1; vector<long long> vis; vector<vector<long long>> adj; long long dfs(long long v) { vis[v] = 1; long long value = 1; for (long long u : adj[v]) { if (!vis[u]) { val... |
#include <bits/stdc++.h> using namespace std; long long sum(long long a[], long long n, long long s) { for (long long i = 0; i < n; i++) s += a[i]; return s; } long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 9; char s[N]; bool vis[N]; struct Point { long long x, y, id; Point(long long _x = 0, long long _y = 0, long long _id = 0) { x = _x; y = _y; id = _id; } Point operator-(const Point& b) const { return Point(x - ... |
#include <bits/stdc++.h> using namespace std; int n, m, ans; int a[100005]; vector<int> v[100005]; void solve() { int i, j, k, flag = 0, ok, sz, tmp; for (i = 1; i <= 500; i++) { ok = 1; random_shuffle(a + 1, a + n + 1); for (j = 1; j <= m; j++) { sz = v[a[j]].size(); ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const double PI = 3.14159265359; int n, k; long long S; vector<vector<long long>> dp(25); vector<long long> fact(20, 1ll); long long getFactVal(int mask, vector<long long>& vi) { long long ans = 0; int m = vi.size(); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int count = 0; int len = s.size(); bool small = false; for (int i = 0; i < len; i++) { if (s[i] < a ) { count++; } if (s[0] >= a ) { small = true; } } if (count ==... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int deep[200000 + 10], to[200000 + 10]; int len; string s; stack<int> tmp; int best_deep[200000 + 10]; void dfs(int l, int r, int dep) { deep[l] = dep; if (l == r - 1) { best_deep[l] = dep; return; } in... |
#include <bits/stdc++.h> using namespace std; int main() { int R, x1, y1, x2, y2; scanf( %d%d%d%d%d , &R, &x1, &y1, &x2, &y2); if ((long long)(x2 - x1) * (x2 - x1) + (long long)(y2 - y1) * (y2 - y1) >= (long long)R * R) { printf( %.12f %.12f %.12f n , (double)x1, (double)y1, (double)R); ... |
#include <bits/stdc++.h> using namespace std; long long i, j, p, l, m, n, c, d, t, k; long long a[int(3e5 + 11)]; string s; long long dp[4][2][int(3e5 + 11)]; int main() { cin >> s; long long n = s.size(); long long pas1 = 0, pas2 = 0; for (int i = 1; i <= n; i++) { if (s[i - 1] == a ... |
#include <bits/stdc++.h> using namespace std; int n, k; struct node { int ou, j1, j2, j3; } a[10020]; void setup() { int i, j; int ou = 2, ji = 1; for (i = 1; i <= 10010; i++) { while (ou % 3 == 0) ou += 2; a[i].ou = ou; ou += 2; a[i].j1 = ji; a[i].j2 = ji + 2; ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000000000000000ll; long long b[230400], h[230400], d[230400], ans, t[230400], n, m; struct node { long long c, e; } a[230400]; struct seg { long long l, r, val, z; } s[230400 * 4]; bool cmp(node u, node v) { if (u.c == v.c)... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 9, maxV = 536, MOD = 1e9 + 7, AND = (1 << 20) - 1, lg = 21; vector<int> farg[maxN], adj[maxN], adjc[maxN], elems[maxN]; int incom[maxN], comp[maxN], idx; set<pair<int, int> > mys; stack<int> stc; bool vi[maxN]; void dfs(int... |
#include <bits/stdc++.h> using namespace std; int main() { int a[102][102]; int b, c, i, j, n, m; cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) cin >> a[i][j]; b = n; while (b % 2 == 0 && b / 2 != 0) { c = 0; for (i = 1; i <= b / 2; i++) for (j = ... |
#include <bits/stdc++.h> using namespace std; int cnt[200005]; int calc(int t) { int res = 0; for (int i = 1; i <= 200000; i++) { res += cnt[i] / t; } return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n; cin >> n; pair<long long int, long long int> a[n]; for (long long int i = 0; i < n; i++) cin >> a[i].first >> a[i].second; sort(a, a + n)... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, s, n, e; cin >> t; for (int i = 0; i < t; i++) { cin >> s >> n >> e; long long l = 0, r = e + 1, m; if (e == 0) { if (s > n) cout << 1 << endl; else cout << 0 << endl; co... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000 + 10; inline int read() { int x = 0; bool f = true; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = false; c = getchar(); } while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int main() { int n; cin >> n; int x[n], y[n], dx[n], dy[n], s[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> dx[i] >> dy[i] >> s[i]; } float ans = -1; int eff_s; float t1, t2; for (int i... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; namespace Xrocks {} using namespace Xrocks; namespace Xrocks { class in { } user_input; class out { } output; in& operator>>(in& X, int& Y) { scanf( %d , &Y); return X; } in& operator>>(in& X, char* Y) { sc... |
#include <bits/stdc++.h> using namespace std; void Solved() { int n; cin >> n; int one = 0; int two = 0; vector<int> ans; long long sum = 0; for (int i = 1; i <= n; i++) { int te; cin >> te; if (te % 2 == 0) { two++; } else { one++; } } ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { for (ll i = 0; ... |
#include <bits/stdc++.h> using namespace std; template <class T> string i2s(T x) { ostringstream o; o << x; return o.str(); } template <class T> vector<T> split(const string& s) { vector<T> v; istringstream is(s); T t; while (is >> t) v.push_back(t); return v; } vector<st... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; long long int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += 1ll * a[i]; } long long int m = ceil(sum / 2); long long... |
#include <bits/stdc++.h> using namespace std; template <typename TYPE> inline TYPE sqr(const TYPE& a) { return a * a; } const long double EPS = 1e-9; const long double PI = 2 * acos(0.0); const int N = 300010; int a[N]; int main() { int n; scanf( %d , &n); long long s = 0; for (int... |
#include <bits/stdc++.h> using namespace std; using ll = long long; inline int read(); const int M = 200016, MOD = 1000000007; int sz; int ch[M][26], len[M], link[M], pre[M]; void extend(const char *s) { for (int i = 0, lst = 0; s[i]; ++i) { int c = s[i] - a , cur = ++sz; len[cur] = len[l... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; ++j) { if (j == i) continue; ... |
#include <bits/stdc++.h> using namespace std; inline int lowbit(int x) { return x & -x; } int read() { int kkk = 0, x = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) c = getchar(), x = -1; while (c >= 0 && c <= 9 ) kkk = kkk * 10 + (c - 0 ), c... |
#include <bits/stdc++.h> using namespace std; const int max_n = 1000, max_k = 100; int dp[max_n][max_k]; int p[max_n + 5]; int main() { int n, k, mod; cin >> n >> k >> mod; p[0] = 10 % k; for (int i = 0; i < n; i++) p[i + 1] = p[i] * 10 % k; memset(dp, 0, sizeof dp); for (int dig = 1; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 4e18; const int N = 5e5 + 1; vector<int> vec; vector<pair<int, ll> > g[N]; int n, op, t, l, r, q, s, pos[N][2]; void construct(int node = 1, int b = 1, int e = n) { pos[node][op] = ++t; if (b == e) { if (op ... |
#include <bits/stdc++.h> using namespace std; vector<long long> primes; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, q; cin >> n >> q; vector<pair<int, int> > ans; int tmp(-1); vector<bool> state; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int powP[2001] = {1}; int invPowP[2001] = {1}; int hashW[2001] = {0}; vector<pair<int, int> > hashTable[100003]; void findPos(string& w, string& subW, vector<int>& posSubW) { unsigned int j = 0, k = subW.size(); for (unsigned int i = 0; (i + k) <= w.size... |
#include <bits/stdc++.h> const long long mod = 1e8; using namespace std; bool in(int x, int l, int r) { return l <= x && x <= r; } void solve() { long long l, r; cin >> l >> r; vector<long long> v; long long p = -1; for (int i = 61; i >= 0; i--) { unsigned long long mask = 1ull << i; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename T> i... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 100; int b, d, lenA, lenC; string a, c; int dp[maxn + 10], nex[maxn + 10]; void cope(int x) { dp[x] = 0; nex[x] = x; int use = 0; while (use < lenA) { if (a[use] == c[nex[x]]) { if (++n... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, i, j, k, ct; bool swapped = false; cin >> n >> m; if (n < m) { swap(n, m); swapped = true; } vector<vector<int>> ans(n, vector<int>(m, -1)); ct = 0; if (m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; while (t--) { unsigned long long int a, b, c, d; cin >> a >> b >> c >> d; unordered_map<unsigned long long int, unsigned long long int> mp, mp1; fo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int people = n - x; int wizards = x; people *= 100; wizards *= 100; int needed = max(0, n * y - wizards); cout << (needed + 99) / 100 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int a[400500], b[400500], n, tot; 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 - 0 ; ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> v; vector<int> vn; for (int i = 0; i < n; i++) { string a; cin >> a; bool cn = false; int y = 0; for (int j = 0; j < v.size(); j++) { if (a == v[j]) { y = j;... |
#include <bits/stdc++.h> using namespace std; bool vowel(char c) { return (c == a || c == e || c == o || c == i || c == u ); } int cvowel(string& s) { int n = 0; for (char& c : s) { n += vowel(c); } return n; } int getlast(string& s) { for (int i = s.size() - 1;; i--) ... |
#include <bits/stdc++.h> using namespace std; int n, c, a[2], r = 0; int main() { cin >> n >> c >> a[0]; for (int i = 1; i < n; i++) cin >> a[i % 2], r = max(r, a[i % 2 ^ 1] - a[i % 2] - c); cout << r; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> tab(n); for (int i = 0; i < n; i++) cin >> tab[i]; for (int i = 0; i < n; i++) { if (tab[i] % 2 == 0) continue; else { if (i == (n - 1) || tab[i + 1] == 0) { cout << NO ... |
#include <bits/stdc++.h> using namespace std; long long n, m, a, b, x, cnt, ans; deque<long long> V; map<long long, long long> mp; long long arr[1000001]; int main() { cin >> n >> a >> b; for (int i = 1; i <= n; i++) { cin >> arr[i]; } sort(arr + 1, arr + n + 1); ans = (n - a) + 1;... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int MAXN = 200001; int c[MAXN * 3 + 10]; int n; char s[MAXN + 10]; int sum[MAXN + 10]; int lowbit(int x) { return x & (-x); } void update(int pos, int delta) { while (pos <= n) { c[pos] = min(c[pos], delta); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, n1, n2, limiter = 1, fight = 0, temp; cin >> n >> n1; queue<int> p1, p2; for (int i = 1; i <= n1; i++) { cin >> temp; p1.push(temp); limiter *= i; ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 200002, inf = 1111111111; const int max_p = 500005; int n, q, a[max_n], z[max_p], cnt[max_p], used[max_n]; long long ans; int get_cnt(int x) { int res = 0; for (int i = 1; i * i <= x; ++i) { if (x % i == 0) { int d = i; ... |
#include <bits/stdc++.h> using namespace std; void aent(long long int *a, long long int n) { for (long long int i = 0; i < n; i++) cin >> a[i]; } string arrtostr(long long int *a, long long int n) { ostringstream os; for (long long int i = 0; i < n; i++) os << a[i]; string str(os.str()); ret... |
#include <bits/stdc++.h> using namespace std; inline char read() { static const int IN_LEN = 1000000; static char buf[IN_LEN], *s, *t; return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++); } template <class T> inline void read(T &x) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, i; cin >> n; int a[n]; map<long int, int> mp; for (i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } cout << mp.size() << endl; } } |
#include <bits/stdc++.h> const int N = (int)1e3 + 5; int n; int a[N]; int b[N]; int u[N]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } int main() { int ts; scanf( %d , &ts); while (ts--) { for (int i = 0; i < N; ++i) { u[i] = 0; } scanf( %d , &n); fo... |
#include <bits/stdc++.h> using namespace std; void ng() { cout << -1 << n ; } void solve() { int N; cin >> N; map<int, int> M; vector<int> A(N); for (auto &x: A) { cin >> x; M[x]++; } for (auto &[key, val]: M) { if (val > (N + 1) / 2) return ng(); ... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[100]; int sol[1000000]; void prueba(int ind) { sol[0] = ind; priority_queue<pair<int, int> > q; for (int i = 1; i <= m; i++) { if (ind == i) { if (a[i] > 1) q.push(pair<int, int>(a[i] - 1, i)); } else { q.pus... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int nmax = 5e4 + 5; int l[nmax], r[nmax]; int main() { int n, x; scanf( %d %d , &n, &x); for (int i = 0; i < n; ++i) { scanf( %d %d , l + i, r + i); } long long res = 0; for (int i = 0; i < n;) { i... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; register char c = getchar(); bool f = 0; while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - ) c = getchar(), f = 1; while (c >= 0 && c <= 9 ) x = x * 10 + c - 48, c = getcha... |
#include <bits/stdc++.h> template <typename T> inline T abs(T a) { return a < 0 ? -a : a; } template <typename T> inline T min(T a, T b) { return a < b ? a : b; } template <typename T> inline T max(T a, T b) { return a > b ? a : b; } template <typename T> inline void swap(T& a, T& b) {... |
#include <bits/stdc++.h> using namespace std; struct Upgrade { int id, i, val; Upgrade(int _id = 0, int _i = 0, int _val = 0) : id(_id), i(_i), val(_val) {} friend bool operator<(const Upgrade &a, const Upgrade &b) { return a.val < b.val; } }; struct Data { Upgrade upgrade; long lo... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; bool prime[N]; int phi[N], deg[N]; void sieve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); sieve(); int n, k; cin >> n >> k; priority_queue<pair<int, int>, vector<pair<int, int>>, ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100010; int n, m, k, q; vector<int> G[maxN]; int pre[maxN], s[maxN], e[maxN], cnt[maxN], t; bool nroot[maxN]; void dfs(int cur) { s[cur] = ++t; cnt[cur] = 1; for (int i = 0; i < (int)G[cur].size(); i++) { int nxt = G[cur][i];... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<string> tt(n); for (int i = 0; i < n; ++i) { cin >> tt[i]; } int const INF = 1000000000; vector<int> dp(k + 1, INF), ndp(k + 1, INF); dp[0] = 0; for (int day = 0; day < n; ++d... |
#include <bits/stdc++.h> using namespace std; int n, id = 0; int Hash[333], L[333]; map<string, int> M; vector<int> v; int kmp(int Len) { int len = v.size(); int lps[len], I = 0, num = 0; lps[0] = 0; for (int i = 1; i < len; i++) { if (v[I] != v[i]) I = -1; lps[i] = ++I; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; int N; pair<int, int> point[MAXN]; int cntx[MAXN], cnty[MAXN], cnt1, cnt2; map<int, vector<pair<int, int> > > samex, samey; int fa[MAXN]; int find(int x) { return (x == fa[x]) ? x : fa[x] = find(fa[x]); } void merge(int u, int v) { ... |
#include <bits/stdc++.h> using namespace std; const long long int E = 1e18 + 7; const long long int MOD = 1000000007; int main() { long long int n; cin >> n; while (n--) { string s; cin >> s; bool P = true; bool same = true; for (int i = 0; i < s.size(); i++) { ... |
#include<bits/stdc++.h> using namespace std; #define fo(a,b,c) for(int a=b;a<=c;++a) #define fr(a,b,c) for(int a=b;a>=c;--a) #define ll long long #define pq priority_queue int t,n,a[30010]; int cnt[3]; bool check() { if(cnt[1]==cnt[2]&&cnt[1]==cnt[0]) return false; return true; } int ma... |
#include <bits/stdc++.h> using namespace std; int main() { int xa, ya, xb, yb, n, count = 0; cin >> xa >> ya >> xb >> yb; if (xa > xb) { int t = xa; xa = xb; xb = t; } if (ya > yb) { int t = ya; ya = yb; yb = t; } cin >> n; int x[n], y[n], r[n]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, a; cin >> n >> a; int arr[n + 1]; int cnt = 0; for (int i = 1; i <= n; i++) { cin >> arr[i]; } for (int i = 1; i <= n; i++) { if (arr[i]) { int temp = i - a;... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, y; }; long long cross(point a, point b, point c) { return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y); } int main() { point a, b, c; cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y; long long ans = cross(a,... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long po(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } ... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1}; const int mod[2] = {1000000007, 1000000009}; const int p[2] = {29, 31}; const int maxn = 3000; int add(int a, int b, int k) { return a + b >= mod[k] ? a + b - mod... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int n; long long int dn[6010], dinamik2[6010]; int main() { string ar; string ar2; cin >> ar; cin >> ar2; n = ((int)(ar2.size())); long long res = 0; for (int k = 0; k < ((int)(ar.size())); k++) { for (... |
#include <bits/stdc++.h> using namespace std; int main() { string s; set<string> l; int ans = 0; while (getline(cin, s)) { if (s == ) break; if (s[0] == + ) { l.insert(s.substr(1)); } else if (s[0] == - ) { l.erase(s.substr(1)); } else { int i = 0;... |
#include <bits/stdc++.h> using namespace std; int main() { int pb, mb, bb, m; cin >> pb >> mb >> bb >> m; int s1 = 2 * pb; int temp = 2 * m; if (2 * m >= s1) { cout << -1 << endl; return 0; } int s2 = 2 * mb; if (2 * m >= s2) { cout << -1 << endl; return 0; ... |
#include <bits/stdc++.h> using namespace std; string a, b; struct node { int x, y; }; vector<node> ans; void rua() { ans.clear(); int n; scanf( %d , &n); cin >> a >> b; for (int i = 0; i < n; i++) if (a[i] != b[i]) for (int j = i + 1; j < n; j++) { if (a[i] ==... |
#include <bits/stdc++.h> const int N = 100100; struct Edge { int weight, type; int x, y; int num; bool operator<(const Edge& other) const { return weight == other.weight ? type > other.type : weight < other.weight; } } edges[N]; int n, m; int x[N], y[N]; bool b[N]; int main() { ... |
#include <bits/stdc++.h> using namespace std; bool fun(int n) { if (n == 1) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int main() { int n; scanf( %d , &n); if (fu... |
#include <bits/stdc++.h> const int MAXN = 55; const int MAXS = 10105; const int MOD = 1000000007; int n; bool g[MAXN][MAXN]; std::vector<int> e[MAXN][MAXN]; std::vector<int> tr[MAXS]; int f[MAXS]; void input() { int m; scanf( %d%d , &n, &m); for (int i = 0; i < m; ++i) { int x, y, nv... |
#include <bits/stdc++.h> using namespace std; bool jolmetsz(long long a, long long b, long long c, long long x1, long long y1, long long x2, long long y2) { return -c - a * x1 < b * y1 && -c - a * x2 > b * y2; } int main() { long long x1, x2, y1, y2, n, db = 0; cin >> x1 >> y1 >> x2 ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } string str; cin >> str; bool flag = 0; int start = 0; set<int> s; for (int i = 0; i < str.length(); i++) { if (!flag && str[i] ==... |
#include <bits/stdc++.h> using namespace std; set<int> s; int main() { int x; cin >> x; s.insert(x); for (;;) { x++; while (x % 10 == 0) x /= 10; int sz = s.size(); s.insert(x); if (sz == s.size()) { printf( %d , s.size()); return 0; } } } ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 266, inf = 1011111111; const string ans[] = { !x&x , x&y&z , !z&x&y , x&y , !y&x&z , x&z , !y&x&z|!z... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.