func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int a[100], n, m, x, h, ans, l, r; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; a[x]++; } for (int i = 1; i <= 50; i++) { if (a[i] == 0) continue; if (a[i] > n / 2) { cout << Bob ; return 0; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int maxn = 2e5 + 10; int N, K; int L[105], R[105]; struct min_segtree { int tree[maxn * 3]; void init() { for (int i = 0; i <= 2 * 2 * N + 2048; ++i) tree[i] = INF; } void update(int l, int r, int pos, int id, int... |
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); const int N = 2e5; long long gi() { long long w = 0; bool q = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) q = 0, c = getchar(); while (c >= 0 && c <= 9 ) w =... |
#include <bits/stdc++.h> using namespace std; template <class P, class Q> inline bool mmin(P &a, Q b) { if (a > b) { a = b; return true; } return false; } template <class P, class Q> inline bool mmax(P &a, Q b) { if (a < b) { a = b; return true; } return false... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z, q, w, e; cin >> x >> y >> z >> q >> w >> e; int leg = 0; int el = 0; leg = abs(x - y) * q; el = 3 * e + abs(x - z) * w + abs(y - x) * w; if (el <= leg) { cout << YES ; } else { cout << NO ; } ... |
#include <bits/stdc++.h> using namespace std; string solve(string s, int t) { while (t--) { for (int i = s.size() - 1; i >= 1; i--) { if (s[i] == G && s[i - 1] == B ) { swap(s[i], s[i - 1]); i--; } } } return s; } int main() { int n, t; cin ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long linf = 0x3f3f3f3fLL; int main() { int n; scanf( %d , &n); if (n < 10) puts( 1 ); else { int aux = n; while (aux >= 10) { aux /= 10; } int num = aux + 1; aux = n; ... |
#include <bits/stdc++.h> using namespace std; template <class T> void checkmax(T &t, T x) { if (x > t) t = x; } template <class T> void checkmin(T &t, T x) { if (x < t) t = x; } template <class T> void _checkmax(T &t, T x) { if (t == -1 || x > t) t = x; } template <class T> void _che... |
#include <bits/stdc++.h> using namespace std; long long a[200005], b[200005], c[200005], mod = 998244353, ans = 0; int main() { long long n; cin >> n; c[1] = c[n] = (long long)n; for (long long i = 2; i <= n / 2; i++) { c[i] = (n - i + 1) * i; c[n - i + 1] = c[i]; } if (n % 2 =... |
#include <bits/stdc++.h> using namespace std; int main() { double n, k, m, l, a, b, f, d; cin >> n >> k; long long kek = n; double cnt1 = 0, cnt2 = 0; while (kek % 2 == 0) { kek /= 2; cnt1++; } kek = n; while (kek % 5 == 0) { kek /= 5; cnt2++; } cout.p... |
#include <bits/stdc++.h> using namespace std; int k, n; int a[2201]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); int ans = 0; for (int i = 1; i <= k; i++) { ans += a[i]; } cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, cnt; char s[2100][2100], ans[2100][2100]; int tp[2100 << 1]; bitset<2100> a[2100], a1; unsigned long long b1[2100], b2[2100]; int v1[2100][2100], v2[2100][2100], v3[2100][2100], mp[2100][2100], lk[2100][2100]; int num[2100], beg[2100], ed[2100],... |
#include <bits/stdc++.h> using namespace std; int a[100004]; int main() { int n, no; cin >> n >> a[0]; a[0] = (a[0] - 1) % 2; for (int i = 1; i < n; i++) { cin >> no; a[i] = (a[i - 1] + (no - 1)) % 2; } for (int i = 0; i < n; i++) { if (a[i] == 1) { cout << 1 n ;... |
#include <bits/stdc++.h> using namespace std; set<unsigned long long> V; int zeroes(unsigned long long num) { int res = 0; while (num % 2LL == 0) { res++; num /= 2LL; } return res; } int main(void) { unsigned long long n; cin >> n; if (n == 576460752303423490LL) return ... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << endl; err(++it, args...); } const long long mod = pow(10, 9) + 7; const long long N... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; int n, q; int v[111111], c[111111]; long long first[111111]; long long calc(long long a, long long b) { int m1 = 0, m2 = 0; for (int i = 1; i <= n; ++i) first[i] = -inf; first[0] = 0; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > vp; vector<long long> v; set<long long> st; long long ara[500005]; map<string, long long> mp; long long Set(long long N, long long pos) { return N = N | (1LL << pos); } long long reset(long long N, long long pos) { return ... |
#include <bits/stdc++.h> using namespace std; struct Ev { int pos; bool st; Ev(int pos, bool st) : pos(pos), st(st) {} inline bool operator<(const Ev &rhs) const { return pos < rhs.pos; } }; int n, k; vector<Ev> ev; int f[200005], rf[200005]; const int MOD = 1e9 + 7; int c(int n, int k) ... |
#include <bits/stdc++.h> using namespace std; int main() { int N, i; cin >> N; char ch; int o = 0, n = 0, e = 0, z = 0, r = 0; for (i = 0; i < N; i++) { cin >> ch; if (ch == o ) o++; else if (ch == n ) n++; else if (ch == e ) e++; else if ... |
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 9; const int Mod = 1000000007; long long n, d, b; long long a[N]; int main() { cin >> n >> d >> b; for (int i = 1; i <= n; i++) { scanf( %I64d , &a[i]); } for (int i = 1; i <= n; i++) a[i] = a[i - 1] + a[i]; long ... |
#include <bits/stdc++.h> int solve(int n, int m, std::vector<int> const& costs) { int chosen_row_minimum = -1; for (int i = 0; i < n; ++i) { auto min = std::min_element(costs.cbegin() + i * m, costs.cbegin() + i * m + m); if (*min > chosen_row_minimum) { chosen_row_minimum = *min... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 25; const long long INF = 1e15 + 7; const long long mod = 998244353; long long dp[N]; long long binpow(long long a, long long b) { a %= mod; long long res = 1; while (b > 0) { if (b & 1) res = res * a % mod; a = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 30; int a[M], b[M]; char ans[26 * N]; int gcd(int x, int y) { return (!y) ? x : gcd(y, x % y); } int main() { ios::sync_with_stdio(0); int n, cnt = 0, sum = 0, pos = 0, qaq = 0, tmp = 0; scanf( %d , &n); for (int i = 1... |
#include <bits/stdc++.h> using namespace std; const bool print = false; const int N = 5e5 + 7; int n, m; vector<int> gr[N]; int cyk[N], odl[N], par[N]; vector<int> mycyk[N]; bool odw[N]; int ans[N]; vector<int> child[N]; int dpd[N], dpu[N]; void dfs1(int v) { odw[v] = 1; for (int i : gr[... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n + 2]; int pos[n + 2]; for (int i = 1; i <= n; i++) { cin >> a[i]; pos[a[i]] = i; } int swap = 0; for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int FFTMOD = 119 << 23 | 1; const int INF = (int)1e9 + 23111992; const long long LINF = (long long)1e18 + 23111992; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; int gcd(int n, int m) { if (m == 0) return n; return gcd(m, n % m); } int lcm(int n, int m) { return n * m / gcd(n, m); } ll fact(ll n) { if (n == 1 or n == 0) return 1; else return ((n % 1000000007) * (fact(... |
#include <bits/stdc++.h> using namespace std; class Node { public: Node *prev, *next; int k; Node(int K) { k = K; prev = next = NULL; }; void insert(int K) { Node *n = new Node(K); n->prev = this; if (this->next == NULL) this->next = n; else { ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long n1, long long n2) { if (!n1) return n2; if (!n2) return n1; if (n1 % n2 == 0) return n2; return gcd(n2, n1 % n2); } long long powmod(long long base, long long exponent) { base %= 1000000007; long long ans = 1; whil... |
#include <bits/stdc++.h> using namespace std; void input() {} const int N = 1e5 + 4, mod = 1e9 + 7; int t, k, l, r; long long dp[N]; int solve(int i = 1e5) { if (i < 0) return 0; if (i == 0) return 1; long long &ret = dp[i]; if (~ret) return ret; ret = solve(i - 1) % mod; ret += solv... |
#include <bits/stdc++.h> using namespace std; set<int> x, y; int vx[200006], vy[200006]; set<int> mx, my; set<int>::iterator it1, it2; void gao(set<int> &t1, set<int> &t2, int *v, int x) { if (!t1.count(x)) { it1 = t1.lower_bound(x); it2 = it1, it1--; int l = *it2 - *it1; v[l]--;... |
#include <bits/stdc++.h> using namespace std; char a[55]; int main() { int n, i, j, k, ans, x; int len; while (cin >> a) { ans = 0; x = 0; len = strlen(a); for (i = 0; i < len; i++) { for (j = len - 1; j > i; j--) { for (k = i; k <= j; k++) { if (a... |
#include <bits/stdc++.h> using namespace std; string S = 402 n1 1000000 n40001 400 n40800 399 n41597 398 n42392 397 n43185 396 n43976 395 n44765 394 n45552 393 n46337 392 n47120 391 n47901 390 n48680 389 n49457 388 n50232 387 n51005 386 n51776 385 n52545 384 n53312 383 n54077 382 n... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 * 1000 + 17, sq = 1000; int n, a[MAXN]; vector<pair<int, int> > p; bool cmp(int i, int j) { i--, j--; if (p[i].first / sq != p[j].first / sq) return p[i].first < p[j].first; return ((p[i].first / sq) % 2 ? p[i].second > p[j].secon... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cin.get(); string s; deque<pair<string, bool>> storage; while (n--) { getline(cin, s); storage.push_back(pair<string, bool>(s, true)); } deque<pair<string, bool>>::iterator it1, it2; bool flag... |
#include <bits/stdc++.h> using namespace std; template <typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using max_pq = priority_queue<T>; const int inf = 2e9 + 5; const long long l_inf = 2e18 + 5; const int mod_v = 1e9 + 7; const int max_n = 1e5 + 5; const ... |
#include <bits/stdc++.h> using namespace std; vector<int> V[100045]; double size[100045]; int par[100045]; double ans[100045]; void dfs(int v) { size[v] = 1; for (int i = 0; i < V[v].size(); i++) dfs(V[v][i]); for (int i = 0; i < V[v].size(); i++) size[v] += size[V[v][i]]; } void bfs(int st)... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e8; vector<vector<int>> groupCosts; vector<int> oldDP, newDP; void solveDP(int L, int R, int L1, int R1) { if (R < L) return; int mid = (L + R) / 2; int res = oo, pos = L1; for (int i = L1; i <= min(mid, R1); i++) { int n... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t, n, i, x; cin >> t; while (t--) { cin >> n; i = n - 1; x = n; cout << 2 << endl; while (i != 0) { cout << i << ... |
#include <bits/stdc++.h> using namespace std; class DS { public: DS(int rows, int cols) : _rows(rows), _cols(cols), _ans(0) { int n = rows + cols; _p.resize(n, -1); _r.resize(n, 0); _nr.resize(n, 0); _nc.resize(n, 0); for (int i = 0; i < rows; ++i) _nr[i] = 1; for (i... |
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; if (a[1] == 8 || a[1] == 1 ) { if (a[0] == a || a[0] == h ) cout << 3 << endl; else cout << 5 << endl; return 0; } if (a[0] == a || a[0] == h ) cout << 5 << endl; e... |
#include <bits/stdc++.h> using namespace std; long long n, m, b[110][10010], i, j, k, minn, l, p, w, ind; string a[10005]; int main() { cin >> n >> m; p = false; w = false; for (i = 0; i < n; i++) { k = -1; cin >> a[i]; for (j = 0; j < m; j++) { if (a[i][j] == 1 ) { ... |
#include <bits/stdc++.h> using namespace std; char s[20][20]; long long n; long long tmp1[15][16400][65]; long long tmp2[15][16400][65]; long long visit[20]; long long a[20]; long long k; long long fst; long long all; void dfs(long long pos, long long msk, long long ans) { if (pos == k) { ... |
#include <bits/stdc++.h> using namespace std; using namespace std; int n, T; int t[5005]; double p[5005]; double dp[5005][5005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> T; for (int i = 1; i <= n; i++) cin >> p[i] >> t[i], p[i] *= 0.01; dp[0][0] = ... |
#include <bits/stdc++.h> using namespace std; int vis[10], A[300], B[300]; int ct[300], mrk[300]; vector<pair<int, int>> ans; int main() { int n, x; scanf( %d , &n); for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { scanf( %d , &x); A[i] |= (1 << j) * x; } ... |
#include <bits/stdc++.h> using namespace std; int n; const int mxN = 1000; int prnt[mxN]; int rnk[mxN]; vector<int> adj[mxN]; vector<pair<int, int>> ans; int vis[mxN]; int find(int i) { if (prnt[i] != i) prnt[i] = find(prnt[i]); return prnt[i]; } void join(int x, int y) { int xroot = f... |
#include <bits/stdc++.h> using namespace std; clock_t time_p = clock(); void time_taken() { time_p = clock() - time_p; cerr << Time Taken : << (float)(time_p) / CLOCKS_PER_SEC << n ; } const long long mod = 1e9 + 7; const long long INF = 1e18; void solve() { int n; cin >> n; vecto... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535897932384626433832795; const double EPS = 1e-9; set<int> good; void gen(int x) { good.insert(x); if (x > 100 * 1000 * 1000) { return; } gen(10 * x + 4); gen(10 * x + 7); } vector<pair<int, int> > swaps; ... |
#include <bits/stdc++.h> using namespace std; const long long M = 2 * (1e5) + 7, mod = 1e9 + 7; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; { long long n, x1, x2; cin >> n >> x1 >> x2; vector<pair<long long, long long>> v; v.push_b... |
#include <bits/stdc++.h> const int MX = 1e6 + 23; const long long MOD = 998244353; int read() { char k = getchar(); int x = 0; while (k < 0 || k > 9 ) k = getchar(); while (k >= 0 && k <= 9 ) x = x * 10 + k - 0 , k = getchar(); return x; } int n, m, c[MX], w[MX]; int a[MX], b[MX];... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, j = 1; string x; cin >> n >> x; for (int i = 1; i <= n; i += j) { cout << x[i - 1]; j++; } return 0; } |
#include <bits/stdc++.h> int Flag, sum, flag[105], n, m, a, b, A[105], map[105][105]; void dfs(int last_last, int last) { int S; flag[last] = 1; for (int i = 1; i <= n; i++) { if (!map[last][i]) continue; if (map[i][last_last]) { S = A[i] + A[last] + A[last_last]; if (S < sum... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int vs, ve; int t, d; cin >> vs >> ve >> t >> d; int cur = vs; int sm = vs; int pre = vs; for (int i = 2; i <= t; i++) { while (cur < ve && abs(pre - cur) <... |
#include <bits/stdc++.h> struct count_seg { struct node { std::array<int, 2> c; bool flip = false; }; std::vector<node> seg; count_seg() : seg() {} explicit count_seg(int N) : seg(2 * N) {} std::array<int, 2> query_all() { return seg[1].c; } void update_node(int a) { int ... |
#include <bits/stdc++.h> using namespace std; long long tree[4 * 100100]; long long a[100100]; int n; void build(int from, int to, int node) { if (from == to) { tree[node] = a[from]; return; } int mid = (from + to) / 2; build(from, mid, 2 * node); build(mid + 1, to, 2 * node + ... |
#include <bits/stdc++.h> using namespace std; struct gam { int o; long long k; int nez; long long bd; long long kd; gam() { o = 0; k = 0; nez = 0; bd = 0; kd = 0; } }; bool mycomp(gam i, gam j) { return (i.k < j.k); } int main() { long long n; ... |
#include <bits/stdc++.h> using namespace std; template <typename X> inline X abs(const X& a) { return a < 0 ? -a : a; } template <typename X> inline X sqr(const X& a) { return a * a; } int main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; double first = (sq... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int a[maxn]; long long n, k; bool ok(long long d) { long long ret = 0; for (int i = 0; i < n; ++i) { ret += (a[i] - 1 + d) / d; } return ret * d <= k; } int main() { ios::sync_with_stdio(false); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) { return a; } else { return b; } } long long min(long long a, long long b) { if (a < b) { return a; } else { return b; } } struct P { double x, y; P() {}... |
#include <bits/stdc++.h> using namespace std; void DFS(int s); vector<int> v[60]; int d = 0; int c[200]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i <= 50; i++) v[i].clear(); memset(c, 0, sizeof(c)); for (int i = 1; i <= m; i++) { int u, vv; scanf( %d %d ... |
#include <bits/stdc++.h> using namespace std; const long long maxx = 1e9 + 7; bool compare(const pair<long long, long long> &a, const pair<long long, long long> &b) { return a.first > b.first || (a.first == b.first && a.second < b.second); } long long inline power(long long a, long long b, ... |
#include <bits/stdc++.h> using namespace std; const long long M = 2e5 + 10; const long long INF = 0x3f3f3f3f; const long long mod = 998244353; int mans = INF; int n, c, dp[M][2], f[M], l[M]; int main() { scanf( %d%d , &n, &c); memset(dp, INF, sizeof(dp)); for (int i = 1; i < n; i++) scanf( %d ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const long long INF = (long long)1e18; int n; long long a[11], val[11]; long long dp[1 << 8][1 << 8]; int lastBit[1 << 8]; long long del[11][1 << 8]; long... |
#include <bits/stdc++.h> using namespace std; int n, d, res; int a[200005]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (a[i] == 2) d++; } if (d <= n / 2) { res += d; n -= 2 * d; res += n / 3; cout << res; return 0; } else {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); printf( %d n , min(n, m) + 1); for (int i = 0; i <= min(n, m); i++) { printf( %d %d n , min(n, m) - i, i); } } |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n; int a[10001], c[10001], d[10001]; int ans = 0; char str[101]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %s , str); if (str[0] == M ) a[i] = 1; scanf( %d %d , &c[i], &d[i]);... |
#include <bits/stdc++.h> using namespace std; char s1[5010], s2[5010]; int dp[5010][5010]; int main() { int i, j, ind, n, m, ans; cin >> n >> m; cin >> s1; cin >> s2; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) - 1; i... |
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; string direc = URDL ; const long long MOD2 = (long long)1000000007 * (long lon... |
#include <bits/stdc++.h> using namespace std; long long n, k, x; long long inp[200005]; long long precom[64][2]; long long num; long long ans; int main() { cin >> n >> k >> x; long long i, j, kl; for (i = 0; i < n; ++i) { scanf( %lld , &inp[i]); for (j = 0; j < 63; ++j) { i... |
#include <bits/stdc++.h> using namespace std; const int nax = 3e5 + 5; long long n, x1, x2; array<long long, 2> c[nax]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> x1 >> x2; for (int i = 0; i < n; i++) cin >> c[i][0], c[i][1] = i; sort(c, c + n); for (int rep = 0; rep... |
#include <bits/stdc++.h> using namespace std; int n, q; int a[1000007]; int st[1000007]; int en[1000007]; vector<pair<int, int> > v_st[1000007]; long long ans[1000007]; class Tree { public: pair<long long, int> tr[6 * 1000007]; void init(int where, int IL, int IR) { tr[where] = {0, 0}; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 100005; int a[maxn], b[maxn]; int main() { long long d, k, a, b, t; scanf( %I64d%I64d%I64d%I64d%I64d , &d, &k, &a, &b, &t); if (d < k) { printf( %I64d n , d * a); return 0; } d -= k; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 2e9 + 10, MAX = 2100, MOD = 1e9 + 7, MAXL = 25; void OUT(long double o, int x) { cout << fixed << setprecision(x) << o; return; } long long dp[MAX][MAX], ra[MAX], a[MAX], re[200000], w[MAX]; vector<int> v[MAX]; pair<long long, lon... |
#include<bits/stdc++.h> using namespace std; namespace Ruri{ #define ms(a,b) memset(a,b,sizeof(a)) #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ? #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i) #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[... |
#include <bits/stdc++.h> using namespace std; int blk_size; struct node { int l, r, id; long long int ans = 0; }; bool compare(node a, node b) { if (a.l / blk_size != b.l / blk_size) return (a.l) / blk_size < (b.l) / blk_size; return a.r < b.r; } bool compare2(node a, node b) { retur... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = n, p = 1; i - 1; i >>= 1, p <<= 1) { for (int j = 0; j < (i + 1) / 2; j++) cout << p << ; if (n % p) n -= p / 2; } cout << n; } |
#include <bits/stdc++.h> using namespace std; int nx[1000514 * 2][26], spt; int fl[1000514 * 2], ll[1000514 * 2], lp[1000514 * 2]; int newnode() { memset(nx[spt], 0, sizeof(nx[spt])); fl[spt] = ll[spt] = lp[spt] = 0; return spt++; } int dp[1000514 * 2]; void add(int root, int& last, char A) { ... |
#include <bits/stdc++.h> using namespace std; bool flag = 0; void dfs(int u, vector<vector<int> > &g, vector<int> &mark, string &order) { mark[u] = 1; for (auto to : g[u]) { if (mark[to] == 1) flag = 1; else if (mark[to] == 0) dfs(to, g, mark, order); } order.push_back(... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 9, mod = 998244353; template <const int32_t MOD> struct modint { int32_t value; modint() = default; modint(int32_t value_) : value(value_) {} inline modint<MOD> operator+(modint<MOD> other) const { int32_t c = this->value + ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[105], ma = 0, mi = 110, maxi, mini, tc; cin >> tc; for (int i = 0; i < tc; i++) { cin >> a[i]; if (a[i] > ma) { ma = a[i]; maxi = i; } if (a[i] <= mi) { mi = a[i]; mini = i; } ... |
#include <bits/stdc++.h> using namespace std; int main() { char c; int n, b = 0, a = 0; cin >> n; while (n > 0) { cin >> c; if (c == A ) a++; else b++; n--; } if (a > b) cout << Anton ; else if (a < b) cout << Danik ; else ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 5e5 + 10; int a[N]; int dp[2][N]; int minv[N]; int sum[N]; int n, k, p; class BIT { int a[110]; public: void init() { memset((a), (0x1f), sizeof(a)); } inline int lowbit(int x) { return x & -x;... |
#include <bits/stdc++.h> using namespace std; int n, k, s[444], dp[444][55][444]; int main() { cin >> n >> k; s[0] = 0; for (int i = 1; i <= n; i++) cin >> s[i], s[i] += s[i - 1]; int ans = 0; for (int i = 1; i <= n; i++) for (int j = 2; j <= min(i, k); j++) for (int l = 1; l <= ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, N = 5050; int dp[N][N / 2][2], a[N]; int main() { int n; scanf( %d , &n), a[0] = a[n + 1] = -INF; for (int i = 1; i <= n; i++) scanf( %d , a + i); memset(dp, INF, sizeof dp); for (int i = 1; i <= n; i++) dp[i][0][0] = ... |
#include <bits/stdc++.h> using namespace std; int n, k, a, rev[132001 * 2], g[2][132001 * 2], ntt[132001], v1[132001], v2[132001], fr[132001], ifr[132001], as[132001], fg = 255, inv[132001], vl[132001]; int pw(int a, int p) { int as = 1; while (... |
#include <bits/stdc++.h> using namespace std; map<string, int> m; int main() { int n; cin >> n; string h; cin >> h; m[h]++; for (int i = 0; i < n; i++) { string s; cin >> s; string a = , b = ; for (int i = 0; i < 3; i++) a += s[i]; for (int i = 5; i < 8; i... |
#include <bits/stdc++.h> using namespace std; bool check(int hr, int min) { if (hr % 10 == 7 || hr / 10 == 7 || min % 10 == 7) { return true; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x, hr, min, res = 0; cin >> x >> hr >> min; whil... |
#include <bits/stdc++.h> using namespace std; unsigned long long k, n, i, j, m; unsigned long long v[105][105]; vector<unsigned long long> l; int main() { cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { cin >> v[i][j]; k = max(k, v[i][j]); } k++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (n > m) swap(n, m); cout << n + 1 << endl; for (m = 0; n >= 0; m++, n--) cout << n << << m << endl; } |
#include <bits/stdc++.h> using namespace std; template <class T> void print(vector<T> v) { cerr << [ ; if (v.size()) cerr << v[0]; for (int i = (1); i < (v.size()); ++i) cerr << , << v[i]; cerr << ] n ; } template <class T> string i2s(T x) { ostringstream o; o << x; return o... |
#include <bits/stdc++.h> using namespace std; char s[500005]; int A[500005][2]; int B[500005]; int C[500005]; int main() { ios::sync_with_stdio(false); int n; memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); memset(C, 0, sizeof(C)); cin >> n; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int n, k, p, i; struct reg { int x, y, z; } v[100100]; inline bool cmp1(reg a, reg b) { if (a.x != b.x) return a.x > b.x; return a.y > b.y; } inline bool cmp2(reg a, reg b) { return a.y < b.y; } char s[5000]; int main() { int n, sol = 0; ... |
#include <bits/stdc++.h> using namespace std; int n, m, a, b, mas[30], summ[100005]; long long sum, countt; string s; map<pair<char, long long>, int> matr; int main() { ios_base::sync_with_stdio(false); cin.tie(0); for (int i = 0; i < 26; ++i) cin >> mas[i]; cin >> s; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int INF_INT = 2147483647; const long long INF_LL = 9223372036854775807LL; int gcd(int a, int b) { return ((b == 0) ? a : gcd(b, a % b)); } int lcm(int a, int b) { return a * b / gcd(a, b); } void solve() { int n; cin >> n; long long tmp = 1; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); } template <class T, class U> void chmin(T &t, const U &u) {... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = LLONG_MAX; int main() { string s; cin >> s; int x = s.size(); cout << 26 * (x + 1) - x; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, A, B; double p[25]; double a[625][625], l[625][625], u[625][625]; vector<int> g[25]; double y[625], x[625], b[625]; int id[25][25]; void edge(int ea, int b, int c, int d, double e) { if (ea < b) swap(ea, b); if (c < d) swap(c, d); a[id[... |
#include <bits/stdc++.h> using namespace std; void Freopen() { freopen( title .in , r , stdin); freopen( title .out , w , stdout); } int read() { int g = 0, f = 1; char ch = getchar(); while (ch < 0 || 9 < ch) { if (ch == - )... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; const double eps = 1E-9; const double Exp = 2.718281828459045; const double pi = 3.14159; const double E = 2.7182818284590452354; const int Max_Bit = 63; const int INF = 2000000000; const long long LINF = 1000000000000000007ll; const int MOD = 1000000007; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.