func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int read() { int r = 0, t = 1, c = getchar(); while (c < 0 || c > 9 ) { t = c == - ? -1 : 1; c = getchar(); } while (c >= 0 && c <= 9 ) { r = (r << 3) + (r << 1) + (c ^ 48); c = getchar(); } return r * t; } nam... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, k; cin >> n >> m >> k; long long int a[m]; for (int i = 0; i < m; i++) cin >> a[i]; long long int s = 0, S = 0; for (int i = 0; i < m; i++) { long long int d; if ((a[i] - s) % k == 0) d = (a[i]... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long long mod = 998244353; const long long sz = 2e5 + 9; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a %... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); const int MAX_N = (int)1e7; vector<bool> isPrime(MAX_N, true); isPrime[1] = false; for (int i = 2; i < MAX_N; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } const int N = 1e2 + 9; char s[N], t[... |
#include <bits/stdc++.h> using namespace std; int main() { long long kkk, kk, otv = 0; string ss; long long i, a; cin >> a; for (i = 0; i < a; i++) { long long s1, s2, s3; cin >> s1 >> s2 >> s3; if ((s1 > s2 + s3 + 1) || (s2 > s1 + s3 + 1) || (s3 > s1 + s2 + 1)) cout <<... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, i; while (scanf( %lld%lld , &n, &k) != EOF) { long long a[k + 1]; vector<pair<long long, long long> > v; for (i = 0; i < k; i++) { cin >> a[i], v.push_back(make_pair((n % a[i]), i + 1)); } sort(v... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) using namespace std; const int maxn = 510; const int inf32 = 1e9 + 10; const long long inf64 = 1e18 + 10; const int mod = 998244353; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; bool bad[(1 << 20) + 10]; int belong[maxn], frequent[21]; int main() { int n, m, d; scanf( %d%d%d , &n, &m, &d); for (int i = 0; i < m; i++) { int s, x; scanf( %d , &s); while (s--) { scanf( %d , &x)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string a; cin >> a; int ans = 0; vector<int> vc; for (size_t i = 0; i < a.size(); i++) { if (a[i] == w && a[i - 1] == t && a[i + 1] == o && a[i + 2] == o &&... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct SD { int x, y, c; } p, pp; int f[50000], bk[110][110]; int n, m, k, maxx, ans, cur, sum, x, y; int minn; int nex[4][2] = {0, 1, 1, 0, 0, -1, -1, 0}; char mapp[1100][1100]; queue<struct SD> q; int bfs(int x, int y) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int test; cin >> test; while (test--) { int n; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] != ? ) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7, N = 1e5 + 10; void test() { ll n, m; cin >> n >> m; vector<vector<ll>> a(n, vector<ll>(m)); ll cnt = 0; for (ll i = 0; i < n; ++i) { for (ll j = 0; j < m; ++j) { char c; cin >> c... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; long long mod_add(long long a, long long b, long long m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; } long long mod_mul(long long a, long long b, long long m) { a = a % m; b = b % m; return (((a * b) % m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, cnt = 0; cin >> n; string s[n]; long long int h1[10] = {}, h2[10] = {}; for (int... |
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> #include<vector> #include<algorithm> #define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i) #define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i) #define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i]) #define Li inline #define R regi... |
#include <bits/stdc++.h> using namespace std; const int N = 6e4; long long vis[N]; long long ans[N]; vector<long long> adj[N]; void dfs(long long i, long long pa) { if (vis[i] == 1) return; else { vis[i] = 1; ans[i] = pa; for (vector<long long>::iterator itr = adj[i].begin();... |
#include <bits/stdc++.h> using namespace std; struct Node { int a, b, id; } p[100005]; bool mark[100005]; bool cmp1(const Node &p1, const Node &p2) { if (p1.b != p2.b) return p1.b > p2.b; else return p1.a < p2.a; } bool cmp2(const Node &p1, const Node &p2) { if (p1.a != p2.a) ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr ... |
#include <bits/stdc++.h> using namespace std; long long int expo(long long int base, long long int exponent, long long int mod) { long long int ans = 1; while (exponent != 0) { if (exponent & 1) ans = (1LL * ans * base) % mod; base = (1LL * base * base) % mod; exponent... |
// Problem: C. Minimum Ties // Contest: Codeforces - Educational Codeforces Round 104 (Rated for Div. 2) // URL: https://codeforces.com/contest/1487/problem/C // Memory Limit: 256 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org) //Weakness disgust me #include bits/stdc++.h... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const double err = 1e-12; const double PI = 3.141592653589793; const int N = 2e5 + 5; int n; vector<int> V; bool chk(int val) { auto it = upper_bound((V).begin(), (V).end(), val); for (; it != V.end(); it++) { int... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { scanf( %d%d , &n, &m); long long dp[m + 2]; int now = 0; int c, sum = 0; for (int i = 0; i < m; i++) { scanf( %d , &c); sum += c; dp[i] = sum; } dp[0] = -2147483647; long long ans = -2147483647; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> v(n); for (auto &first : v) cin >> first; int z = 0; for (auto first : v) if (first == 0) z++; if (z <= 1) { cout << 0 n ; return; } vector<pair<int, int> > cnt(n, make_pa... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int x; x = n % 4; if (n == 0) cout << 1 ; else if (x == 0) cout << 6 ; else if (x == 1) cout << 8 ; else if (x == 2) cout << 4 ; else if (x == 3) cout... |
#include <bits/stdc++.h> using namespace std; vector<int> grav[2050]; int n; int m, k; int mark[2050]; bool bad[2050]; int sz[2050]; void dfs(int v, int color) { mark[v] = color; for (int i = 0; i < (int)grav[v].size(); i++) { int u = grav[v][i]; if (mark[u] == 0) dfs(u, color); ... |
#include <bits/stdc++.h> using namespace std; void solve(); int arr[200005]; int count1[200005]; int count2[200005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } long long sum1 = 0; long long sum2 = 0; int cnt1 = 0; int cnt2 = 0; int ... |
#include <bits/stdc++.h> using namespace std; const int N = 2000 * 2000 + 1; int n, m, mark[N], mx, rep; string s; vector<int> adj[N]; bool circle(int v) { mark[v] = 1; for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i]; if (mark[u] == 1 || (!mark[u] && circle(u))) return true; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int a[maxn]; int n, m, ma, mi; int sum[2000005], ans[2000005]; bool ok(int mid) { int ans = 0, i; for (i = mid; i <= ma; i += mid) { ans += sum[i + m] - sum[i - 1]; } if (ans == n) return true; return false; }... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> arr(4 * n, 0); for (int i = 0; i < 4 * n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end()); int f = 1, i = 0, j = 4 * n - 1, area =... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, x, y, i; cin >> n >> x >> y; for (i = 1; (i + n - 1) <= y; i++) { if (((i * i) + (n - 1)) >= x) { cout << i << endl; n--; while (n--) cout << 1 << endl; return 0; } } cout << ... |
#pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) #include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, dd, q; cin >> n >> dd >> q; int arr[200001]; for (int i = 0; i < 200001; i++) { arr[i] = 0; } for (int h = 0; h < n; h++) { int t1, t2; cin >> t1 >> t2; arr[t1]++; arr[t2 + 1]--; } int cou... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--){ int n; cin >> n; vector<int> arr(n,0); for(int i = 0; i < n; i++){ cin >> arr[i]; } vector<int> str; str.push_back(arr[0]); ... |
#include <bits/stdc++.h> using namespace std; int a; char c[100009]; unsigned int dp[200009] = {1}; int main() { scanf( %d%s , &a, c); for (int i = a; i >= 1; i--) { c[i] = c[i - 1]; } if (a & 1) { cout << 0; } else { int e = a >> 1; int q = 0; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf( %d , &n) == 1) { int ara[n + 4], diftab[n + 4]; ara[0] = 0; for (int i = 1; i <= n; i++) { scanf( %d , &ara[i]); diftab[i - 1] = ara[i] - ara[i - 1]; } int ansara[n + 1], index = 0; ... |
#include <bits/stdc++.h> using namespace std; map<int, int> uf; map<int, vector<int> > contents; map<int, int> val; void make(int a) { if (uf.find(a) == uf.end()) { uf[a] = a; contents[a].push_back(a); val[a] = 0; } } int main() { cin.sync_with_stdio(0); cin.tie(0); i... |
#include <bits/stdc++.h> using namespace std; vector<int> g[200005]; int par[19][200005]; int depth[200005]; int dp[200005]; char s[200005]; void dfs(int u, int p, int d, int val) { par[0][u] = p; depth[u] = d; dp[u] = val ^ (1 << (s[u] - a )); for (int i = 0; i < g[u].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; bool *Seive(long long n, bool *p) { memset(p, 1, sizeof(p)); long long i, j; for (i = 2; i <= n; i++) { if (p[i] == 1) for (j = i * i; j <= n; j += i) { p[j] = 0; } } p[1] = 0; return p; } long long gcd(long lo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; cin >> t; while (t--) { string s; cin >> s; vector<int> counts; int current_count = 0; for (char c : s) { if (c == 1 ) { current_count += 1; } else if (curre... |
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <class T> o... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n; long long a[N], b[N]; int f[N][2]; long long WIN(long long x, long long y) { assert(x <= y); if (y & 1) return !(x & 1); if (x * 2 > y) return x & 1; if (x * 4 > y) return 1; return WIN(x, y / 4); } long long ... |
#include <bits/stdc++.h> int main() { char str[120]; gets(str); int len = strlen(str) - 1; int i; int count = 0; int reversed = 0; for (i = 0; i < len; i++) { if (str[i] == V && str[i + 1] == K ) { str[i] = c ; str[i + 1] = c ; ++count; } } ... |
#include <bits/stdc++.h> using namespace std; const int maxCol = 200010; const int maxID = 400010; const int INF = 400010; typedef struct RangeInfo { int dist[2][2]; int L; int R; RangeInfo() { L = R = -1; } RangeInfo(int idx, const vector<vector<bool> >& isEmpty) { L = R = idx; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; const int M = 22; const long long mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long l... |
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define ret(x) return cout<<x,0; #define rety return cout<< YES ,0; #define retn return cout<< NO ,0; typedef long long ll; typedef double db; typedef long double ld; #define stt string #define ve vector<ll> #define se set<ll> #def... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } long long F[2][2][1009][1009]; void ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int pref[N]; vector<int> v; int fsoma(int l, int r) { l--; int ans = pref[r]; if (l >= 0) ans -= pref[l]; return ans; } long long n, k, l; void rbest(pair<int, int> &a, pair<int, int> b) { if (b.first > a.first or ... |
#include <bits/stdc++.h> using namespace std; void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); } int main() { fast(); unsigned long long over = pow(2, 32); string s; int i; unsigned long long num = 0; stack<unsigned long long... |
#include <bits/stdc++.h> using namespace std; long long n, m; char A[1020304], B[1020304]; int data[1020304][27], vis[1020304]; int main() { cin >> n >> m; scanf( %s%s , A + 1, B + 1); int la = strlen(A + 1), lb = strlen(B + 1); memset(vis, 0, sizeof(vis)); int len = 0; int Tot = 0; ... |
#include <bits/stdc++.h> using namespace std; int n, m, t, k; long long l[10005], r[10005]; int x[10005]; char s1[10005][11], s2[10005][11]; int main() { scanf( %d , &n); long long lx = -2 * 1000000000, ly = 2 * 1000000000; l[0] = -2 * 1000000000; r[0] = 2 * 1000000000; int flag = 1; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; long long calc(long long nk, long long mk) { return (n / (nk + 1)) * (m / (mk + 1)); } int main() { cin >> n >> m >> k; if (k > n + m - 2) { cout << -1; return 0; } long long nk = min(k, n - 1); long long mk =... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int minr = 1e9 + 2; int maxl = 0; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; if (l > maxl) { maxl = l; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> report(n); int posCount = 0; int negCount = 0; for (int i = 0; i < n; i++) { cin >> report[i]; if (report[i] >= 0) { posCount++; } else { negCount++; } } if... |
#include <bits/stdc++.h> using namespace std; int b[105]; int vis[105]; int main() { int n; scanf( %d , &n); int a[105]; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); b[a[i]]++; } int ans1 = 0; int ans2 = 0; int jo = 1; int mm = 0; for (int i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int main() { string s1; string s2; while (cin >> s1 >> s2) { int n = s1.length(), m = s2.length(); int dp[n + 1][m + 1]; for (int i = 0; i < n + 1; i++) dp[i][0] = i; for (int i = 0; i < m + 1; i++) dp[0][i] = i; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; struct Trie { struct Node { char c; vector<pair<int, int> > n; Node* ch[26]; Node(char ch) { this->c = ch; for (int i = 0; i < 26; i++) this->ch[i] = NULL; } }; Node* root; vector<pair<int, int> > res; in... |
#include <bits/stdc++.h> using namespace std; const int N = 1E5 + 5; int t[N], n, a[N], f[N], b[N], k, x, mid; vector<int> G[N]; long long ans; bool O = 0; int work() { memset(f, 0, sizeof(f)); for (int i = k; i <= n - k + 1; i++) f[b[i]]++; int o = 0; for (int i = 1; i <= n; i++) if... |
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 2e5 + 10; const long long mod = 1e9 + 7; const bool debug = false; int F[N], Finv[N], inv[N]; void init() { inv[1] = 1, F[0] = Finv[0] = 1; for (int i = 2; i < N; i++) inv[i] = (mod - mod / i) * 1ll... |
#include <bits/stdc++.h> using namespace std; int n; long long a[1010]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } long long k; cin >> k; cin >> k; cin >> k; long long x = (long long)a[2] * a[1] / k; long double dx = x; long long ans = (long... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long _pow(long long a, long long b) { long long x = 1; for (long long j = 0; j < b; j++) { x *= a; } return x; } bool test(int a, int n, in... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int m = max((3 * a) / 10, a - (a * c) / 250); int v = max((3 * b) / 10, b - (b * d) / 250); if (m > v) cout << Misha << endl; else if (v > m) cout << Vasya << endl; else ... |
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; const long long arr = 2e5; long long a[arr], aa[arr]; long long n, d, b; bool check(long long u) { for (long long i = 1; i <= n; i++) a[i] = aa[i]; long long pluss = 0; long long uu = u; long long start = 1; long... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> m; int finalPos[4 * n]; memset(finalPos, -1, sizeof(finalPos)); for (int i = (2 * n) + 1, j = 0; i <= m; i++, j += 2) { finalPos[j] = i; } for (int i = 1... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.1415926535897932384626433832795l; template <typename T> inline auto sqr(T x) -> decltype(x * x) { return x * x; } template <typename T> inline T abs(T x) { return x > T() ? x : -x; } template <typename T1, typename T2> in... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T re() { T N = 0; char c = getchar(); bool neg = 0; for (; c < 0 || c > 9 ; c = getchar()) neg |= c == - ; for (; c >= 0 && c <= 9 ; c = getchar()) N = (N << 3) + (N << 1) + c - 0 ; return neg ? -N : N; } c... |
#include <bits/stdc++.h> int n, m, i, j, w[2001][3], v[2001], ct, a, b, c, t, tt, r[2001][3]; int min(int a, int b) { if (a > b) return b; return a; } int main() { scanf( %d%d , &n, &m); for (i = 0; i < m; i++) { scanf( %d%d%d , &a, &b, &c); w[a][0] = b, w[b][1] = a, w[a][2] = c; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a = 97, z = 97 + 25, t = n; string s = ; for (int i = 0; i < n; i++) { if (t >= k) { for (int j = 0; j < k; j++) { s += a + j; } i += k; i--; t -= k; ... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int grandN; vector<int> result; for (int i = 0; i < N; i++) { vector<int> grandmas; int temp; int res = 1; cin >> grandN; for (int j = 0; j < grandN; j++) { cin >> temp; gran... |
#include <bits/stdc++.h> const int N = 1010; int n, m, k; int i, j, d, mi, t; int a[N], b[N]; int main() { scanf( %d %d , &n, &m); for (i = 0; i <= n; i++) scanf( %d , &a[i]); for (i = 0; i <= m; i++) scanf( %d , &b[i]); if (n > m) { if (a[0] * b[0] > 0) printf( Infinity ); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000010; int n, m, cnt, head[maxn], vis[maxn], mark[maxn], ans[maxn], tot; struct edge { int to, next; } e[maxn]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = ... |
#include <bits/stdc++.h> using namespace std; map<string, string> vars; struct proc { string name, arg[10]; int argn; proc(string v, bool V) { string til = ; int k = 0; for (int i = 0; i < v.length(); i++) { if (v[i] == ( ) { name = til; til = ; ... |
#include <bits/stdc++.h> using namespace std; int a[105]; double t[105]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int cnt; for (int d = -1000; d <= 1000; d++) { if (d != 0) { for (int i = 0; i < n; i++) { t[i] = a[i] * 1.0 /... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; bool is_prime(long long n) { if (n == 1 || n == 0) return false; if (n == 2 || n == 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 1; (6 * i + 1) <= n; i++) { if (6 * i + 1 == n) return ... |
#include <bits/stdc++.h> using namespace std; int main() { int h1, m1, h2, m2, result1, result2; char c = : ; while (cin >> h1 >> c >> m1 >> h2 >> c >> m2) { if (m1 < m2) { h1 -= 1; m1 += 60; } result2 = m1 - m2; result1 = h1 - h2; if (result1 < 0) result1 ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; n = n / 2520; cout << n; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; map<string, int> mat; int fonction(string a, string b, string c) { int x = (mat[b] - mat[a] + 12) % 12; int y = (mat[c] - mat[b] + 12) % 12; int z = (mat[c] - mat[a] + 12) % 12; if (x == 4 && y == 3 && z == 7) return 1; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void scanv(vector<T>& v, int n) { v.resize(n); for (int i = 0; i < n; i++) cin >> v[i]; } template <typename T> void scanvv(vector<vector<T> >& v, int n, int m) { v.resize(n); for (int i = 0; i < n; i++) scanv(v[i], m); } ... |
#include <bits/stdc++.h> using namespace std; long long n, m, s[7]; long long lin[100005][1 << 7], cov[1 << 7]; char ch[100005], ans[100005]; vector<long long> e[100005]; bool hall(long long x) { for (long long ss = 0; ss <= (1 << 6) - 1; ss++) { long long sum = 0; for (long long i = 1; i <=... |
/** * Author: Daniel * Created Time: 2021-03-13 13:41:37 **/ // time-limit: 2000 #include <bits/stdc++.h> using namespace std; #define F first #define S second #define ER erase #define IS insert #define PI acos(-1) #define PB pop_back #define EB emplace_back #define lowbit(x) (x ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int ans = INT_MAX; for (int i = 0; i * i <= n; i++) { ans = min(ans, i + (n + i) / (i + 1)); } cout << ans - 1 << n ; } return 0; } |
#include <bits/stdc++.h> const int MAX_N = (int)5e5 + 4, MAX_M = (int)1e7 + 4; const double eps = 1e-6; const int mod = (int)1e9 + 7; using namespace std; int n; int a[MAX_N]; bool pr[MAX_M]; int lp[MAX_M], mu[MAX_M]; inline void sieve() { for (int i = 2; i < MAX_M; i++) { if (pr[i]) continu... |
#include <bits/stdc++.h> using namespace std; int get() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } return x * f; } const int N = 1e6 + 5, Base... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, x = 0, c = 0; cin >> n; while (n != 1) { if (x == 3) { cout << -1 << endl; break; } if (n % 6 == 0) { n /= 6; c++; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5; const int mod = 1e9 + 7; int cnt; int head[MAX + 5], to[4 * MAX + 5], nex[4 * MAX + 5]; void add(int u, int v) { to[++cnt] = v; nex[cnt] = head[u]; head[u] = cnt; } int n, m; int _cnt; long long prime[MAX + 5], es[MAX + 5... |
#include <bits/stdc++.h> using namespace std; int fx[] = {0, 0, 1, -1}; int fy[] = {1, -1, 0, 0}; int n, i, j, p, q, flag, _count, k; char s[101][101]; int main() { cin >> n; for (i = 0; i < n; i++) { scanf( %s , s[i]); } for (i = 0; i < n; i++) { for (k = 0; k < n; k++) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, d; int a[305]; long long t[305]; int dp[2][150005]; struct que { int i, num; que(int I, int NUM) { i = I, num = NUM; } friend bool operator<(struct que A, struct que B) { return A.num > B.num; } }; int compute() { int s0 = 0, s1 = 1... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_str... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int dp[1001][1001][2]; long long int foo(long long int l, long long int r, int f) { if (l > r) return 0; if (dp[l][r][f]) return dp[l][r][f]; if (r == 1 && l == 0) return 1 - f; if (l > 0) { if (f) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int mod = 1e9 + 9; long long qpow(long long a, long long b) { long long base = a; long long ans = 1; while (b) { if (b & 1) { ans = (ans * base) % mod; } base = (base * base) % mod; b = b >... |
#include <bits/stdc++.h> using namespace std; long long b[200005]; int main() { int t; cin>>t; while(t--) { map<long long ,int >q; int n; scanf( %d ,&n); for(int i=1;i<=n+2;i++) { scanf( %lld ,&b[i]); q[b[i]]++; } sort(b+1,b+1+2+n); long long sum=0; for(... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; cin >> n; vector<int> cand(26, 1); string t, w; int f = 0, ans = 0; for (int i = 0; i < n - 1; i++) { cin >> t >> w; if (f == 1) { ans += (t == ! || t == ? ); continue... |
#include <bits/stdc++.h> using namespace std; char getc() { char c = getchar(); while ((c < A || c > Z ) && (c < a || c > z ) && (c < 0 || c > 9 )) c = getchar(); return c; } int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); } int read() { int x = 0, f = 1; char c =... |
#include <bits/stdc++.h> using namespace std; string s; char c[200005]; int dem[11]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int Tests; cin >> Tests; while (Tests--) { cin >> s; int n = s.size(); int pos = -1; int cpos = 0; mems... |
#include <bits/stdc++.h> using namespace std; using ll = long long; void io() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int N = 1e5 + 5; vector<int> g[N]; int sz[N], parent[N], done[N]; int lvl[N]; void dfs(int u, int p) { sz[u] = 1; for (int v : g[... |
#include <bits/stdc++.h> using namespace std; int n, m, len; int arr[110]; int brr[110]; int main() { int i, j, k, t, a, b; ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n >> m; for (i = 0; i < m; i++) { memset(arr, 0, sizeof(arr)); for (j = 0; j < n; ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 500; const long long INF = 1e9; const long long BITS = 64; const long double EPS = 1e-9; void bye() { cout << n ; exit(0); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 50; const int MOD = 1e9 + 9; int n, k, a, b, c, d, m, L, R, tot = 1; pair<int, int> cities[MAXN]; struct TreeNode { int x, l, r, lson, rson; pair<int, int> v; } tree[MAXN]; int newNode(int &x) { return x = ++tot; } pair<int, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; vector<pair<int, int>> v; for (i = 0; i < n; i++) { int x, y; cin >> x >> y; v.push_back(make_pair(x, y)); } int ans = 0; int total = 0; bool u, d, l, r; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 500 + 7; long long mod = 1e9 + 7; bool solve(long long l, long long r, long long mx, long long& ans) { if (r - l + 1 > mx) { return false; } ans = -l + 1; return true; } int main() { ios_base::sync_with_stdio(0), cin.tie(0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.