func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, N = 100007; int n; long long ts, tf, t, a[N], ans = (long long)1e18, id; int main() { cin >> ts >> tf >> t; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; while (a[n] > tf - t) n--; a[++n] = tf - t + 1; long lo... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int n, m, q; long long suma[N], b[N], sumb[N]; long long solve(long long x) { int pos = lower_bound(sumb + n, sumb + m + 1, x) - sumb; if (pos > m) return x - sumb[m]; if (pos == n) return sumb[pos] - x; return min(x - sumb... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000005; int n; char s1[maxn], s2[maxn]; int main() { scanf( %d%s%s , &n, s1 + 1, s2 + 1); reverse(s1 + 1, s1 + n); for (int i = 1; i < n; ++i) { if (s1[i] == N ) s1[i] = S ; else if (s1[i] == S ) s1[i] =... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y, a, b; }; point rotate(point p) { point p1 = p; int x = p1.x - p1.a, y = p1.y - p1.b; p1.x = -y + p1.a; p1.y = x + p1.b; return p1; } bool comp(point p1, point p2) { if (p1.x == p2.x) return p1.y < p2.y; re... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; string s; cin >> n >> s; n += 3; vector<int> a(n), la(n), ra(n), lmi(n), lma(n), rmi(n), rma(n); int j = 2; for (int i = 0; i < n - 3; i++) { if (s[i] == ( ) ... |
#include <bits/stdc++.h> using namespace std; ; const long long maxn = 1e5 + 7; const long double pi = 3.14159265358979323846; struct pirog { long long r; long long h; long long i; }; long long V[4 * maxn]; pirog A[maxn]; vector<pirog> C; void update(long long v, long long tl, long long ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; int main() { int flag = 0; long long n, a, b; cin >> n >> a >> b; long long x = a, y = b; if (a > b) { swap(a, b); flag = 1; } if (a * b > 6 * n) { printf( %lld n , a * b); printf( %lld %l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 7; const int inf = 0x3f3f3f3f; int a[maxn]; char s[150]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; scanf( %s , s); int x = 0, y = 0; for (int i = 0; i < n; i++) { if (s[i... |
#include <bits/stdc++.h> void print(int n) { if (n == 4) { printf( 1 * 2 = 2 n ); printf( 3 * 4 = 12 n ); printf( 2 * 12 = 24 n ); } else if (n == 5) { printf( 5 * 4 = 20 n ); printf( 3 + 2 = 5 n ); printf( 5 - 1 = 4 n ); printf( 20 + 4 = 24 n ); } } int main(... |
#include <bits/stdc++.h> using namespace std; const int N = 666; const int inf = 1e9; struct edge { int pr; int to; int cap; } e[111111]; int tot = 1, la[N]; void clr() { tot = 1; memset(la, 0, sizeof(la)); } void adde(int x, int y, int z) { e[++tot].pr = la[x]; la[x] = tot... |
#include <bits/stdc++.h> int main() { int x, h, m, hh, mm; scanf( %d , &x); scanf( %d%d , &h, &m); hh = h, mm = m; for (int i = 0; i <= 24 * 60; i++) { int tmp = x * i; h = hh, m = mm; while (m < tmp) { m += 60; h--; if (h == -1) h = 23; } m -=... |
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> T my_pow(T n, T p) { if (p == 0) return 1; T x = my_pow(n, p / 2); x = (x *... |
#include <bits/stdc++.h> using namespace std; int n, x, i, a[100100], b[100100]; priority_queue<pair<long long, int>> q; long long m, mx, mn, cur, cnt, le, ri, h; int fnd(int i, long long v) { int lft = 0, rgh = a[i]; while (lft < rgh) { int mid = (lft + rgh) / 2 + 1; cur = a[i] - 3LL * mi... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long INFLL = 1e18 + 1; const int MAX = 200001; const long long MOD = 1000000007; long long inq(long long k, long long q) { if (q == 0) return 1; long long l = inq(k, q / 2); if (q % 2 == 0) return l * l % MOD; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n, m, arr[303][303]; scanf( %d %d , &n, &m); bool can = true; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf( %d , &arr[i][j]); if (... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g, sg; vector<bool> vis; void dfs(int u) { vis[u] = 1; for (int v : g[u]) { if (!vis[v]) { sg[u].push_back(v); sg[v].push_back(u); dfs(v); } } } int main() { ios_base::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; vector<set<int> > graph; vector<int> eliminar; set<int>::iterator ite; void elim(int N) { eliminar.clear(); for (int i = 1; i <= N; i++) if (graph[i].size() == 1) eliminar.push_back(i); } int main() { int n, m, n1, n2, temp, contador; cin... |
#include <bits/stdc++.h> using namespace std; int n, a, b, c, f = 0; int main() { cin >> n >> a >> b >> c; for (int i = 0; i <= c; i++) { for (int j = 0; j <= b; j++) { if (n - j - 2 * i >= 0 && n - j - 2 * i <= a / 2) { f++; } } } cout << f; } |
#include <bits/stdc++.h> using namespace std; int main() { int i, n, flag = 0; cin >> n; int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) flag = 1; } if (flag) cout << -1 << endl; else cout << 1 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int a[MAXN]; int main() { int n, tot = 0, flag = -1, num = 0; scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); sort(a, a + n); for (int i = 0; i < n - 1; ++i) { if (i != 0 && a[i] == a[i + 1] && a[i... |
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p) { out << ( << p.first << , << p.second << ) ; return out; } template <typename T> ostream& operator<<(ostream& out, vector<T> const& v) { int l = v.size();... |
#include <bits/stdc++.h> using namespace std; using ll = long long; void dump(const vector<int>& a) { for (int i = 0; i < a.size(); i++) { cerr << a[i] << ; } cerr << endl; } vector<pair<int, int>> factorise(long long m) { vector<pair<int, int>> res; for (long long i = 2; i * i <=... |
#include <bits/stdc++.h> using namespace std; long long n, m, h[100005], p[100005], f[100005]; bool check(long long x) { int now = 1; for (int i = 1; i <= n; i++) { long long rest = x - abs(h[i] - p[now]); if (rest < 0) continue; long long nowp = p[now]; while ((p[now] <= h[i] || p... |
#include <bits/stdc++.h> using namespace std; char s[3][3], t[3][3]; vector<char> vs, vt; int main() { scanf( %s%s%s%s , s[0], s[1], t[0], t[1]); if (s[0][0] != X ) vs.push_back(s[0][0]); if (s[0][1] != X ) vs.push_back(s[0][1]); if (s[1][1] != X ) vs.push_back(s[1][1]); if (s[1][0] != X... |
#include <bits/stdc++.h> using namespace std; const int INF32 = 0x3f3f3f3f; const long long INF64 = 0x3f3f3f3f3f3f3f3f; const int mod2 = 1e9 + 9; const int mod = 1e9 + 7; const int N = 2e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k, m; long long sum = 0; ... |
#include <bits/stdc++.h> int n, m, r; int mat[61][61], opt[61][61][61]; int main() { scanf( %d%d%d , &n, &m, &r); for (int i = (0); i < (n); i++) for (int j = (0); j < (n); j++) for (int k = (0); k < (n); k++) opt[i][j][k] = 1000000000; for (int k = (0); k < (m); k++) { for (int i ... |
#include <bits/stdc++.h> using namespace std; bool DBG = 0; const int dbg = 0; using ii = pair<int, int>; using cd = int64_t; cd gcd(cd a, cd b) { return b ? gcd(b, a % b) : a; } using _LD = long double; struct ld { cd a, b; ld(cd a, cd b = 1) : a(a), b(b) { reduce(); } ld operator-() const ... |
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, u, i1, i2, s; long long f[60][60][2], C[60][60]; inline void M(int j, int k, long long A) { A %= 1000000007; f[i][j][k] = (f[i][j][k] + A) % 1000000007; } inline long long pow(long long x, long long y) { long long an = 1; for (... |
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1123456; const long long MOD = 1123456769; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); srand(time(0)); vector<int> v; int n, m... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000100; int N; long long arr[MAXN]; long long csum; long long nv[MAXN]; long long dp[MAXN][2]; long long gogo(long long x) { nv[0] = 0; for (int i = 0; i < N; i++) { nv[i + 1] = (nv[i] + arr[i]) % x; } for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200033; int n; bool col[MAXN]; struct edge { int t, nx; } E[MAXN << 1], E_[MAXN << 1]; int first[MAXN], edges_nums = 0; inline void add(int f, int t) { E[++edges_nums].t = t; E[edges_nums].nx = first[f]; first[f] = edges_nums... |
#include <bits/stdc++.h> using namespace std; char str[100030]; int main() { while (gets(str) != NULL) { int len = strlen(str), m, n1 = 0, n2 = 0; for (int i = 0; i < len; i++) if (str[i] >= a && str[i] <= z ) n2++; else n1++; int m1 = 0, m2 = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100 + 10; pair<int, int> a[MAX_N]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i; sort(a, a + n); int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void chkmin(T &x, T y) { if (y < x) x = y; } template <typename T> inline void chkmax(T &x, T y) { if (y > x) x = y; } template <typename T> inline T add(T x, T y) { return (x + y) % 1000000007; } template <type... |
#include <bits/stdc++.h> using namespace std; bool dp[105][55][210][2]; char com[105], n; int chg, off = 105; int dir(int d) { return d ? 1 : -1; } int main() { cin >> com + 1; n = strlen(com + 1); cin >> chg; memset(dp, false, sizeof(dp)); dp[0][0][off][1] = true; for (int i = 0; i ... |
#include <bits/stdc++.h> #define ll long long int #define vi vector<ll> #define vvi vector<vector<ll>> #define pii pair<ll, ll> #define pb push_back #define rep0(i, n) for(ll i = 0;i<n;i++) #define rep1(i, n) for(ll i = 1;i<n;i++) #define all(v) v.begin(),v.end() #define fast ... |
#include <bits/stdc++.h> using namespace std; int n; int a[100100]; int s0[100100]; int s1[100100]; vector<pair<int, int> > res; int TK1(int x, int tt) { int l = x + 1; int r = n; int res = -1; while (l <= r) { int m = (l + r) / 2; if (tt == s1[m] - s1[x]) { res = m; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, ans, w[300000], d[300000], a, b; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; i++) { w[i] = i; d[i] = 1; } ans = 1; for (int i = 1; i <= m; i++) { cin >> a >> b; while... |
#include <bits/stdc++.h> using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); void solve() { string s; cin >> s; s = . + s + ? ; bool f = true; for (int j = 1; j < s.size() - 1; j++) { if (s[j] == s[j - 1] && s[j] != ? ) { ... |
#include <bits/stdc++.h> using namespace std; int luat_tot(vector<int>& attack, vector<int>& defense, multiset<int> carti); int luare(vector<int>& attack, multiset<int> carti); int main() { int n, m, c; char s[10]; vector<int> attack, defense; multiset<int> carti; cin >> n >> m; for (int... |
#include <bits/stdc++.h> using namespace std; long long tree[1000005 * 4], lazy[1000005 * 4]; vector<int> vc[1000005], vc2[1000005]; int ara[2][1000005]; void update(int node, int st, int en, int l, int r) { if (l > r) return; if (lazy[node]) { tree[node] += lazy[node] * (en - st + 1); if ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T updmax(T& a, T b) { return a = max(a, b); } template <class T> inline T updmin(T& a, T b) { return a = min(a, b); } class Solution { public: void solve() { long long n; string s; cin >> n >> s; ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 100005; string s; long long int gcd(long long int a, long long int b) { if (a % b == 0) return b; return gcd(b, a % b); } long long int lcm(long long int a, long long int b) { return a * b / gcd(max(a, b), min(a, b)); } int main... |
#include <bits/stdc++.h> using namespace std; const int jly = 1000000007; const unsigned long long bas = 31; int f[2][1000005], *p[2]; unsigned long long q[1000005]; char t[1000005]; struct bxt { int l; char *s; unsigned long long *h; inline void init(char *u) { for (l = 0; u[l]; ++l... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) #pragma GCC optimize( O2 ) using namespace std; void timestamp(char const* const tag, bool absolute = false); int x2; void read() { cin >> x2; } vector<int> get_divs(int x) { vector<int> ans; for (int d = 2; d *... |
#include <bits/stdc++.h> const int maxn = 1e9; const double EI = 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427; using namespace std; int c[1000100]; char d[1000100]; int main(void) { int n, i, j, k, l, r, mm, mi; while (~scanf( %d , &n)) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const int MOD = 1e9 + 7; int n, m, c = 0; long long col = 0, sum = 0; int cost[MAXN], comp[MAXN]; bool us[MAXN]; pair<int, int> ans[MAXN]; vector<int> d[MAXN]; stack<int> path; void dfs(int x, int pr) { us[x] = true; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 5001; vector<map<int, pair<int, int>>> tree; vector<int> have; vector<long long> dp_down, cnt_down; long long ans = 2e18; void DFSDown(int node) { cnt_down[node] = have[node]; for (auto p : tree[node]) { int cnt, vec; tie(cn... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; solve(); return 0; } void solve() { long long n; cin >> n; long long mat[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) {... |
#include <bits/stdc++.h> const int maxn = 1e5 + 100; const double eps = 1e-7; const int INF = 1e9; using namespace std; bool f[maxn]; int a[maxn]; struct Node { int i, num; bool operator<(const Node &rhs) const { return i < rhs.i || (i == rhs.i && num < rhs.num); } }; int main() { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 2; bool isPrime[maxn]; vector<int> primeNumbers; int smallestPrimeDiv[maxn]; const int maxn2 = 1e5 + 2; int a[maxn2]; int b[maxn2]; bool primeUsed[maxn]; void sieve(int n) { for (int i = 1; i <= n; ++i) { isPrime[i] = 1; ... |
#include <bits/stdc++.h> using namespace std; long long a; int b = 1; bool check(long long x) { if (x < 0) x = -x; while (x) { if (x % 10 == 8) return 1; x /= 10; } return 0; } int main() { scanf( %lld , &a); while (!check(a + b)) ++b; printf( %d , b); } |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000005; const int inf = 0x3f3f3f3f; long long a[maxn]; int q[maxn]; int main() { int n; cin >> n; long long p = 0; long long pans = 0; for (int i = (1); i < (n + 1); i++) { cin >> a[i]; pans += abs(a[i] - i); ... |
#include <bits/stdc++.h> int main(void) { int n; char s[102]; scanf( %d n , &n); gets(s); if (s[0] == S && s[n - 1] == F ) { printf( YES ); } else { printf( NO ); } } |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 7; const long long mod = 1e9 + 7; const long long INF = 1e9 + 7; const long long mlog = 22; const long long SQ = 400; long long T[maxn * 4]; long long a[maxn], b[maxn]; long long x[maxn], y[maxn], k[maxn]; void add(long long ... |
#include <bits/stdc++.h> using namespace std; int N; vector<pair<int, int> > VX[5]; vector<pair<int, int> > VY[5]; int X[101010]; int Y[101010]; int C[101010]; void ref() { for (int i = 1; i <= N; i++) swap(X[i], Y[i]); } bool f(int m, int a, int b, int c) { int x1 = VX[a][m - 1].first + 1; ... |
#include <bits/stdc++.h> using namespace std; int n, m, w, h; set<int> Set[2]; set<int>::iterator iter; priority_queue<int> qu[2]; int vis[2][200010], point[2][200010]; char s[10]; int main() { int i, j, k, l, r, p, a, b; long long ans; scanf( %d%d%d , &w, &h, &k); Set[0].insert(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } const int mod = 1e9 + 7... |
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void outarr(Tp _begin, Tp _end, const char* _delim = ) { for (Tp current = _begin; current != _end; ++current) { std::cout << *current << _delim; } std::cout << n ; } using ll = long long; using pii = std::pai... |
#include <bits/stdc++.h> using namespace std; long long fastxp(long long b, long long e) { if (e == 1) return b; else { long long ans = fastxp(b, e / 2); ans = (ans * ans) % 998244353; if (e % 2 == 1) { ans = (ans * b) % 998244353; } return ans; } } int ma... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const int N = 3e5 + 7; const int LG = 19; int go[N][LG]; int a[N]; int last[LG]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; for ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n, k, l = 9999, j = 9999, s, i; cin >> n >> m >> k; int a[n + 3]; for (i = 1; i <= n; i++) cin >> a[i]; for (i = m + 1; i <= n; i++) { if (a[i] != 0 && a[i] <= k) { l = (i - m); break; } } for (... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 9; const long long maxn = 3e2 + 9; long long a[maxn][maxn]; pair<long long, long long> q[N]; long long front, rear; long long dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool vis[maxn][maxn]; void solve() { memset(vis, 0, ... |
#include <bits/stdc++.h> using namespace std; long long mod; long long power(long long a, long long p) { long long res = 1; while (p) { if (p & 1) res = res * a % mod; a = a * a % mod; p >>= 1; } return res; } long long inv(long long a) { return power(a, mod - 2); } class m... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> m; map<long long, long long>::iterator it; long long ans[200500]; int main() { long long n, i, x, y, pr = -1, cur = 0; cin >> n; for (i = 0; i < n; i++) { cin >> x >> y; m[x]++; m[y + 1]--; } for (it ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int dp[maxn][maxn]; int n, ans; int tim[maxn]; int dfs(int i, int j) { if (dp[i][j]) return dp[i][j]; int ti = tim[i], tj = tim[j], tk = tim[j + 1]; if (j == n + 1) return dp[i][j] = ti; if (j == n) return dp[i][j] = max(ti... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long A[N]; int n; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> A[i]; int ans = 1; int len = 1; for (int i = 1; i < n; i++) { if (A[i] <= 2 * A[i - 1]) len++, ans = max(len, ans); els... |
#include <bits/stdc++.h> using namespace std; int main() { char a[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> a[i][j]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (a[i][j] != a[2 - i][2 - j]) { cout << NO ; return 0; ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 205; long long dp[maxn][maxn][maxn]; long long n; string s, t; long long recur(long long pos, long long changes, long long sum) { if (pos == n) return 0; if (dp[pos][changes][sum] != -1) return dp[pos][changes][sum]; long long ... |
#include <bits/stdc++.h> using namespace std; struct node { double x, y, t, val; } pnt[2050]; struct Edge { int u, v, next; } edge[2050 * 2050]; int head[2050], tot = 0; void add(int u, int v) { edge[tot].u = u; edge[tot].v = v; edge[tot].next = head[u]; head[u] = tot++; } doub... |
#include <bits/stdc++.h> using namespace std; bool sorting(const pair<long long int, long long int>& a, const pair<long long int, long long int>& b) { if (a.first != b.first) { return (a.first > b.first); } else return (!(a.second >= b.second)); } int main() { ios_base::sy... |
#include <bits/stdc++.h> using namespace std; struct node { int x1, y1; } ar[500101]; bool cmp(node &b1, node &b2) { if (b1.x1 == b2.x1) return b1.y1 < b2.y1; return b1.x1 < b2.x1; } int main() { long long q, i, j, k, v, c = 0, p1, p2, t, n, x, y, p; cin >> n; for (i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; int k, res; string s; int cs(int x) { int dem(0); while (x != 0) { x /= 10; dem++; } return dem; } int main() { int t; cin >> t; while (t--) { cin >> k; res = 0; int ii; for (int i = 1; i <= 1000000... |
#include <bits/stdc++.h> using namespace std; const int nmax = 100005; int n, cnt, one, two1, two2, p[nmax]; vector<int> v[nmax]; bitset<nmax> viz; int main() { cin.sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) cin >> p[i]; for (int i = 1; i <= n; i++) if (!viz[i]) { ... |
#include <bits/stdc++.h> using namespace std; const int p = 1000000007; long long n; int k, ans; int inv[123]; int F[55][55][10110]; int exp(int a, int b, int c) { int d = 1; while (b) { if (b & 1) d = 1LL * d * a % c; b >>= 1; a = 1LL * a * a % c; } return d; } int f... |
#include <bits/stdc++.h> using namespace std; int n, m; string a[33]; int z[33][33]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) for ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j = 0, r, ctr = 0, ans; cin >> n; string s, s7; cin >> s; string s1 = RGB ; string s2 = GBR ; string s3 = BGR ; string s4 = GRB ; string s5 = RBG ; string s6 = BRG ; j = 0; for (i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; vector<int> temp; for (int i = 1; i < n; i++) { int val = arr[i] - arr[i - 1] - 1; temp.push_back(val); } sort(temp.b... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s, ans, temp; cin >> s; int flag = 0; for (int i = 0; i < k; i++) { for (int j = i; j < n; j += k) { if (s[i] != s[j]) { flag = 1; break; } } if (f... |
#include <bits/stdc++.h> using namespace std; int a[100100]; int num[100100]; int main() { set<int> s; int n; cin >> n; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = n; i >= 1; i--) { s.insert(a[i]); num[i] = s.size(); } s.clear(); long long sum = 0; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> a[i][j]; } int b[m][n]; bool flag = false; int index = -1; for (int i = 0; i < m; i++) { for (int j = 0;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long u, long long v) { if (u < v) swap(u, v); while (v != 0) { int r = u % v; u = v; v = r; } return u; } pair<int, int> row[200000], col[200000]; int main(void) { int n, m, k; cin >> n >> m >> k; fo... |
#include <bits/stdc++.h> int dizi[100015]; int main() { int i, m, n, fark, k, j; scanf( %d %d %d %d , &m, &n, &k, &j); for (i = 1;; i++) { j = (j * m + n) % k; if (dizi[j]) { printf( %d , i - dizi[j]); break; } dizi[j] = i; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, m, i, j, k, a1, a2, a3, a4, res, ans, sum; bool k1, k2, k3; long long l, r, M; string s, q, s1, s2; long long a[5000000]; int main() { cin >> n >> a4; for (i = 1; i <= n; i++) cin >> a1 >> a2, a[i] = a1 * a2; for (i = 2; i <= n; i++) a... |
#include <bits/stdc++.h> using namespace std; int sum(int a) { int sum = a; while (a) { sum += a % 10; a /= 10; } return sum; } int main() { vector<int> v; int a; cin >> a; int b = a; while (a) { int check = sum(a); if (check == b) v.push_back(... |
#include <bits/stdc++.h> using namespace std; int N, Cnt = 0; double A[4005], C[4005], Ans = 0.0, Anx; double Abs(double x) { return x < 0 ? -x : x; } int main() { scanf( %d , &N); for (int i = 1; i <= 2 * N; i++) scanf( %lf , &A[i]), C[i] = A[i] - (int)A[i]; for (int i = 1; i <= 2 * N; i++) { ... |
#include <bits/stdc++.h> int main() { int k, a, b; scanf( %d , &k); for (int i = k / 2000 + (k % 2000 > 0);; ++i) { b = i * 2000 - k; a = i - b; if (b <= 1e6 && a < 0 && a >= -1e6) break; } puts( 2000 ); for (int i = 1; i <= 1998; ++i) printf( 0 ); printf( %d %d n , a, b... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s, s1 = , s2 = ; cin >> n >> s; reverse(s.begin(), s.end()); for (int i = 0; i < s.size(); ++i) { if (i % 2 == 0) s1 += s[i]; else s2 += s[i]; } reverse(s1.begin(), s1.end()); cou... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:10000000000 ) #pragma GCC optimize( O3 ) using namespace std; const int MOD = 1000000007; const int INF = 1000000007LL; const long long INF2 = 1LL << 62LL; const long double EPS = 1e-9; const int SIZE = 200010; mt19937 rng(time(0)); uniform_in... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( O3 ) #pragma GCC optimize( O2 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) template <typen... |
#include <bits/stdc++.h> using namespace std; vector<int> arr; int n, k; long long sum[5500]; double mx = -1e9; int main() { cin >> n >> k; for (int x, i = 1; i <= n; i++) { cin >> x; arr.push_back(x); sum[i] = sum[i - 1] + x; } for (int i = 1; i <= n; i++) { for (int... |
#include <bits/stdc++.h> using namespace std; int main() { int t, i, j, f, n; cin >> t; while (t--) { cin >> n; string s; cin >> s; f = 0; for (i = 0; i < n; i++) if (s[i] == 0 ) { f = 1; if (i >= n / 2) cout << 1 << << i + 1 << ... |
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) using namespace std; void err(istream_iterator<string> it) { cerr << endl; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << t ; err(++it, args...); } template <ty... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-9; int ROUND(double x) { return (int)(x + 0.5); } bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; } bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); } double SQSUM(double ... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5, mod = 1e8, inf = 1e9 + 5; long double pi = acos(-1); long long n, m, k, dp[N][15], a[N]; int main() { cin >> n >> m >> k; for (int i = 1; i <= n; i++) cin >> a[i]; long long maxans = 0; for (int i = 0; i <= m; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long a[maxn], x[maxn], y[maxn], c[7], d[7], ans; int n, m; bool cmp(long long x, long long y) { return x > y; } void sol(int pos, int num, int flag) { memset(d, 0, sizeof(d)); if (flag) { for (int i = 1; i <= pos; i++... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &x, T y) { if (y > x) x = y; } template <class T> inline void umin(T &x, T y) { if (y < x) x = y; } const int N = 2e5 + 5, B = 0x7fffffff; struct edge { int u, v, l, r; } a[N]; vector<pair<int, pair<int... |
#include <bits/stdc++.h> using namespace std; 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 INF = 1e17; long long int NINF = (INF * -1); priority_queue<pair<long long int, long long int>, vector<pair<long long int, ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename T1> T amax(T& a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T& a, T1 b) { if (b < a) a = b; return a; } const long long N = 200005, INF = 2000000000000000000; void solve() ... |
#include <bits/stdc++.h> #pragma optimization_level 3 #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int inf = INT32_MAX; struct Node { Node *l = 0, *r = 0; vector<int> m1, m2; N... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.