func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, c1 = 0, c2 = 0; cin >> n; char x[n]; for (int i = 0; i < n; i++) { cin >> x[i]; if (x[i] == A ) c1++; else if (x[i] == D ) c2++; } if (c1 > c2) cout << Anton ; else if (c1 < c2) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; } inline int sub(int x, int y) { x -= y; return x < 0 ? x + mod : x; } inline int mul(int x, int y) { return 1ll * x * y % mod; } int quick_pow(i... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int flag = 0; int n; int now; cin >> n >> now; int l = now, r = now; int past = 0; for (int i = 0; i < n; i++) { int len, lb, rb; cin >> len >> lb >> rb; ... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1}; const int maxn = 1000; const int mod = 998244353; int res, sum, r, n; string s; int main() { ios::sync_with_stdio(false); cin >> s; for (char c : s) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, s, r, m, ans; string x; cin >> n >> m; long long a[n + 1][m + 1]; for (i = 1; i <= n; i++) { if (i % 2 == 1) { for (j = 0; j < m; j++) a[i][j] = 0; } else { for (j = 0; j < m; j++) a[i][j] =... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { int k; cin >> k; string s; cin >> s; int ps = 0; int maxps = 0; for (int i = k - 1; i >= 0; --i) { if (s[i]... |
#include <bits/stdc++.h> int main(void) { int matrix[12][12]; memset(matrix, 0, sizeof(matrix)); int i; char s[3]; int col_r, row_r, col_k, row_k; scanf( %s , s); col_r = s[0] - a + 2; row_r = s[1] - 1 + 2; scanf( %s , s); col_k = s[0] - a + 2; row_k = s[1] - 1 + 2;... |
#include <bits/stdc++.h> const int mod = 1e9 + 7; const double eps = 1e-6; const double pi = acos(-1); const int inf = 0x7fffffff; using namespace std; int a[105]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); if (a[1] == 3) return 0 * printf( NO n )... |
#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 = 350000; int n, k; int result[maxn]; int cost[maxn]; int main() { ios_base::sync_with_stdio(false); ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long MOD = 1e9 + 6; const long long inf = 2e18; const int maxn = 200005; const int maxa = 300005; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long powmod(long long a, long long b) {... |
#include <bits/stdc++.h> using namespace std; const int MOD = 999999929, MAXN = 300005, P2 = (1 << 19), MTS = (1 << 20) + 5; int pot2[MAXN]; int TREE[MTS][2]; int n; long long suma(int p, int k, int num) { p += P2; k += P2; long long res = 0LL; while (p < k) { if ((p & 1)) { re... |
#include <bits/stdc++.h> using namespace std; const int inf = ~0u >> 1, mod = (int)(1e9) + 7; int n, m; long long pow2[555 * 555], f[555][555]; int main() { scanf( %d%d , &n, &m); pow2[0] = 1ll; for (int i = 0; i < (int)500 * 500; ++i) pow2[i + 1] = (pow2[i] * 2ll) % mod; f[0][0] = 1ll; fo... |
#include <bits/stdc++.h> using namespace std; long long int MOD = 998244353; long long int exp(long long int n, long long int e) { if (e == 0) return 1; long long int temp = exp((n * n) % MOD, e / 2); return e % 2 == 0 ? temp : (temp * n) % MOD; } long long int inverse(long long int n) { return ex... |
#include <bits/stdc++.h> using namespace std; int n, k, x, y, p; int v[109][109]; int main() { cin >> n >> k; p = n; while (p) { v[x++][y++] = k; p--; } for (int i = 0; i < n; i++) { for (int h = 0; h < n; h++) cout << v[i][h] << ; cout << n ; } return 0;... |
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) - 1; const long double EPS = 1e-9; const long double PI = fabs(atan2(0.0, -1.0)); const int MAXV = 80010; int n; vector<int> g[MAXV]; void load() { scanf( %d , &n); for (int i = 0, u, v; i < n - 1; i++) { scanf( %d%d ,... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 1e18; const long double eps = 1e-10; struct Pnt { long long x, y; Pnt(long long x, long long y) : x(x), y(y) {} }; Pnt operator+(Pnt a, Pnt b) { return {a.x + b.x, a.y + b.y}; } bool operator==(Pnt... |
#include <bits/stdc++.h> using namespace std; template <typename T> void debug(T v, string delimiter = n ) { for (__typeof(v.begin()) it = v.begin(), it_end = v.end(); it != it_end; it++) cout << *it << delimiter; cout << flush; } int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; string ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300000; int sub[2 * MAXN + 5][2]; int par[2 * MAXN + 5]; int getRoot(int a) { while (par[a] > 0) { a = par[a]; } return a; } long long int ans = 0; void dsu(int a, int b) { int x0 = sub[a][0] + sub[b][0]; int x1 = s... |
#include <bits/stdc++.h> using namespace std; bool flag = 0; void sss(int &n, int &k) { if (flag == 0) n = n + k; else if (flag == 1) n = n - k; } void print(int &now, int k) { k += 48; if (k > now) { while (k != now) { printf( + ); now++; } } else i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; double dp[2][maxn][maxn]; double s[maxn][maxn], s2[maxn][maxn]; inline double S(int x1, int y1, int x2, int y2) { return s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1]; } inline double S2(int x1, int y1, int x2, in... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long mod = 1000000007; long long sols = 0, ti = 0; for (int i = s.size() - 1; i >= 0; i--) { if (s[i] == b ) ti++; else { sols += ti; ti *= 2; sols %= mod; ti ... |
#include <bits/stdc++.h> using namespace std; int n, t; string str1, str2; int main() { scanf( %d %d , &n, &t); cin >> str1 >> str2; int l1 = n - t, l2 = n - t; string ans; ans.resize(n); for (int i = 0; i < n; i++) { if (l1 == 0 && l2 == 0) break; if (str1[i] == str2[i]) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; struct M { int v[2][2]; } A, V, c[1 << 20]; struct Vec { int v[2]; } a[1 << 20], Vec0; bool E(const M& a) { return a.v[0][0] == 1 && a.v[1][1] == 1 && a.v[0][1] == 0 && a.v[1][0] == 0; } M operator*(const M& a, const... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(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 if (a.first == b.first) return (a.second > b.second); else r... |
#include <bits/stdc++.h> const unsigned long long M1 = 1e8 + 7; const unsigned long long M2 = 1e9 + 7; const unsigned long long M3 = 998244353; const int N = 2e5 + 5; int n, m, k, U[N], V[N], h[10], ans; unsigned long long k1[N], k2[N], k3[N], f1[10][10], f2[10][10], f3[10][10], g[10][10]; unsigned ... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; int arr[N][N], n; vector<int> adj[N], revAdj[N]; bool visited[N]; vector<int> vec; void dfs(int v) { visited[v] = 1; for (auto i : revAdj[v]) if (!visited[i]) dfs(i); vec.push_back(v); } void dfs2(int v) { visited[... |
#include <bits/stdc++.h> using namespace std; int a[2 * 100000 + 10]; int n, m, k; bool find(int pos) { int m1 = 0; while (m1 < m && pos <= n) { int k1 = k; while (pos <= n && a[pos] <= k1) { k1 -= a[pos++]; } m1++; } return pos == n + 1 ? 1 : 0; } int main() ... |
#include <bits/stdc++.h> constexpr int Mod = 1e9 + 7; inline int fpm(int a, int b) { int res = 1; while (b) { if (b & 1) res = 1LL * res * a % Mod; a = 1LL * a * a % Mod; b >>= 1; } return res; } int n, m, k, r, c, sx, sy, tx, ty; int tot; int main() { scanf( %d%d%d , &... |
#include <bits/stdc++.h> using namespace std; const int buf_size = 1e5 + 5; char buf[buf_size], *S, *T; inline char gc() { if (S == T) T = (S = buf) + fread(buf, 1, buf_size, stdin); return S != T ? *(S++) : EOF; } inline int in() { int x = 0, f = 1; char c = gc(); while (c < 0 || c > ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; char s[maxn], t[maxn]; int s_big[30], s_small[30], t_big[30], t_small[30]; int main() { while (scanf( %s%s , s + 1, t + 1) != EOF) { memset(s_big, 0, sizeof(s_big)); memset(s_small, 0, sizeof(s_small)); memset(t_bi... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> P; bool used[111]; int pos; bool ok(int T) { if (T == pos) return true; used[T] = true; for (int i = 0; i < P.size(); i++) { if (used[i] == false) { if (P[T].first > P[i].first && P[T].first < P[i].second || ... |
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int binpow(int a, int p) { if (!p) return 1; int g = binpow(a, p >> 1); if (p % 2 == 0) return (g *... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const double EPS = 1e-8; const double PI = acos(-1); const int MAX_N = 400000; struct SegSum { int bit[MAX_N + 1]; int n; void init(int _n) { n = _n; memset(bit, 0, sizeof(bit)); } int sum(int i) { i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int t, n; long long x[maxn + 10], y[maxn + 10], z[maxn + 10]; long long l[4], r[4], tl[4], tr[4]; long long a[4]; void update(int p, long long a, long long b) { l[p] = max(l[p], a - b); r[p] = min(r[p], a + b); } bool calc() {... |
#include <bits/stdc++.h> using namespace std; int main() { long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; n = n * k; if (n % 2 == 1) cout << n / 2 + 1; else cout << n / 2; cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ll; typedef vector<long long> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i+... |
#include <bits/stdc++.h> using namespace std; int a, b, c; int sisa(int x, int n) { if (x >= 0) return x % n; else if (abs(x) % n == 0) return 0; else return ((abs(x) / n) + 1) * n + x; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; int k; cin >> k; if (k == 0) { if (n % 6 == 0 || n % 6 == 5) cout << 0; else if (n % 6 == 1 || n % 6 == 2) cout << 1; else cout << 2; } else if (k == 1) { if (n %... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 4, INF = 1e9; int sub[N], par[N], nn, level[N]; set<int> adj[N]; vector<int> ar[N]; void dfs(int n, int p) { for (auto i : ar[n]) if (i != p) level[i] = level[n] + 1, dfs(i, n); } void dfs1(int n, int p) { nn++; sub[n] =... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1000 + 10; int n, m, k, t; vector<pair<int, int> > w; int main() { cin >> n >> m >> k >> t; for (int i = 0; i < k; i++) { int f, s; cin >> f >> s; w.push_back(make_pair(f, s)); } sort(w.begin(), w.end()); for ... |
#include <bits/stdc++.h> using namespace std; long long n, m; int gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); long long a, b = 0, c = 0, t, lj = 0, k = 0, r = 0, l = 0, sum = 0, rr, ... |
#include <bits/stdc++.h> using namespace std; long long a[100010]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lld , &a[i]); int m; scanf( %d , &m); long long l = 0; while (m--) { long long w, h; scanf( %lld%lld , &w, &h); l = max(l, a[w -... |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int N = 3 + 1e5; struct node { int x, h, id; bool operator<(const node& b) const { return x < b.x; } } a[N]; struct { int l, r, v; bool flag; } tr[1000000 * 4]; int n; int b[N * 10], t; int ans[N]; void... |
#include <bits/stdc++.h> using namespace std; int n, a[1005]; void Solve() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); for (int i = 1;; ++i) { for (int j = 2; j <= n; ++j) { if (a[j] < a[j - 1]) goto fail; } printf( %d n , i - 1); break; fail... |
#include <bits/stdc++.h> using namespace std; void print(pair<int, int> v) { if (v.first < 10) { cout << 0 << v.first << : ; } else { cout << v.first << : ; } if (v.second < 10) { cout << 0 << v.second; } else { cout << v.second; } } int main() { int n; ... |
#include <bits/stdc++.h> using namespace std; int rdn() { int ret = 0; bool fx = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) fx = 0; ch = getchar(); } while (ch >= 0 && ch <= 9 ) ret = ret * 10 + ch - 0 , ch = getchar(); return fx ? ret : -ret; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, z; cin >> x >> y >> z; long long ans1 = x / z + y / z, ans2 = 0; x %= z; y %= z; if (x + y >= z) { ans1++; ans2 = min(z - x, z - y); } cout << ans1 << << ans2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { long long pl, pr, vl, vr, k; double ans = 0; cin >> pl >> pr >> vl >> vr >> k; for (int h = 1; h <= 9; h++) { for (int i = 0; i < (1 << h); i++) { int x = 0, y = 1; for (int j = 0; j < h; j++) { ... |
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); long long int pow1(long long int n, long long int k) { long long int ret = 1; while (k) { if (k % 2 == 1) ret = (ret * n) % 1000000007; n = (n * n) % 1000000007; k /= 2; } return ret; } string s, s... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7, llinf = 1e18 + 123; void xru() { setlocale(LC_ALL, rus ); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } void dolitb(long long p, long long x, set<long long>& s, vector<long long>& a) { if (s.... |
#include <bits/stdc++.h> using namespace std; int n, k; string s; int sol(string a) { int co = 0; for (int i = 0; i < k; i++) if (s[i] != a[i % 3]) co++; int ans = co; for (int i = 1; i <= n - k; i++) { if (s[i - 1] != a[(i - 1) % 3]) co--; if (s[i + k - 1] != a[(i + k - 1) % 3... |
#include <bits/stdc++.h> using namespace std; const int mx = 8e3; void run_case(void) { int n; cin >> n; vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i]; int d = x[1] - x[0]; for (int i = 1; i < n - 1; i++) { if (x[i + 1] - x[i] != d) { cout << x[n - 1] << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e4 + 10; struct Edge { int from, to, l, r, nxt; } e[N << 2]; int head[N], cnt = 0; int n, m, k, s1, s2, f, book[N]; long long d1[N], d2[N]; void add(int u, int v, int l, int r) { e[++cnt] = (Edge){u, v, l, r, head[u]}; head[u]... |
#include <bits/stdc++.h> using namespace std; int mark(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return i; } return 0; } int main() { int n; cin >> n; int res = n; while (n != 1) { if (n % 2 == 0) { n = n / 2; res += n; } else { ... |
#include <bits/stdc++.h> using namespace std; #define st first #define nd second #define pb push_back #define cl(x,v) memset((x), (v), sizeof(x)) #define db(x) cerr << #x << == << x << endl #define dbs(x) cerr << x << endl #define _ << , << typedef long long ll; typedef long double l... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010 + 1; const double EPS = 1E-8; int n; double a[MAXN], low[MAXN], high[MAXN], mmin, mmax; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %lf , &a[i]); if (i) { low[i] = 10 * a[i] / (i + 1); ... |
#include <bits/stdc++.h> using namespace std; bitset<6> a[6]; bool check(int i, int j, int k) { if (a[i][j] and a[i][k] and a[j][k]) return 1; if (!a[i][j] and !a[i][k] and !a[j][k]) return 1; return 0; } int main() { int n; cin >> n; for (int i = 0; i < 6; ++i) a[i].reset(); for (... |
#include <bits/stdc++.h> using namespace std; int n; int v[100111]; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> v[i]; sort(v, v + n); int ans = 1; for (int i = 0; i < n; i++) { if (v[i] >= ans) { ans++; } } cout ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, ans, st, ed; cin >> n; string s; cin >> s; st = 1, ed = 1; for (i = 1; i < n; i++) { if (s[i] == s[i - 1]) st++; else break; } for (i = n - 2; i >= 0; i--) { if (s[i] == s... |
#include <bits/stdc++.h> using namespace std; const long long inf = 6 * 1e18; const long long Mod = 1e9 + 7; const long double pai = acos(-1); long long N, Add, Remove, Move; long long A[100009]; long long Cost(long long Goal) { long long More = 0, Need = 0; for (int i = 0; i < N; i++) { if ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; long long int n, a, cnt = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; v.push_back(a); } for (int i = 1; i < n - 1; i++) { if (v[i] < v[i - 1] && v[i] < v[i + 1]) cnt++; else if ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int f = 0; for (int i = 1; i <= n; i++) { if (n % i == 0) { a[f] = i; f++; } } int h = 0; int j; for (int i = 0; i < f; i++) { for (j = 0; j <= f / 2; j++) { ... |
#include <bits/stdc++.h> using namespace std; long long dp[1 << 13][13], g[1 << 13]; bool good[1 << 13]; int parent[1 << 13], root[1 << 13], n; long long solve(int mask, int root); long long f(int mask) { if (g[mask] == -1) { if (root[mask] == -1) { g[mask] = 0; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 2100; inline long long add(long long a, long long b) { long long c = a + b; if (c >= (1000000007)) { c -= (1000000007); } return c; } inline long long mul(long long a, long long b) { return (a * b) % (1000000007); } i... |
#include <bits/stdc++.h> using namespace std; enum op_t { AND = 0, OR, XOR, VAL }; op_t bin_op_from_string(const string& s) { if (s == AND ) { return AND; } else if (s == OR ) { return OR; } else if (s == XOR ) { return XOR; } else { throw std::runtime_error( Unknown op:... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18 + 5; const long long MOD = (long long)1e9 + 7; const int MAXN = 55; const int MAXM = 20005; struct ST { long long val[4 * MAXM], add[4 * MAXM]; void init(int l, int r, int idx) { add[idx] = val[idx] = 0; ... |
#include <bits/stdc++.h> using namespace std; int csum[2000][2000]; int rsum[2000][2000]; int segCol[2000][2 * (1 << 11)]; int segRow[2000][2 * (1 << 11)]; int l[2 * (1 << 11)]; int r[2 * (1 << 11)]; void init() { for (int i = (1 << 11); i < 2 * (1 << 11); i++) l[i] = r[i] = i - (1 << 11); for (... |
#include <bits/stdc++.h> using namespace std; long long n, m; long long dp[102][10005]; long long fwd[105][105]; long long ar[105][105]; long long solve(long long row, long long rem) { if (row > n || rem == m) { return 0; } if (dp[row][rem] != -1) return dp[row][rem]; long long i, ans ... |
#include <bits/stdc++.h> using namespace std; int s[200500]; vector<int> gr[200500]; int res[200500]; map<int, map<int, int> > w; char clr[200500]; vector<int> com; int sum = 0; int root = 0; vector<int> tr[200500]; void dfs(int i) { clr[i] = 1; sum += s[i]; for (auto u : gr[i]) { ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; using PII = pair<int, int>; char S[55][55]; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int n = 50, m = 50; int x = 2, y = 2; bool flag = true; auto newline = [&]() { y = 2; x += flag ? 3 : 2; ... |
#include <bits/stdc++.h> using namespace std; long long powmod(long long a, long long b, long long MOD) { long long res = 1; a %= MOD; for (; b; b >>= 1) { if (b & 1) res = res * a % MOD; a = a * a % MOD; } return res; } const int N = 1e5 + 5; int a[N]; map<long long, int> m;... |
#include <bits/stdc++.h> using namespace std; long long cyc[1000006][27], n, m; long long done[1000006]; string a, b; int main() { cin >> n >> m; cin >> a >> b; int s1 = a.size(); int s2 = b.size(); long long tot = s1 * n; memset(cyc, 0, sizeof(cyc)); memset(done, 0, sizeof(done));... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; const int N = 2000; int board[N][N]; bool flip_row[N]; bool flip_col[N]; int bar[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int y = 0; y < n; ++y) {... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T gcd(T a, T b) { if (b == 0) return a; ... |
#include <bits/stdc++.h> int dizi[200005][3], ans[200005]; int main() { int n, i, x, y; scanf( %d , &n); if (n == 3) { printf( 2 1 3 ); return 0; } for (i = 1; i <= n; i++) { scanf( %d %d , &x, &y); dizi[i][1] = x; dizi[i][2] = y; } for (i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int cnt[(1 << 19)], mn[(1 << 19)], mx[(1 << 19)], ans[(1 << 19)]; void solve(int L, int R) { if (L + 1 == R) { ans[L] = 0x3f3f3f3f; mn[L] = cnt[L] ? 0 : 0x3f3f3f3f; mx[L] = cnt[L] ? 0 : -0x3f3f3f3f; } else { int M = (L + R) / 2, i, H = ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const int MAXN = 1000100; int q = 0, qq, n; double x[MAXN], y[MAXN]; double c1[MAXN]; double c2[MAXN]; double c[MAXN]; void solve() { cin >> n; for (int i = 0; i < n; ++i) { cin >> c1[i]; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { count = 0; ... |
#include <bits/stdc++.h> using namespace std; int arr[400033], pp; int main() { int n, k, i; scanf( %d%d , &n, &k); for (i = 0; i < k; i++) scanf( %d , &arr[i]); stack<int> s; int curr = 1, pos = 1; for (i = 0; i < k; i++) { if (arr[i] == curr) curr++; else s.pu... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool elem(set<T> st, T val) { return (st.find(val) != st.end()); } template <typename T> void printv(vector<T> vt) { for (int i = 0; i < (int)vt.size() - 1; ++i) cout << vt[i] << ; cout << vt[vt.size() - 1] << endl; } int... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 1000005; long long f[5010][5]; int _prev[5010][5], n; int a[MAXN]; long long sum[MAXN]; int main() { scanf( %d , &n); for (int i = (1); i < (n + 1); i++) scanf( %d , a + i); for (int i = (1); i < (n + ... |
#include <bits/stdc++.h> using namespace std; int n; const long long mod = 1e9 + 7; long long w[100010], ans = 0; vector<int> g[100010]; map<long long, int> mp[100010]; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } void dfs(int u, int fa) { for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; if (N * (N - 1) / 2 <= K) { cout << no solution n ; return 0; } for (int i = 0; i < N; ++i) cout << 0 << i << n ; } |
#include <bits/stdc++.h> using namespace std; void swapCols(int p1, int p2, vector<vector<int> >& matrix) { for (int i = 0; i < ((int)(matrix).size()); i++) swap(matrix[i][p1], matrix[i][p2]); } void swapRows(int p1, int p2, vector<vector<int> >& matrix) { for (int i = 0; i < ((int)(matrix[0]).siz... |
#include <bits/stdc++.h> using namespace std; long long n, tmp, ans, curr; string s; deque<pair<long long, long long> > v; void add(long long val, long long pos) { while (v.front().first <= val) { curr -= v.front().first * (v[1].second - v.front().second); v.pop_front(); } v.push_front... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, s; cin >> a >> b >> s; if (a < 0) a *= -1; if (b < 0) b *= -1; if (s < (a + b) || (s - a - b) % 2 != 0) cout << No << endl; else cout << Yes << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[1 << 14], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 14, stdin), p1 == p2) ? EOF : *p1++; } inline long long read(long long &x) { x = 0; bool f = 1; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-7; double dp[10050][1005]; int ans[1005]; int main() { int k, q, p, i, j; cin >> k >> q; memset(dp, 0, sizeof dp); dp[0][0] = 1; for (i = 1;; ++i) { for (j = 1; j <= k; ++j) { dp[i][j] += dp[i - 1][j] * j / k... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int N = 2005; int z, n, k, c, i, ind, tab[N]; char t[N]; string s; vector<pair<int, int> > v; void sett(int val, int ind) { if (tab[ind] == val) return; int i = ind + 1; while (tab[i] != val) i++; v.push_back... |
#include <bits/stdc++.h> using namespace std; vector<vector<pair<int, int> > > Mat; vector<int> Grafo; vector<int> Entrada; vector<int> Rev; vector<int> Aristas; stack<int> STACK; vector<int> Backi; int grafos; bool dfs(int A, int i, int pos) { Grafo[A] = grafos; Entrada[A] = pos; Backi[... |
#include <bits/stdc++.h> using namespace std; ifstream f( 1.in ); int n, k, x; long long a[205], ans; long long dp[205][205]; int main() { cin >> n >> k >> x; for (int i = 1; i <= n; i++) cin >> a[i]; if (k * (x + 1) - 1 < n) cout << -1 ; else { for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf( %d , &N); pair<int, int> *P = new pair<int, int>[N]; int *A = new int[N]; for (int i = 0; i < N; i++) { scanf( %d , &P[i].first); P[i].second = i; } sort(P, P + N); int p = 0; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int dcmp(double x, double y) { return fabs(x - y) <= 1e-9 ? 0 : x < y ? -1 : 1; }; vector<long long> holder; void dfs(long long num, int i) { if (i == 10) { if (num) holder.push_back(num); return; } dfs(num * 10 + 4, i + 1); dfs(num... |
#include <bits/stdc++.h> using namespace std; int n, m; int getsum(long long x) { int res = 0; for (int i = 0; i <= m; i++) { long long num = x + i; while (num > 0) { res += num % 10; num /= 10; if (res > n) return n + 1; } } return res; } int main() {... |
#include <bits/stdc++.h> using namespace std; const int N = 301; int i, j, l, r, k, x, y, z, t, tot; int f[N][26], sum[N], p[N], q[N]; long long A[N][N], E[N][N], tmp[N][N]; long long n, m, a[N], INF, ans; char s[N]; void build(int value) { int x = 0, t; for (int i = 0; i < strlen(s); i++) { ... |
#include <bits/stdc++.h> int main() { int i = 0, j, t, n; char p[100]; scanf( %s , p); n = strlen(p); for (; i < n - 1; i = i + 2) { for (j = 0; j < n - 1; j = j + 2) { if (p[j] > p[j + 2]) { t = p[j]; p[j] = p[j + 2]; p[j + 2] = t; } } ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1000; const int mod = 1000 * 1000 + 3; int toInt(string x) { stringstream second; second << x; int ret; second >> ret; return ret; } string Ex(int x) { for (int l = 1, p = 26;; l++, p *= 26) if (x <= p) { x-... |
#include <bits/stdc++.h> using namespace std; int main() { long long tt; cin >> tt; while (tt--) { long long n; cin >> n; vector<long long> v(n); for (auto &i : v) cin >> i; bool ans = false; for (size_t i = 0; i < n; i++) { if (v[i] >= v[i - 1]) { a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; map<char, vector<int> > m; for (int j = 0; j < s.size(); j++) { m[s[j]].push_back(j); } for (int i = 0; i < n; i++) { string p; cin >> p; long long f = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long p = 998244353; long long n, ans, a[1000010], c[1000010], cnt[1000010]; long long ksm(long long x, long long y) { long long xlh = 1; while (y) { if (y & 1) xlh = xlh * x % p; x = x * x % p; y /= 2; } return xlh; } ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.