func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct edge { int u, v; long long g, s; bool operator<(const edge &cmp) const { return s < cmp.s; } } e[50005], a[50005]; int n, m, cnt, p[205], tam; long long gt, st; bool cmpG(edge a, edge b) { return a.g < b.g; } int find(int x) { if (p[x] =... |
#include <bits/stdc++.h> const int MAXN = 2e5 + 10; using namespace std; 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(); return f * x; } ... |
#include <bits/stdc++.h> using namespace std; long long int tree[6000005], a[3000005], minp[3000005], upd[3000005]; long long int cun[3000005]; long long int d[3000005]; long long int n; void sieve() { a[0] = 1; a[1] = 1; for (long long int i = 1; i < 1e6 + 1; i++) { for (long long int j =... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> g[50005]; vector<int> t[50005]; int T; int col[1000005]; int team[50005]; mt19937 mt(1235577); int x[100005], y[100005]; int ans[50005]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < (int)(m); ++i) { int fr... |
#include <bits/stdc++.h> using namespace std; vector<long long> num; void solve() { int n; cin >> n; char arr[2][n]; for (int i = 0; i < 2; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } int row = 0, col = 0; int visited[2][n]; memset(visited, false,... |
#include <bits/stdc++.h> using namespace std; int main() { int x, x0, y, y0; cin >> x >> y >> x0 >> y0; char s[100013]; cin >> s; int a[513][513] = {}; int num = 0; for (int i = 0; s[i] != 0 ; i++) { if (a[x0][y0] != 1) { cout << 1 ; num++; } else { ... |
#include <bits/stdc++.h> using namespace std; int a[40000005]; void oku() { int n; cin >> n; for (int i = 0; i < n; i++) a[i] = i; int l, k; for (k = 2, l = 0; k <= n; k++, l++) { int r = (n - 1) / k; a[n + l] = a[r * k + l]; for (; r > 0; r--) { a[r * k + l] = a[(r -... |
#include <bits/stdc++.h> const int maxN = 1000000; char in[maxN + 1]; int occ[10], instanceOfRest[7] = {8169, 8961, 8619, 6891, 8691, 9168, 8196}; int main() { scanf( %s , in); int s = std::strlen(in); for (int i = 0; i < s; i++) occ[in[i] - 0 ]++; occ[1]--, occ[6]--, occ[8]--, occ[9]--; in... |
#include <bits/stdc++.h> using namespace std; int b[200100]; int l[200100], r[200100]; int main(){ int T; scanf( %d , &T); int tot = T; int num = 0; while (T--){ num++; int N, K, M; scanf( %d%d%d , &N, &K, &M); for (int i = 1; i <= M; i++) scanf( %d... |
#include <bits/stdc++.h> using namespace std; enum faces { Tetrahedron = 4, Cube = 6, Octahedron = 8, Dodecahedron = 12, Icosahedron = 20 }; int main() { int n; cin >> n; long long total = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s == Tetrah... |
#include <bits/stdc++.h> using namespace std; long long even[222222] = {0}, a[222222], odd[222222] = {0}, backEven[222222], cur, best = numeric_limits<int>::min(), besteven = 0; int main() { int n; scanf( %d , &n); for (int i = 2; i <= n; i++) cin >> a[i]; even[1] = 0; odd[1] = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; const int mod = 998244353; const int inf = 0x3f3f3f3f; vector<int> G[maxn]; int id[maxn]; struct SEG { int ma[maxn << 2]; SEG() { memset(ma, -1, sizeof ma); } void update(int rt, int pos, int l, int r, int val) { if ... |
#include <bits/stdc++.h> using namespace std; long long int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; void solve() { int n, m; cin >> n >> m; int mex = INT_MAX, curr = 0; for (int i = 0; i < m; i++) { int l, r; cin >> l >> r; mex = min(mex, r - l + 1); } cout << mex... |
#include <bits/stdc++.h> using namespace std; unsigned int dp[100010]; int n, m, maxx; char str[100010]; int main() { cin >> n; if (n & 1) { cout << 0 << endl; return 0; } scanf( %s , str + 1); dp[0] = 1; for (int i = 1; i <= n; i++) if (str[i] == ? ) { m++; ... |
#include <bits/stdc++.h> using namespace std; int n; string a, b; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b; int p1 = -1, p2 = -1; for (int i = 0; i < n; i++) { if (a[i] != b[i]) { p1 = i; break; } } for (int i = n - 1; i >=... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; pair<int, int> pa[maxn]; int main() { int n, a, b; scanf( %d%d%d , &n, &a, &b); for (int i = 0; i < n; ++i) { scanf( %d , &pa[i].first); pa[i].second = i + 1; } sort(pa, pa + n); for (int i = 0; i < n; ++i... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100005; vector<pair<long long, char>> adj[maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, m; cin >> n >> m; for (long long i = 0; i < m; i++) { long long u, v; char c; cin >> ... |
#include <bits/stdc++.h> using namespace std; int n, k, l, c, d, p, nl, np; int main() { cin >> n >> k >> l >> c >> d >> p >> nl >> np; int a, b, e; a = (k * l) / nl; b = c * d; e = p / np; cout << min(min(a, b), e) / n << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> ch(26); for (int i = 0; i < n; i++) { char c; cin >> c; ch[c - a ]++; } if (k >= *max_element(ch.begin(), ch.end())) cout << YES ; else cout << NO ; return... |
/* #pragma GCC optimize( O2 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( avx,avx2,sse,sse2,fma ) */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int , int> pii; mt19937 rng(chrono::stea... |
#include <bits/stdc++.h> using namespace std; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; bool debug = false; int main() { int n, L, a; cin >> n >> L >> a; int ans = 0, now = 0; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 7; bool pri(int a) { if (a == 1) return 0; for (int i = 2; i * i <= a; i++) { if (a % i == 0) { return 0; } } return 1; } long long n, m, t, a[200000]; string s; int main() { cin >> t; while (t--)... |
#include <bits/stdc++.h> using namespace std; unsigned short log2(unsigned short x) { unsigned short log = 0; while (x > 1) { log++; x /= 2; } return log; } int main() { unsigned short a, b, n, r; cin >> n >> a >> b; a -= 1; b -= 1; n /= 2; if (a / n != b / n)... |
#include <bits/stdc++.h> using namespace std; template <class flow_t, const flow_t inf> struct Dinic { struct edge_t { long long to; flow_t cap, flow; edge_t(long long to = 0, flow_t cap = 0, flow_t flow = 0) : to(to), cap(cap), flow(flow) {} }; long long n, s, t; vecto... |
#include <bits/stdc++.h> using namespace std; template <class _Tp> _Tp gcd(_Tp a, _Tp b) { return (b == 0) ? (a) : (gcd(b, a % b)); } const long long Inf = 1000000000000000000ll; const int inf = 1000000000; char buf[1 << 25], *p1 = buf, *p2 = buf; inline int getc() { return p1 == p2 && (p2 = (p1... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int lim = (int)sqrt(n); int val; for (int i = 1; i <= lim; i++) { if (n % i == 0) val = i; } cout << val << << n / val << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i; cin >> n; for (i = 3; n / i >= 1; i = i * 3) if (n % i != 0) break; cout << n / i + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-13; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int k = n / m; vector<int> v(n); vector<vector<int>> d(m); for (int i = 0; i < (int)(n); ++i) { ci... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { cin >> x; } void _R(int64_t &x) { cin >> x; } void _R(double &x) { cin >> x; } void _R(long double &x) { cin >> x; } void _R(char &x) { cin >> x; } v... |
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7, maxn = (int)1e5 + 5; int a[maxn], d[maxn]; int mpow(int A, int N) { int ret = 1; while (N) { if (N & 1) ret = (ret * 1ll * A) % mod; A = (A * 1ll * A) % mod; N >>= 1; } return ret; } int main() { ... |
#include <bits/stdc++.h> using namespace std; set<int> s; int cnt[1009]; int vec[1009]; vector<int> ans; int main() { int a, b, c, d, e, i, j, k, l, n, m, x, y, t, p; scanf( %d , &t); for (p = 1; p <= t; p++) { scanf( %d , &n); s.clear(); ans.clear(); for (i = 0; i <= n; ... |
#include <bits/stdc++.h> using namespace std; struct abc { int p, q, idx; }; bool compareTwoStudents(abc a, abc b) { if (a.p != b.p) return a.p < b.p; return (a.q < b.q); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s, s1, s2; int a, b, c, x, y, z, p, q,... |
#include <bits/stdc++.h> int main() { int a, b, c, d, e, i; scanf( %d %d %d %d %d , &a, &b, &c, &d, &e); int arr[e]; if (a == 1 || b == 1 || c == 1 || d == 1) printf( %d n , e); else { for (i = 1; i <= e; i++) { if (i % a == 0) arr[i - 1] = 1; else if (i % b =... |
#include <bits/stdc++.h> using namespace std; const int N = 107; const long long mod = 1e9 + 7; const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1}; const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1}; const long double pi = acos(-1.0); const int B = (int)sqrt(N); int d[16 / 2][2 * 4]; int main() { ios_base::... |
#include <bits/stdc++.h> using namespace std; const int MAX = 30; int num[MAX], x[MAX]; char s[1000 + 10]; int main() { int n; while (cin >> s >> n) { int m = n; string a; memset(num, 0, sizeof num); int len = strlen(s), sum = 0; for (int i = 0; i < len; ++i) { if... |
#include <bits/stdc++.h> using namespace std; void print_ret(const std::vector<long long>& ret) { long long r = 0; for (typeof((ret).end()) it = (ret).begin(); it != (ret).end(); ++it) r ^= *it; cout << r << endl; cout << ret.size() << endl; for (typeof((ret).end()) it = (ret).begin(); it ... |
#include <bits/stdc++.h> using namespace std; void print(vector<pair<int, int> > &v) { for (int i = 0; i < v.size(); i++) cout << v[i].second << ; cout << endl; } int main() { int n; cin >> n; vector<pair<int, int> > input; for (int i = 0; i < n; i++) { int x; cin >> x; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 200000; struct el { int l, r, id; } a[MAX_N], b[MAX_N]; long k[MAX_N]; class compare { public: bool operator()(el a, el b) { return a.r < b.r; } }; int main() { int n, m; cin >> n; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int a[18] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; long long n; int main() { cin >> n; if (n == 0) { cout << 1 << endl; return 0; } int res = 0; while (n != 0) { int m = n % 16; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << (n + 1) / 36 << << ((n + 1) / 3) % 12; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int l = 0; int r = 0; vector<int> a(3); vector<int> b(3); for (int i = 0; i < 3; i++) { a[i] = (int)(s[i] - 0 ); b[i] = (int)(s[i + 3] - 0... |
#include <bits/stdc++.h> using namespace std; const int N = 1100000; const int M = 21; vector<int> adj[N]; int par[N][M]; int vis[N]; void dfs(int u, int p) { par[u][0] = p; for (int v : adj[u]) { if (v == p) continue; dfs(v, u); } } int main() { ios_base::sync_with_stdio(0... |
#include <bits/stdc++.h> using namespace std; int pct(int x) { return __builtin_popcount(x); } int pct(long long x) { return __builtin_popcountll(x); } int bt(int x) { return 31 - __builtin_clz(x); } int bt(long long x) { return 63 - __builtin_clzll(x); } int cdiv(int a, int b) { return a / b + !(a < 0 || a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c; while (cin >> n >> a >> b >> c) { int s = a + b + c; double ans = (1.0 * n / s); if (a == 0 && b == 0 && c == 0) printf( %.1lf %.1lf %.1lf n , 0.0, 0.0, 0.0); else printf( %.16f %.16f %.16f n ,... |
#include <bits/stdc++.h> using namespace std; int n, dp, q, c, b; string ans = ; void update(int &x) { if (x == 0) x = 1; else x = 0; } int main() { scanf( %d , &n); int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) scanf( %d , &a[i][j]); } ... |
#include <bits/stdc++.h> using namespace std; const string DIRECTION = NEWS ; string s[2]; int n, a[2][1000100], pre[1000100]; void calcPre(int p[]) { int i = 0, j = -1; pre[0] = -1; while (i < n) { while (j >= 0 && p[i] != p[j]) j = pre[j]; i++; j++; pre[i] = (j >= n || p... |
#include <bits/stdc++.h> using namespace std; const int nsz = 3e5; int n; long long k, mod, a[nsz + 5], b[nsz + 5], ans; map<long long, int> mp; long long inline qpow(long long a, int p) { long long res = 1; for (; p; p >>= 1) { if (p & 1) { res *= a; res %= mod; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char ch = getchar(); int fh = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); x *= ... |
#include <bits/stdc++.h> using namespace std; const int N = 255; int cnt; int n, a, b, k, f; map<string, int> M; map<pair<int, int>, int> Edge; int main() { scanf( %d %d %d %d %d , &n, &a, &b, &k, &f); int last = 0; int res = 0; for (int i = 1; i <= n; ++i) { string aa, bb; cin... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1; int n, sol, counter; bool mark[20]; void check(long long x) { if (x > n) return; if (x != 0) sol++; for (int i = 0; i <= 9; i++) { if (mark[i]) { if (i != 0 || (i == 0 && x != 0)) check(x * 10 + i); } else { ... |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ii = pair<int, int>; using ld = long double; const int N = 5e5; bool flip[N], still[N]; int par[N], asdjashsgggg[N], x[N]; int find(int v, bool& b) { b = flip[v]; while (par[v] != v) { v = par[v]; b ^= flip[v... |
#include <bits/stdc++.h> using namespace std; int dfn[200002], low[200002], tot, head[200002], num, f[200002]; int p[20][200002]; int deep[200002], n, m, q, st[200002], top, dep[200002]; bool vis[200002]; inline long long rd() { long long x = 0; char c = getchar(); bool f = 0; while (!isdigi... |
#include <bits/stdc++.h> using namespace std; int cnt_list, pos[20200], pa[20100], len[20100], fs[20100], pc[20100], ls[20100], cnt_ls, tmp[20100], cnt, n, num_q; struct pp { int id; char ch; }; vector<pp> adj[20201]; pp now; void dfs(int id, int pr) { int i, j, s, p, q, ip; pos[id] ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) #pragma GCC optimize( -ffloat-store ) using namespace std; const auto start_time = std::chrono::high_resolution_clock::now(); void aryanc403() {} const long long int INF = 0xFFFFFFFFFFF... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e18; const string nl = n ; long long n, k, hld = 0, sum, hld1 = 0; vector<long long> a; int32_t main() { ios::sync_with_stdio(0); cin.tie(nullptr); cin >> n >> k; a.resize(n); for (aut... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, i; cin >> t; for (i = 1; i <= t; i++) { cin >> n; if (n % 4 == 0) cout << YES << n ; else cout << NO << n ; } return 0; } |
#include <bits/stdc++.h> const int ms = 200200; const int eps = z - a + 1; void print(int x) { for (int i = 0; i < eps; i++) { std::cout << ((x & (1 << i)) ? 1 : 0); } std::cout << n ; } char t[200200]; std::string str[200200]; int main() { int n; std::cin >> n; int isn... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; int N, M; int a[110]; int b[110]; int sum[110]; int num[110][30]; char ans[110]; void solve(int n) { string temp; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } vector<string> getWords(string s) { string cur = ; vector<string> vec; for (int i = 0; i < s.size(); i++) { if (s[i] == ... |
#include <bits/stdc++.h> using namespace std; int n, k, r, c; vector<string> grip; int main() { grip.clear(); cin >> r >> c >> n >> k; string ful = ; for (int i = 0; i < c; i++) ful += . ; for (int i = 0; i < r; i++) grip.push_back(ful); for (int i = 0; i < n; i++) { int y, x; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int h[N], nex[N << 1], to[N << 1], tot, dis[N]; void add(int x, int y) { to[++tot] = y; nex[tot] = h[x]; h[x] = tot; } int fa[N][30], dep[N], lg[N]; void dfs(int u, int fath, int d) { dis[u] = d; fa[u][0] = fath; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const long long M = 1000000007; long long a; int main() { scanf( %I64d , &a); a %= 360; a += 360; long long ans = 0, mx = -1; for (int i = 0; i < 4; i++) { if (mx < abs((a + i * 270) % 360 - 180)) { mx = abs(... |
#include <bits/stdc++.h> using namespace std; int pos[100005]; pair<int, int> tree[100005]; bool func(pair<int, int> x, pair<int, int> y) { return (x.first) < (y.first); } int main() { int n; for (int i = 1; i < 100005; i++) { pos[i] = 2e9 + 1000; } pos[0] = -2e9; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<char> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } vector<char> t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } vector<int> ans; for (int i = 0; i < n; i++) { if (s[i... |
#include <bits/stdc++.h> using namespace std; int main() { int a[200], n, c = 0; double sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } sort(a, a + n); while (double(sum / n) < 4.5) { sum += (5 - a[c]); c++; } cout << c; re... |
#include <bits/stdc++.h> using namespace std; char buffer[2000020], *p1, *p2; template <class T> void read(T& x) { char ch = ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, 2000020, stdin), p1 == p2)) ? EOF : *p1++); x = 0; bool f = 1; w... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100010; int n, parent[maxN], child[maxN]; long long f[maxN], g[maxN], res; struct ioi { int v, w; }; vector<ioi> adj[maxN]; void dfs(int u) { child[u] = 1; for (int i = 0; i < adj[u].size(); ++i) { int v = adj[u][i].v; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int ans = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) ans = (ans << 1) + (ans << 3) + (ch ^ 48), ch = getchar(); return ans; } inline long long L_read() { long ... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static const long long L = 233333; static char sxd[L], *sss = sxd, *ttt = sxd; if (sss == ttt) { ttt = (sss = sxd) + fread(sxd, 1, L, stdin); if (sss == ttt) { return EOF; } } return *sss++; } inline c... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, sum = 0; cin >> n >> m; vector<int> v; for (int i = 0; i < n; i++) { int ff; cin >> ff; v.push_back(ff); } for (int i = 0; i < m; i++) { int x; cin >> x; if (x == 1) { int l, k; ... |
#include <bits/stdc++.h> using namespace std; map<int, int> used; int main() { int n, k; scanf( %d %d , &n, &k); int a[n]; long long ans = 0; int p = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); used[a[i]]++; if (used[a[i]] == k) { ans += (long long)(n - i... |
#include <bits/stdc++.h> const int maxn = 2e5 + 9, inf = 0x3f3f3f3f; void Chkmax(int &x, int y) { if (y > x) x = y; } int n, ans, mx, root; int a[maxn], sum[maxn]; void Solve(int v) { static int b[maxn], last[maxn << 1]; for (int i = 1; i <= n; ++i) { if (a[i] == root) { b[i] = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, x; cin >> n >> x; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int k, l; cin >> k >>... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int add[N << 6], num[N << 6], lazy[N << 6], ls[N << 6], rs[N << 6], total; int init() { num[total] = add[total] = lazy[total] = 0; ls[total] = rs[total] = -1; return total++; } void down(int l, int r, int o) { if (ls[o] =... |
#include <bits/stdc++.h> using namespace std; const int maxm = 1000000 + 5; const int maxn = 6400 + 5; struct Edge { int to, next; } edges[maxm]; int indices[maxn]; int deg[maxn]; char ans[maxm]; int an; int over; inline int Trans_index(char* s) { return (s[0] - 0 ) * 80 + (s[1] - 0 ); } v... |
#include <bits/stdc++.h> using namespace std; const int N = 1000050; int a[N]; int main() { int n, k; cin >> n >> k; if (n == 1 && k == 10) cout << -1 << endl; else { if (k == 10) { cout << 1 ; for (int i = 1; i < n; i++) cout << 0 ; cout << endl; } ... |
#include <bits/stdc++.h> using namespace std; const long dad = 1e6; int n, m, l = 1, r; long long k; long long d[dad], a[dad], b[dad], res, ans[dad], dem[dad]; struct yasu { int id, l, r; } p[dad], c[dad]; bool cmp(yasu u, yasu v) { return (u.l / 300 < v.l / 300 || (u.l / 300 == v.l / 300 && u.r... |
#include <bits/stdc++.h> using namespace std; using ll = unsigned long long; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int k; cin >> k; int n = (1 << k); vector<vector<ll> > a(n, vector<ll>(n, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const int xinc[] = {0, 0, 1, -1}; const int yinc[] = {1, -1, 0, 0}; const long double PI = acos(-1.0); int n, k; void solve() { cin >> n >> k; int d = n - k; if (k == 1) { cout << 1; for (int i = 0; i < n - 1; i++... |
#include <bits/stdc++.h> using namespace std; struct info { double val; string a; }; vector<info> t; int n, x, y, hcnt, sumh; double aa; long long res = 0; bool cmp(const info &u, const info &v) { return u.val > v.val; } int main() { string a; cin >> n; for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; char s[N], t[N]; int dp[N][N][15][2]; int main() { int n, m, lim; scanf( %d %d %d %s %s , &n, &m, &lim, s, t); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { for (int k = 0; k < 15; k++) { dp[i][... |
#include <bits/stdc++.h> using namespace std; int a[100010], dp[100010][2]; char s[100010]; int main() { int(n); scanf( %d , &n); for (int i = 0; i < (n); ++i) scanf( %d , &(a[i])); scanf( %s , (s)); memset((dp), -1, sizeof((dp))); dp[n][1] = 0; for (int i = n - 1; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; const long long N = 200100; const long long oo = 2e18; long long i, n, m, l, r, mid; long long a[N], f[N][2]; inline long long read() { long long x = 0, f = 0, c = getchar(); for (; c > 9 || c < 0 ; f = c == - , c = getchar()) ; for (; c >=... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300000; const int MAX_E2 = 1 << 20; const long double PI = acosl(-1.0); struct Elm { long double x, y, th; Elm() : x(0.0), y(0.0), th(0.0) {} Elm(long double _x, long double _y, long double _th) : x(_x), y(_y), th(_th) {} ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); cout << arr[(n - 1) / 2]; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; map<long long, int> cnt; bool vis[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; long long a[n]; memset(vis, 0, sizeof(vis)); for (int i = 0; i < n; i++) { long long x; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000 * 1000 * 1000 + 7; long long n, m; map<long long, long long> mp; long long get(long long x) { if (x < 0) return 0; if (mp.find(x) != mp.end()) return mp[x]; long long y = x / 2, z = x - x / 2; mp[x] += get(y) * get(z); mp[x... |
#include <bits/stdc++.h> using namespace std; long long n, i; long long a[2019]; int b[2100], ok[2100]; const int MAXN = 2000; long long C[MAXN + 1][MAXN + 1]; void init() { int i, j; for (i = 0; i <= MAXN; ++i) { C[0][i] = 0; C[i][0] = 1; } for (i = 1; i <= MAXN; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 19; double pw2[8 * N]; struct mynum { double v; int sh; mynum(double _v, int _sh) { v = _v; sh = _sh; } mynum() {} mynum shift(int x) { return mynum(v, sh + x); } friend mynum operator+(mynum a, mynum b) { ... |
#include <bits/stdc++.h> using namespace std; const long long MN = 505, MOD = 1000 * 1000 * 1000 + 7; long long a[MN], dp[MN][MN]; int32_t main() { long long n; cin >> n; for (long long i = 0; i < n; i++) cin >> a[i], dp[i + 1][i + 1] = 1; for (long long s = 1; s < n; s++) for (long long l... |
#include <bits/stdc++.h> using namespace std; struct node { long long a, sum; } t, tt; vector<node> vec[300005]; long long cost[300005], in[300005], dp[300005][2], vis[300005]; queue<node> que; int main(void) { long long i, j, n, m, a, b, c; long long ans; scanf( %lld , &n); ans = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 9; long long n, k; long long a[N]; long long ans; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cerr << ; cin >> n >> k; for (int i = 0; i < (n); i++) cin >> a[i], a[i]--; sort(a, a + n, greater<l... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; for (cin >> (t); (t)--;) { int n, d; cin >> n >> d; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int ans = a[0]; for (int i = 1; i < n; i+... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using ppi = pair<int, pii>; using vpi = vector<pii>; const int kMod = 1e9 + 7; struct ModInt { long long n; ModInt(long long n = 0) : n(n % kMod) {} ModInt operator+(const ModInt& oth) { return n + ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s, ans; cin >> s; ans = ; for (int i = 0; i < s.size(); i++) { ans = ans + s[i]; if (s[i] == a || s[i] == e || s[i] == i || s[i] == o || s[i] == u || s[i] == y ) { fo... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007, maxn = 110; int n, k, mat[maxn], fact[maxn], dp[maxn][maxn * maxn], stup[maxn][maxn]; long long m; int pot(int a, long long b) { if (!b) { return 1; } if (b == 1) { return a; } int rek, ost; rek = pot... |
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void read(Tp& x) { x = 0; int 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; template <class T> inline T bigmod(T p, T e, T M) { if (e == 0) return 1; if (e % 2 == 0) { T t = bigmod(p, e / 2, M); return (t * t) % M; } return (bigmod(p, e - 1, M) * p) % M; } template <class T> inline T gcd(T a, T b) { if (b... |
#include <bits/stdc++.h> using namespace std; int unibit[60] = {0}; long long a[200005]; long long unia[200005] = {0}; int main() { int n, k, x; cin >> n >> k >> x; long long orr = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; orr |= a[i]; long long b = a[i]; for (int ... |
#include <bits/stdc++.h> using namespace std; char a[105][105], s[105], res[105], letter, letter2, help[105]; int i, j, k, N, lens, lena[105]; int main() { scanf( %d , &N); gets(a[103]); for (i = 0; i < N; i++) { gets(a[i]); lena[i] = strlen(a[i]); for (j = 0; j < lena[i]; j++) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.