func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &a, T const &b) { return a > b ? a = b, 1 : 0; } template <class T> inline bool chkmax(T &a, T const &b) { return a < b ? a = b, 1 : 0; } const int M = 35; const int N = 205; const int Mod = 998244353; lo... |
#include <bits/stdc++.h> using namespace std; struct T { long long nu, p; bool operator<(const T& o) const { if (nu > o.nu) return true; if (nu == o.nu && p > o.p) return true; return false; } }; long long n, k, m; T plazas[111111]; long long sum[111111]; long long donde[1111... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; const double inf = 1e9; int n, m, x[N], b[N], pre[N]; double dp[N]; bool check(double mid) { for (int i = 1; i <= n; i++) dp[i] = inf; for (int i = 0; i <= n; i++) { for (int j = i + 1; j <= n; j++) { double tmp = dp[i] ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b, c, d, e, i, j, k, l; cin >> a >> b; if (a <= b) cout << abs(a - b) << endl; else if (a % 2 + b % 2 == 1) cout << 1 << endl; else cout << 0... |
#include <bits/stdc++.h> using namespace std; long long a[200001]; long long search(long long l, long long h, long long target) { if (h - l <= 1) { if (a[l] > target) return l; else return h; } long long mid = (l + h) / 2; if (a[mid] > target) return search(l, mid... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, nn; cin >> n; nn = n * 2; vector<int> arr(nn); for (int i = 0; i < nn; ++i) cin >> arr[i]; sort(arr.begin(), arr.end()); long long ans, now; ans = arr[nn - 1] - arr[n]; ... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long INF = 0x3f3f3f3f3f3f3f3f; const long long llinf = (1LL << 62); const int inf = (1 << 30); const long long nmax = 5e5 + 50; const int mod = 1e9 + 7; using namespac... |
#include <bits/stdc++.h> using namespace std; const int N = 100100, L = 18; int n, m, Q; int dep[N], p[N][L]; set<int> adj[N]; map<int, int> mp[N]; int get(int par, int i) { if (mp[par][i] == i) return i; return mp[par][i] = get(par, mp[par][i]); } void mrg(int par, int u, int v) { u = get... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T b, T p, T m) { T ret; if (p == 0) return 1; if (p & 1) { ret = (bigmod(b, p / 2, m) % m); return ((b % m) * ret * ret) % m; } else { ret = (bigmod(b, p / 2, m) % m); return (ret * ret) % m; ... |
#include <bits/stdc++.h> using namespace std; int a[200000], dp[600000]; int main() { int n, l; cin >> n >> l; for (int i = 1; i <= n; i++) { double x; cin >> a[i] >> x; } int maxx = -1; for (int i = 1; i <= n; i++) { dp[i] = 1; for (int j = 1; j < i; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int j, i, k, n, m, x; float d[6000], a[5008], b[5009]; cin >> n >> m; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; d[i] = (float)(1.0 * a[i]) / b[i]; } sort(d, d + n); printf( %.8f , d[0] * m); return ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a, b, c; cin >> a >> b >> c; a *= 10; long long q = 0; for (long long j = 0; j <= 9; j++) { a += j; if (a % b == 0) { q = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; stack<int> s; int ans = 0; for (int i = 0; i < n; i++) { int x; cin >> x; while (!s.empty()) { ans = max(ans, s.top() ^ x); if (x > s.top()) { s.pop(); } else { ... |
#include <bits/stdc++.h> using namespace std; template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } int n, d; const int geta = 260; const int MX = 30000; int dp[30010][520]; int cnt[30010]; int main()... |
// __ // _______ / _|_ _ _ __ _ _ ___ // |_ / _ |_| | | | __| | | / __| created on // / / __/ _| |_| | | | |_| __ 18 Mar 2021 00:06:00 // /___ ___|_| __, |_| __,_|___/ // |___/ #include<bits/stdc++.h> using na... |
#include <bits/stdc++.h> using namespace std; long long sb[5050], dp[5050][5050], sum[5050], num[5050]; int n, i, j, k; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %lld , &sb[i]); } sort(sb + 1, sb + n + 1); for (i = n, j = n; i >= 1; i--) { dp[1][i] = 1; ... |
#include <bits/stdc++.h> using namespace std; deque<int> check(deque<int> mas) { int l = 0, r = mas.size() - 1; bool flag = true; for (; l < mas.size() / 2; l++, r--) { if (mas[r] < 0) { mas[r - 1]--; mas[r] += 10; } if (mas[l] == mas[r] + 1 && l != r - 1) { mas... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long fac[1100000], inv[1100000], p[1100000]; long long pow_mod(long long a, long long b, long long m) { long long ans = 1LL; a %= m; while (b) { if (b & 1) ans = ans * a % m; a = a * a % m; b >>= 1; ... |
#include <bits/stdc++.h> using namespace std; inline int readInt() { static int n, ch; n = 0, ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) n = n * 10 + ch - 0 , ch = getchar(); return n; } const int MAX_N = 500000 + 3; int n, k, a[MAX_N], b[MAX_N]; struct Dat... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5; long long n, m, k, a[N], c, res; struct stru { long long col, x, l, r; }; vector<stru> v; vector<vector<long long>> mp(N), pr(N); signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> m >> k; ... |
#include <bits/stdc++.h> namespace modular { const int MOD = 1000000007; inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; } inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; } inline int mul(int x, int y) { return 1LL * x * y % MOD; } inline int qpow(int x, int y) { i... |
#include <bits/stdc++.h> const int N = 2e5 + 5; using namespace std; vector<int> G[N]; long long b[N]; int vis[N]; long long ans[N]; long long flag = 1; void dfs(int x, int fa) { long long minn = 0x3f3f3f3f; if (b[x] == -1) { for (int i = 0; i < G[x].size(); i++) { int g = G[x][i];... |
#include <bits/stdc++.h> using namespace std; template <typename T> int len(const T& a) { return a.size(); } using ll = long long; constexpr long double EPS = 1e-7; long double Check(const vector<long double>& a, long double x) { vector<long double> new_a(a.size()); long double bestmin = 1e8, ... |
#include <bits/stdc++.h> using namespace std; int read() { 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 + ch - 0 ; ch = getchar(); } return x * f; } ... |
#include <bits/stdc++.h> using namespace std; struct data { int to, head; } e[750000 * 2]; stack<int> s; vector<int> cir[750000]; int n, m, len, head[750000], dfn[750000], low[750000], cnt, num, p[750000], binv[750000], d[750000]; int ans, tot; long long mm; int mul(int a, int b) { int a... |
#include <bits/stdc++.h> using namespace std; int n, m, k; long long rase[100][100], satis[100]; long long DP[20][(int)1e6 + 1]; long long solve(int index, int mask) { if (DP[index][mask] != -1) { return DP[index][mask]; } if (__builtin_popcount(mask) == m) { return DP[index][mask] = 0... |
#include <bits/stdc++.h> using namespace std; int n, s[4]; int main() { scanf( %d , &n); for (int x, i = 1; i <= n; i++) scanf( %d , &x), s[x]++; cout << n - max(s[1], max(s[2], s[3])); } |
#include <bits/stdc++.h> using namespace std; inline int read() { 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 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[200005]; int colour[200005]; long long dp[200005]; long long ans[200005]; void dfs(long long source, long long p) { dp[source] = colour[source]; for (int i = 0; i < v[source].size(); ++i) { if (v[source][i] == p) continue; ... |
#include <bits/stdc++.h> using namespace std; int t, n, m; long long r, ans[800005]; stack<int> s; vector<pair<char, vector<int>>> v; char x[800005 * 6]; void dfs(int a) { if (v[a].first == _ ) return; vector<int> tv; for (int i : v[a].second) { dfs(i); if (v[a].first == v[i].firs... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans = 0, ini = 1, mul = 10; long long int temp; cin >> n; while (mul <= n) { temp = mul / 10; ans += (mul - temp) * ini; mul *= 10; ++ini; } mul /= 10, ini; if (n - (mul - 1) >= 0) { ... |
#include <bits/stdc++.h> using namespace std; vector<pair<pair<long long int, long long int>, pair<long long int, long long int> > > q; int main() { long long int n, x1, cur, x, y, cost, type, ans, best[200501], i; cin >> n >> x; for (i = 0; i < n; i++) { cin >> x1 >> y >> co... |
#include <bits/stdc++.h> using namespace std; class fenwick { int n; vector<long long> v; public: long long sum(int r) { long long rval = 0; for (; r >= 0; r = (r & (r + 1)) - 1) { rval += v[r]; } return rval; } void update(int in, int d) { for (; in <... |
#include <bits/stdc++.h> char a[1002][34], b[34]; int point[1002], res[1002], h[1002]; int main() { int n, x, i, j, p = 1; scanf( %d , &n); scanf( %s %d , &a[0], &x); point[0] += x; h[0] = point[0]; res[0] = 0; for (i = 1; i < n; i++) { scanf( %s %d , &b, &x); for (j = 0; j... |
#include <bits/stdc++.h> using namespace std; int n, m, c[410000], f[410000], fa[410000], ch[410000][2], sum[410000], sz[410000]; int edgenum, vet[2100000], Next[2100000], Head[11000000]; long long ans, d[410000], sz2[410000]; bool vis[410000]; vector<int> vec[410000][2]; bool nroot(int x) { return ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a; int n; int i; bool ans; cin >> n; a.resize(n); for (i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); ans = false; for (i = 1; i < n; i++) { if (a[i] > a[i - 1] && 2 * a[i - ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100002]; int find(int v, int* parent) { if (parent[v] == v) { return v; } return find(parent[v], parent); } int vis[100002]; int dp[100002]; void dfs(int u) { vis[u] = 1; for (int i = 0; i < g[u].size(); i++) { int... |
#include <bits/stdc++.h> using namespace std; int d[100][100]; char s[10000]; int main() { int i, j, k, max, min, ans1, ans2, o, p, e1, e2, e3, tot, x, y, n; string name1, name2; map<string, int> mp; vector<string> a; vector<int> aa; scanf( %d , &n); mp.clear(); a.clear(); me... |
#include <bits/stdc++.h> using namespace std; char s[100003], ss[100003]; int main() { int ans = 0; scanf( %s , s + 1); int len = strlen(s + 1); int n = 0; for (int i = 1; i <= len; i++) { if (n > 0 && ss[n] == s[i]) { n--; ans++; } else ss[++n] = s[i]; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 25; long long f[N], s[N], a[N], res; int n; deque<pair<long long, long long> > dq; bool ok(pair<long long, long long> x, pair<long long, long long> y, pair<long long, long long> z) { return ((x.second - y.second) * (z.first - y.... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:20000000 ) using namespace std; const long long mod = 1000000007; const double eps = 1e-7; const long long INF = 1000000000000000; int main() { string s; cin >> s; int x = -1, k = 0; for (int(i) = (0); (i) < (s.size()); ++(i)) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int LIM = 32; const int SIZ = 380; const int MOD = 1000000007; int n, m, cnt, comp, prvi, prvi_edg, nula; set<int> st; queue<int> q; map<int, int> mp; int p[SIZ][SIZ], val[MAXN], bio[MAXN], r[MAXN], e[MAXN], dp[SIZ][MAXN]; ... |
#include <bits/stdc++.h> using namespace std; stack<char> s; char c; int now = 1; int main() { while (cin >> c) { if (s.empty()) { s.push(c); } else { if (s.top() == c) { s.pop(); now = 3 - now; } else { s.push(c); } } } ... |
#include <bits/stdc++.h> using namespace std; void maximize(int &a, int b) { a = max(a, b); } const long long int modulo = 1e9 + 7; void add(int &a, long long int b) { a = (a + b) % modulo; } int n; int memcompute[20][2][1000005]; int expo3[2]; int compute(int x, int y, long long int available) { in... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = (1e-10); int main() { int tc; cin >> tc; while (tc--) { int n; cin >> n; vector<pair<int, int> > stud(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; ... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> bool umin(T1 &x, const T2 &y) { if (x > y) return x = y, true; return false; } template <typename T1, typename T2> bool umax(T1 &x, const T2 &y) { if (x < y) return x = y, true; return false; } template <ty... |
#include <bits/stdc++.h> using namespace std; long long a, b, c; int main() { long long t; scanf( %lld , &t); while (t--) { scanf( %lld%lld%lld , &a, &b, &c); if (a < c) printf( 1 ); else printf( -1 ); if (a * b > c) printf( %lld n , b); else ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 2000005; vector<long long> open[maxN]; vector<pair<long long, long long> > box; long long a[maxN], b[maxN], p[maxN]; priority_queue<long long> demolished; bool cmp(long long a, long long b) { return p[a] < p[b]; } int main() { long long ... |
#include <bits/stdc++.h> using namespace std; long long n, u, r; long long a[31], b[31], k[31], p[31]; int op[31]; long long res = -(1e18); void doit(int); int main() { cin >> n >> u >> r; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int f = 1, x = 0; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long N = 1003; long long dp[N][N]; int32_t main() { long long n, k; cin >> n >> k; long long a[n + 1]; for (long long i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); long long pos = 0; ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int c; cin >> c; int k = 2000; int x = (((k - c) % k) + k) % k; long long cur = x; while (cur * (k - 1) <= c) { cur += k; } long long y = ((1LL * cur * (k - 1)) - c) / k; cout << k << end... |
#include <bits/stdc++.h> void Get(int &T) { char C; bool F = 0; for (; C = getchar(), C < 0 || C > 9 ;) if (C == - ) F = 1; for (T = C - 0 ; C = getchar(), C >= 0 && C <= 9 ; T = T * 10 + C - 0 ) ; F && (T = -T); } void Get(long long &T) { char C; bool F = 0; f... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; const int M = 30005; const int inf = 99999999; int n, m, tot, s, t, Cost, Flow; int adj[M], nxt[M], flow[M], val[M], pre[M], data[M], dist[M], vis[M], d[M]; int g[N]; char pattern[N]; char text[N]; void ins(int x, int y, int f, int v)... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 4; int n, k, b[N], vis[N]; long long l, dp[N], temp[N]; const long long mod = 1e9 + 7; struct node { friend bool operator<(node x, node y) { if (x.a == y.a) return x.pos < y.pos; return x.a < y.a; } int a, pos; }; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> vector<T>& operator--(vector<T>& v) { for (auto& i : v) --i; return v; } template <typename T> vector<T>& operator++(vector<T>& v) { for (auto& i : v) ++i; return v; } template <typename T> istream& operator>>(istream&... |
#include <bits/stdc++.h> using namespace std; const int N = 105; char s[N], t[N]; int dis(char a, char b) { int t = abs(a - b); return min(t, 26 - t); } int main() { int n; scanf( %d , &n); scanf( %s , s + 1); t[1] = A , t[2] = C , t[3] = T , t[4] = G ; int ans = 1e9; for... |
#include <bits/stdc++.h> using namespace std; long long arr[1000]; long long seg[1000005]; long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } void buildtree(long long start, long long end, long long treenode) { if (start == end) { seg[tree... |
#include <bits/stdc++.h> using namespace std; int type[100005]; int lead[100005], degree[100005]; vector<int> go(int n) { vector<int> v; while (true) { if (degree[n] > 1) { return v; } else if (lead[n] == -1) { v.push_back(n); return v; } v.push_back(n); ... |
#include <bits/stdc++.h> using namespace std; int n, k, h, cnt, tmp[100010], ans[100010]; long double eps; struct lemming { int v, w, id; bool operator<(const lemming &tmp) const { return w < tmp.w || (w == tmp.w && v < tmp.v); } } a[100010]; bool check(long double x) { int now = 1; ... |
#include <bits/stdc++.h> using namespace std; int dp[100][100]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; if (n == 1 || n == 2) { cout << -1; return 0; } int m = INT_MAX; int mi = -1; int a[n]; int m2 = INT_MIN;... |
#include <bits/stdc++.h> using namespace std; int main() { long long dp[100001], dp2[100001]; long long n; string a, b; long long match, k; cin >> a >> b >> k; string a2 = a; n = a.length(); a = a + a.substr(0, n - 1); match = 0; for (int i = 0; i <= 2 * n - 2; i++) { i... |
#include <bits/stdc++.h> using namespace std; int n, m; int state[10000]; int cnt, sum; void dfs(int depth) { if (depth >= m) { for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { if (state[i] > state[j]) ++cnt; } } } else { for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int inf = 2e9 + 5; double PI = 3.14159265358979323846; void solve() { int n; cin >> n; int x = (int)sqrt(n); int best = inf; for (int i = max(1, x - 2); i <= x + 2; i++) { for (int j = ma... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; double pi = acos((double)-1); const int MOD = 1000000007; const int INF = 2147483647; int main() { clock_t tStart = clock(); int tests = 1; for (int test = 1; test <= tests; test++) { int n, m, dx, dy;... |
#include <bits/stdc++.h> constexpr int P = 998244353; struct Matrix { int a[4]; Matrix() : a{} {} friend Matrix operator*(const Matrix &lhs, const Matrix &rhs) { Matrix res; res.a[0] = (1ll * lhs.a[0] * rhs.a[0] + 1ll * lhs.a[1] * rhs.a[2]) % P; res.a[1] = (1ll * lhs.a[0] * rhs.a[1] + ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int a[205], b[105]; set<int> st; int n; void solve() { cin >> n; for (int i = 1; i <= n; i++) cin >> b[i]; st.clear(); for (int i = 1; i <= 2 * n; i++) st.insert(i); for (int i = 1; i <= n; i++) { st.erase(b[... |
#include <bits/stdc++.h> using namespace std; int N, a[100005], b[100005]; char s1[100005], s2[100005]; long long x11, x01, x10, x00, ans; int main() { scanf( %d , &N); cin >> s1; cin >> s2; for (int i = 1; i <= N; ++i) a[i] = s1[i - 1] - 0 , b[i] = s2[i - 1] - 0 ; for (int i = 1; i <= N... |
#include <bits/stdc++.h> using namespace std; short p[402][402 * 402]; int a[402][402], n, m, l, r, j, i, d[402][402], f[402][402], ans; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) scanf( %d , &a[i][j]); for (j = 1; j <= m; ++j) { for (l = n; l >... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100005; const double eps = 1e-8, Pi = acos(-1.0); int n; double a, x[Maxn], y[Maxn], dis[Maxn]; pair<double, double> pos[Maxn]; priority_queue<double, vector<double>, greater<double> > Pr; bool check(double r) { int m = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; inline long long small(char a, char b) { return min(abs(a - b), min(a + 26 - b, b + 26 - a)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, pos; cin >> n >> pos; string x; cin >> x; bool gotomi... |
#include <bits/stdc++.h> using namespace std; int n, m, w[100010], in1, in2, in3; double ans; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &w[i]); for (int i = 1; i <= m; i++) { scanf( %d%d%d , &in1, &in2, &in3); ans = max(ans, (w[in1] + w[in2]) * 1.0 / in... |
#include <bits/stdc++.h> using namespace std; const int64_t LINF = 1LL << 62; struct Point { int x, y; bool operator<(const Point& o) const { return x < o.x || (x == o.x && y < o.y); } }; inline int64_t cross(const Point& o, const Point& a, const Point& b) { return (a.x - o.x) * (int64_t... |
#include <bits/stdc++.h> using namespace std; int main() { int n, start, x; cin >> n >> start >> x; int ans = x; int val, nt; cout << ? << start << endl; cin >> val >> nt; if (val >= x) { cout << ! << val << endl; return 0; } int best = start; long long diff... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> inline string toStr(T x) { stringstream st; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const long long inf = (1ll << 60); int n, m, k, cnt, a, b, v[N], p[N], ta[N], tb[N], td[N], ca[N << 2], cb[N << 2], cd[N << 2], flag[N], pa, pb, pc, pd; long long A[N], B[N], C[N], D[N], co[N], sum, ans = inf; int read() { int x ... |
#include <bits/stdc++.h> using namespace std; int main() { int len, i; bool chk = true; string str; cin >> str; char ch = a ; len = str.size(); for (i = 0; i < len; i++) { if (str[i] > ch) { chk = false; break; } else if (str[i] == ch) ch++; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; long long gi() { long long x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getc... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238; long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } char str[20... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int INF = 1e9; int n, m; char mt[1505][1505]; const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; bool flag = false; pair<int, int> vis[1505][1505]; void dfs(int x, int y) { int ax = (x % n + n) % n, ay = (y % m + m) % ... |
#include <bits/stdc++.h> using namespace std; struct bian { int next, point, w; } b[10000]; int d[2100][2100], n, x[2100], f[2100], pd[2100], pre[2100], p[2100], len; long long e[2100][2100]; int getmin() { int num = 2e9, where = 0; for (int i = 1; i <= n; i++) if (pd[i] == 0 && f[i] < num... |
#include <bits/stdc++.h> using namespace std; int a[5], r[5] = {0, 2, 3, 4, 1}; int main() { for (int i = 1; i <= 4; i++) scanf( %d , &a[i]); for (; a[1] != 1 || a[2] != 1 || a[3] != 1 || a[4] != 1;) { int x = rand() % 4 + 1; if (a[x] == 1 && a[r[x]] == 1) continue; if ((a[x] % 2 == 0) &... |
#include <bits/stdc++.h> using namespace std; long long n, m, mn, mx, l, t, mn2 = INT_MAX, mx2 = INT_MIN; set<long long> q; int main() { cin >> n >> m >> mn >> mx; long long a[m]; for (int i = 0; i < m; i++) { cin >> a[i]; if (a[i] < mn2) mn2 = a[i]; if (a[i] > mx2) mx2 = a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { { ios_base::sync_with_stdio(false); cin.tie(0); }; int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<int> matching; vector<int> vis(3 * n + 1, 0); for (int i = 1; i <= m; i++) { ... |
#include <bits/stdc++.h> char x[200005]; int dp[200005], maxdp[26]; int main() { int n; scanf( %d , &n); scanf( %s , x + 1); for (int i = 1; i <= n; i++) { x[i] = x[i] - a ; dp[i] = 1; } maxdp[x[1]] = 1; for (int i = 2; i <= n; i++) { for (int j = x[i] + 1; j < 26; j... |
#include <bits/stdc++.h> using namespace std; int main() { int t, m; cin >> t >> m; vector<int> A; A.resize(m); int c = 0; for (int i = 0; i < m; ++i) A[i] = 0; for (int i = 0; i < t; ++i) { string z; int tmp; cin >> z; if (z[0] == d ) { for (int j = 0; j... |
#include <bits/stdc++.h> using namespace std; inline int Rint() { int x; scanf( %d , &x); return x; } const int MOD = 1e9 + 7; const int MAXN = 1e5 + 10; int alll(char* str_a, char* str_b, int n) { int ret = 1; for (int i = 0; i < n; ++i) { if (str_a[i] == ? ) ret = ret * 10ll % M... |
#include <bits/stdc++.h> using namespace std; struct ip { long long a, b, c, d, m; }; ip getip(long long num, int mm) { return {(num & (255 << 24)) >> 24, (num & (255 << 16)) >> 16, (num & (255 << 8)) >> 8, num & 255, mm}; } vector<ip> numtoip(pair<long long, long long> p) { long lon... |
#include <bits/stdc++.h> using namespace std; string imp = Impossible n ; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); clock_t startTime; double getCurrentTime() { return (double)(clock() - startTime) / CLOCKS_PER_SEC; } const int N = 1e5 + 1e3; long long MOD = 1e9 + 7; ... |
#include <bits/stdc++.h> using namespace std; void mex(string &s) { s.back()++; for(int i=s.length()-1;i>=1;i--) { if(s[i]> z ) { s[i]= a ; s[i-1]++; } } if(s[0]> z ) { s.push_back( a ); ... |
#include <bits/stdc++.h> using namespace std; int a[105]; int b[105]; int main() { int n, m, i, j; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d%d , &a[i], &b[i]); int con = 0; for (i = 1; i <= 10000; i++) { int s = 0; for (j = 1; j <= n; j++) s += (i * a[j] / b[j] + ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; int n, m, k, second; int a[500005]; int b[500005]; int cnt[500005]; int rbd[500005]; int stat[500005]; int app[500005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; string t, s; cin >> s >> t; n = t.size(); vector<long long> pi(n + 1, 0); for (long long i = (long long)1; i != (lon... |
#include <bits/stdc++.h> using namespace std; int a[101], b[101]; int main() { int n, m; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); cin >> m; for (int i = 0; i < m; ++i) cin >> b[i]; sort(b, b + m); cout << a[n - 1] << << b[m - 1] << endl; return 0; ... |
#include <bits/stdc++.h> using namespace std; char name[105][20]; long long type[105], w[105], h[105], border[105], space[105]; int link[105][105]; bool caled[105]; int n, m; void cal(int x) { if (caled[x]) return; caled[x] = true; if (link[x][0] == 0) return; int i, k; if (type[x] == ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 505; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char dc[] = { R , L , D , U }; string ans; int n; bool grid[MAX][MAX], vis[MAX][MAX]; int dp[MAX][MAX][4]; bool valid(int x, int y, int dir) { return dp[x][y][dir] = ~dp[x][y... |
#include <bits/stdc++.h> using namespace std; struct Grass { int sizee; char dir; } a[100005]; int n; bool flag[100005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].dir; } for (int i = 1; i <= n; i++) { cin >> a[i].sizee; } int nowx = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, a[200000], x, y, ans; multimap<int, int> M; pair<int, int> P; int main() { scanf( %d , &n); for (int i = 1; i <= (n); ++i) scanf( %d , &a[i]); scanf( %d%d , &x, &y); sort(a + 1, a + n + 1); n = unique(a + 1, a + n + 1) - a - 1; for (... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int>>> adj[(long)(1e5)]; int sub[(long)(1e5)]; int w[(long)(1e5)]; int c[(long)(1e5)]; int dfs(int r, int p) { int cnt = 0; for (int i = 0; i < adj[r].size(); i++) { if (adj[r][i].first != p) { w[adj[r][i].first] ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; struct Edge { int to, nxt; } e[N << 1]; int h[N], idx, a[N]; void Ins(int a, int b) { e[++idx].to = b; e[idx].nxt = h[a]; h[a] = idx; } long long dis[N], siz[N]; void dfs(int u, int fa) { siz[u] = a[u]; for (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.