func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> const int N = 1005; int n, K; int w[N][N]; std::vector<int> ansx, ansy; int main() { memset(w, -1, sizeof w); bool f = true; scanf( %d%d , &n, &K); for (int i = 1; i <= n; ++i) { int cnt = K; for (int j = 1; j <= n && cnt > 0; ++j) if (j != i && w[i... |
#include <bits/stdc++.h> using namespace std; int n, m, *dot, inf = 2e9, bg = 1e9, lg, rg, add, *ar; bool er = 0; void push(int nu) { dot[nu * 2] = min(dot[nu * 2], dot[nu]); dot[nu * 2 + 1] = min(dot[nu * 2 + 1], dot[nu]); dot[nu] = inf; } void cha(int nu, int l, int r) { if (l >= lg and r ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int v = min(n, m); int p = n + m - 1 - v; cout << p << << v << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; struct tree { int l, r; int tl, tr, parent; long long sum, nextsum, occupy; } trees[232222]; long long a[2][2], b[2][2]; int s[111111]; int ids = 0; long long pre = -1; void make_matrix(long long tm) { if (tm ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct data { int t, g; }; int memo[250][4][66000]; int n, t; data in[20]; int f(int time, int genre, int bit) { if (memo[time][genre][bit] != -1) return memo[time][genre][bit]; if (time == t) return memo[time][genre][bit... |
#include <bits/stdc++.h> using namespace std; int go_to_hall(string maxx, string minn, int base) { string h = ; int a = 0; for (int i = minn.size() - 1, j = maxx.size() - 1; i >= 0; j--, i--) { int q1 = minn[i] - 0 , q2 = maxx[j] - 0 ; int q3 = q1 + q2 + a; if (q3 >= base) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> struct BIT { int n; vector<T> dat; BIT(int n = 0) { initialize(n); } void initialize(int nin) { n = nin; dat.resize(n, 0); } T sum(int i) { T s = 0; while (i >= 0) { s += dat[i]; i =... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const long long mo = 1e9 + 7; const long long inf = 1e9; const long long Inf = 1e18; int a[N], b[N]; int main() { int n, m, tot = 0; scanf( %d%d , &n, &m); int nw = 0; for (int i = (1); i <= (m); ++i) { scanf( %d ,... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const long long MOD = 1000000007; const int INF = 1e9; const long long LINF = 1LL * INF * INF; const int MAXN = 100007; const double EPS = 1e-7; con... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> a(2 * n); for (int i = 0; i < 2 * n; i++) { scanf( %d , &a[i]); } sort(a.begin(), a.end()); printf( %s n , (a[n - 1] != a[n]) ? YES : NO ); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, h; long long dp[40][40]; int main() { scanf( %d %d , &n, &h); memset(dp, 0, sizeof(dp)); for (int i = 0; i <= n; i++) { dp[0][i] = 1; } for (int h = 1; h <= n; h++) { for (int i = 1; i <= n; i++) { for (int j = 0; j < i... |
#include <bits/stdc++.h> using namespace std; inline int read(int f = 1, int x = 0, char ch = ) { while (!isdigit(ch = getchar())) if (ch == - ) f = -1; while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f * x; } const int N = 1e5 + 5; struct Edge { int next, to; E... |
#include <bits/stdc++.h> using namespace std; long long int binExp(long long int x, long long int n, long long int m) { long long int res = 1; while (n) { if (n & 1) res = (res * x) % m; x = (x * x) % m; n >>= 1; } return res; } long long int modInv(long long int i, long long i... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, k, i; scanf( %lld %lld , &t, &k); long long dp[100001]; dp[0] = 1; for (i = 1; i < 100001; i++) { dp[i] = dp[i - 1]; if (i >= k) dp[i] += dp[i - k]; dp[i] = dp[i] % 1000000007; } long long sum[10000... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n; long long p[200002], i[200002], v[200002], lvl[200002], ans; vector<int> G[200002]; void dfs(int x, int par) { if (par) lvl[x] = lvl[par] + 1; for (auto it : G[x]) { if (it == par) continue; dfs(it, x); a... |
#include <bits/stdc++.h> using namespace std; int N, M; typedef struct node { double x; double y; node operator-(node b) { node ret; ret.x = x - b.x; ret.y = y - b.y; return ret; } node operator+(node b) { node ret; ret.x = x + b.x; ret.y = y + b.y; ... |
#include <bits/stdc++.h> template <typename T> inline T max(T a, T b) { return a > b ? a : b; } template <typename T> inline T min(T a, T b) { return a < b ? a : b; } template <typename T> inline T abs(T a) { return a > 0 ? a : -a; } template <typename T> inline void repr(T &a, T b) { ... |
#include <bits/stdc++.h> using namespace std; set<int> ss; map<int, int> mm; int arr[2 * 100003], pr[2 * 100003], nxt[2 * 100003]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; for (int i = 0; i < int(n); i++) { cin >> arr[... |
#include <bits/stdc++.h> using namespace std; int main() { int v1, v2, t, d, i = 2; scanf( %d%d%d%d , &v1, &v2, &t, &d); int sum = v1 + v2; while (i != t) { i++; if (v1 < v2) { v1 += d; sum += v1; } else { v2 += d; sum += v2; } } printf... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; const int INF = 2e9 + 5; int main() { cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0); int n; ... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int k; cin >> k; map<char, int> dict; for (int i = 0; i < 27; i++) dict[i + a ] = 0; for (int i = 0; i < s.length(); i++) dict[s[i]]++; map<char, int>::iterator it; vector<pair<int, char> > letras; ... |
#include <bits/stdc++.h> using namespace std; int n, k, p; int dp[105][55]; int modd(int x) { if (x < 0) return x + p; else if (x >= p) return x - p; return x; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); ... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)1e5 + 10; int a[maxN]; int n; vector<pair<int, int> > ans; int cop[maxN]; bool solve_stupid(int n) { for (int i = 1; i <= n; i++) cop[i] = a[i]; vector<pair<int, int> > all; for (int i = 1; i <= n; i++) { for (int j = i ... |
#include <bits/stdc++.h> using namespace std; void fileio() {} vector<vector<long long int>> g; vector<long long int> bit; long long int n; void add(long long int i, long long int x) { while (i <= n) { bit[i] += x; i += (i & (-i)); } } long long int query(long long int i) { long ... |
#include <bits/stdc++.h> using namespace std; template <class T> using min_pq = priority_queue<T, vector<T>, greater<T>>; const int MAXN = 1e5 + 10, MAXQ = 3e5 + 10, MAXL = 18, ALP = 26, MOD = 1e9 + 7, MAXK = 17, MAXA = 10, MAXB = 24, MAXBB = (1 << MAXB); const string no = NO n , yes = YES n ; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; map<long long, long long> rt, lf; long long a[n]; for (long long i = 0; i < n; i++) { cin >> a[i]; rt[a[i]]++; } long long ans = 0; for (long long i = 0; i < n; i++) { if (a[i]... |
#include <bits/stdc++.h> using namespace std; const int NO_OF_ALPHABETS = 26; vector<int> degree(NO_OF_ALPHABETS, 0); vector<int> graph[NO_OF_ALPHABETS]; vector<int> component_no(NO_OF_ALPHABETS, 0); void dfs(int v, int parent_v, int c) { component_no[v] = c; for (int i = 0; i < graph[v].size(); i++... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MOD2 = 998244353; const float pi = 3.141592653; long long power(long long a, long long b) { if (b == 0) return 1; long long p = power(a, b / 2); if (b & 1) return p * p * a; else return p *... |
#include <bits/stdc++.h> using namespace std; int n, m, V, i, x, y, z, tot, e[505], fir[505], ne[505 * 2], la[505 * 2], va[505 * 2]; double v, o, a[505][505], b[505], c[505]; void ins(int x, int y, int z) { la[++tot] = y; ne[tot] = fir[x]; fir[x] = tot; va[tot] = z; } void dfs(int A, i... |
#include <bits/stdc++.h> using namespace std; int M[17], R[17], n, sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> M[i]; for (int i = 1; i <= n; i++) cin >> R[i]; for (int i = 1; i <= 720719; i++) for (int j = 1; j <= n; j++) { if (i % M[j] == R[j]) { sum++;... |
#include <bits/stdc++.h> using namespace std; int main() { int res = 0; int n, x; cin >> n >> x; for (int i = 1; i <= n; ++i) { if (x % i == 0 && x / i <= n) ++res; } cout << res; } |
#include <bits/stdc++.h> using namespace std; int op[1000005]; bool value[1000005]; bool change[1000005]; long req[1000005][2]; bool calc(long i) { if (i <= 0) return false; value[i] = false; if (op[i] == 4) { value[i] = (req[i][0] == 1); } if (op[i] == 3) { value[i] = !(calc... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, a[N], lm[N], rm[N], q[N]; vector<int> tree[35]; long long ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); for (int j = 0; (1 << j) <= a[i]; j++) if (a[i] & (1 << j)) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; char c; while (~scanf( %d , &n)) { c = a ; for (i = 1; i <= n; i++) { printf( %c , c); c++; if (c == e ) c = a ; } puts( ); } return 0; } |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) bool isPrime(long long int n) { for (long long int i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; } b... |
#include <bits/stdc++.h> using namespace std; void shift(vector<int> &ans) { for (int i = 0; i < ans.size() - 1; i++) { ans[i] = ans[i + 1]; } } bool check(vector<int> ans, int c) { for (int i = 0; i < ans.size(); i++) { if (c == ans[i]) return true; } return false; } int mai... |
#include <bits/stdc++.h> using namespace std; long long a[3]; long long kq; void nhap() { cin >> a[0] >> a[1] >> a[2]; } void cbi() { sort(a, a + 3); } void xuli() { if (a[0] == a[1] && a[1] == a[2]) { cout << a[0]; exit(0); } if (a[0] + a[1] < a[2] / 2) kq = 1ll * a[0] + a[1];... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 0x7ffffff; const int magic = 348; string s1, s2; string s; int n; int nxt1[200], nxt2[200]; int main() { cin >> s1 >> s2; cin >> n; n %= 4; nxt1[94] = 62; nxt1[62] = 118; nxt1[118] = 60; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300000; const int MAX_E2 = 1 << 20; struct Elm { int l, r, v; Elm() {} Elm(int _l, int _r, int _v) : l(_l), r(_r), v(_v) {} Elm(int _l) : l(_l), r(_l), v(1) {} Elm operator+(const Elm &e) const { if (v == 0) return e; ... |
#include <bits/stdc++.h> using namespace std; int n, m, a[100005], b[100005]; vector<int> g[100005]; int next_id, from[100005], to[100005]; bitset<1000> tree[4 * 100005], primes; int lazy[4 * 100005]; void dfs(int u) { from[u] = next_id++; b[from[u]] = a[u] % m; for (int i = 0; i < g[u].size()... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t > 0) { int x, m, n; cin >> x; m = x / 7; n = x % 7; if (n == 0) cout << m << endl; else cout << m + 1 << endl; t--; } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, u, v; vector<int> g[100005], gr[100005]; vector<int> order; bool used[100005]; int G[100005], C[100005], k = 0; void dfs1(int x) { used[x] = 1; for (int(i) = (0); (i) < (g[x].size()); (i)++) { int nn = g[x][i]; if (!used[nn]) dfs1... |
#include <bits/stdc++.h> int ways[37 * 2 + 1][37 * 2 + 1], k; void init() { int i, j; ways[0][0] = 1; for (i = 0; i <= k * 2; i++) for (j = 0; j <= k * 2; j++) ways[i][j] = i == 0 || j == 0 ? 1 : (ways[i - 1][j] + ways[i][j - 1]) % 998244353; } int oo[1 + (4000 - 1) * 4], o... |
#include <bits/stdc++.h> using namespace std; int main() { int a[100001], b[100001]; int n, i, x, y; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); x = 0; while (a[x] == b[x] && x < n - 1) { x++; } y = n - 1; while (a[y] ... |
#include <bits/stdc++.h> using int64 = long long; constexpr int Maxn = 200000; constexpr int p = 1000000007; template <class _Tp1, class _Tp2> inline void inc(_Tp1& x, const _Tp2& y) { x += y; (p <= x) && (x -= p); } template <class _Tp1, class _Tp2> inline void dec(_Tp1& x, const _Tp2& y) { ... |
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; const int MAXN = 1e3 + 10; using namespace std; char str[MAXN][MAXN]; int data[MAXN]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> str[i]; for (int i = 0; i < m; i++) cin >> data[i]; long long ans = 0; f... |
#include <bits/stdc++.h> using namespace std; long long ans = 0; void solve1(vector<int> &ar, bool yeah) { int sz = ar.size(); int mid = sz / 2 + yeah * (sz % 2) - 1; int L = mid; int minL = ar[mid]; int maxL = ar[mid]; int minR = (1 << 30); int maxR = 0; for (int R = mid + 1; R < ... |
#include <bits/stdc++.h> char data[41][41]; int t[41][41][41][41]; int chk[41][41][41][41]; int main() { int a, b, c, d, i, j, k, l, p, q, sum = 0; scanf( %d %d %d , &a, &b, &q); for (i = 0; i < a; ++i) { scanf( %s , data[i]); for (j = 0; j < b; ++j) { if (data[i][j] == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; long long ax, ay, bx, by, cx, cy, flag = 0; long long f(long long x1, long long y1, long long x2, long long y2) { long long res = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); return res; } bool isColinear() { long long res1 = (by - ay) * (cx - bx); ... |
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX / 2; int extractMin(set<int> &mySet) { set<int>::iterator it = mySet.begin(); int ans = *(it); mySet.erase(it); return ans; } int search(set<int> &mySet, int index) { set<int>::iterator it = mySet.lower_bound(ind... |
#include <bits/stdc++.h> template <typename T, int NDIMS> struct tensor_view { static_assert(NDIMS >= 0, NDIMS must be nonnegative ); protected: std::array<int, NDIMS> shape; std::array<int, NDIMS> strides; T* data; tensor_view(std::array<int, NDIMS> shape_, std::array<int, NDIMS> strides_,... |
#include <bits/stdc++.h> using namespace std; int anc[200007]; int sz[200007]; int x[200005], y[200005]; vector<int> g[200005]; int get_set(int v) { if (v == anc[v]) { return v; } return anc[v] = get_set(anc[v]); } void unite_sets(int u, int v) { u = get_set(u); v = get_set(v);... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<long long> vec(n + 1); for (int i = 1; i <= n; i++) cin >> vec[i]; vector<long long> a; for (int i = 1; i < n; i++) { if (i & 1) a.pu... |
#include <bits/stdc++.h> using namespace std; int n; long long x[100010]; long long y[100010]; long long dispoint(long long x1, long long y1, long long x2, long long y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } bool issame(long long x1, long long y1, long long x2, long long y2, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n; cin >> n; vector<int> ans; for (int i = 0; i <= 400; i++) { for (int j = 0; j <= 200; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int T; cin >> T; while (T--) { long long int n; string second; cin >> n; cin >> second; vector<char> v, v1; int first = 0; int f1 = 0; int f2 = 0; for (i... |
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? YES : NO ); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { x += y; ... |
#include <bits/stdc++.h> using namespace std; void ipgraph(long long n, long long m); vector<vector<long long>> v; vector<bool> vis; long long p = pow(10, 9) + 7; long long power(long long a, long long b, long long p) { if (b == 0) return 1; long long c = power(a, b / 2, p); if (b % 2 == 0) ... |
#include <bits/stdc++.h> using namespace std; inline void in(int &x) { x = 0; int f = 1; char s = getchar(); while (s < 0 || s > 9 ) { if (s == - ) f = -1; s = getchar(); } while (s >= 0 && s <= 9 ) { x = x * 10 + s - 48; s = getchar(); } x *= f; } ... |
#include <bits/stdc++.h> const double pi = acos(-1); using namespace std; vector<int> v; int c[1000000]; int main() { int n; double h; cin >> n >> h; double s = h / (2 * double(n)); for (int i = 1; i < n; i++) { printf( %.10f n , sqrt(s * 2 * h * i)); } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, num[105], ans = 0, i; int main() { scanf( %d , &n); for (int j = 1; j <= n; ++j) scanf( %d , &num[j]); if (n % 2 == 0 || n < 3) { printf( -1 n ); return 0; } for (int i = n; i >= 3; i -= 2) { int max_n = max(num[i], num[i -... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[100007]; int dis[100007]; void bfs() { queue<int> q; bool vis[100007]; memset(vis, false, sizeof(vis)); dis[1] = 1; vis[1] = true; q.push(1); while (!q.empty()) { int s = q.front(); q.pop(); for (auto u :... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[50]; double dp[51][51][51]; bool viz[51][51][51]; long long choose[51][51]; double go(int i, int j, int k) { if (i == m - 1) return j <= a[i] * k; double &d = dp[i][j][k]; if (viz[i][j][k]) return d; double res = 0; for (int... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const bool debugger1 = 0; const bool debugger2 = 0; const bool debugger3 = 0; const bool debugger4 = 0; const bool debugger5 = 0; const long long MOD = 1e9 + 7, P = 1e9 + 7; long long n; long long sca, scb; std::vector<pa... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const int INF = 2e9; const long long MOD = 1e9 + 7; const int MAXN = 1e5 + 2; const int MN = 1e6 + 3; int d1, d2; int p1, p2; bool usual = 1; int ans[MN]; int main() { int n, q; scanf( %d %d , &n, &q); p1 = 0, p2... |
#include <bits/stdc++.h> int main() { long double val = 0.0; unsigned transistors = 0, seconds = 0; std::cin >> transistors >> seconds; std::cout.precision(25); std::cout << (long double)transistors * powl(1.000000011, (long double)seconds) << std::endl; retu... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long maxn = 2001; long long h[maxn], dp[maxn][2 * maxn]; signed main() { long long n, k; scanf( %lld%lld , &n, &k); for (long long i = 1; i <= n; i++) scanf( %lld , &h[i]); dp[0][2001] = 1; for (long ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; typedef double LD; const int N = 250000 + 5; int n; int b[N]; long long a[N]; const int L = 200; const int E = N / L + 10; long long mi[2][E]; long long S[2][E]; long long ad[E]; void F(int in) { int s... |
#include <bits/stdc++.h> using namespace std; int p, q, r, s, t, u; int a[25]; int b[25]; int dp[25][25]; int n; int c[25]; int sgn(int x) { if (x > 0) return 1; else if (x < 0) return -1; else return 0; } int main() { int i, j; int n, k, a, b; cin >> n >> k... |
#include <bits/stdc++.h> using namespace std; int prime[1000005]; int ans[5]; int idx; set<int> s, s1; set<int>::iterator it; int main() { int i, j; for (i = 2; i <= 1000000; i++) { if (prime[i] == 1) continue; for (j = i + i; j <= 1000000; j += i) prime[j] = 1; } int n; sc... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, i, j; char e, f; string s, x, y; set<string> v; cin >> x >> y; x[0] = x[0] - a + 1 + 0 ; a = x[0] - a + 1; b = x[1] - 0 + 1; e = x[0]; f = x[1]; y[0] = y[0] - a + 1 + 0 ; v.insert(x); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, d; cin >> n >> m >> d; long long x, y, z, i, j, c = 1; map<long long, long long> mp, mp2; set<long long> st; vector<long long> v; for (i = 0; i < n; i++) { cin >> x; v.push_back(x); st.insert(x);... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 400; int dp[N + 1][N + 1]; bool solve(string str, string t1, string t2) { int n = str.size(); int m = t1.size(); for (int j = 1; j <= m; ++j) dp[0][j] = -1; for (int i = 1; i <= n; ++i) { for (int j = 0; j ... |
#include <bits/stdc++.h> using namespace std; int a[2010]; char str[1010]; int ans[2010]; int tmp[2010]; int main() { int n; cin >> n; scanf( %s , str); for (int i = 0; i < n; i++) { a[i] = str[i] - 0 ; } for (int i = n; i < 2 * n; i++) { a[i] = a[i - n]; } for (... |
#include <bits/stdc++.h> using namespace std; int INT_MAX_VAL = (int)1e20; int INT_MIN_VAL = (int)-1e20; long long LONG_MAX_VAL = (long long)1e20; long long LONG_MIN_VAL = (long long)-1e20; long long C, Hr, Hb, Wr, Wb; long long func(long long x) { long long y = (C - Wb * x) / Wr; return Hb * x + ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; struct node { int l, r, id; } a[maxn]; bool cmp(node a, node b) { return a.l < b.l; } multiset<pair<int, int> > s; vector<int> ans; int main() { multiset<pair<int, int> >::iterator it; int n, k; cin >> n >> k; f... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; const int MOD = 1e9 + 7; class Problem { public: int N, Q, t, k, d; char ch; string S; void solve(std::istream& input, std::ostream& output); }; void Problem::solve(std::istream& input, std::ostream& output) { inp... |
#include <bits/stdc++.h> using namespace std; int visited[505], dp[505]; int d, x, y, flag; vector<int> vec[505]; vector<pair<int, int> > adj; int var[505]; void dfs(int u, int dist) { visited[u] = 1; d = max(d, dist); for (int i = 0; i < vec[u].size(); i++) { if ((u == x && vec[u][i] ==... |
#include <bits/stdc++.h> using namespace std; struct SegmentTree { struct Node { Node *lch, *rch; long long sum; Node() { lch = rch = nullptr; sum = 0; } void up() { sum = 0; if (lch != nullptr) sum += lch->sum; if (rch != nullptr) sum += rch... |
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); int n, m; vector<long long> seq[100010]; long long a[100010]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= m; i++) { scanf( %I64d , &a[i]); } long long initial = 0; a[0] = a[1]; a[m + 1] = a[m]; ... |
#include <bits/stdc++.h> using namespace std; int Scan(); int n, m, w, num; double aver, cur[105]; vector<pair<int, double> > res[105]; double place(double V, int i) { double D = aver - cur[num]; double L = min(D, V); res[num].push_back(make_pair(i, L)); cur[num] += L; if (fabs(cur[num] ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, m; cin >> n; long long int ans = ((n % 10) - 1) * 10; m = 1; while (n > 0) { ans += (m); m++; n /= 10; } cout << ans << n ; } int main() { ios_base::sync_with_stdio(false); cin.t... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double ans = 0; cin >> n; for (int i = 0; i < n; i++) { double x, y; cin >> x >> y; ans += y; } cout << 5 + ans / n; } |
#include <bits/stdc++.h> using namespace std; struct sans { long long int t1; long long int b1; }; bool func(sans s1, sans s2) { return s1.t1 < s2.t1; } long long int qw[2 * 100000 + 1]; pair<long long int, long long int> s1[2 * 100000 + 1]; int main() { long long int t, n, i, j; string s1... |
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define FOR(i, n) for (signed i = 0; i < n; ++i) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define VI vector<int> #define VII vector<VI> #define PII pair<int, int> #defin... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<long long> a, b; for (int i = 0; i < n; i++) { long long temp; cin >> temp; long long p = sqrt(temp); if (p * p == temp) a.push_... |
#include <bits/stdc++.h> using namespace std; const int N = 2000 + 10; const double PI = acos(0.0) * 2; const double eps = 1e-10; const double STD = 0.999459; const int dx[4][2] = {0, 1, 1, 0, 0, -1, -1, 0}; const double One = 0.8; int n; char s[N]; double a[N][N], b[N][N], coef[10][10]; bool vi[N... |
#include <bits/stdc++.h> using namespace std; int a[55]; long long int C[55][55]; double dp[55][55][55]; void precompute(int N) { for (int i = 0; i <= N; ++i) C[i][0] = 1; for (int i = 1; i <= N; ++i) for (int j = 1; j <= i; ++j) C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; } double func(int n, ... |
#include <bits/stdc++.h> using namespace std; int r1, c1, r2, c2; int rook(int r1, int c1, int r2, int c2) { if (r1 == r2 || c1 == c2) { return 1; } else { return 2; } } int bishop(int r1, int c1, int r2, int c2) { if ((r1 + c1) % 2 == 0 && (r2 + c2) % 2 != 0) return 0; if ((r1... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const double eps = 1e-9; const int inf = 1e9; long long a[N]; long long dis[N]; int n, m; vector<pair<int, long long> > adj[N]; void dij() { set<pair<long long, int> > q; for (int i = 1; i <= n; i++) { dis[i] = a[i]; ... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return a ? gcd(b % a, a) : b; } int main() { string s; cin >> s; int a[26] = {0}; for (int i = 0; i < s.length(); i++) a[s[i] - a ]++; string ans = s; for (int i = 0; i < s.length(); i++) ans[i] = # ; for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int k = 0; string star = * ; for (int i = 0; i < 12; i++) star = star + star; a = star + a + star; int res = 3000; for (int i = 0; i < a.size(); i++) { int u = 0; for (int j = 0; j < b... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; reverse(t.begin(), t.end()); if (s == t) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; const int N = 400010; class TWO_SAT { vector<int> A[N], T[N]; int tag[N]; int noot[N]; vector<int> topo; bool vis1[N]; void dfs1(int u) { vis1[u] = true; for (auto v : A[u]) if (!vis1[v]) dfs1(v); topo.push_back(u); ... |
#include <bits/stdc++.h> using namespace std; int n, m, a, b; bool x[101]; bool y[101]; int main() { scanf( %d%d , &n, &m); memset(x, false, sizeof x); memset(y, false, sizeof y); scanf( %d , &b); for (int i = 0; i < b; i++) { scanf( %d , &a); x[a] = 1; } scanf( %d , &b... |
#include <bits/stdc++.h> using namespace std; template <typename T> void rd(T &t) { t = 0; int f = 1; char p = getchar(); while (p < 48 || p > 57) { if (p == 45) f = -1; p = getchar(); } do { (t *= 10) += p - 48; p = getchar(); } while (p > 47 && p < 58); t ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } const int N = 30; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 48 + 10; vector<int> adj[MAX_N]; vector<int> ziro; bool mark[MAX_N]; int ans[MAX_N][3]; int poi = 0; vector<int> dfs(int v) { vector<int> ret; ret.push_back(v); mark[v] = 1; for (auto i : adj[v]) if (!mark[i]) { ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 10000; const int MAXBLOCKS = 10000; const int MAXRECT = 4 * MAXBLOCKS; const int MAXGN = 2 + 4 * MAXN + MAXRECT; const int MAXGM = 6 * MAXN + 2 * 2 * 14 * MAXRECT; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.