func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> #ifndef ONLINE_JUDGE #define debug(x) cout << #x << : << (x) << endl #else #define debug(x) #endif using namespace std; typedef long long ll; typedef vector<int> vi; const int maxn=1e6+7,inf=0x3f3f3f3f,mod=1e9+7; string s[4]; int n; int cnt1[4],cnt0[4]; int ma... |
#include <bits/stdc++.h> using namespace std; int main() { string n; int count = 0; cin >> n; stack<char> s; for (int i = 0; i < n.length(); i++) { if (n[i] == ( ) { s.push(n[i]); } else if (n[i] == ) ) { if (s.size() != 0) { char tops = s.top(); ... |
#include <bits/stdc++.h> using namespace std; struct nodo { int v, c, i, d; nodo() {} nodo(int V, int C, int I, int D) { v = V, c = C, i = I, d = D; } }; int ans[200055], I[200055]; int n, m; void solve(vector<vector<nodo> > v) { int d[m + 5]; memset(d, -1, sizeof(d)); queue<int> Q; ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 9; vector<long long> g[maxn]; long long n, m, a, b; bool used[maxn]; pair<long long, long long> dfs(long long v, long long u) { used[v] = 1; pair<long long, long long> ans(1, v == u); for (long long to : g[v]) { if ... |
#include <bits/stdc++.h> using namespace std; struct point { int x, id; }; struct node { int l, r, t; inline void in() { scanf( %d%d , &l, &r), --r; } inline bool operator<(const node &a) const { return l < a.l; } } a[500005]; int n, K; long long sta[2][500005]; int f[500005], shu[500005... |
#include <bits/stdc++.h> using namespace std; int main() { map<long long, pair<long long, long long> > mpl; vector<long long> ml; long long n, q, xi, amyor = 0; scanf( %lld %lld , &n, &q); deque<long long> dq; for (int i = (0); i < int(n); i++) { scanf( %lld , &xi); amyor = max(a... |
#include <bits/stdc++.h> using namespace std; vector<long long> factors; int IT_MAX = 1 << 17; int MOD = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-10; template <typename T> int BS(vector<T> &mas, T val) { ... |
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int> > g; vector<bool> used; vector<bool> cyc; vector<int> cl; vector<int> p; int cycle_st, cycle_end; bool dfs(int v, int parent) { cl[v] = 1; for (size_t i = 0; i < g[v].size(); ++i) { int to = g[v][i]; if (to == ... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, m = 0, z = 0, res = 0; cin >> n >> m >> z; for (int i = 1; i <= z; i++) if (i % n == 0 && i % m == 0) res++; cout << res; return 0; } |
#include <bits/stdc++.h> using namespace std; string itosm(long long x) { if (x == 0) return 0 ; string ans = ; while (x > 0) { ans += ((x % 10) + 0 ); x /= 10; } reverse(ans.begin(), ans.end()); return ans; } long long stoim(string str) { long long ans = 0; long ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, i, j, ll, l; cin >> n; string a[n], s; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n, [&](const string &a, const string &t) { return a.size() < t... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout... |
#include <bits/stdc++.h> using namespace std; char str[25][510]; int g[25][25]; int main() { int n, m, i, j, l1, l2, fuck, temp, k; scanf( %d%d , &n, &m); for (i = 0; i < n; i++) scanf( %s , str[i]); for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { temp = 0; l1 = str... |
#include <bits/stdc++.h> using namespace std; int A[10010] = {0}; int D; int N, M, P; int g; int fact[20010] = {0}; int fp = 0; int Hash[20010] = {0}; int place[10010] = {0}; int F[20010] = {0}; long long power(long long a, long long k, long long Mod) { long long o = 1; for (; k > 0; k >>=... |
#include <bits/stdc++.h> using namespace std; int t, n, a[200005], p[200005]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { p[i] = i - 1; } int su... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int n, m; int h[maxn], in[maxn], q[maxn], sg[maxn], sum[maxn], vis[maxn]; vector<int> G[maxn]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) scanf( %d , &h[i]); for (int i = 1; i <= m; ++i) { int u, ... |
#include <bits/stdc++.h> using namespace std; int n, v[10004]; vector<array<int, 3> > ans; void go(int x, int y, int z) { v[x] -= x * z; v[y] += x * z; ans.push_back({x, y, z}); } int main() { int t; cin >> t; while (t--) { ans.clear(); int sum = 0; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; struct Envelope { int s, t, d, w; }; const int NMAX = 100010, MMAX = 210, KMAX = 100010; const long long LLINF = 0x7fffffffffffffffLL; int n, m, k; Envelope red[KMAX]; vector<int> v[NMAX]; int red_t[NMAX]; long long f[NMAX][MMAX]; bool cmp(int a, i... |
#include <bits/stdc++.h> using namespace std; vector<int> v[300005]; int n, m, s; int edgeck[300005], Etype[300005]; pair<int, int> E[300005]; int vis[300005]; void bfs() { memset(vis, 0, sizeof(vis)); queue<int> que; que.push(s); while (!que.empty()) { int now = que.front(); q... |
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long int T; int N, K; int A[200201]; int main() { //ios::sync_with_stdio(0); cin.tie(0); scanf( %d , &T); while(T--) { scanf( %d %d , &N, &K); for(int i=1; i<=N; i++) { if (i <= K) A... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; const long long linf = 1e18 + 5; const int N = 3000 + 5; int n, x, y, all, up[N], down[N], w[N]; vector<pair<int, int> > v[N]; void dfs(int root, int x, int w, int up, int down) { ::up[x] = up; ::down[x] = down; ::w[x] = w;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, temp; cin >> n; vector<int> num; while (n != 0) { cin >> temp; num.push_back(temp); n--; } sort(num.begin(), num.end()); int smallest = 1; for (int i = 0; i < num.size(); i++) { if (smallest != ... |
#include <bits/stdc++.h> using namespace std; int a[300001]; int m, n, res = 1, x; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; m = n; printf( 1 ); for (int i = 1; i <= n; ++i) { cin >> x; a[x] = 1; res++; while (a[m... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n, a, b, ans = 0; cin >> n >> a >> b; if (b >= 0) { if (b >= n) { ans = b % n; ans += a; } else ans = a + b; if (ans > n) ans %= n; } else if (n == -b) { ans = a... |
#include <bits/stdc++.h> using namespace std; int cycles; vector<vector<int> > g; vector<int> vis; void dfs(int u) { vis[u] = 1; for (auto v : g[u]) { if (vis[v]) { if (vis[v] == 1) cycles++; continue; } dfs(v); } vis[u] = 2; } long long gcd(long long a, l... |
#include <bits/stdc++.h> using namespace std; long long N = 1e5 + 10; vector<vector<long long> > v1(N, vector<long long>(2)); vector<vector<long long> > v; long long dfs(long long s, long long n, vector<long long>& level) { long long val = 0; for (auto u : v[s]) { if (level[u] == 0) { va... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, m, k, s, t; vector<int> g[N]; int dis[N]; bool spc[N]; bool ok(int lim) { priority_queue<pair<int, int> > stk; fill_n(dis, n, INT_MAX); dis[s] = 0; stk.push({-dis[s], s}); while (!stk.empty()) { int d, u;... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; int a[7]; for (int i = 0; i < 6; i++) { a[i] = s[i] - 0 ; } int ans = 3; for (int i = 0; i <= 9; i++) { for (int j = 0; j <=... |
#include <bits/stdc++.h> using namespace std; const int N = 100 + 10; int a[N]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n + n; i++) scanf( %d , &a[i]); sort(a, a + n + n); if (a[n] > a[n - 1]) puts( YES ); else puts( NO ); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<vector<int>> g(n); for (int i = 0; i < n - 1; ++i) { int x, y; cin >> x >> y; --x; --y; g[x].push_back(y); g[y].push_back(x)... |
#include <bits/stdc++.h> using namespace std; char s[2000]; int n, len, ans; int dpmin[120][55][2], dpmax[120][55][2]; bool u[120][55][2]; int inf = 10005000; bool go(int i, int n, int d) { if (i == len) { if (n % 2 == 0) return 1; return 0; } if (u[i][n][d]) return 1; u[i][n][... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e09 + 5e3; const long long linf = 2e18 + 5e3; const int mxn = 5e2 + 5; void solve() { int n; cin >> n; vector<int> a(n), b(n); vector<pair<int, int> > as, bs; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int ... |
#include <bits/stdc++.h> using namespace std; long long n; long long a[100005]; long long preA[100005]; int main() { cin >> n; for (long long i = 0; i < n; ++i) { cin >> a[i]; } preA[0] = 0; for (long long i = 1; i < n; ++i) { preA[i] = preA[i - 1] + a[i]; } set<long lo... |
#include <bits/stdc++.h> int n, a[100001], i, d = 0, s = 0; int main() { scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d , &a[i]); std::sort(a, a + n); for (i = 0; i < n; i++) if (a[i] >= s) { d++; s += a[i]; } printf( %d , d); } |
#include <bits/stdc++.h> using namespace std; const int INF = 1001001001; const long long INFL = 1001001001001001001LL; template <typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true... |
#include <bits/stdc++.h> using namespace std; bool bSearch(int* toys, int item, int from, int to) { if (from > to) return false; else { int midPoint = (from + to) / 2; if (item < toys[midPoint]) return bSearch(toys, item, from, midPoint - 1); else if (item == toys[midPoint]) ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; int a, b, n, p; int main() { cin >> a >> b >> n; for (int x = -1000; x < 1001; x++) { p = 1; for (int i = 0; i < n && p <= 1000; i++) p *= x; if (a * p == b) { cout << x; return 0; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int j1 = 0; j1 < t; j1++) { long long int n; cin >> n; long long int arr[n]; long long int sum1 = 0; long long int sum2 = 0; for (int j = 0; j < (n / 2); j++) { arr[j] = ((2 * j) ... |
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0); void _R(int &x) { scanf( %d , &x); } void _R(int64_t &x) { scanf( %lld , &x); } void _R(double &x) { scanf( %lf , &x); } void _R(char &x) { scanf( %c , &x); } void _R(char *x) { scanf( %s , x); } int main() { long long x, ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int N = 1e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k, m; cin >> n >> k >> m; vector<int> in(k); for (int &e : in) cin >> e; sort(begin(in), end(in)); const int A = accum... |
#include <bits/stdc++.h> using namespace std; template <class T> void splitstr(const string &s, vector<T> &out) { istringstream in(s); out.clear(); copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out)); } static void redirect(int argc, const char **argv) { ios::sync_with_std... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 1000; const long long INF64 = 1e18; const int N = 1001000; const int MOD = 1e9 + 7; const double EPS = 1E-9; long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); } int add(int first, int second, int m) { firs... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int INF = 2147483647; const long long LLINF = 9223372036854775807LL; template <class T> T gcd(T a, T b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } template <class T> T lcm(T a, T b) { ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; inline long long read() { long long f = 1, x = 0; char s = getchar(); while (s < 0 || s > 9 ) { if (s == - ) f = -1; s = getchar(); } while (s >= 0 && s <= 9 ) { x = x * 10 - 0 + s; s = getch... |
#include <bits/stdc++.h> int n, m, k; std::unordered_set<int> G[100123]; int deg[100123]; inline bool CheckClique(int x) { std::vector<int> V({x}); for (int y : G[x]) V.emplace_back(y); for (int u : V) for (int v : V) if (u < v && (!G[u].count(v))) return false; return true; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int long long n, c = 0; cin >> n; for (int long long i = 1; i < n; i++) { if (n % i == 0) { c++; } } cout << (c); return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; long long f[MAXN][MAXN][MAXN]; int a[MAXN]; string s; int n; long long solve(int l, int r, int pf) { if (l >= r) return 0; if (r - l == 1) return a[pf]; long long &cur = f[l][r][pf]; if (cur > 0) return cur; cur = max(... |
#include <bits/stdc++.h> using namespace std; inline int absi(int a) { return (a > 0) ? a : -a; } const int md = 51123987; inline void add(int &a, int b) { a += b; if (a >= md) a -= md; } int a[155]; int tmp[4]; int nxt[155][4]; int dp[155][55][55][55]; int main(void) { int n, mx; sc... |
#include <bits/stdc++.h> using namespace std; int T[5000000], sl[5000000], sr[5000000], a[200005], rt[200005], la[200005], pos[200005]; int i, j, n, num, tmp, ans; void build(int l, int r, int &node) { node = ++num; if (l == r) return; int mid = (l + r) >> 1; build(l, mid, sl[node]); b... |
#include <bits/stdc++.h> using namespace std; int getint() { unsigned int c; int x = 0; while (((c = getchar()) - 0 ) >= 10) { if (c == - ) return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - 0 ); } while (((c = getchar()) - 0 ) < 10); return x... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { char c; bool nega = 0; while ((!isdigit(c = getchar())) && c != - ) ; if (c == - ) { c = getchar(); nega = 1; } x = c - 48; while (isdigit(c = getchar())) x = x * 10 + c - 4... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x1, x2, y1, y2, xmin, xmax, ymin, ymax; cin >> x1 >> y1 >> x2 >> y2; xmin = x1; xmax = x2; ymin = y1; ymax = y2; int total = (x2 - x1) * (y2 - y1); for (int a = 1; a < n; ++a) { cin >> x1 >>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x1, x2, s = 0, x, y1 = 0, y2 = 0, sm = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x; for (int i = 0; i < x; i++) cout << 7 << ; cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> a[100010]; int x; int now; void print() { cout << YES << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j] << ; cout << endl; } } int main() { cin >> n >> m; now = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, d = 0, count = 0, maxCount = 0; cin >> n >> d; string s = ; for (int i = 0; i < d; i++) { cin >> s; int res = 1; for (int j = 0; j < s.size(); j++) { res &= (s[j] - 0 ); } if (res == 1) { ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return... |
#include <bits/stdc++.h> using namespace std; vector<int> zp; int zer; int one; int n; int allz; int q() { cout << ? << ; for (int i = 0; i < n; i++) { cout << zp[i]; } cout << endl; int x; cin >> x; return x; } void get(int bg, int ed, int W) { if ((zer != -... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) #pragma comment(linker, /STACK:20000007 ) #pragma GCC optimize( unroll-loops ) const int N = (int)1e6 + 100; const int maxn = (int)1e3 + 100; const int base = (int)1e9; const int mod = (int)1e9 + 7; const int inf = INT_MAX;... |
#include <bits/stdc++.h> using namespace std; vector<long long> res; long long n, a, b; void solve(long long x, long long y) { long long i, k; for (i = 1, k = 0; k < x; i += a, k++) { for (long long j = i + 1; j < i + a; j++) res.push_back(j); res.push_back(i); } for (k = 0; k < y; i... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T-- > 0) { int N; cin >> N; struct MM { int min, max; }; MM data[129]; for (int i = 0; i <= 128; ++i) { if (i >= 63 && i < 63 + N) data[i] = {i - 62, i - 62}; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; scanf( %d , &n); ; if (n == 1) { scanf( %d , &a); scanf( %d , &b); printf( %d %d n , a, b); return 0; } multimap<int, int> l; multimap<int, int>::iterator p, it; set<int> s; for (int i... |
#include <bits/stdc++.h> using namespace std; int ToInt(string& s, int len) { int r = 0; for (int i = 0, max_ = (len); i < max_; ++i) { r *= 10; r += s[i] - 0 ; } return r; } int GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; } int LCM(int a, int b) { return a * (b / GCD(a... |
#include <bits/stdc++.h> using namespace std; long long a = 0, b = 0, f = 0, t = 0, x[101010], s2 = 0, s3 = 0, i = 0, j = 0, p = 0, k = 0; string d1, d2, d3; int main() { cin >> a >> p; for (b = 1; b <= a; b++) { cin >> f; if (f > p) s2 += 2; else s2 += 1; ... |
#include <bits/stdc++.h> using namespace std; #define fr(i, a, b) for(int i = a; i < b; ++i) #define rf(i, a, b) for(int i = a - 1; i >= b; --i) #define len(v) size(v) #define all(v) begin(v), end(v) #define int long long #define ff first #define ss second #define ii pair<int, int> #define vi vec... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { long long x[3]; cin >> x[0] >> x[1] >> x[2]; sort(x, x + 3); x[2] -= x[1] - x[0]; cout << x[1] + x[2] / 2 << endl; } } |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, kol, tmp, flag[1000]; char s[1000][1000]; int main() { cin >> n >> m; for (i = 1; i <= n; i++) { cin >> s[i]; } for (j = 0; j < m; j++) { tmp = 0; for (i = 1; i <= n - 1; i++) if ((s[i][j] > s[i + 1][j]) && (... |
#include <bits/stdc++.h> using namespace std; int a[501][501], b[501][501], i, j, n, m, k; int main() { vector<int> vea; vector<int> veb; cin >> n >> m; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) cin >> a[i][j]; } for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) cin... |
#include <bits/stdc++.h> using namespace std; struct sz { long long f[2][2]; } a, b, c, z; long long p, x, y, ans, dt; int n, f[1000007]; sz chen(sz a, sz b) { sz c; c.f[0][0] = c.f[0][1] = c.f[1][0] = c.f[1][1] = 0; for (int k = 0; k <= 1; k++) for (int i = 0; i <= 1; i++) for... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i; cin >> n; long long int a[n]; for (i = 0; i < n; i = i + 1) { cin >> a[i]; } long long int mn = a[n - 1]; long long int m[n]; for (i = n - 1; i >= 0; i--) { mn = min(mn, a[i]); m[i] = mn;... |
#include <bits/stdc++.h> using namespace std; long long n; bool use[100000 + 10], b[100000 + 10]; int a[100000 + 10], Now; int Ans; int L[100000 + 10], R[100000 + 10], CNT = 0; int main() { int Cnt = 0; scanf( %I64d , &n); for (long long i = 3; i <= n; i += 2) { if (b[i]) continue; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long a[n]; for (int i = 0; i < n; ++i) { a[i] = i + 1; } long long ans = 0; long long i = 1, j = 1, k = 2; for (in... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, q, len[N]; char name[N][20], ip[N][20]; bool dy(char ip1[], char ip2[], int len) { for (int i = 0; i < len; i++) if (ip1[i] != ip2[i]) return 0; return 1; } int main() { scanf( %d%d , &n, &q); for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> arr{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 4, 9, 25, 49}; int i = 0, k = 0; int l = arr.size(); while (i < l) { string s; cout << arr[i] << endl; cin >> s; if (s ... |
#include <bits/stdc++.h> using namespace std; int n, A[100001], Ans[100001]; bool k[100001]; int solve(int x) { if (Ans[x]) return Ans[x]; int tmp = 0, cnt = 0, pre = 1; for (int i = 1; i <= n; i++) { if (!k[A[i]]) { if (cnt == x) { tmp++; cnt = 1; for (in... |
#include <bits/stdc++.h> int atob(int t, int a, int b) { int ret = 0, p = 1; while (t) { ret += t % b * p; p *= a; t /= b; } return ret; } int maxbit(int t) { int ret = t % 10; while (t) { if (ret < t % 10) ret = t % 10; t /= 10; } return ret; } in... |
#include <bits/stdc++.h> using namespace std; const long long oo = 1e9; const int maxSize = 1001000; const int mod = 1e9 + 7; const double EPS = (1e-9); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } int main() { int one = 0, remain1 = 0, two = 0, a, b; int n, res... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 7; int n; int a[N], b[N], x[N], y[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &a[i], &b[i]); } for (int i = 1; i <= n; i++) { scanf( %d%d , &x[i], &y[i]); } sort(a + 1, a + ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1791791791; const long long INFLL = 1791791791791791791ll; template <int input_buf_size, int output_buf_size> class FastIO { char cbuf[input_buf_size + 1]; int icur = 0; inline bool go_to_next_token() { while (cbuf[icur] == ||... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; bool operator<(const complex<double>& a, const complex<double>& b) { if (fabs(a.imag() - b.imag()) > EPS) return a.imag() < b.imag(); return a.real() + EPS < b.real(); } class cmp { public: bool operator()(const complex<doub... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long INF = 1e9 + 5; const long long mod = 1e9 + 7; const double pi = 3.1415926536; map<char, int> mp, mp2; int main() { ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0); ; string n, m; ... |
#include <bits/stdc++.h> using namespace std; long long n, l, r, K, p; bool check(long long x) { long long t = K % (n + x); if (t == 0) t = n + x; if (t > min(p * 2, p + x)) return 0; if (t < p + max(0LL, x - n + p - 1)) return 0; return 1; } signed main() { scanf( %lld%lld%lld%lld , &... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { while (a) { b %= a; swap(a, b); } return b; } struct Vector2D { long long x, y; Vector2D() {} Vector2D(long long x, long long y) : x(x), y(y) {} }; Vector2D operator-(const Vector2D& l... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 7007; const int MAXM = 300007; const int INF = 1 << 29; const int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; char reactor[15][15], rescue[15][15]; int N; int table[15][15]; bool isIn(int x, int y) { return x >= 1 && y >= 1 && x <= N &&... |
#include <bits/stdc++.h> using namespace std; pair<int, int> dataarr[502]; int main() { int n; cin >> n; int minin = n, maxin = 0; for (int i = 1; i <= n; i++) { cin >> dataarr[i].first; dataarr[i].second = i; if (dataarr[i].first < minin) { ... |
#include <bits/stdc++.h> using namespace std; void loadData(void); int proc(void); void printRes(int); int left1, right1, left2, right2; int pow2[31]; int getRes(int, int, int, int); int getMaxCLevelAndPos(int, int, int&); bool lyb_debug = false; int main(int argc, char** argv) { loadData(); ... |
#include <bits/stdc++.h> using namespace std; struct point { long long int x, y; point() {} point(long long int _x, long long int _y) { x = _x; y = _y; } }; bool cmp(const point &a, const point &b) { if (a.x == b.x) return a.y < b.y; return a.x < b.x; } struct freq { ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-10; const double PI = acos(-1.0); struct Edge { int to, cost; Edge(int t, int c) : to(t), cost(c) {} bool operator>(const Edge& rhs) const { return cost > rhs.cost; } }; long long N, S; vector<int> dp, parent; vector<vector<... |
#include <bits/stdc++.h> using namespace std; string a, b; int k; int main() { cin >> a; k = 1; if (a.size() % 2 == 0) { while (k != a.size() + 1) { if (k % 2 != 0) { b += a[a.size() - k / 2 - 1]; } else { b += a[k / 2 - 1]; } k++; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 2005, INF = 1e9; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; pair<int, int> dis[N][N]; bool done[N][N]; string g[N]; int n, m, sx, sy, L, R; bool valid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m && g[x][y] == . ; ... |
#include <bits/stdc++.h> long long int gcd(long long int a, long long int b) { return (a ? gcd(b % a, a) : b); } inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return (n >> b) & 1; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &=... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; long long a[N], b[N], p[N], money; int top, n, m, ans, st[N]; vector<long long> v[N]; priority_queue<long long> q; void get_sale_day() { for (int i = 1; i <= n; ++i) { while (top && a[i] >= a[st[top]]) --top; st[++top] = i... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int Maxn = 500005; map<long long, int> mp; vector<pair<int, int> > g[Maxn]; long long c[Maxn]; int pw2[Maxn] = {1}, par[Maxn], n, m, k, sz, ans; int find(int u) { return par[u] == u ? u : par[u] = find(par[u]); } int main(... |
#include <bits/stdc++.h> std::vector<int> dsc[100005]; int st[5005], fi[5005], vt[5005], nx[5005], mx[5005]; int a[100005]; double prob[5005]; double f[5005][5005 + 5]; void sx(int l, int r) { if (l >= r) return; int i = l, j = r; int chot = vt[l + rand() % (r - l + 1)]; int chot2 = fi[chot]... |
#include <bits/stdc++.h> using namespace std; const int maxv = 2045; const long long mod = 1e9 + 7; const int maxn = 1e6 + 40; long long fac[maxn], inv[maxn]; long long qpow(long long a, long long p) { long long ans = 1; long long xx = a; while (p > 0) { if (p & 1) ans = (xx * ans) % mod; ... |
#include <bits/stdc++.h> using namespace std; int n, m, md, len, i, j, k, prv, c[505][505], dpf[505][505], dpr[505][505]; long long cur, crst, f[505], rst[505]; long long sum(long long x) { return (x * (x + 1LL)) / 2; } int main() { scanf( %d%d%d , &n, &m, &md); for (i = 0; i <= n; i++) { c[i][0... |
#include <bits/stdc++.h> using namespace std; constexpr long long int MOD = 1000000007; constexpr double EPS = 1e-8; long long int N, M, K, H, W, L, R; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; vector<int> v(N); for (auto &i : v) cin >> i >> i; cin >> K; for (... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:36777216 ) using namespace std; int n, m; long long f[2005][2005], sum[2005][2005]; char ch[2005]; int main() { cin >> n >> m; scanf( %s , ch + 1); f[0][0] = 1; for (int i = 0; i <= n; i++) sum[i][0] = 1; for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dx[] = {-1, 0, 1, 0}; long long dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long b, q, l, m; cin >> b >> q >> l >> m; if (abs(b) > l) { cou... |
#include <bits/stdc++.h> using namespace std; int main() { int k, i; cin >> k; int a[12]; for (i = 0; i < 12; i++) cin >> a[i]; sort(a, a + 12); int sum = 0, c = 0; while (sum < k && i > 0) { i--; sum = sum + a[i]; c++; } if (sum >= k) cout << c; else ... |
#include <bits/stdc++.h> using namespace std; int m; vector<string> users; vector<string> msgs; vector<string> owners(101); map<string, int> mp; bool vis[1001][1001]; int mem[1001][1001]; void printResults() { for (int i = 0; i < msgs.size(); i++) { cout << owners[i] << msgs[i].substr(msgs[i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.