func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; namespace Elaina { template <class T> inline T Max(const T x, const T y) { return x < y ? y : x; } template <class T> inline T Min(const T x, const T y) { return x < y ? x : y; } template <class T> inline T fab(const T x) { return x < 0 ? -x ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000007; const long double eps = 1e-9; const long double pi = 3.141592653589793; const long double e = 2.718281828459045; int dp[100005], h[100005]; int n, mmm; int main() { memset(dp, -1, sizeof(dp)); memset(h, 0, sizeof(h)); ... |
//THINK ALOUD !! #include <bits/stdc++.h> #define debug(x) cout << -> [ << #x << = << x << ] n #define debug2(x, y) cout << -> [ << #x << = << x << , << #y << = << y << ] n #define debug3(x, y, z) cout << -> [ << #x << = << x << , << #y << = << y << , << #z << ... |
#include <bits/stdc++.h> using namespace std; const int inft = 1000000009; const int MAXN = 1000006; int n, T[MAXN], A[MAXN], B[MAXN]; int main() { scanf( %d , &n); for (int i = 0; i < (n); ++i) scanf( %d , &T[i]); A[0] = 1; for (int i = 1; i < n; ++i) A[i] = min(A[i - 1] + 1, T[i]); B[n -... |
#include <bits/stdc++.h> using namespace std; template <class T> T mymax(T a, T b) { return a > b ? a : b; } template <class T> T mymin(T a, T b) { return a < b ? a : b; } int main() { int n; int a[1001]; int s[1001] = {0}, sz, ymax = -1; int i, j, k; cin >> n; for (i = 1... |
#include <bits/stdc++.h> using namespace std; const long long K = 1000000000000000000; map<int, int> M; int q, mn, w[600005], nxt[600005], Q[600005], anc[600005], r; char opt[5], s[600005]; long long ans0, ans, g, ansx, ansy; int mask((1 << 30) - 1); int calc(int x) { return w[Q[lower_bound(Q + 1, Q + r... |
#include <bits/stdc++.h> using namespace std; long double chance[100005]; int main() { int n, p; while (cin >> n >> p) { memset(chance, 0, sizeof chance); long double tmp; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; int tem = b / p - (a - 1) / p; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int _inf = 0xc0c0c0c0; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long _INF = 0xc0c0c0c0c0c0c0c0; const long long mod = (int)1e9 + 7; const int N = 4e5 + 100; int n, m; vector<int> vc[N]; int to[N]; multiset<... |
#include <bits/stdc++.h> using namespace std; map<long long, long long>::iterator itr; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int32_t main() { c_p_c(); long long t; cin >> t; while (t--) { long long num, k; cin >> num >> k; vector<... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 3e5 + 10; vector<pair<int, int>> vp[N]; vector<int> v[N]; int pos[N]; int deg[N]; int vis[N]; vector<int> ans; void dfs(int x, int p = 0, int o = 0) { if (vis[x]) return; v[p].push_back(x); vis[x] ... |
#include <bits/stdc++.h> using namespace std; int main() { string pal, pal2; int x = 0; bool b1 = false; cin >> pal; for (int i = 0; i < pal.size(); i++) { if (pal[i] == W and pal[i + 1] == U and pal[i + 2] == B ) { i += 2; if (b1 == true) { pal2 += ; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 0 ), c = getchar(); return x * f; } c... |
#include <bits/stdc++.h> using namespace std; long long nMod = 1e9 + 7; inline long long GCD(long long a, long long b) { while (b != 0) { long long c = a % b; a = b; b = c; } return a; }; inline long long LCM(long long a, long long b) { return (a / GCD(a, b)) * b; }; void vietn... |
#include <bits/stdc++.h> using namespace std; struct node { long long int word, prefix; node *child[2]; node() { word = prefix = 0; child[0] = child[1] = NULL; } }; void insert(node *root, long long int x, long long int bit) { root->prefix += 1; if (bit < 0) { root->wor... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, n; cin >> a >> b >> n; bool exist(false); for (int i = 0; i < 10; i++) { if ((a * 10 + i) % b == 0) { cout << a * 10 + i; string s(n - 1, 0 ); cout << ... |
#include <bits/stdc++.h> using namespace std; bool vis[100010]; int pr[100010], e; void Shai() { vis[1] = true; for (long long i = 2; i <= 1000ll; i++) { if (!vis[i]) { pr[++e] = i; for (long long j = i * i; j <= 1000ll; j += i) { vis[j] = true; } } } ... |
#include <bits/stdc++.h> using namespace std; ifstream in( test.in ); ofstream out( test.out ); const int DIM = 2e3 + 1; const int INF = 1e9 + 7; int dp[DIM]; set<int> mst; deque<int> que; vector<int> edg[DIM]; int main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); int k, n... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 4; bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) retu... |
#include <bits/stdc++.h> using namespace std; int main() { int t; t = 1; while (t--) { int n, m, i, j; cin >> n >> m; int a[n + 2][m + 2]; int ii = -1, jj = -1; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> a[i][j]; if (a[i][j] > 0) ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long a, b, x, y; long long best, ansp, ansq; int main() { while (cin >> a >> b >> x >> y) { long long gg = gcd(x, y); x /= gg; y /= gg; best = -1; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 10; int n, k; long long fac[maxn + 10], afac[maxn + 10]; long long qpow(long long a, long long b) { long long ret = 1LL; while (b) { if (b & 1) ret = ret * a % mod; a = a * a % mod; b >>= ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int INF = 0x3f3f3f3f; char tmp[20][20]; char raw[MAXN]; long long n, m, T, k; bool check(int l, int r) { for (int i = 1; i <= n; i++) { if (r - l + 1 < strlen(tmp[i])) continue; else { int cur_len ... |
#include <bits/stdc++.h> using namespace std; int read() { int tot = 0, fh = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fh = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { tot = tot * 10 + c - 0 ; c = getchar(); } return tot * fh; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; bool flag[21][21]; int deg[21], id[21]; vector<int> G[21]; inline int cmp(int x, int y) { return deg[x] != deg[y] ? deg[x] < deg[y] : x < y; } bool vis[21]; inline void dfs(int np) { vis[np] = 1; for (int &x : G[np]) { if (!vis[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300300; int a[maxn]; set<int> st; int MIN(int x, int y) { return x < y ? x : y; } int MAX(int x, int y) { return x > y ? x : y; } int main(void) { st.clear(); int n, i, j, mi, mx, fg = 0, x; scanf( %d , &n); for (i = 1; i <= n ... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e8; const int N = 500; int n; int ans; int a[N]; set<int> p; int m; int b[N][2]; struct Edge { int to, cap, flow; Edge() : to(), cap(), flow() {} Edge(int _to, int _cap) : to(_to), cap(_cap), flow(0) {} }; int sz; ... |
#include <bits/stdc++.h> using namespace std; int p[200007]; int c1[200007]; int c2[200007]; bool used[200007]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { scanf( %d , &p[i]); } for (int i = 0; i < n; ++i) { scanf( %d , &c1[i]); c1[i]--; } for (i... |
#include <bits/stdc++.h> using namespace std; long long dp[64][64][64][64]; double fact[64]; int main() { int n, a[64], p, s = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; s += a[i]; } cin >> p; if (s <= p) { printf( %.9f n , (double)n); return 0; }... |
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(false); long long int n; cin >> n; vector<long long int> a(n), start(n), end(n); for (long long int i = 0; i < n; i++) { cin >> a[i]; start[i] = i; end[i] = i + 1; } for (long long int i = 0;... |
#include <bits/stdc++.h> using namespace std; int T, a, b, c, d, k; int main() { cin >> T; for (; T--;) { cin >> a >> b >> c >> d >> k; int sol1 = 0; int sol2 = 0; if (a % c == 0) sol1 = a / c; else sol1 = a / c + 1; if (b % d == 0) sol2 = b / d;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const int mod1 = 998244353; const int mod2 = 1e9 + 7; const int b1 = 337; const int b2 = 421; const int inf = 2147483647; struct Pair { int x[2] = {}; bool operator<(const Pair a) const { return x[0] < a.x[0] || x[0] == a... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; const int P = 10000007; int m, n; char str[N]; char ans[N]; int l[N], r[N]; int p[N]; bool ok(int i, int m) { if (++i < m) return 0; return (r[i] - r[i - m]) == ((l[i] - l[i - m] * p[m]) * p[i - m]); } int dfs(int i, int i... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, out = 0; cin >> n; for (i = 1; i <= n; i++) { out += pow(2, i); } cout << out; return 0; } |
#include <bits/stdc++.h> using namespace std; enum STATE { IN, OUT, BOUNDRY }; const double PI = acos(-1.0); void fast_in_out() { std::ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); } int dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; int dy[] = {-1, 1, 0, 0, -1, -1, 1, 1, 0}; int l... |
#include <bits/stdc++.h> const int MOD = 1000000007; int64_t dp[2001][2001]; int main() { int n, m, k; std::cin >> n >> m >> k; dp[0][0] = 1; for (int i = 1; i <= 2000; ++i) { dp[i][0] = 1; for (int j = 1; j < i; ++j) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD; ... |
#include <bits/stdc++.h> using namespace std; struct __timestamper {}; vector<vector<int>> g; vector<vector<int>> id; vector<int> used; vector<int> ts; void dfs(int v, int x) { if (used[v]) return; used[v] = 1; for (int i = 0; i < (int)g[v].size(); i++) { if (id[v][i] < x) { dfs(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; char str1[maxn], str2[maxn]; int a[maxn], len1, len2; bool book[maxn]; bool judge(int x) { for (int i = 1; i <= x; i++) book[a[i] - 1] = 1; int j = 0, cnt = 0; for (int i = 0; i < len2; i++) { for (; j < len1; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int l, r, d; scanf( %d %d %d , &l, &r, &d); if (d < l) printf( %d n , d); else if (d > r) printf( %d n , d); else { int res = r - d; res = res % ... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int a; scanf( %d , &a); mp[a]++; } int res = n; while (!mp.empty()) { for (auto itr = mp.begin(); itr != mp.end();) { if (--itr... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200001; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; string s; cin >> s; int ans = 2e9; vector<int> can; vector<string> cand; for (int i = 0; i < 10; i++) { priority_queue... |
#include <bits/stdc++.h> using namespace std; vector<int> aa; char s[100005]; int n; void doit() { scanf( %s , s + 1); n = strlen(s + 1); int last = 0, ans = 0; for (int i = 1; i <= n; i++) if (s[i] == 1 ) { if (last > 0) ans += i - last - 1; last = i; } printf... |
#include <bits/stdc++.h> using namespace std; int lsone(int n) { return (n & -n); } void mult(long long int a[25][25], long long int b[25][25], long long int c[25][25], int m, int n, int p) { for (int i = 1; i <= m; i++) { for (int j = 1; j <= p; j++) { c[i][j] = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; inline long long labs(long long a) { return a < 0 ? (-a) : a; } template <typename T> inline T sqr(T x) { return x * x; } struct Node { int deep; int p; vector<int> to; int tin, tout; }; const int MAXN = 100005; vector<pair<int, int> > ... |
#include <bits/stdc++.h> using namespace std; int a[1005]; int b[2005]; int main() { int p, q, l, r; cin >> p >> q >> l >> r; while (p--) { int val1, val2; cin >> val1 >> val2; for (int i = val1; i <= val2; i++) a[i] = 1; } while (q--) { int val1, val2; cin >> v... |
#include <bits/stdc++.h> using namespace std; int n, m = 100000, a, b, c, cnt; struct Point { int x, y; Point() {} Point(int a, int b) { x = a, y = b; } bool operator==(Point b) const { return x == b.x && y == b.y; } Point operator+(Point b) { return Point(x + b.x, y + b.y); } Point operat... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[300004]; int n, nr, r, Min, poz, f1, f2, ch1, ch2, sol, soli, sol2, i, j, l, v[300004], m[300004]; char s[300004], b[300004]; bool ok1, ok2; int main() { scanf( %d , &n); scanf( %s , &s); nr = 0; Min = 1000000000; for (... |
#include <bits/stdc++.h> using namespace std; struct male { const string adjective = lios ; const string noun = etr ; const string verb = initis ; }; struct female { const string adjective = liala ; const string noun = etra ; const string verb = inites ; }; int main() { ios... |
#include <bits/stdc++.h> using namespace std; long long A[200005], dp[300005]; int main() { long long a, b, h, w; scanf( %lld%lld%lld%lld , &a, &b, &h, &w); long long n; scanf( %lld , &n); long long i, j; for (i = 1; i <= n; i++) { scanf( %lld , A + i); } if (h >= a && w >= b... |
#include <bits/stdc++.h> int main() { char string[101]; int i = 0; while (scanf( %c , &string[i]) && string[i++] != n ) if (string[i - 1] == H || string[i - 1] == Q || string[i - 1] == 9 ) { printf( YES ); exit(0); } printf( NO ); } |
#include <bits/stdc++.h> using namespace std; const int N = 111; const int INFI = 2147483627; int a[N], b[N]; int main() { int n, ans = -1, flag, t; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 1; i < n; i++) { b[i - 1] = a[i] - a[i - 1]; if (ans < ... |
#include <bits/stdc++.h> using namespace std; int n; long long j; long long ix, iy; int mx[100100], my[100100]; inline void reflect(int in, long long ax, long long ay, long long& bx, long long& by) { bx = ax + ((mx[in] - ax) << 1); by = ay + ((my[in] - ay) << 1); return; ... |
#include <bits/stdc++.h> using namespace std; const int ALPH = z - a + 1; const int W = 1000 * 1000; const int MOD = 1000 * 1000 * 1000 + 7; template <typename T> vector <int> computePrefPref(const T &s) { int n = s.size(); vector <int> res(n + 1, 0); int i = 1,... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int mod = 1e9 + 7; long long a[N], b, c, d, dis; pair<int, int> p; bool mark = true; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, n, m, k, ans = 0, sum = 0, mn = 1e8, mx = 0, x, y; cin >> t; stri... |
#include <bits/stdc++.h> using namespace std; vector<int> q[100002]; int ans[100002]; int flag, v[100002]; int k; void dfs(int len, int x, int f) { int i; v[x] = len; ans[len] = x; for (i = 0; i < q[x].size(); i++) { int j = q[x][i]; if (j == f) continue; if (v[j] != -1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, c, n, sum = 0, Max, Min; cin >> a >> b >> c >> n; Max = max(max(a, b), c); sum = a + b + c; if (3 * Max - sum > n) cout << NO << endl; else { su... |
#include <bits/stdc++.h> using namespace std; double dp[105][105 * 1005]; int a[105]; int main(void) { int n, m; scanf( %d%d , &n, &m); int sum = 0; for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); sum += a[i]; } if (m == 1) { printf( %.10f n , 1.0); return 0; ... |
#include <bits/stdc++.h> using namespace std; int solve() { int n, m, tx = 0; cin >> n >> m; vector<int> t(m), a(m), b(m), g[n], c(n), tout(n); for (int i = 0; i < m; i++) { cin >> t[i] >> a[i] >> b[i]; --a[i], --b[i]; if (t[i]) g[a[i]].push_back(b[i]); } function<bool(int ... |
#include <bits/stdc++.h> using namespace std; const int sz = 1e6 + 9; int n, m, k; long long tr[sz], tr_sum, tr_cnt; long long ret[sz], ret_sum, ret_cnt; int d, first, t, c; vector<pair<pair<int, int>, pair<int, int>>> v; vector<pair<long long, long long>> home; long long home_ans[sz]; long long ans... |
#include <bits/stdc++.h> using namespace std; inline int read() { register int x = 0; register bool f = 0; register char ch = getchar(); while (!isdigit(ch)) { f ^= !(ch ^ - ); ch = getchar(); } while (isdigit(ch)) { x = ((x + (x << 2)) << 1) + (ch ^ 0 ); ch = getch... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int p = 0, t = 1; if (s.substr(0, 4) == http ) { p = 1; cout << http:// ; } else cout << ftp:// ; int i = p + 3; while (!(s[i] == r && s[i + 1] == u ) || t) { cout << s[i]; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6; const long long inf = 1e17; long long overFlow(long long a, long long b) { if ((inf / a) < b) return 1; return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x0, y0, ax, ay, bx, by; cin >> x0 >> y... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, i, zer = -1, one; cin >> n; string s; string ans = ; cin >> s; for (i = 0; i < n; i++) { if (s[i] == 1 ) break; zer = i; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; long long int prod = 1; char mat[105][105]; cin >> n >> m; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> mat[i][j]; } } for (i = 0; i < m; i++) { unordered_set<char> s; ... |
#include <bits/stdc++.h> using namespace std; int n, k, m; int a[111]; int c[111][111]; long long dp[111][111][111]; long long f(int idx, int cnt, int last) { if (idx > n) return cnt == k ? 0 : 1e13; if (dp[idx][cnt][last] != -1) return dp[idx][cnt][last]; long long ans = 1e13; if (a[idx]) ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const int mod = 998244353; int up(int x, int y) { return x + y >= mod ? x + y - mod : x + y; } int a[1010], dp[1010][1010], pos[100010], n, k; int cal(int x) { for (int i = 0; i <= k; ++i) for (int j = 0; j <= n; ++j) dp[i][j] =... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int n, x, temp, cntr = 0; cin >> n >> x; while (n--) { cin >> temp; v.push_back(temp); } sort(v.begin(), v.end()); while (v[(v.size() - 1) / 2] != x) { cntr++; v.push_back(x); sort(v.b... |
#include <bits/stdc++.h> using namespace std; template <typename T> double DIS(T va, T vb) { return sqrt((double)(va.x - vb.x) * (va.x - vb.x) + (va.y - vb.y) * (va.y - vb.y)); } template <class T> inline T INT_LEN(T v) { int len = 1; while (v /= 10) ++len; return len; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; pair<int, int> arr[n]; for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second; sort(arr, arr + n); for (int i = 0; i < n; i++) { if (arr[i].second >= ans) { ans = arr[i].second; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n - 1); vector<int> b(n - 1); for (auto &d : a) cin >> d; for (auto &d : b) cin >> d; for (int u = 0; u <= 3; ++u) { vector<int> ans; ans.push_back(u); bool flagg = true; for... |
#include <bits/stdc++.h> int modExp(long long a, long long n, int p) { int ret = 1; for (a = (a % p + p) % p; n; n >>= 1, a = 1LL * a * a % p) if (n & 1) ret = 1LL * ret * a % p; return ret; } int main() { long long n, m; scanf( %lld%lld , &n, &m); printf( %lld n , (modExp(3, n, m) +... |
//naveen mall #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define pb push_back #define sz(c) (int)c.size() #define len(c) (int)c.length() #define vec vector #define int lon... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, k; cin >> n >> k; string A, B; cin >> A >> B; long long ret = 0; long long ways = 1; bool isinf = false; for (auto i = (0); i != (n); +... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int a[10]; map<string, int> mp; map<int, string> p; string s; int main() { int i, j, k; int n, m; for (i = 1; i <= 5; i++) cin >> a[i]; mp[ S ] = 1; mp[ M ] = 2; mp[ L ] = 3; mp[ XL ] = 4; mp[ XXL ] =... |
#include <bits/stdc++.h> using namespace std; vector<long long> a; struct SegTree { struct Node { long long left, right, mid, size; }; Node combine(const Node& A, const Node& B, long long m) { Node C; if (A.left < A.size) { C.left = A.left; } else { if ((a[m - 1... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 10; const int LCM = 840; const int n = 8; long long w; long long cnt[MAXN], f[MAXN][MAXN * LCM]; int main() { scanf( %lld , &w); for (int i = 1; i <= n; i++) scanf( %lld , &cnt[i]); memset(f, -1, sizeo... |
#include <bits/stdc++.h> using namespace std; const long long M = 998244353; long long f[300005]; vector<long long> m1[300005], m2[300005]; int32_t main() { std::ios::sync_with_stdio(0); std::cin.tie(0); ; long long n; cin >> n; for (long long i = 0; i < n; i++) { long long x, y;... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; void print(vector<long long> &a) { int n = a.size(); for (int i = 0; i < n; i++) { cout << a[i] << ; } cout << endl; } void print(vector<int> &a) { int n = a.size(); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long digit(long long n) { long long ans = 0; long long i = 0; while (n > 0) { long long tmp = n % 10; if (tmp != 0) { ans = ans + (tmp * pow(10, i)); i++; } n = n / 10; } return ans; } int main() { ... |
#include <bits/stdc++.h> using namespace std; namespace thecold { inline int read() { int res = 0; bool flag = false; char c = getchar(); while (!isdigit(c)) flag = (c == - ), c = getchar(); while (isdigit(c)) res = res * 10 + (c ^ 48), c = getchar(); return !flag ? res : -res; } cons... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, x, y, b[N], cnt[N], a[N]; bool vis[N]; bool cmp(int i, int j) { return make_pair(cnt[b[i]], b[i]) > make_pair(cnt[b[j]], b[j]); } int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 20; int n, a[MAX]; int main(void) { int T; scanf( %d , &T); while (T--) { scanf( %d , &n); bool allBad = 1; int rl = 0, rr = 0; scanf( %d , &a[1]); for (register int i = (2); i <= (n); ++i) { sc... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<long long, int>> xs(n); for (int i = 0; i < xs.size(); ++i) { cin >> xs[i].first; xs[i].second = i + 1; } sort(xs.begin(), xs.end()); int k; cin >> k; vector<long long> sums1(n), s... |
#include <bits/stdc++.h> using namespace std; const int maxn = 505; int a[maxn][maxn], b[maxn][maxn]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j+... |
#include <bits/stdc++.h> #pragma GCC optimize( O2,unroll-loops ) using namespace std; const int mod = 1000000007, N = 17; int n, x, ans; int A[1 << N], B[N + 1][1 << N], C[N + 1][1 << N], D[1 << N], E[1 << N]; long long fib[1 << N]; inline void fix(int& x) { if (x >= mod) x -= mod; if (x < 0) x +=... |
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <functional> using namespace std; typedef long... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; int N; int A[MAXN]; int B[MAXN]; int ans[MAXN]; bool is_permutation() { sort(B + 1, B + 1 + N); for (int i = 1; i <= N; ++i) if (B[i] != i) return false; return true; } void solve(bool has... |
#include <bits/stdc++.h> using namespace std; int n, x, sum, ans, a; int main() { scanf( %d %d , &n, &x); for (int i = 0; i < n; i++) { scanf( %d , &a); sum += a; } sum = abs(sum); ans = (sum / x) + (sum % x != 0); printf( %d n , ans); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long N = 200411; vector<int> root; int now, n, s[N], p[N], toghe; void dfs(int v) { if (s[v]) { if (s[v] == now) root.push_back(v); return; } s[v] = now; dfs(p[v]); } int main() { scanf( %d , &n); for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n; vector<vector<int> > g(n); for (int i = 0; i < n - 1; i++) { cin >> x >> y; x--; y--; g[x].push_back(y); g[y].push_back(x); } int res = 0; for (int i = 0; i < n; i++) { i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long int> dis(n); vector<long long int> ans(n); vector<bool> vis(n, 0); long long int acc = 0; for (long int i = 0; i < n; i++) { cin >> dis[i]; acc += dis[i]; } vector<vector<int>... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const long long mod = 1e9 + 7; template <typename T> inline T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> inline T q_pow(T a, T x) { T ans = 1, tmp = a; while (x) { if (x & 1) (ans *= tmp) ... |
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > mul(vector<vector<long long> > a, vector<vector<long long> > b) { vector<vector<long long> > c; c.resize(a.size()); for (int i = 0; i < c.size(); i++) c[i].resize(b[0].size(), 0); for (int i = 0... |
#include <bits/stdc++.h> using namespace std; int main() { long int n; cin >> n; long int a[n]; for (long int i = 0; i < n; i++) cin >> a[i]; long int b[101] = {0}; for (long int i = 0; i < n; i++) b[a[i]]++; long int c[101] = {0}; long int ans = 0; for (long int i = 1; i <= 100;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; if (n == 3) { cout << >vv << endl << ^<. << endl << ^.< << endl; cout << 1 << << 3; } if (n == 5) { cout << >...v << endl << v.<.. << endl << ..^.. << endl ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } using ll = long long; const ll mod = 1e9 + 7; const int maxn = 1e6 + 5; int n, k; string S; bool test(int start) { string s = S; int cur = 0; for (int i = 0; i < star... |
#include <bits/stdc++.h> using namespace std; long long vis[200005], cnt[200005], arr[200005]; void solve() { long long i, j, k, l, m, n, x, sz = 0, flag = 1, mx = 0; cin >> n; for (i = 0; i <= n; i++) vis[i] = cnt[i] = 0; for (i = 0; i < n; i++) { cin >> arr[i]; cnt[arr[i]]++; i... |
#include <bits/stdc++.h> using namespace std; int q1() { int a1, a2, a3, a4; int a[100009]; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a1 >> a2 >> a3 >> a4; a[i] = a4 + a3 + a2 + a1; } int t = a[0]; sort(a, a + n); int j = 1; for (int i = n - 1; i >= 0;... |
#include <bits/stdc++.h> using namespace std; int m, l, r, a[1200000]; string s; int main() { cin >> s; m = s.size(); l = 1; r = m; for (int i = 0; i < m; i++) if (s[i] == l ) { a[r] = i + 1; r--; } else { a[l] = i + 1; l++; } for (int i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50 + 5; const int maxm = 2e5 + 5; int n, k; int a[maxm]; vector<int> res[maxm]; int main() { cin >> n >> k; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) { int tmp = a[i], j = 0; while (true) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int A[n + 1]; A[0] = 0; for (int i = 1; i < n + 1; i++) { cin >> A[i]; } int dollar = A[1]; int cou = 0; for (int i = 1; i < n; i++) { cou = cou + A[i] - A[i + 1]; if (cou < 0) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.