func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long double PI = 4.0 * atan(1.0); void EnchomSolve() { int l; long double L; long double ans = 0.0; long double area; long double height; long double help, help2; scanf( %d , &l); L = (long double)l; help = L / sqrt(3.0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int x = min(a, b / 2); int y = min(x, c / 4); cout << y * 7; return 0; } |
#include <bits/stdc++.h> using namespace std; struct EDGE { int to, next, w, co; } e[100000]; int head[100], top, vis[100000]; void add(int u, int v, int w, int co) { e[top].to = v; e[top].w = w; e[top].co = co; e[top].next = head[u]; head[u] = top++; } struct _ { int max_flow,... |
#include <bits/stdc++.h> using namespace std; struct station { int pos, price; } a[200003]; int T[800008], d, n, m; long long cnt; bool comp(station A, station B) { return (A.pos < B.pos); } void Build_MinIT(int, int, int); int Find_Min(int, int, int, int, int); int main() { scanf( %d %d %d , ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double lo = 0.0, hi = 10000000.0; for (int i = 1; i <= n; i++) { int sta; cin >> sta; lo = max(lo, (double)10.0 * sta / i); hi = min(hi, (double)10.0 * (sta + 1) / i); } int nextlo = floor(lo ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:102400000,102400000 ) using namespace std; int lowbit(int x) { return (x & -x); } template <class T_> T_ f_abs(T_ x) { return x < 0 ? -x : x; } template <class T_> T_ f_max(T_ a, T_ b) { return a > b ? a : b; } template <class T_> T_... |
#include <bits/stdc++.h> using namespace std; int arr[111]; int main() { int n; scanf( %d , &n); arr[0] = 0; for (int i = (1); i < (n + 1); ++i) scanf( %d , &arr[i]); int ans = 0; if (n % 2 == 0 || n == 1) { printf( -1 n ); return 0; } for (int i = n; i >= 1; i -= 2) { ... |
#include <bits/stdc++.h> using namespace std; namespace {}; int sgn(int x) { return x >= 0 ? 1 : -1; } int arr[200001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> arr[i]; arr[i] = sgn(arr[i]); ... |
#include <bits/stdc++.h> using namespace std; struct info { long long fs, sm, id; } bd[100001]; int cmp(info a, info b) { return a.fs < b.fs; } int main() { ios_base::sync_with_stdio(0); long long int i, j, x, n, cnt = 0, m, y, k, ans = 0, cf, cm, a, rr1 = 0, l, r, md... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<long long int> a(n); vector<long long int> b(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b... |
#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; const int maxn = 1e5 + 5; long long n, num; long long a[maxn]; long long vis[maxn]; priority_queue<long long> pq; void fnd(long long x) { if (vis[a[x]] == 0) { vis[a[x]] = 1; num++; fnd(a[x]); } else return; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 5; vector<int> adj[maxN]; int s[maxN], par[maxN]; void dfs(int n, int p) { par[n] = p; for (int i = int(0); i < int((int)adj[n].size()); i++) { if (adj[n][i] != p) dfs(adj[n][i], n); } } int main() { ios_base::sync_... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000001; const long double EPS = 1e-9; const int MOD = 1000000007; const long long LLINF = 1000000000000000001; const int maxn = 1042; int n; int a[maxn]; char ans[maxn][maxn]; bool good[maxn]; int main() { ios_base::sync_with_st... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int h[n]; for (int i = 0; i < n; i++) cin >> h[i]; int max; int a[n]; a[n - 1] = 0; max = h[n - 1]; for (int i = n - 2; i >= 0; i--) { if (h[i] > max) { a[i] = 0; max = h[i]; }... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c; do c = getchar(), f = c == - ? -1 : f; while (!isdigit(c)); do x = (x << 3) + (x << 1) + c - 0 , c = getchar(); while (isdigit(c)); return x * f; } struct Point { int x, y, px, py, id; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50 + 5, maxL = (1 << 20) + 10; int N, L; char s[maxn][25]; bool vis[maxL]; long double F[maxL], R[25]; long long dask[maxL]; bool check(int tt, int k) { if (dask[tt] & (1LL << k)) return false; else return true; } lon... |
#include <bits/stdc++.h> using namespace std; int tot, n; int vis[110]; int p[110]; int dp[2][262144], cs[110][262144], pre[110][262144]; int have[100]; int a[110], b[110]; string print(int sta) { string x = ; for (int i = tot - 1; i >= 0; i--) { if (sta & (1 << i)) x += 1 ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int c[100]; for (int i = 0; i < n; i++) cin >> c[i]; int ans = 0; int min = a > b ? b : a; for (int i = 0; i < n / 2; i++) { if (c[i] == 0 && c[n - 1 - i] == 2 || c[i] == 2 && c[n - 1 - i] =... |
#include <bits/stdc++.h> using namespace std; void read(long long a = 0) { freopen( in , r , stdin); if (a) freopen( out , w , stdout); } long long a[100009 * 10], b[100009 * 10]; long long n, m; bool bs(long long num) { bool vis[100009 * 10] = {}; long long space = 0; for (int i = num... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 9; const int N = 4040; int n, w, b; long long fac[N], f[N][N], inv[N]; long long qpow(long long x, long long p) { long long res = 1ll; while (p) { if (p & 1) { res = (res * x) % mod; } x = (x * x) % m... |
#include <bits/stdc++.h> using namespace std; long long f(string s, long long m) { map<char, long long> a; map<char, long long>::iterator ii; long long i; for (i = 0; i < s.size(); i++) { a[s[i]]++; } long long best = 0; for (ii = a.begin(); ii != a.end(); ii++) best = max(best, ii... |
#include <bits/stdc++.h> template <class T> void rd(T &x) { x = 0; int f = 1; char c; while (!isdigit(c = getchar())) if (c == - ) f = -1; do { x = (x << 3) + (x << 1) + (c ^ 48); } while (isdigit(c = getchar())); x *= f; } using namespace std; const int N = 1e5 + 5; ... |
#include <bits/stdc++.h> using namespace std; int n, k, v1, v2, L; bool can(double m) { double bus = 0, nbus = 0; for (int i = 0; i < (n + k - 1) / k; i++) { if (i == 0) bus += m * v2; else bus += m * v1; nbus += m * v1; if (bus > L) return false; double sb = ... |
#include <bits/stdc++.h> using namespace std; inline long long Calc(const int &x) { long long res = 0; for (long long i = 1; i <= x; i *= 10) res += x - i + 1; return res; } inline long long CalcSum(const int &x) { long long res = 0; for (long long i = 1; i <= x; i *= 10) res += 1ll * ... |
#include <bits/stdc++.h> const int INF = 1e9; using namespace std; void dfs(int v, int p, vector<vector<int> > &graph, vector<int> &sz) { sz[v] = 1; for (auto u : graph[v]) if (u != p) { dfs(u, v, graph, sz); sz[v] += sz[u]; } } void dfs(int v, int p, vector<vector<int> > &... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5; int n; double a[MAXN], b[4], t; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; b[3] = 1; for (int i = 1; i <= n; i++) { cin >> t; b[0] += t; b[1]++; if (b[1] * b[2] <=... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x0f0f0f0f; template <class S, class T> inline pair<S, T> MP(S a, T b) { return make_pair(a, b); } template <class T> inline auto LX(T &X) -> decltype((X.first)) { return X.first; } template <class T> inline auto LX(const T &X) ->... |
#include <bits/stdc++.h> using namespace std; int arr[101][1001]; int n, m; int g[101][101]; vector<int> col[1001]; set<int> row[101]; bool ans[101][101]; int main() { scanf( %d , &n), scanf( %d , &m); for (int i = 0; i < m; ++i) { int x, y; scanf( %d , &x), scanf( %d , &y); g[... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p1, p2; cin >> n; cin >> p1; int a1[p1]; for (int i = 0; i < p1; i++) cin >> a1[i]; cin >> p2; int a2[p2]; for (int i = 0; i < p2; i++) cin >> a2[i]; sort(a1, a1 + p1); sort(a2, a2 + p2); vector<int>::itera... |
#include <bits/stdc++.h> using namespace std; int n; int v[5], p[5]; int cnt[5], add[5]; int getMaxScr(int acc, int tot) { int MaxScr; for (int i = 0; i < 6; i++) { int t = 1 << i; if (tot >= t * acc) MaxScr = (i + 1) * 500; } return MaxScr; } bool ok(int m) { int vScr = 0,... |
#include <bits/stdc++.h> using namespace std; long long big = 1000000007; unsigned long long gcd(unsigned long long a, unsigned long long b) { if (a == 0) return b; return gcd(b % a, a); } string getbin(unsigned long long x) { if (x == 0) return 0 ; string ret = ; while (x != 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int d[10]; d[0] = 1; d[1] = 5; d[2] = 10; d[3] = 25; d[4] = 50; d[5] = 100; d[6] = 500; d[7] = 1000; d[8] = 5000; d[9] = 10000; int a[1000009]; a[0] = 1; for (int j = 0; j < 10... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 0; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) f ^= (ch == - ); for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 0 ; return f ? -x : x; } const long long maxn ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long double p[N], k[N]; int par[N]; vector<int> v[N]; bool vstd[N]; void dfs(int node) { if (vstd[node]) return; vstd[node] = true; for (auto u : v[node]) { if (u != par[node]) { k[node] += p[u]; par[u] ... |
#include <bits/stdc++.h> using namespace std; int main() { char next; long long int neg = 0, pos = 0; cin >> next; bool estado = false; string orden = ; while (next != = ) { if (next == ) { cin >> next; } if (next == - ) { estado = true; cin >... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << -1; } else cout << n << << n + 1 << << n * (n + 1); } |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, large = 2000000000, small = -2000000000; string s1, s2; cin >> n; for (int i = 0; i < n; i++) { cin >> s1 >> x >> s2; if ((s1 == > && s2 == Y ) || (s1 == <= && s2 == N )) { if (x >= small) { s... |
#include <bits/stdc++.h> using namespace std; const int N = 405; char mp[30], s[N], a[5], b[5]; int L, n, m, e[N][N], nxd[30], nxs[30], flg[30], lim[N], tmp[N], mx[2]; vector<int> ans; bool chk(int pos, int v, int x, bool ff) { if (lim[pos] != -1 && lim[pos] != flg[v]) return 0; for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); char s[1000010]; int n, m, a, b; vector<int> vec[1000010]; vector<int> p[1000010]; int x[1000010], y[1000010], sum[1000010], ans[1000010]; int Lowbit(int x) { return x & (-x); } void Update(int pos, int val) { while (pos > 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, c, min_cost, min_a, min_b, min_c; cin >> a >> b >> c; if (b % a == 0 && c % b == 0) { cout << 0 << endl; cout << a << << b << << c << endl; } else { ... |
#include<bits/stdc++.h> using namespace std; int dp[510][127010],mod,c[510][510],s[127010],jc[510]; int sol(int n){ s[0]=dp[n-1][0]; for(int i=1;i<=n*(n-1)/2;i++)s[i]=(s[i-1]+dp[n-1][i])%mod; int ans=0; for(int i=1;i<n;i++)for(int j=i+1;j<=n*(n-1)/2;j++)(ans+=1ll*(n-i)*dp[n-1][j]%mod*s[j-(i+1)]%mod)%=... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; vector<pair<long long, int>> adj[10 * MAXN]; long long dist[10 * MAXN]; int par[10 * MAXN]; int go1(int idx, int l, int r, int ds) { if (idx > 1) { int par = idx / 2; adj[par + ds].push_back({0, idx + ds}); } if (... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[300001]; long long n, k, s, m; bool b[300001]; inline long long read() { long long sum = 0, x = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) x = -1; ch = getchar(); } while (ch >... |
#include <bits/stdc++.h> using namespace std; int main() { int te; cin >> te; while (te--) { int n, m, x, ji = 0, ou = 0; cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> x; if (x & 1) ji++; else ou++; } if (ji == 0) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, q[1000010], a[1000010], del[1000010], sz[1000010], p[1000010]; stack<int> res; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) scanf( %d , &a[i]); if (a[m] <= n) a[m + 1] = n + 1; for (int i = 1; i <= m; i++) for (int... |
#include <bits/stdc++.h> using namespace std; int s0, t0, t1, n, m, Next[500000 + 5]; char s[500000 + 5], t[500000 + 5]; void GetNext() { Next[0] = -1; int j = 0, k = -1; while (j < m) { if (!~k || t[j] == t[k]) Next[++j] = ++k; else k = Next[k]; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 * 100 + 10; vector<int> g[maxn]; int a[maxn], b[maxn]; bool p[maxn]; int n, m; void input() { cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; g[u].push_back(v); g[v].pu... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; int main() { string s; cin >> s; int k; cin >> k; unordered_set<string> st; for (int i = 0; i < k; i++) { string temp; cin >> temp; st.insert(temp); string temp2 = ; temp2 = temp2 + te... |
#include <bits/stdc++.h> using namespace std; long long n, x, y; long long dp[10000005]; int main(void) { scanf( %lld%lld%lld , &n, &x, &y); dp[1] = x; for (int i = 2; i <= n; ++i) { if (i & 1) { dp[i] = min(dp[i - 1] + x, dp[(i + 1) >> 1] + x + y); } else dp[i] = min(dp[... |
#include <bits/stdc++.h> using namespace std; int n, nn, sum; vector<double> q; double x, ans, anss; int main() { scanf( %d , &n); sum = 0; for (int i = 1; i <= 2 * n; i++) { scanf( %lf , &x); ans += (x - floor(x)); if (floor(x) == ceil(x)) sum++; } if (sum > n) n = n * 2... |
#include <bits/stdc++.h> using namespace std; struct TnT { int k, f; } T[111]; bool cmp(TnT a, TnT b) { if (a.f == b.f) return a.k < b.k; return a.f < b.f; } map<int, int> t; int main() { ios::sync_with_stdio(false); int n, m, ans = -1; cin >> n >> m; for (int i = 0; i < m; i++... |
#include <bits/stdc++.h> using namespace std; bool distinct(int n) { set<int> a; int i, c = 0; while (n > 0) { int d = n % 10; a.insert(d); n /= 10; } int l = a.size(); for (int i = 0; i <= l - 1; i++) { c++; } if (c == 4) { return true; } else { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int a[n], sum = n - 1; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } cout << sum / n << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; char A[2005][2005], B[2005][2005]; int last_valid; pair<int, int> lb[26], ub[26]; bool ans; void _clear(int n, int m) { for (int i = 0; i < 26; ++i) { lb[i] = make_pair(INT_MAX, INT_MAX); ub[i] = make_pair(INT_MIN, INT_MIN); } for (int i ... |
#include <bits/stdc++.h> using namespace std; int n; string s; long long dp[200011]; const long long Mod = 1e9 + 7; long long f[200011][3]; long long power(long long x, long long n) { if (n < 0) return 0; if (n == 0) return 1; if (n % 2 == 0) return power(x * x % Mod, n / 2); return x * po... |
#include <bits/stdc++.h> using namespace std; int n, x[1042], y[1042]; double eps = 0.00000001; int dist2(int x1, int y1, int x2, int y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) ... |
#include <bits/stdc++.h> using namespace std; vector<int> vec[100010]; long long a[100010]; long long s; int n; long long dfs(int f, int u, long long val) { int sz = vec[u].size(), v; long long ret = 0, mv = ((long long)1e18), tmp; if (sz == 1 && vec[u][0] == f) return (a[u] = ((val) < (a[... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; template <class T> inline void smin(T &a, T b) { if (a > b) a = b; } template <class T> inline void smax(T &a, T b) { if (a < b) a = b; } int qf, qb, q[11111111]; long long res[555], a[555][55... |
#include <bits/stdc++.h> using namespace std; const int N = 400005; int n, q, K, m, i, j, k, h[N], t[N], num, fa[N], s[N], id[N], size[N], son[N], tp[N], dep[N], head[N], adj[N * 2], nxt[N * 2], p[N], cnt, stk[N], top, g[N], Head[N], Adj[N * 2], Nxt[N * 2], l, f[N]; void dfs(int x, int dad) { si... |
#include <bits/stdc++.h> using namespace std; int main() { int BIG = 1000000; int n, k; cin >> n >> k; string s; int a[2][n + 2 * k]; int x[2][n + 2 * k]; for (int i = 0; i < 2; i++) { cin >> s; for (int j = k; j < n + k; j++) { if (s[j - k] == - ) a[i][j] ... |
#include<bits/stdc++.h> #define pairs pair<int,int> #define loop(i,a,n) for(int i=a;i<n;i++) #define m_p make_pair #define fi first #define se second #define pb push_back #define ll long long #define all(v) v.begin(),v.end() using namespace std; //vector<ll> siz; /*ll indes(ll i,ll right){ l... |
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int main() { long long N, M, ans = 0, Last = 0; scanf( %I64d%I64d , &N, &M); long long Min = min(N, M); for (long long i = 1, j; i <= Min; i = j + 1) { j = min(N / (N / i), M); long long tmp; if (j & 1LL) ... |
#include <bits/stdc++.h> using namespace std; const int N = 2E5 + 10, mod = 1E9 + 7, M = 1E6 + 10, lim = 1E6; int n, m, a[N], s[N], ans[N]; struct node { int l, r, num; } p[N]; vector<int> f[M]; int pos[M]; inline int cmp(node x, node y) { return x.r < y.r; } struct sgtree { int l, r, sum; }... |
#include <bits/stdc++.h> using namespace std; long long fact[1000010]; long long m = 1e9 + 7; long long me(long long a, long long b, long long m) { long long ans = 1; while (b > 0) { if (b % 2 == 1) { ans = (ans % m * a % m) % m; } a = (a * a) % m; b /= 2; } retur... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { string s; cin >> s; string res = ; for (int i = 0; i < n; i++) { if (s[i] <= 1 ) continue; else { if (s[i] == 4 ) res += 3 , res += 2 , res += 2... |
#include <bits/stdc++.h> int W[21][11]; void F() { W[1][1] = 0; W[1][2] = 0; W[1][3] = 0; W[1][4] = 0; W[1][5] = 0; W[1][6] = 0; W[1][7] = 0; W[1][8] = 0; W[1][9] = 0; W[1][10] = 0; W[2][1] = 0; W[2][2] = 0; W[2][3] = 0; W[2][4] = 0; W[2][5] = 0; W[2][... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int i, j, n, ans = 0, k1, k2; cin >> n; long long int arr[n]; vector<vector<long long int> > vec(26); for (i = 0; i < n; i++) { cin >> arr[i]; vec[a... |
#include <bits/stdc++.h> using namespace std; const int MAX = 500005; long long a[MAX], pre[MAX], suf[MAX], t; int main() { int ans = -1, pos = 0, n; scanf( %d , &n); for (register int i = 1; i <= n; i++) { scanf( %lld , &a[i]); pre[i] = pre[i - 1] | a[i]; } for (register int i =... |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, string> > all[10010]; int main() { int n, m; cin >> n >> m; string name; int reg, sc; for (int i = 0; i < n; i++) { cin >> name >> reg >> sc; all[reg].push(make_pair(sc, name)); } for (int i = 1; i <= m;... |
#include <bits/stdc++.h> using namespace std; long long n = 1009; int LG2(int N) { int ans = 0; while (N) { N >>= 1; ans++; } return ans - 1; } int main() { cin.tie(0); cin.sync_with_stdio(0); int n; cin >> n; map<string, int> M; int o = 1; vector<long l... |
#include <bits/stdc++.h> using namespace std; #define INF 1000000009 int get(int i){ cout << ? << i+1 << endl; cout.flush(); int a; cin >> a; int b; if(i == 0) b = INF; else{ cout << ? << i << endl; cout.flush(); cin >> b; } re... |
#include <bits/stdc++.h> using namespace std; int N, M; int timew, cnt; stack<int> si; int low[2000005], dep[2000005], siz[2000005], dfn[2000005], nex[2000005], las[2000005], Arrive[2000005], st[2000005], cnt1; bool isin[2000005]; void jt(int xx, int yy) { cnt++; nex[cnt] = las[xx]; las[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const int inf = 1e9 + 100; int a[N + 100], b[N + 100]; vector<pair<int, int> > mon[N + 100]; int tree[N * 4 + 100], lazy[N * 4 + 100]; void build(int v, int tl, int tr) { if (tl == tr) { tree[v] = -b[tl + 1]; return; } ... |
#include <bits/stdc++.h> using namespace std; char s[500][500]; int di[4] = {-1, 1, 0, 0}; int dj[4] = {0, 0, -1, 1}; typedef int int2d[500][500]; int2d p[26]; int2d d; struct Pos { int r, c; Pos(int r = 0, int c = 0) : r(r), c(c) {} void init(int r, int c) { this->r = r; this->c... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } const int tt = 75; int n; int m; int x[100]; int y[100]; int z[100]; vector<int> v; vector<int> w[300]; int res[301][301][2]; int was[301][301][2]; map<int, int> num; int f[300]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base :: sync_with_stdio(false); cin.tie(NULL); int t ; cin >> t ; while(t--) { int a , b ; cin >> a >> b ; a-=b ; while(b--) cout << a ; string d = cba ; for(int i = 0 ; i < a ; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m, rr[10][10]; long long func(long long), dp[(1 << 21)]; map<long long, pair<long long, long long> > mr; long long check(long long i, long long j) { return (abs(mr[i].first - mr[j].first) + abs(mr[i].second - mr[j].second)) == 3; } ... |
#include <bits/stdc++.h> using namespace std; bool f(int n, int h, int c, int t) { return (2 * n + 1ll) * abs(1ll * n * (h + c - 2 * t) + t - c) <= (2 * n - 1ll) * (1ll * n * (h + c - 2 * t) + h - t); } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); long long t = 1; cin... |
#include <bits/stdc++.h> using namespace std; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rg... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; int rd() { int k = 0; char c = getchar(); while (c > 9 || c < 0 ) c = getchar(); while (c >= 0 && c <= 9 ) k = k * 10 + c - 0 , c = getchar(); return k; } const int N = 300000, M = 600001; int T, x, y, f[M], sx[... |
#include <bits/stdc++.h> using namespace std; vector<long long> adj[100007][2]; long long ecnt[100007][2] = {0}; long long ss[100007] = {0}; long long sum = 0; long long n, m, q; int main() { cin >> n >> m; for (long long i = 0; i < m; i++) { long long a, b; cin >> a >> b; --a; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int maxdp[27]; int dp[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; string str; cin >> n >> str; for (int i = 0; i < n; ++i) { for (int c = 26; c > str[i] - a ; --c) maxdp[str[i] - a... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 1e2 + 5; int main() { int n, m, c; string s[SIZE], extract, f; c = 0, f = acef ; cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { extract.push_ba... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t, n, m, i, j; cin >> n >> m; string a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long f = 0; for (long long i = 0; i < n; i++) { for (long long j ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; pair<int, pair<int, int> > A[maxn]; map<int, int> X; map<int, int> Y; int Hx[maxn], Hy[maxn]; int ans[maxn]; int fa[maxn]; int fi(int u) { if (fa[u] == u) return u; return fa[u] = fi(fa[u]); } void un(int u, int v) { ... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> adj[100005], stx, sty; long long mx = 0ll, ans[100005]; int sz[100005], par[100005]; pair<int, int> centroid = {0, 0}; bool cmp(int u, int v) { return sz[u] < sz[v]; } void dfs(int nw, int bf) { par[nw] = bf; sz[nw] = 1; for (i... |
#include <bits/stdc++.h> using namespace std; long long int a, b; bool temp = false; int main() { cin >> a; for (b = 1; b <= 500; b++) if ((b * (b + 1)) / 2 == a) { temp = true; break; } if (temp) cout << YES ; else cout << NO ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int inf = 1e5 + 9, lg = 20; int n, q, timer = 1; vector<int> adj[inf], level[inf]; int depth[inf], in[inf], out[inf], parent[inf][lg]; void dfs(int u, int par) { in[u] = timer++; level[depth[u]].push_back(in[u]); for (auto v : adj[u]) if ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1000000 + 5; int f[maxn], inv[maxn], finv[maxn]; void init() { inv[1] = 1; for (int i = 2; i < maxn; i++) inv[i] = (mod - mod / i) * 1ll * inv[mod % i] % mod; f[0] = finv[0] = 1; for (int i = 1; i < m... |
#include <bits/stdc++.h> using namespace std; long long int func1(long long int i) { long long int m = i; return i * (i + 1) * (2 * i + 1) / 6 - (m + m + 2) * i * (i + 1) / 2 + (m + m + 1 + m * m) * i; } long long int func2(long long int x, long long int i) { return x * (i + i * i - i * (... |
#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; int main() { string a, b; int k = 0, l = 0, n; cin >> a >> b; n = a.size(); for (int i = 0; i < n; i++) { if (a[i] == 4 && b[i] == 7 ) { k++; } else if (a[i] == 7 && b[i] == 4 ) { l++; } } int p = max(k... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> T gcd(T a, T b) { return ((b == 0) ? a : gcd(b, a % b)); } void solve() { int n, k; long long x; cin >> n >> k >> x; string s; cin >> s; x--; int cnt = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { long long n, s, t; cin >> n >> s >> t; cout << max(n - s + 1, n - t + 1) << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long f[105], g[105][2], q[105], t, n; int main() { f[1] = 1; f[2] = 2; for (int i = 3; i <= 86; ++i) f[i] = f[i - 1] + f[i - 2]; int cases; for (scanf( %d , &cases); cases--;) { scanf( %I64d , &n); t = 0; for (int i = 86; i; ... |
#include <bits/stdc++.h> using namespace std; namespace runzhe2000 { const int INF = 1 << 29; int ft[100005], gt[100005], f[100005][10], g[100005][10], timer = 1, c[10], sta[100005], top; char s[100005]; bool insta[100005]; struct node { int ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int r = 0, b = 0, y = 0, g = 0; int len = s.size(); for (int i = 0; i < len; i++) { if (s[i] == B ) b = i % 4; else if (s[i] == G ) g = i % 4; else if (s[i] == R ) r = i % ... |
#include <bits/stdc++.h> int main() { unsigned short x; std::cin >> x; (x > 1) ? std::cout << x << << x : std::cout << -1; } |
#include <bits/stdc++.h> using namespace std; long long n, k, a[300005], b[300005]; int main() { cin >> n >> k; k--; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i < n; i++) b[i] = a[i + 1] - a[i]; long long res = a[n] - a[1]; sort(b + 1, b + n); for (int i = n - 1; i >= n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.