func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MX = 2e5 + 5; const long long INF = 1e18; const long double PI = acos((long double)-1); int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long tc; cin >> tc; while ... |
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define lb lower_bound #define up upper_bound #define sz(h) (int)h.size() #define all(h) h.begin(), h.end() #define mod 1000000007 #define mod1 998244353 #define MAX 2000010 #define cas(... |
#include <bits/stdc++.h> using namespace std; struct bottle { int number; double len; double lento; double diflen; } a[100005], b[100005]; int cmp(bottle a, bottle b) { if (a.diflen > b.diflen) return 1; return 0; } int main() { double x1, y1, x2, y2, c1, c2, x, y; scanf( %lf... |
#include <bits/stdc++.h> using namespace std; vector<int> d; int countDivisors(int n) { if (d[n] != 0) return d[n]; int res = 0; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (n / i == i) res++; else res += 2; } } d[n] = res; return... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, m, ans = 0; scanf( %I64d%I64d%I64d , &a, &b, &m); if (a >= m || b >= m) printf( 0 n ); else if (a <= 0 && b <= 0) printf( -1 n ); else { if (a < 0 || b < 0) { if (a > b) swap(a, b); ans =... |
#include <bits/stdc++.h> using namespace std; template <typename T> void chkMax(T &x, T y) { if (y > x) x = y; } template <typename T> void chkMin(T &x, T y) { if (y < x) x = y; } template <typename T> void inline read(T &x) { int f = 1; x = 0; char s = getchar(); while (s < 0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int n, m; unsigned long long A, B, C; struct E { int u, v; E(int u, int v) : u(u), v(v) {} }; struct Graph { int n, m, deg[maxn], cur[maxn]; unsigned long long hash_[maxn]; vector<E> edge; vector<int> small[max... |
#include <bits/stdc++.h> using namespace std; using namespace std; long long m = 33554431; long long bigmod(long long b, long long p) { if (p == 0) return 1; if (p % 2 == 0) { long long temp = bigmod(b, p / 2); return (temp * temp) % m; } return (bigmod(b, p - 1) * (b % m)) % m; } ... |
//begin #include <Core> /* * Package: StandardCodeLibrary.Core * Last Update: 2012-12-21 * */ #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <utility> #include <vector> #include <list> #include <string> #include <stack> #include <queue> #include <d... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; pair<int, int> a[MAX]; int bin_Upper(vector<pair<int, int> >& a, int l, int r, int x, int last) { int m = (l + r) / 2; if (l > r) return last; if (x > a[m].second) return bin_Upper(a, m + 1, r, x, last); if (x <= a[m].second) ... |
#include <bits/stdc++.h> int max(int a, int b) { return a > b ? a : b; } long long int min(long long int a, long long int b) { return a < b ? a : b; } int main() { using namespace std; int t, a, b; cin >> t; while (t--) { cin >> a >> b; cout << min(min(a, b), (a + b) / 3) << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; while (s.size() && s[0] == 0 ) { s.erase(s.begin()); } while (s.size() && s[(int)s.size() - 1] == 0 ) { s.erase(s.begin() + (int)s.size() - 1); ... |
#include <bits/stdc++.h> using namespace std; char pic[105][105]; int vis[105][105]; int disx[] = {-1, 1, 0, 0}; int disy[] = {0, 0, -1, 1}; struct node { int ro, lo, len; node() {} node(int rr, int ll, int le) { ro = rr; lo = ll; len = le; } }; int main() { int n, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y; cin >> n >> m; pair<int, pair<int, int> > arr[n]; int arr1[n], arr2[n]; for (int i = 0; i < n; ++i) cin >> arr1[i]; for (int i = 0; i < n; ++i) cin >> arr2[i]; for (int i = 0; i < n; ++i) { arr[i].second.fir... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; int n, m, it; bool a[250][250]; int u[250][250], lx, ly, rx, ry, k; const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; void go(int vx, int vy) { if ... |
#include <bits/stdc++.h> using namespace std; long long vp(pair<int, int> a, pair<int, int> b) { return (long long)a.first * b.second - (long long)a.second * b.first; } pair<int, int> mn(pair<int, int> a, pair<int, int> b) { return make_pair(a.first - b.first, a.second - b.second); } int main() { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x = 0, y; cin >> n; y = n * n / 2.0 + n / 2.0; cout << 6 * y + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; vector<long long> data; long long a, b, h, w, n, t, minVal; inline void swap(int &a, int &b) { int tmp = a; a = b; b = tmp; } inline int mini(int a, int b) { return a < b ? a : b; } bool cmp(long long a, long long b) { return a > b; } int dfs(int... |
#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; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } inline long long toLongLong(string s) { long long v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ... |
#include <bits/stdc++.h> using namespace std; const int imax = 1e9 + 7; const long long lmax = 1e18; const int maxn = 2005; int P[maxn], C[maxn], A[maxn]; vector<int> adj[maxn]; vector<int> dfs(int cur) { vector<int> ans(0), v(0); for (int next : adj[cur]) { v = dfs(next); ans.insert(a... |
#include <bits/stdc++.h> using namespace std; void fastIO() { ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(20); } long long A[100006]; long long B[100006]; long long C[100006]; long long rev(long long a, long long b) { return a > b; } int main() { fastIO(); vector<lon... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const long long inf = 1e17 + 7; string first(long long num) { string second = ; for (long long i = 0; i < num; i++) second += * ; return second; } signed main() { ci... |
#include <bits/stdc++.h> using namespace std; int n, x; bool vis[300010]; int a[300010]; int ans = 1; int main() { scanf( %d , &n); x = n; printf( %d , ans); for (int i = 1; i < n; i++) { scanf( %d , &a[i]); vis[a[i]] = 1; bool p = 0; bool v = 0; while (vis[x])... |
#include <bits/stdc++.h> using namespace std; struct piece { int x, y; char p[20][20]; piece(int _x, int _y) : x(_x), y(_y) {} bool operator<(const piece& rhs) const { if ((x * y) != (rhs.x * rhs.y)) return (x * y) < (rhs.x * rhs.y); else return x < rhs.x; } }; st... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t > 0) { int a[3]; for (int i = 0; i < 3; i++) { cin >> a[i]; } sort(a, a + 3); long c; if (a[0] == a[1] && a[1] == a[2]) c = 0; else if (a[0] == a[1] && a[2] - a[... |
#include <bits/stdc++.h> using namespace std; int main() { int l, r, i, j, d, tp; cin >> l >> r; bool f; for (i = l; i <= r; i++) { tp = i; int arr[10]; for (j = 0; j < 10; j++) arr[j] = 0; while (tp > 0) { d = tp % 10; tp = tp / 10; arr[d]++; } ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; using VI = vector<int>; using VC = vector<char>; using VS = vector<string>; using VL = vector<long long>; using VVI = vector<VI>; using VVL = vector<VL>; using MII = map<int, int>; using MIVI = map<int, VI>; using MSS = map<string... |
#include <bits/stdc++.h> using namespace std; const int N = 15000001; int64_t primes[N]; int64_t gcd(int64_t a, int64_t b) { if (a == 0) return b; else return gcd(b % a, a); } int64_t Power(int64_t base, int64_t e) { if (e == 0) return 1; int64_t ans = base; e--; while (e... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, i, j, cnt, k, lo, hi, mid; cin >> t; while (t--) { string s, t; cin >> s >> t; vector<long long int> v[26]; for (i = 0; s[i]; i++) { v[s[i] - a ].push_back(i); } bool flag = true; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (--t >= 0) { long long a, b, c, d; cin >> a >> b >> c >> d; if (a <= b) { cout << b << endl; continue; } if (c <= d) { cout << -1 << endl; continue; } ... |
#include <bits/stdc++.h> using namespace std; vector<int> a[10005]; int main() { int n, x, k = 0; cin >> n; x = (sqrt(1.0 + 8 * n) + 1) / 2; cout << x << endl; for (int i = 1; i <= x; i++) for (int j = i + 1; j <= x; j++) a[i].push_back(++k), a[j].push_back(k); for (int i = 1; i <= x... |
#include <bits/stdc++.h> using namespace std; char s[200010]; int n, k; int sa[200010]; int ra[200010], tr[200010]; int lcp[200010]; int l[200010], r[200010]; stack<int> ls, rs; set<long long> ss; bool CmpSa(int a, int b) { if (ra[a] != ra[b]) return ra[a] < ra[b]; int aa = a + k < n ? ra[a ... |
#include <bits/stdc++.h> using namespace std; template <typename G, typename H> struct triple { G first, second, T; triple(G x, G y, G z) : first(x), second(y), T(z) {} triple() : first(0), second(0), T(0) {} bool operator<(const triple<G, H> other) const { return first > other.first; } }; int... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e2 + 10; const int INF = 1 << 30; char str[MAXN][MAXN]; int Pow(int a, int b) { if (b == 0) return 1; int res = 1; while (b--) res *= a; return res; } int main() { int a, b, n; while (scanf( %d%d%d , &a, &b, &n) != EOF... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int maxn = 2e5 + 10; int a[maxn]; char s[maxn]; const char *t = LR ; int main() { int n; cin >> n; for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); scanf( %s , s); ... |
#include <bits/stdc++.h> using namespace std; long long po(long long x, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = (res * x) % 998244353; n = n / 2; x = (x * x) % 998244353; } return res; } long long fac[500000 + 1] = {0}; long long ifac[500000 + 1] = ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; long long int a[n]; for (long long int i = 0; i < n; i++) { a[i] = 0; } long long int x; for (long long int i = 0; i < m; i++) { cin >> x; a[x - 1] += 1; } long long in... |
#include <bits/stdc++.h> const int maxn = 11111; struct dsu { int f[555]; int c; void init() { int i; c = 0; for (i = 1; i <= 505; i++) f[i] = i; } int find(int a) { return f[a] == a ? a : f[a] = find(f[a]); } void Union(int x, int y) { x = find(x), y = find(y); ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 2; vector<int> G[MAXN]; double f[MAXN]; int siz[MAXN]; int pa[MAXN]; void dfs(int u) { for (int i = 0; i < G[u].size(); ++i) { int v = G[u][i]; f[v] = f[u] + 1.0 + (siz[u] - siz[v] - 1.0) / 2.0; dfs(v); } }... |
#include <bits/stdc++.h> void sc(int &x) { scanf( %d , &x); } void sc(int &x, int &y) { scanf( %d%d , &x, &y); } void sc(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); } void sc(long long &x) { scanf( %lld , &x); } void sc(long long &x, long long &y) { scanf( %lld%lld , &x, &y); } void sc(long long ... |
#include <bits/stdc++.h> using namespace std; const int MX = 100009; int arr[MX]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) scanf( %d , arr + i); int add = 0; for (int i = 0; i < m; ++i) { int cmd; scanf( %d , &cmd); if (cmd == 1) { i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p = 1000000000; cin >> n; int k[n], i; for (i = 0; i < n; i++) { cin >> k[i]; } i = 0; int j = 0, sum = 0; while (n--) { sum = 0; while (k[i]--) { cin >> j; sum = sum + j * 5 + 15; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; const double eps = 0.000001; int q(int i, int j, vector<int> &ps) { if (i > j) return 0; if (i) return ps[j] - ps[i - 1]; return ps[j]; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int n, m; set<int> s; const int nax = 5e5 + 4; int link[nax]; set<pair<int, int>> edge; vector<vector<int>> group; inline void make_set(int i) { link[i] = i; } int Find(int a) { if (link[a] == a) return a; return (link[a] = Find(link[a])); } vo... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n; vector<pair<int, long long> > fa[100], fb[100]; long long powmod(long long a, long long k) { long long ret = 1; while (k) { if (k & 1) { ret = ret * a % mod; } a = a * a % mod; k >>= 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n), b(m); int an; cin >> an; for (int i = 0; i < an; ++i) { int t; cin >> t; a[t] = 1; } int bn; cin >> bn; for (int i = 0; i < bn; ++i) { int t; ci... |
#include <bits/stdc++.h> using namespace std; int main() { string s, out; cin >> s; for (int i = 0; s[i] != 0 ; i++) { s[i] = tolower(s[i]); if (s[i] == o || s[i] == u || s[i] == i || s[i] == e || s[i] == a || s[i] == y ) ; else { out += . ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int ans = 0, flag = 1; for (int i = 0; i < n; i++) { if (s[i] != ? ) { if (s[i] == s[i + 1]) { flag = 0; } } else if (i == 0 || i == n - 1 || s[i + 1] == s[i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50 + 10; int n, m, vis[maxn][maxn], need[maxn][maxn]; struct node { int x, y, a, b; } p[maxn]; vector<node> vec; inline void move(int id, int x, int y) { vec.push_back((node){p[id].x, p[id].y, p[id].x + x, p[id].y + y}); vis[p[id].... |
#include<cmath> #include<iostream> #include<sstream> #include<cstdio> #include<cstring> #include<string> #include<cstdlib> #include<istream> #include<vector> #include<stack> #include<set> //#include<unordered_map> #include<map> #include<algorithm> #include<queue> #define mmp make_pair #d... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1000000007; const int inv3 = (mod + 1) / 3; const int maxn = 3003003; int fac[maxn], ifac[maxn]; int qpow(int a, int n) { int ans = 1; for (; n; n >>= 1, a = (ll)a * a % mod) if (n & 1) ans = (ll)ans * a % mo... |
#include <bits/stdc++.h> using namespace std; string mt[1226], sc[1226], s[51], q1, q2; int n, k1, k2, c; map<string, int> O, Z, P; pair<pair<pair<int, int>, int>, string> p[51]; vector<string> v; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; } for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; int n, q; vector<int> l, r, x, y; vector<long long> sum; double ans(int x1, int y1, int x, int y) { long long a = y1 - y; long long b = x - x1; long long c = -a * x - b * y; double xs = -1.0 * c / a; int ll = 0, rr = n - 1; while (ll <= rr)... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:1024000000,1024000000 ) char s[2000006]; long long dp[2000006][5]; int main() { int i, j, k, l; int n; while (cin >> s) { memset(dp, 0, sizeof(dp)); int len = strlen(s); if (s[0] == ? ) { dp[0]... |
#include <bits/stdc++.h> const int p = 1000000007; int c[1105][1105], d[1005], f[1005][50][1005]; int h, i, j, k, m, n, s, t; int main() { d[0] = 1; for (i = 1; i <= 1001; i++) d[i] = 1LL * i * d[i - 1] % p; for (i = 0; i <= 1100; i++) for (j = 0; j <= i; j++) if ((j == 0) && (j == i))... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000009; struct mat22 { long long M[2][2]; mat22(int a) { M[0][0] = M[1][1] = 1, M[0][1] = M[1][0] = 0; } mat22() { M[0][0] = M[1][1] = 0, M[0][1] = M[1][0] = 0; } }; mat22 pw[500000]; mat22 Spw[500000]; struct node { int z, ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; long long n, s, ans, ans2, ret; struct Node { long long val, tmp; int id; } node[N]; bool cmp(Node A, Node B) { return A.tmp < B.tmp; } bool check(int x) { for (int i = 1; i <= n; i++) { node[i].tmp = node[i].val + nod... |
#include <bits/stdc++.h> using namespace std; struct node { int val; int mx[32]; }; int n, k, p; vector<int> a[200005]; node st[4 * 200005]; int b[5]; void build(int si, int ss, int se) { if (ss == se) { st[si].val = 0; for (int i = 0; i < p; i++) { int val = 0; f... |
#include <bits/stdc++.h> using namespace std; template <class T> struct Seg { const T ID = 0; T comb(T a, T b) { return a + b; } long long n; vector<T> seg; void init(long long _n) { n = _n; seg.assign(2 * n, ID); } void pull(long long p) { seg[p] = comb(seg[2 * p], seg[2 *... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, t = 0; string road; cin >> n >> road; for (int i = 1; i < n; ++i) { if (road[i] == L ) { t = i; for (int j = i + 1; j < n; ++j) { if (road[j] == . ) { s = j; break; ... |
#include <bits/stdc++.h> using namespace std; template <class T> void in(T &x) { x = 0; bool f = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = 1; c = getchar(); } while ( 0 <= c && c <= 9 ) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(... |
#include <bits/stdc++.h> using namespace std; int main() { int T, n; cin >> T; double R1, R2, R3; while (T--) { scanf( %lf%lf%d , &R1, &R2, &n); R3 = R1 - R2; double k1 = -1 / R1; double k2 = 1 / R2; double k3 = 1 / R3; double k4 = k1 + k2 + k3; double ans; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; set<int> s; for (int i = 0, x; i < n; i++) { cin >> x; s.insert(((x + i) % n + n) % n); } puts(s.size() == n ? YES : NO ); } return 0;... |
#include <bits/stdc++.h> using namespace std; int n; char a[5]; char s1[3], s2[3]; void solve() { int i, vt, kq1, kq2; scanf( %d , &n); n = n % 4; a[0] = v ; a[1] = < ; a[2] = ^ ; a[3] = > ; for (i = 0; i < 4; i++) if (a[i] == s1[0]) vt = i; kq1 = 0; kq2 = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf( %d%d , &a, &b); for (int i = b + 1; i <= a + b + 1; i++) printf( %d , i); for (int i = b; i >= 1; i--) printf( %d , i); return 0; } |
#include<iostream> #include<math.h> #include<bits/stdc++.h> #include <string> #include <vector> using namespace std; #define pi (2*acos(0.0)) #define ll long long int #define ull unsigned long long int #define lp(i , start , n) for(int i = start ; i < n; i++) int main(){ ios::sync_wi... |
#include <bits/stdc++.h> using namespace std; int a[10000000], b[10010000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } int p = 0; sort(a, a + n); for (i... |
#include <bits/stdc++.h> using namespace std; const int MAX_INT = INT32_MAX; const long long MAX_LL = INT64_MAX; const long long mod = 1e9 + 7; const int N = 1; bool primes[N + 1]; int npr(int n, int r) { int res = 1; for (auto i = n - r + 1; i <= n; i++) res *= i; return res; } int ncr(in... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s, k; cin >> s; map<string, int> m; for (int i = 0; i < s.size() - 9; i++) { if (s[i] != - && s[i + 1] != - && s[i + 2] == - && s[i + 3] != - && s[i... |
#include <bits/stdc++.h> using namespace std; FILE* in = stdin; FILE* out = stdout; const int MAX = 100001; const int INF = 1000000001; int n; int dist[MAX]; long long a[MAX]; int main(void) { fscanf(in, %d , &n); for (int i = 0; i < n; i++) fscanf(in, %lld , &a[i]); sort(a, a + n); ... |
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << = << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != , ) cerr << *sdbg++; cerr << = << h << , ; _dbg(sdbg + 1... |
#include <bits/stdc++.h> using namespace std; long long int sum1, sum2; inline void in(long long int &_8) { long long int _6 = 1; char _0; while (((_0 = getchar()) < 0 || _0 > 9 ) && _0 != - ) ; _0 == - ? (_6 = -1, _8 = 0) : (_8 = _0 - 0 ); while ((_0 = getchar()) >= 0 && _0 <= ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; scanf( %d , &n); vector<int> a(n), b(n); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); --a[i]; } for (int i = 0; i < n; ++i) { scanf( %d , &b[i]); --b[i]; } vector<in... |
#include <bits/stdc++.h> using namespace std; int n, f[2][30], a[100005], b[100005]; string s; int main() { scanf( %d , &n); int now = 1, pre = 0; for (int i = 1; i <= n; i++, swap(now, pre)) { cin >> s; int len = s.length(); memset(f[now], 0, sizeof f[now]); for (int j = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; set<long long> myset; set<long long>::iterator it; long long n, k, q, t; map<long long, int> mp; cin >> n >> k; for (long long i = 0; i < n; i++) { scanf( %I64d , &t); v.push_back(t); myset.... |
#include <bits/stdc++.h> using namespace std; const int nmax = 2e5 + 42; int n, k; int main() { cin >> n >> k; int d = (n - k) / 2; int cycle = d + 1; for (int i = 1; i <= n; i++) if (i % cycle == 0) cout << 1 ; else cout << 0 ; return 0; } |
#include <bits/stdc++.h> using namespace std; char s[105]; int main() { int n; cin >> n; cin >> s; int flag = 0; for (int i = 1; i < n; i++) { if (s[i] != ? && s[i] == s[i - 1]) { flag = 1; break; } } if (flag) cout << No << endl; else { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 6, m = 8; vector<string> a(n); vector<vector<int>> u; vector<int> loc(m); loc = {3, 3, -1, 4, 4, -1, 3, 3}; u.push_back(loc); u.push_back(loc); loc = {2, 2, -1, 3, 3, -1, 2, 2}; u.push_back(loc); u.push_back(l... |
#include <bits/stdc++.h> using namespace std; bool solve(const vector<int>& hps, const vector<int>& hero, vector<int>& soln, int frm, int dir) { soln.clear(); int n = hps.size(); if (n == 0) return true; vector<int> heroes; heroes.push_back(0); for (int i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; bool SortbySecDesc(const pair<long long, long long> &a, const pair<long long, long long> &b) { return a.second > b.second; } bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } int main() ... |
#include <bits/stdc++.h> int main() { int k, tk; long long n, ck, a; scanf( %I64d %d , &n, &k); long long menor = n; scanf( %I64d , &a); tk = 1; ck = n / a; menor = n % a; for (int i = 1; i < k; i++) { scanf( %I64d , &a); if (n % a < menor) { tk = i + 1; ... |
#include <bits/stdc++.h> std::vector<std::vector<int>> ad; std::vector<int> fm; std::vector<bool> tmp; int f(int x) { if (fm[x] >= 0) return fm[x]; for (int y : ad[x]) f(y); for (int y : ad[x]) tmp[fm[y]] = true; fm[x] = int(std::find(begin(tmp), end(tmp), false) - begin(tmp)); for (int y : ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, i; long long h, k, a[100005], cnt = 0; cin >> n >> h >> k; for (i = 0; i < n; i++) cin >> a[i]; long long carry = 0; for (i = 0; i < n; i++) { if (carry + a[i] <= h) { ... |
#include <bits/stdc++.h> using namespace std; const int L = 50500, C = 27, N = 11, root = 0, None = -987958798; const char END = { ; struct node { int s[C], b[N], par, val; } t[L * 22] = {}; char ch[L * 22] = {}; int n, l = 0, tot = 0, x[N] = {}, y[N] = {}, d[N] = {}, in[L * 22] = {}, q[L * ... |
#include <bits/stdc++.h> using namespace std; struct node { int co, key; } num[1010]; int seven; char str[1010 * 100]; int init; bool cmp(node x, node y) { return x.co < y.co; } int main() { scanf( %d , &init); scanf( %s , str); seven = 1; int cnt = 1; int length = strlen(str); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const long long p1 = 737; const long long p2 = 3079; const long long m1 = 1000000123; const long long m2 = 1000000321; vector<long long> p_pow1(N), p_pow2(N); pair<vector<long long>, vector<long long> > H[3]; void init() { p_pow1[... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, c, d, p, nl, np; { cin >> n >> k >> l >> c >> d >> p >> nl >> np; int D = k * l; D /= nl; cout << min(D, min((c * d), (p / np))) / n << endl; } } |
#include <bits/stdc++.h> using namespace std; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, 1, 0, -1}; int dx2[] = {1, -1, -1, 1, 0, 0, -1, 1}; int dy2[] = {1, -1, 1, -1, 1, -1, 0, 0}; int kmx[] = {-1, -1, 1, 1, 2, -2, 2, -2}; int kmy[] = {2, -2, 2, -2, -1, -1, 1, 1}; int bishopX[] = {-1, 1, -1, 1}; int bi... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int n, i, j, k, c, v, l = 1, r = 1, maxm = 0, minm; cin >> n; int A[n]; string s; cin >> s; for (i = 0; i < n; i++) A[i] = 0; for (i = 0; i < n; i++) { for (j =... |
#include <bits/stdc++.h> using namespace std; int div1(int a, int b) { if (a % b == 0) return a / b; else return a / b + 1; } int main() { int k, n, s, p; while (scanf( %d%d%d%d , &k, &n, &s, &p) != EOF) { int ever_need = div1(n, s); int ans = div1(ever_need * k, p); ... |
#include <bits/stdc++.h> using namespace std; const int N = 105; const int oo = 1e9; int g[N][N], n, m; int col[N]; vector<pair<int, int> > ans; pair<int, int> get(int val) { for (int i = 1; i <= m; ++i) { if (g[1][i] < val) return {oo, val}; } memset(col, 0, sizeof(col)); ans.clear(... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define inf 1e18 #define nn n #define vll vector<long long int> #define vl vector<long int> #define ff first #define ss second int main() { #ifndef ONLINE_JUDGE freopen( input.... |
#include <bits/stdc++.h> using namespace std; const int size = 400007; const long long modulo = 1000000007; const int INF = 2e9; const double EPS = 1e-8; const double PI = acos(-1.0); int d[2][size]; char board[2][size]; int compo[size]; int l[size], r[size]; int main() { ios_base::sync_with_s... |
#include <bits/stdc++.h> using namespace std; static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3f; static const double EPS = 1e-10; static const double PI = acos(-1.0); inline int read() { int X = 0; bool flag = 1; char ch = getchar(); while (ch < 0 || ch > ... |
#include <bits/stdc++.h> using namespace std; int n, m; pair<int, int> joker[2] = {{-1, -1}, {-1, -1}}; pair<int, int> s1 = {-1, -1}, s2 = {-1, -1}; string ranks = 23456789TJQKA , suits = CDHS , a[64][64]; set<string> deck; vector<string> left_cards; void gen_deck() { for (char r : ranks) fo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 25; string str[maxn]; int a[maxn][maxn]; long long dp[1 << 20]; int mask[26], tot[26], big[26], cnt[26], candi[26]; int Min[maxn]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> str[i]; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000006; int t, n, m, x, y; stack<int> s; int rg[N], rs[N], ls[N], lg[N], a[N]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } a[0] = a[n + 1] = 0; for (int i = 1; i <= n + 1; i++) { while (!s.e... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3FFFFFFF; char arr[1001][1001]; int main() { int n, m, x, y, z, p; scanf( %d%d%d%d%d%d , &n, &m, &x, &y, &z, &p); x %= 4; y %= 2; z %= 4; vector<int> a(p), b(p); for (int i = 0; i < p; i++) { scanf( %d%d , &a[i], &... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; if (a < b) return gcd(b, a); while (a > b) { a %= b; } return gcd(b, a); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } const double EPS = 10e-9; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.