func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int b[10][10]; char c[10][4][4]; int main() { char ch; int x = 1, y = 1, x1, y1, l, z, i, j, r; x1 = 3, y1 = 3; for (i = 1; i <= 9; ++i) { if (i > x1) ++x, x1 += 3; y1 = 3; y = 1; for (j = 1; j <= 9; ++j) { if (j % 3 =... |
#include <bits/stdc++.h> using namespace std; long double x[2], y[2], r[2]; inline long double sqr(long double x) { return x * x; } inline long long sqrl(long long x) { return x * x; } inline long double fcos(long double a, long double b, long double c) { return acosl((a * a + b * b - c * c) / (2 * a * b)... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, mini, maxi; cin >> n >> m; long long x = n / m; long long rem = n - (x * m); mini = rem * (x * (x + 1)) / 2 + (m - rem) * (x * (x - 1)) / 2; maxi = ((n - m + 1) * (n - m)) / 2; cout << mini << << maxi; } |
#include <bits/stdc++.h> using namespace std; bool p[5000020]; int prime[5000020]; void criba() { p[0] = false; p[1] = false; for (int i = 2; i <= 5000000; i++) p[i] = true; for (int i = 2; i <= 5000000; i++) { if (p[i]) { prime[i] = 1; for (int h = 2; i * h <= 5000000; h++... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; int n, m; double H, L; cin >> H >> L; cout << fixed << setprecision(10) << ((L * L - H * H) / (2 * H)); return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1000100; int dp[N][2]; int a[] = {1, 2}; int solve(int sum, int idx) { if (sum == 0) return 1; if (sum < 0 || idx == 2) return 0; if (dp[sum][idx] != -1) return dp[sum][idx]; return dp[sum][idx] = solve(sum - a[idx], idx) + solve(sum,... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 600009; const long long MOD = 1e9 + 7; class { public: int n, F[MAXN], G[MAXN]; string s; int Min; void solve() { cin >> n >> s; for (int i = 1; i <= n; ++i) { if (s[i - 1] == ( ) F[i] = F[i - 1] + 1... |
#include <bits/stdc++.h> using namespace std; const bool testcase = 0; const long long int mod1 = 1000000007; const long long int mod2 = 998244353; const long long int N = 1e5 + 5; std::vector<long long int> adj[N]; std::vector<long long int> vis(N, false); bool hasLoop(long long int i, long long int p)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, e_min = INT_MAX, e_max = INT_MIN; list<int> l; cin >> n; for (int i = 1; i <= n; ++i) { cin >> x; if (x < e_min) e_min = x; if (x > e_max) e_max = x; l.push_back(x); } l.remove_if( [e_min, e_... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(0); long long n, m, k, x, y; cin >> n >> m >> k >> x >> y; long long ti = (n * m) + ((n - 2) * m); if (n == 1 || n == 2) ti = n * m; long long upd = 0, mid = 0; long long a[110][110]; long long num =... |
#include <bits/stdc++.h> using namespace std; int a[1001]; int main() { int n, m, c, q = 0; cin >> n >> m >> c; while (m-- && q <= n) { int x; cin >> x; if (x > c / 2) for (q = n; a[q] >= x; --q) ; else for (q = 1; a[q] && a[q] <= x; ++q) ; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, m, i; cin >> n; if (n < 4) { cout << NO << endl; return 0; } cout << YES << endl; if (n % 2) cout << 5 * 4 = 20 << endl << 20 + 3 = 23 << endl <<... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, i, sum = 0; scanf( %d%d%d%d , &a, &b, &c, &d); string str; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == 1 ) sum += a; if (str[i] == 2 ) sum += b; if (str[i] == 3 ) sum += c; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; bool isSquare(int r) { return int(sqrt((double)r)) * int(sqrt((double)r)) == r; } bool check(int a, int b, int c, int d, int N, int M) { int ans = 0; ans += isSquare(a * a * (M - 1) + b * b); ans += isSqua... |
#include <bits/stdc++.h> using namespace std; template <class T, size_t... Is> struct arr_helper; template <class T, size_t... Is> using arr = typename arr_helper<T, Is...>::type; template <class T> struct arr_helper<T> { using type = T; }; template <class T, size_t I, size_t... Is> struct arr_h... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; vector<long long> left; vector<long long> right; long long ok = 0; for (long long i = 0; i < n; i++) { string s; cin >> s; long long l = 0, r = 0; for (auto it : s) { if (it =... |
#include <bits/stdc++.h> using namespace std; int t, n, l, r, pos; char in[1000], ans[1000][10]; bool back; int main() { scanf( %d , &t); while (t--) { back = false; scanf( %s , in); n = strlen(in); for (int i = 1; i <= 8; i++) for (int j = 0; j <= 3; j++) ans[i][j] = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int pw = 1; for (int i = 2; i <= n + 10; i++) { pw *= 2; if (pw > n) { pw /= 2; break; } } int t =... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; cout << s.size() * 25 + 26 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; if (s[0] == > ) { cout << 0; } else if (s[n - 1] == < ) cout << 0; else if (s[0] == < ) { int count1 = 0, co... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } int n; int m; vector<pair<int, int> > w[5000]; pair<int, int> v[5000]; int p[5000], u[5000], pc[5000], px[5000], res[5000]; int go(int x, int p) { for (int i = 0; i < ((int)(w[x]).size()); ... |
#include <bits/stdc++.h> using namespace std; long long ll, tt, i, j, a[234567], b[211212], c[211456], d[213456]; long long x, m, n, r, s, t, k, l, y, z; vector<long long> p[12], q; pair<long long, long long> pp[345678]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> x; if (x =... |
#include <bits/stdc++.h> using namespace std; long long zero = 0; long long one = 1; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); } long long expo(long long x, long long y) { long l... |
#include <bits/stdc++.h> using namespace std; const int N = 300005; struct Tree { int l, r, num1; long long num2; } T[N * 4]; struct Ask { int l, r, col; Ask(int _l = 0, int _r = 0, int _col = 0) { l = _l; r = _r; col = _col; } inline bool operator<(const Ask &b) cons... |
#include <bits/stdc++.h> int main() { int i, sum = 0, n; for (i = 1; i <= 5; i++) { scanf( %d , &n); sum += n; } if (sum % 5 == 0 && sum != 0) printf( %d n , sum / 5); else printf( -1 n ); return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 200001; long long int sz[N], dist[N], every[N]; vector<int> adj[N]; int n, k; void dfs(int start, int p = -1) { for (auto child : adj[start]) { if (child != p) { dfs(child, start); sz[start] += sz[child]; dist[star... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6 + 3; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int t; cin >> t; while (t--) { long long int n, m; cin >> n; long long int a[n + 1]; long long int i =... |
#include <bits/stdc++.h> int main() { int i, j, n, r = 0, c = 0, ans = 0; char str[107][107]; scanf( %d , &n); for (i = 0; i < n; ++i) { scanf( %s , str[i]); r = 0; for (j = 0; j < n; ++j) { if (str[i][j] == C ) { ++r; } } ans += (r * (r - 1)) /... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int NAX = 2e5 + 5, MOD = 1000000007; struct Node { set<pair<int, int>> vals; Node() {} Node lazylazyMerge(const Node &rhs) {} Node seglazyMerge(const Node &rhs, const int &l, const int &r) {} Node segSegMerge(const Nod... |
#include <bits/stdc++.h> using namespace std; int mn[200010 * 4], lazy_value[4 * 200010]; bool lazy[4 * 200010]; void update_node(int idx, int st, int ed, int val) { lazy[idx] = 1; lazy_value[idx] += val; mn[idx] += val; } void update_lazy(int idx, int st, int ed) { if (st == ed) return; ... |
#include <bits/stdc++.h> using namespace std; int mp[1010000], ans; int main() { int n, m, x; cin >> n; for (int i = 1; i <= n; i++) { scanf( %d , &x); mp[x]++; } for (int i = 0; i <= 1e6 + 21; i++) { int num = i; int numcnt = mp[i]; if (numcnt % 2 == 1) ans++; ... |
#include <bits/stdc++.h> using namespace std; long long n, k; string s; int32_t main() { ios_base::sync_with_stdio(false); cin >> n >> k; long long left = 1; long long right = n; while (right - left > 1) { long long m1 = (right + left) / 2; long long m2 = m1 + 1; cout << 1 ... |
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a > b) { return a; } return b; } long long int gcd(long long int a, long long int b) { if (a == 0) { return b; } return gcd(b % a, a); } long long int min(long long int... |
#include <bits/stdc++.h> using namespace std; int n, q, si = 1, leaf; long long ans[500010]; struct Q { int s, e, ind; }; vector<Q> query[500010]; vector<pair<int, int>> tree[500010]; int rs[500010]; struct seg { long long seg[2000010], lazy[2000010]; void prop(int x) { seg[x] += laz... |
#include <bits/stdc++.h> using namespace std; typedef vector <int> vi; typedef pair <int, int> pii; const int MAXN = 2e5 + 5; int N; int perm[MAXN]; bool bio[MAXN]; deque <pii> ans; void load() { scanf( %d , &N); for (int i = 1; i <= N; i++) { int coin; scanf( %d , &coi... |
#include <bits/stdc++.h> using namespace std; struct node { int u, v, w; } arr[300010]; bool cmp(node a, node b) { return (a.w < b.w); } int n, m; int f[300010], f2[300010]; int main() { scanf( %d , &n); ; scanf( %d , &m); ; for (int i = 0; i < m; i++) { scanf( %d , &arr[i].u... |
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmin(T &x, T y) { x = x < y ? x : y; } template <typename T> void chkmax(T &x, T y) { x = x > y ? x : y; } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); while (!isdigit(c)... |
#include <bits/stdc++.h> using namespace std; int main() { double x, y; while (cin >> x >> y) { double l; l = sqrt(x * x + y * y); if (l == (int)l) { cout << black << endl; continue; } int z = (int)l; if (z != l) z++; if (x * y >= 0) { if (... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) { return b; } if (b == 0) { return a; } return gcd(b % a, a); } int main() { long long ra, la, ta, rb, lb, tb; cin >> la >> ra >> ta; cin >> lb >> rb >> tb; long lo... |
#include <bits/stdc++.h> using namespace std; auto start = std::chrono::high_resolution_clock::now(); long double crrtime() { auto stop = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); return ((long double)duration... |
#include <bits/stdc++.h> using namespace std; int long long freq[100005], a[100005], final[100005]; int long long pow1(int long long a, int long long b) { if (a == 0) return 0; int long long x = 1, y = a; while (b > 0) { if (b % 2 == 1) { x = (x * y); if (x > 1000000007) x %= 100... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int xa, ya, xb, yb, n; cin >> xa >> ya >> xb >> yb >> n; vector<int> X(n), Y(n), R(n); for (int i = 0; i < n; ++i) cin >> X[i] >> Y[i] >> R[i]; if (xa > xb) swap(xa, xb); if (ya > yb) swap... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; struct edge { int from; int to; int w; }; int comp(const edge& f, const edge& l) { if (f.from < l.from) return 1; else if (f.from > l.from) return 0; else { if (f.w > l.w) return 1; } ret... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long fastexp(long long b, long long exp) { if (exp == 0) return 1; long long temp = fastexp(b, exp / 2); temp = (temp * temp) % 998244353; if (exp % 2 == 1) temp *= b; return... |
#include<bits/stdc++.h> /* #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including */ using namespace std; //using namespace __gnu_pbds; //typedefs typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typ... |
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000], c[100000][2]; int n, m; long long k, sum; int main() { cin >> n >> k; sum = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); b[i] = a[i]; long long aa = a[i]; sum += aa; } if (sum <= k) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, turn; cin >> n >> k; turn = n / k; if (turn % 2) cout << YES << endl; else cout << NO << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; int n; cin >> n >> a >> b; int ans = 0; for (int i = 0; i < n - 1; i++) { if (a[i] != b[i]) { if (a[i] == 1 ) { if (a[i + 1] == 0 && a[i + 1] != b[i + 1]) { a[i] = 0 ; a[i ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> t, a, b; vector<pair<int, int>> p; void push(int v) { if (t[v] != -1) { t[v * 2] = t[v * 2 + 1] = t[v]; t[v] = -1; } } void update(int v, int l, int r, int vl, int vr, int color) { if (vl > vr) return; if (l ==... |
#include <bits/stdc++.h> using namespace std; int f[11][11][4][100010]; int n; char s[100010]; char c[100010]; int ch(char s) { if (s == A ) return 0; else if (s == C ) return 1; else if (s == T ) return 2; else if (s == G ) return 3; return -1; } void Add... |
#include <bits/stdc++.h> using namespace std; inline void EnableFileIO(const string& fileName, bool local = 0) { if (fileName.empty()) return; if (local) { freopen((fileName + .in ).c_str(), r , stdin); freopen((fileName + .out ).c_str(), w , stdout); return; } freopen((fileNam... |
#include <bits/stdc++.h> using namespace std; int n, ds[3001], sz[3001], ot[3001], a, b, c, no, ans, sum; vector<pair<int, pair<int, int> > > v; int get(int x) { if (ds[x] == x) return x; else return ds[x] = get(ds[x]); } void merge(int x, int y) { sz[x] += sz[y]; ds[y] = x; ... |
#include <bits/stdc++.h> using namespace std; int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1}, n, m; const int N = 1505; char c[N][N]; pair<int, int> seen[N][N]; int mod(int a, int m) { while (a < 0) a += m; return a % m; } bool dfs2(int x, int y) { if (c[mod(x, n)][mod(y, m)] == # ) retur... |
#include <bits/stdc++.h> using namespace std; int vis[200010]; int addnum, vel[400010], head[400010], ne[400010]; int fath[200010][21]; int fa[200010], dep[200010]; pair<int, int> s[200010]; int tot, n, m; vector<int> o, o1, o2; int id[11]; int d[200010], f[200010][2]; int num; int p[200010]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long a[1000]; cin >> n; cin >> a[0]; long max = a[0], min = a[0]; for (int i = 1; i < n; i++) { cin >> a[i]; if (a[i] > max) { max = a[i]; } else if (a[i] < min) { min = a[i]; } } ... |
#include <bits/stdc++.h> using namespace std; int N; vector<int> graph[100010]; int deg[100010]; int sum[100010]; long long dpa[100010], dpb[100010]; long long power(long long x, long long n) { if (n == 0) return 1; long long y = power(x, n / 2); y = y * y % 1000000007ll; if (n % 2 == 1) y... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T x) { return x * x; } const int maxn = 1000; int n, m, val; char s[maxn][maxn]; int f[maxn][maxn]; int sum[maxn][maxn]; long long res; int main() { for (int i = 0; i < int(maxn); i++) for (int j = 0; j < i... |
#include <bits/stdc++.h> using namespace std; long long expo(long long n) { if (n == 0) return 1; if (n % 2) { long long x = expo(n / 2); return x * x * 2; } else { long long x = expo(n / 2); return x * x; } } int main() { ios_base::sync_with_stdio(false); long lo... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const long long INF = 8e18; const int maxn = 1e5 + 5; int n; int cnt[maxn], val[maxn]; long long S, SUM; vector<pair<int, int> > e[maxn]; inline void dfs(int u, int pre) { if (u != 1 && e[u].size() == 1) { cnt[u] = 1; } ... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) { ... |
#include <bits/stdc++.h> int main() { int n, i; scanf( %d , &n); int array[n]; for (i = 0; i < n; i++) { scanf( %d , &array[i]); } int min = 9999999, max = 0, count; for (i = 0; i < n; i++) { if (array[i] < min) { min = array[i]; } if (array[i] > max) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ... |
#include <bits/stdc++.h> using namespace std; int dir4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int dir8[8][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}, {-1, 1}, {1, -1}, {1, 1}, {-1, -1}}; int dir8h[8][2] = {{2, 1}, {-2, -1}, {-1, 2}, {1, -2}, {1, 2}, {-2, 1}, {2, -1}, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i = 1, j = 1, c1, c2; cin >> n; if (n % 2) cout << 9 << << (n - 9) << endl; else cout << 8 << << (n - 8) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t > 0) { long long int n, s; cin >> n >> s; long long int a[n]; long long int sum = 0; for (long long int i = (0); i < (n); i++) { cin >> a[i]; sum = sum + a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T = 1; while (T--) { int n, u; cin >> n >> u; vector<int> v; for (int i = 0; i < n; i++) { int t; cin >> t; v.push_back(t); ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c; cin >> a >> b; sort(a.begin(), a.end()); if (a.length() < b.length()) { reverse(a.begin(), a.end()); cout << a << endl; } else { for (int i = 0; i < a.length(); i++) { for (int j = a.length() - 1... |
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; long long ans = 0; int step = 1; for (int i = 1; i <= M; ++i) { int T; cin >> T; if (T >= step) { ans += T - step; } else { ans += N - step + T; } step = T; ... |
#include <bits/stdc++.h> using namespace std; using i64 = long long; using f64 = double; using f80 = long double; using pii = pair<int, int>; using pll = pair<i64, i64>; using ptx = pair<f64, f64>; const int N = 3e5 + 5, LG = 20; int f[N], conv[N], tmp[N]; int main() { ios::sync_with_stdio(false... |
#include <bits/stdc++.h> using namespace std; long long suf(long long a) { return (a * (a + 1)) / 2; } const long long OO = 1e6 + 10, MOD = 1e9 + 7; vector<vector<int> > adj, can; int dx[]{1, -1, 0, 0, 1, -1, 1, -1}; int dy[]{0, 0, 1, -1, 1, -1, -1, 1}; int main() { std::ios_base::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 1e5; 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 << 1) + (x << 3) + (ch ^ 48); ... |
#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 = 200000; int n; int a[MAXN]; void run() { scanf( %d , &n); for (int i = (0); i < (n); ++i) scanf( %d , &a[i]); sort(a, a + n); int ndiff = unique(a, a ... |
#include <bits/stdc++.h> using namespace std; struct node { int l, r; } e[200010]; bool operator<(node t1, node t2) { return t1.r < t2.r; } int n, ans; int main() { scanf( %d , &n); int w, x; for (int i = 1; i <= n; i++) { scanf( %d%d , &x, &w); e[i].l = x - w; e[i].r = x +... |
#include <bits/stdc++.h> using namespace std; using cd = complex<double>; const double pi = acos(-1); const double EPS = 1e-5; void iter(vector<cd> &a, bool invert) { int n = a.size(); for (int i = 1, j = 0; i < n; i++) { int bit = n >> 1; for (; j & bit; bit >>= 1) j ^= bit; j ^= bi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 5; int boy[maxn], girl[maxn]; int n, m; int main() { int b, g; while (scanf( %d%d , &n, &m) != EOF) { memset(boy, 0, sizeof(boy)); memset(girl, 0, sizeof(girl)); int in; scanf( %d , &b); for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9; long double sqr(long double a) { return a * a; } long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.ti... |
#include <bits/stdc++.h> int res[1100002]; int mark[1100002]; void set(int i, int L, int R, int l, int r, int x) { int LR, RL; if (L <= R && l <= r && L <= l && r <= R && res[i] <= 0 && mark[i] == 0) { if (L == l && R == r) mark[i] = 1; if (res[i] == 0 && L == l && R == r) res[i] = x; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5; char s[maxn]; int a[maxn]; int n, l, r, i, x; int main() { scanf( %s , s + 1); n = strlen(s + 1); for (i = 1; i <= n; i++) a[i] = s[i] - 0 ; l = 1; r = n; if (a[l] != a[r]) { a[l]--; a[l + 1] += 10; ... |
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, c1 = 0, c2 = 0, i1 = 0, i2 = 0, t, cou = 0; cin >> x >> y; if (y < x) { t = x; x = y; y = t; } while (x != y) { if (c1 <= c2) { if (c1 == 0) c1 = 1; x++; i1++; c1 += i1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int q, w, e, r; cin >> q >> w >> e >> r; string s; cin >> s; unsigned long long int c = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 1 ) { c += q; } if (s[i] == 2 ) { c += w; } i... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; string s; cin >> s; char arr[26]; map<int, int> mmap; for (int i = 0; i < 26; i++) { mmap[i] = i; arr[i] = i; } for (int i = 0; i < m; i++) { char pr, nx; cin >> pr >> nx... |
#include <bits/stdc++.h> using namespace std; int a[222]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; int ans = m; for (int i = 0; i < n - 1; i++) if (a[i] - a[i + 1] > ans) ans = a[i] - a[i + 1]; cout << ans - m << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; char str[2001000], g[2001000]; int a[2001000]; int main() { scanf( %s , str); int m; scanf( %d , &m); memset((a), (0), sizeof(a)); for (int(i) = (0); (i) < (m); ++(i)) { int x; scanf( %d , &x); x--; ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 10; char s[M]; map<char, int> mp; int main() { int n; scanf( %d , &n); scanf( %s , s); for (int i = 0; i < n; i++) { mp[s[i]]++; } int minn1 = M; if (mp[ o ] && mp[ n ] && mp[ e ]) { minn1 = min(minn1, mp... |
#include <bits/stdc++.h> using namespace std; void solve(); int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t = 1; while (t--) { solve(); cout << n ; } cerr << time taken : << (float)clock() / CLOCKS_PER_SEC << secs << endl; return 0; }... |
#include <bits/stdc++.h> using namespace std; int n, a[210000], pos[210000], Log2[210000]; int f[210000][21]; void init() { for (int i = 1; i <= n; i++) f[i][0] = i; for (int j = 1; (1 << j) <= n; j++) for (int i = 1; i + (1 << j) - 1 <= n; i++) if (a[f[i][j - 1]] > a[f[i + (1 << (j - 1))]... |
#include <bits/stdc++.h> using namespace std; int a, b, f, k, ans, now; int main() { scanf( %d%d%d%d , &a, &b, &f, &k); if (b < f) { printf( -1 ); return 0; } now = b - f; for (int i = 1; i <= k; i++) { if (i % 2) { if (b < (a - f) + (a - f) * (i != k)) return printf(... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) using namespace std; set<int> st; set<pair<long long, int>> bus[200011]; map<long long, set<pair<int, int>>> q; int n, k, m; int main() { int i; scanf( %d%d%d , &n, &k, &m); for (i = 1; i <= k; ++i) { int xi; ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 10; const long long mod = 1e9 + 7; long long ans; long long n, k; long long a[maxn]; long long z; long long inv[maxn]; long long fact[maxn]; long long pashm[maxn]; void in(); void solve(); long long pwr(long long, long ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 1005; int main() { long long n; while (~scanf( %I64d , &n)) printf( 25 n ); return 0; } |
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 3e5 + 10, inf = 0x3f3f3f3f; int a[maxn], qtd[2 * maxn]; long long ans; void solve(int l, int r) { if (l == r) return (void)(++ans); int m = (l + r) >> 1; solve(l, m); solve(m + 1, r); int Mn = inf, Mx = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; int a[300005]; int b[300005]; int flag; int main() { int n, m; cin >> n >> m; int i = 0, j = 0; for (i = 0; i < m; i++) { cin >> a[i]; cin >> b[i]; j++; } int hh = a[0], ff = b[0]; int cc, fff; int temp = 0; fo... |
#include <bits/stdc++.h> using namespace std; bool SR(int &x) { return scanf( %d , &x) == 1; } bool SR(long long &x) { return scanf( %lld , &x) == 1; } bool SR(double &x) { return scanf( %lf , &x) == 1; } bool SR(char *s) { return scanf( %s , s) == 1; } bool RI() { return true; } template <typename I, typ... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long n, m; long long result = 0; cin >> n >> m; if (n > m) { swap(n, m); } for (long long i = 1; i <= n; i++) { if (i + m < 5) continue; int r = 5 - (i % 5); result++; result += (m - r) / 5; ... |
#include <bits/stdc++.h> using namespace std; double C[55][55], dp[55][55][55]; int a[55], n, m; double dfs(int i, int j, int k) { if (dp[i][j][k] != -1.0) return dp[i][j][k]; double ret = 0; for (int c = 0; c <= i; c++) { int maxq = max(k, int((c + a[j] - 1) / a[j])); ret += dfs(i - c, ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; int visited[MAX]; int a[MAX], dis[MAX]; int n; void bfs() { queue<int> q; int b; visited[1] = 1; dis[1] = 0; q.push(1); while (!q.empty()) { b = q.front(); q.pop(); if (!visited[b + 1] && b + 1 <=... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long int gcd(long long int A, long long int B) { if (!B) return A; return gcd(B, A % B); } int main() { int n; string s; cin >> n >> s; vector<int> pbal(n + 2), sbal(n + 2); vector<bool> pref(n + 1, 1)... |
#include <bits/stdc++.h> using namespace std; int level[10]; int loyal[10]; int n, A; double calculate(int cur, int pass, int B, double rate) { double sum; if (cur == n) { if (pass > n / 2) { return rate; } else return rate * (double(A) / (double)(A + B)); } sum = 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.