func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> void solve() { int n; std::cin >> n; std::stack<int> q; int a = 0; int cur = 1; n += n; while (n--) { std::string s; std::cin >> s; if (s[0] == r ) { if (!q.empty() && q.top() != cur) { while (!q.empty()) q.pop(); ++a;... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool smin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const long long N = 1e5 + 100, lg = 22; long long n, k, add[N], h[N]... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int arr[n][4]; multiset<int> s[4]; for (int i = 0; i < n; i++) { for (int j = 0; j < 4; j++) { cin >> arr[i][j]; s[j].insert(arr[i]... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, k; cin >> n >> m >> k; long long p[m]; for (long long int i = 0; i < m; i++) cin >> p[i]; sort(p, p + m); long long an = 0, x = 0, c = 0, cp = 1; while (1) { long long y = x, pg = ceil((long double)(p[x] -... |
#include <bits/stdc++.h> using namespace std; int main() { int requestNum; cin >> requestNum; vector<pair<int, pair<int, int>>> vect(requestNum); for (int i = 0; i < requestNum; i++) { int num, money; cin >> num >> money; vect.push_back(make_pair(money, make_pair(num, i + 1))); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7; const double PI = 3.1415926536; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool is_prime(long long n) { for (long long i = 2; i * i <= n; ++i) { if (n % i == 0) { re... |
#include <bits/stdc++.h> using namespace std; void faster() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } string s, x, t, ans; long long q, n, a[456789], b[456789], sum, prefa[456789], prefb[456789], k, l, r, mx; bool ok; void dii() { cin >> n; for (int i =... |
#include <bits/stdc++.h> const int INF = 1 << 29; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); ; int n; std::cin >> n; std::vector<int> v(n); for (int &it : v) std::cin >> it; int alice = v[0]; int sum = std::accumulate(v.begin(), v.end(), 0); int t... |
#include <bits/stdc++.h> void dfs(int64_t node, int64_t from, const std::vector<std::vector<int64_t> > &g, std::vector<bool> &visited, int64_t &count, bool &cycle, bool &self) { if (visited[node]) { return; } visited[node] = 1; ++count; for (int64_t p = 0; p < g[node].s... |
#include <bits/stdc++.h> const int N = 1010, M = 2010; int las[M], nxt[M], to[M], cnt; int l[M], r[M], siz[M], mx[N][N], f[N]; inline void add(int u, int v) { cnt++; to[cnt] = v; nxt[cnt] = las[u]; las[u] = cnt; } int n, m; inline void fmin(int &a, int b) { if (a > b) a = b; } inli... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, ans[N], an; struct edge { int to, nx, id, dl; } ee[N]; int eq[N], en = 1; void dfs(int d) { for (int j = eq[d], k; k = ee[j].to, j; j = ee[j].nx) if (!ee[j].dl) { ee[j].dl = 1; dfs(k); ans[--an... |
#include <bits/stdc++.h> using namespace std; void _print(long long t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t)... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double pi = acos(-1); const double EPS = 1e-9; long long binpowmod(long long a, long long b) { a %= MOD; long long ret = 1; while (b) { if (b & 1) ret = ret * a % MOD; a = a * a % MOD; b >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d%d , &n, &k); long long ans1 = 1, ans2 = 1; for (int i = 1; i <= k - 1; i++) ans1 = ans1 * k % 1000000007; for (int i = 1; i <= n - k; i++) ans2 = ans2 * (n - k) % 1000000007; printf( %I64d n , ans1 * ans2 % 100000... |
#include <bits/stdc++.h> using namespace std; const int N = 25, mod = 1e9 + 7; int a[N][N], used[N][N], cur, first, n, m, k; long long ans; int count(int x) { int ans = 0; for (; x; x -= x & -x) ans++; return ans; } void dfs(int x, int y) { if (x == n) { int p = count(cur & ~first), ... |
#include <bits/stdc++.h> using namespace std; int main() { int p1, p2, p3, p4, a, b; cin >> p1 >> p2 >> p3 >> p4 >> a >> b; int m = min(min(min(p1, p2), p3), p4); cout << max(0, min(b + 1, m) - a) << endl; return 0; } |
#include <bits/stdc++.h> const int inf = (1 << 30) - 1; const double eps = 1e-9; using namespace std; int a[111111], n, k, mx = 0, aa; long long s[111111]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; int n; double dp[(1 << 20)]; double a[20][20]; int main() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } dp[(1 << n) - 1] = 1.0; for (int st = (1 << n) - 1; st >= 0; st--) { ... |
#include <bits/stdc++.h> using namespace std; int pr[] = {2, 3, 5, 7, 11, 13, 17, 19}; int big[50000005]; int c[10]; int ans[10100]; int main() { int k; scanf( %d , &k); big[1] = 0; for (int i = 0; i < 7; i++) big[pr[i]] = i + 1; for (int i = 2; i <= 2 * k * k; i++) { if (big[i] ==... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 5; int s[maxn]; int a[maxn]; int main() { int n; scanf( %d , &n); long long ans = 0; for (int i = 1; i <= n; i++) { scanf( %d , &s[i]); } sort(s + 1, s + n + 1); for (int i = 1; i <= n / 2; i++) { a[i]... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9; long long Power(long long a, long long b) { if (b == 0) return 1; long long p = Power(a, b / 2); p = (p * p); if (b & 1) { p = (p * a); } return p; } long long Gcd(long long a, long long b) { if (b ==... |
#include <bits/stdc++.h> using namespace std; const int N = 2e4 + 5; char s[N]; int dp[10][N]; int ans[N]; int len; int dfs(int num, int idx) { if (~dp[num][idx]) return dp[num][idx]; if (idx == len) return 1; else if (idx > len) return 0; int &ret = dp[num][idx]; ret = dfs... |
#include <bits/stdc++.h> using namespace std; long long jc[210000], ny[210000]; char s[210000]; int n, f[210000], g[210000], ans; int C(int n, int m) { if (m > n) return 0; return jc[n] * ny[m] % 1000000007 * ny[n - m] % 1000000007; } int main() { scanf( %s , s + 1); n = strlen(s + 1); ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int mod = 1e9 + 7; const int N = 100 + 10; inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x; } inline int mul(int x, int y) { x = (1LL * x * y) % mod; return x; } vector<pair<int,... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct query { int i, type, l, r, k, p, x; }; int n, m; vector<int> a, _a; query q[N]; int queryCnt; int block_size; int ans[N]; int freqA[N]; int freqL[N], freqR[N], freqV[N]; void increaseFreq(int f) { fre... |
#include <bits/stdc++.h> using namespace std; pair<long long, pair<long long, long long> > stree[4000005]; char sa[1000005]; void build(long long node, long long start, long long end) { if (start == end) { stree[node].first = 0; stree[node].second.first = 0; stree[node].second.second = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t, ss, tt; int bc; vector<int> res; cin >> bc >> s >> t; ss = s; tt = t; sort(ss.begin(), ss.end()); sort(tt.begin(), tt.end()); if (ss != tt) { cout << -1; return 0; } if (!is_permutation(s.... |
#include <bits/stdc++.h> using namespace std; template <class T> typename T::value_type arr_sum(const T& v, int n) { typename T::value_type sum = 0; for (int i = 0; i < n; ++i) sum += v[i]; return sum; } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(fa... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int q; cin >> q; while (q--) { ll a, b, m; cin >> a >> b >> m; if (a == b) { cout << 1 << << a << n ; continue; } b... |
#include <bits/stdc++.h> using namespace std; bool check(string s) { string t = s; reverse(t.begin(), t.end()); return (s == t); } int main() { string s; cin >> s; int l = 0, r = ((int)s.length()) - 1; set<char> all; while (l < r) { all.insert(s[l]); all.insert(s[r]);... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T MAX(T a, T b) { if (a > b) return a; return b; } template <class T> inline T MIN(T a, T b) { if (a < b) return a; return b; } template <class T> inline T ABS(T x) { if (x < 0) return -x; return x; } i... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, -1, 0, 1, -1, -1, 1, 1}; const int dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; int n, pre = 0; int a[1005], b[1005], p[1005]; vector<int> num; bool vis[1005]; bool valid() { int na = 0; set<int> st; for (int j = 0; j < n; ++j) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; if (n % 2 == 0) { for (int i = 0; i < n - 2; i++) { cout << s[i]; if (i % 2) { cout << - ; } } cout << s[n - 2] << s[n - 1]; } if (n % 2) {... |
#include <bits/stdc++.h> int C[100005], D[505][505], L[100005], R[100005], Par[100005]; int N, K, M; using namespace std; int find(int n) { if (Par[n] == n) return n; else return Par[n] = find(Par[n]); } void join(int a, int b) { Par[find(a)] = find(b); } int main() { cin >> N >> M... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> g[100001], vc; int judge(int x) { vc.clear(); int need = x - g[0].size(), ans = 0; for (int i = 1; i < 100001; i++) { for (int j = 0; j < g[i].size(); j++) { if (g[i].size() - j >= x) { need--; ans ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, z; int sum1 = 0, sum2 = 0, sum3 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y >> z; sum1 += x; sum2 += y; sum3 += z; } if ((sum1 == 0) && (sum2 == 0) && (sum3 == 0)) { cout << ... |
#include <bits/stdc++.h> using namespace std; int i, j, n; void solve() { int n; long long l; cin >> n >> l; long long a[n]; for (i = 0; i < n; i++) cin >> a[i]; ; sort(a, a + n); long long m = 2 * max(a[0], l - a[n - 1]); for (i = 0; i < n - 1; i++) { m = max(m, a[i + 1]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int maxd = 205; struct Node { int l, d; } leg[maxn]; bool operator<(const Node &a, const Node &b) { return a.l > b.l; } int n, tot[maxd], td = 0, md = 0; int Solve(int st, int ed) { int cnt = ed - st; int res = td; ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; struct data { int idx, val; bool operator<(const data &a1) const { if (a1.val == val) { return a1.idx < idx; } return val > a1.val; } data(int t, int w) : idx(t), val(w) {} }; set<data> coastline; set<data>::iterator it, i... |
#include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; ll dp[10][200001]; string s = abcdefghijklmnopqrstuvwxyz ; ll findgcd(ll a, ll b) { if (b == 0) { return a; } return findgcd(b, a % b); } bool ispalindrome(string s) { int n... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline int popcount(T t) { if (std::numeric_limits<T>::digits <= std::numeric_limits<unsigned int>::digits) { return __builtin_popcount(t); } else { return __builtin_popcountll(t); } } const long double EPS = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, n3, n4; long long ans; unordered_map<char, int> m; string s; while (cin >> n1 >> n2 >> n3 >> n4) { ans = 0; m[ 1 ] = n1; m[ 2 ] = n2; m[ 3 ] = n3; m[ 4 ] = n4; cin >> s; for (int i = ... |
#include <bits/stdc++.h> using namespace std; bool cmp(double a, double b) { return a > b; } int n; double a[110], x, sum, ans; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lf , &a[i]); sort(a, a + n, cmp); ans = 0; for (int i = 1; i <= n; i++) { sum = 0; f... |
#include <bits/stdc++.h> using namespace std; long long int a[200][3]; int main() { ios ::sync_with_stdio(false); cin.tie(0); ; long long int i, k, l, n, j; cin >> n; for (i = 0; i <= n - 1; i++) cin >> a[i][0] >> a[i][1]; cin >> j; for (i = 0; i <= n - 1; i++) if (j >= a[i][... |
#include <bits/stdc++.h> using namespace std; int N, K; string S; int vis[5050][5050]; vector<pair<int, int>> nex[26]; void dfs(int cur, int mask) { if (vis[cur][mask] || cur + 1 + mask > N) return; vis[cur][mask] = 1; int i; nex[S[cur] - a ].push_back({cur + 1, mask}); for (i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; pair<double, double> get_vec_rotate(pair<double, double> nv, double fi) { return make_pair(nv.first * cos(fi) - nv.second * sin(fi), nv.second * cos(fi) + nv.first * sin(fi)); } pair<double, double> get_normal(pair<double, double> vec) { ... |
#include <bits/stdc++.h> int T; int n, m; bool get() { char ch = getchar(); while (ch != O && ch != X ) ch = getchar(); return (ch == X ); } int map[21][21], con[4001][2], top, cnt[4001], head[401], nxt[100001], b[100001], k = 1, dis[4001], pre[4001]; char ans[41][41]; int q[4001], h... |
#include <bits/stdc++.h> using namespace std; struct node { int active; set<int> prev, next; node() : active(1) {} }; int main() { int n, k, m, i, j; int a, b; cin >> n >> m; int cnt = 1; set<int> sh; set<int>::iterator it; for (i = 0; i < n; i++) sh.insert(i); node* ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 7; struct Node { long long x, y; } node[maxn]; bool cmp(Node a, Node b) { return a.x < b.x; } long long n, k; long long len[maxn]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( unroll-loops ) #pragma GCC optimize( O2 ) constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1}; constexpr long long INF = 1999999999999999997; constexpr int in... |
#include <bits/stdc++.h> using namespace std; const int mxN = 2e5 + 10; vector<int> a[mxN]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { int cnt = 0, x; cin >> x; while (true) { a[x].push_back(cnt); if (!x) break; x >>= 1; cnt+... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1LL << 28; const long long mod = 1LL; vector<int> adj[30]; long long b_search(int val, int indx) { int lo, hi, mid; long long ans = 1e12; lo = 0; hi = (int)adj[indx].size() - 1; while (lo <= hi) { mid = (lo + hi) / 2... |
#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 dp[200009][2], a, par[200009... |
#include <bits/stdc++.h> using namespace std; const long long SZ = 1e5 + 4; const double EPS = 1e-7; const long long mod = 1e9 + 7; const long long hashpow = 2; const long long inf = 2e9; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> ... |
#include <bits/stdc++.h> using namespace std; struct segTree { long long* data; int n; segTree(int n) : n(n) { data = new long long[n * 2](); } void add(int i, long long v) { for (i += n; i; i >>= 1) data[i] += v; } int find(long long v) { int i = 1; while (i < n) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #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; const long long inf = numeric_limits<long long>::max() / 2; const long ... |
#include <bits/stdc++.h> using namespace std; long long base = 31, M = 1000000007, base1 = 29, M1 = 1000000009; long long fpow(long long x, long long y) { if (y == 0) return 1; if (y == 1) return x; long long p = fpow(x, y / 2) % M; p *= p; p %= M; if (y & 1) p *= x; return p % M; } ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)3e5 + 50; struct node { int sum, suf; void add(int val) { sum += val; suf = max(sum, 0); } }; node merge(node L, node R) { return {L.sum + R.sum, max(R.sum + L.suf, R.suf)}; } struct Tree { node dat[4 * N]; ... |
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) return a; else return b; } long long min(long long a, long long b) { if (a < b) return a; else return b; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n, m, a[maxn][maxn]; int sumr[maxn], sumc[maxn]; bool ar[maxn], ac[maxn]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x1, y1; cin >> x1 >> y1; int x2, y2; cin >> x2 >> y2; int ans = 0x3f3f3f3f; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i == 0 && j == 0) { ... |
#include <bits/stdc++.h> int main() { int n, m, a, b, t; while (scanf( %d%d%d%d , &n, &m, &a, &b) != EOF) { if (b == n) b = (n - 1) / m * m + m; a--; b--; if (a > b) while (1) ; if (a / m == b / m || m == 1) t = 1; else if (a % m == 0) { if... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a[1000][7], i, j, m = 0, n; string ar; cin >> n; for (i = 0; i < n; i++) { cin >> ar; for (j = 0; j < 7; j++) { a[i][j] = ar[j] - 48; } } for (j = 0; j < 7; j++) { long long int l = 0; ... |
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N |= (1LL << pos); } int Reset(int N, int pos) { return N &= ~(1LL << pos); } bool Check(int N, int pos) { return N & (1LL << pos); } int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1}; template <class T> ... |
#include <bits/stdc++.h> using namespace std; int getResult(long long y) { printf( %lld n , y); fflush(stdout); int vd; scanf( %d , &vd); if (vd <= 0) exit(0); vd--; return vd; } bool solve(vector<long long> a) { int maxIndex = 0; for (int i = 1; i < 3; i++) if (a[i] > ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const int INFI = 1000 * 1000 * 1000; const long long INFL = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL; const int MX_N = 1000; int N; string s, t; string strs[] = { abc , acb , bac , bca , cab , cba }; int nstrs = 6; int mai... |
#include <bits/stdc++.h> using namespace std; int a[200000]; long long INF = 1e12; inline bool comp_bit(int x, int y) { return !!(x & y); } inline int binsearch(int l, int r, int depth) { return (upper_bound(a + l, a + r, 1 << depth, comp_bit) - a); } long long connect(int depth, int l1, int r1, int l... |
#include <bits/stdc++.h> using namespace std; struct tim { int begin, end; } t[200005]; int cmp(tim a, tim b) { if (a.begin != b.begin) return a.begin < b.begin; return a.end < b.end; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> t[i].begin >> t[i].end; sort... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; const int mod = 1000000007; const int INF = 1000000010; int n; char S[5020]; int L[5010]; int C[5010]; int RV; pair<int, int> RM; int lookup[5010]; int val[5010][15]; int hp[5010][5010]; int H... |
#include <bits/stdc++.h> using namespace std; int c[210]; int pre[210][210]; int precnt[210]; int cnt[210] = {0}; int main() { int n; scanf( %d , &n); for (int i = 0; i < (n); i++) { scanf( %d , c + i); c[i] %= 3; } for (int i = 0; i < (n); i++) for (int j = 0; j < (n);... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } bool isPrime(long long n) { long long c; if (n <= 1) return false; c = sqrt(n); for (int i = 2; i <= c; i++) if (n % i == 0) return false; return true; } int ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5, LOG = 19, off = 1 << 19; pair<int, int> t[LOG][2 * off]; void upd(int x, pair<int, int> p, int lg) { for (x += off; x; x /= 2) { t[lg][x].first = min(t[lg][x].first, p.first); t[lg][x].second = max(t[lg][x].second, p.second)... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:255000000 ) bool firstout = 1; template <class T> T &minn(T &a, T b) { if (b < a) a = b; return a; } template <class T> T &maxx(T &a, T b) { if (a < b) a = b; return a; } int &madd(int &a, int b) { a +=... |
#include <bits/stdc++.h> using namespace std; map<double, int> a; double b[200007]; inline long long int read() { long long int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + c... |
#include <bits/stdc++.h> using namespace std; unsigned long long int n, m, l; unsigned long long int r, k, nn; template <class T> inline T min(T a, T b) { return ((a < b) ? a : b); } char frac[9][500][500]; string p[500]; char isfrac(char a, char b, char c, char d) { char mx = max(max(a, b), m... |
#include <bits/stdc++.h> using namespace std; bitset<4001> g[4001]; int main() { int n, m; cin >> n >> m; vector<pair<int, int> > v; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; g[a][b] = 1; g[b][a] = 1; v.push_back(pair<int, int>(a, b)... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 1e5 + 4; const long long MOD = 998244353; bool ans[2 * N]; long long POW(long long base, long long exponent) { long long result = 1; while (exponent > 0) { if (exponent % 2 == 1) result = (result * base)... |
#include <bits/stdc++.h> using namespace std; int dis[75][1 << 18]; bool mark[75][1 << 18]; int n, m, A, B; vector<pair<int, int> > ve[75]; struct zzt { pair<int, int> to; int di; }; bool operator<(zzt aa, zzt bb) { return aa.di > bb.di; } priority_queue<zzt> q; int fa[75]; int gf(int x) {... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, l, m, n, t, x, y; cin >> n; if (n % 2 == 0) cout << n + 4 << << 4 << endl; else cout << n + 9 << << 9 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; inline bool is_prime(int n) { for (int i = 2; i * i <= n; ++i) if (n % i == 0) return 0; return 1; } inline int Exp(int a, int p, int mod) { int res = 1; while (p) { if (p & 1) res = (long long)res * a % mod; p >>= 1; a = (lon... |
#include <bits/stdc++.h> using namespace std; char str[105]; int main() { int n; scanf( %d , &n); scanf( %s , str); vector<int> g; int sum = 0; for (int i = 0; i < n; i++) { if (str[i] == B ) { sum++; } else { if (sum) g.push_back(sum); sum = 0; }... |
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf( %d , &T); while (T--) { long long s, n, k; scanf( %lld%lld%lld , &s, &n, &k); if (s < k) printf( NO n ); else if (s == k) printf( YES n ); else { long long left_sum = s - n; ... |
#include <bits/stdc++.h> long long gcd(long long a, long long b) { if (a == 0 || b == 0) return (a + b); if (a > b) return (gcd(a % b, b)); return (gcd(a, b % a)); } long long lcm(long long a, long long b) { return ((a * b / gcd(a, b))); } int sqr(int x) { return (x * x); } void out() { puts( ... |
#include <bits/stdc++.h> const int N = 1e5 + 5; const int K = 655; const int mod = 998244353; int T; int n, a[N]; int q[K], v[K], w[K], top = 0; int q2[K], v2[K], w2[K], top2 = 0; int MOD(int x) { return x >= mod ? x - mod : x; } int u(int x, int y) { return (x + y - 1) / y; } int main() { scanf... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, min, max, i, t, f = 0; cin >> n >> m; cin >> min; max = min; for (i = 1; i < n; i++) { cin >> t; if (t > max) max = t; else if (t < min) min = t; } if (2 * min > max) max = 2 * min; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T& x) { char c = getchar(); bool f = false; for (x = 0; !isdigit(c); c = getchar()) { if (c == - ) { f = true; } } for (; isdigit(c); c = getchar()) { x = x * 10 + c - 0 ; } ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200005; struct M { int val, pos; }; M a[Maxn], b[Maxn]; int idx[Maxn], idy[Maxn], Nx[Maxn], Ny[Maxn]; int read() { int sum = 0, t = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) t = -1; c = getch... |
#include <bits/stdc++.h> using namespace std; int n, m, k, i, dis = 10000000, temp, a[1000]; int main() { cin >> n >> m >> k; for (i = 0; i < n; ++i) cin >> a[i]; for (i = 0; i < n; ++i) { if (a[i] != 0 && a[i] <= k) { if (m <= i) temp = (i - m + 1) * 10; else ... |
#include <bits/stdc++.h> using namespace std; int main() { long long k, m = 9, x; long long r = 1, n, j, d = 0; cin >> k; while (k - m * r > 0) { k -= m * r; ++r; m = m * 10; } n = (k - 1) / r; j = (k - 1) % r; x = pow(10, r - 1) + n; for (long i = 0; i < r - j ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, count1 = 0, count2 = 0, sum = 0; scanf( %d , &n); vector<pair<int, int> > v1; vector<pair<int, int> > v2; for (int i = 0; i < n; i++) { int x, a; scanf( %d %d , &x, &a); if (x < 0) { v1.push_back(make_pai... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + c - 0 ; c = getchar(); } return x ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; const int maxm = 100005 * 2; const int maxn = 100005; const int mod = 1000000007; struct Edge { int v, next; } E[maxm]; struct sw { int v, next; } EE[maxm]; int head[maxn], ind; int headd[... |
#include <bits/stdc++.h> using namespace std; int main() { int x, a, b, i, j, k, siz, cnt = 0, p, q, s, t, z, h, po; string str; cin >> str; cin >> x; siz = str.size(); for (i = 0; i < siz; i++) { if (str[i] != * && str[i] != ? ) cnt++; } p = siz - cnt; q = cnt - p; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,abm,mmx,tune=native ) using namespace std; long long gcd(long long i, long long j) { if (j == 0) return i; else return gcd(j, i % j); } template <typename... |
#include <bits/stdc++.h> using namespace std; const int max_n = 303333, inf = 1000111222; int n, x, y; pair<int, int> a[max_n]; void wa() { printf( No n ); exit(0); } int main() { scanf( %d%d%d , &n, &x, &y); for (int i = 0; i < n; ++i) { scanf( %d , &a[i].first); a[i].second =... |
#include <bits/stdc++.h> using namespace std; void prime(long long int n, set<long long int> &s) { if (n % 2 == 0) { s.insert(2); n /= 2; } while (n % 2 == 0) { n /= 2; } for (int i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) { s.insert(i); n /= i; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> inli... |
#include <bits/stdc++.h> using namespace std; bitset<64> f1[3610], f2[3610]; int n, m; map<int, vector<int>> mp1, mp2; int y[66], y2[66]; set<int> s; vector<int> res; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> y[i], y[i] *= 2, mp1[y[i]].push_back(i); for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, m, i, j, zero = 0, neg = 0, tot = 0, val = INT_MIN, val2 = INT_MAX; cin >> n >> m; long long int b[n][m]; for (i = 0; i < n; i++) { f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.