func_code_string stringlengths 59 71.4k |
|---|
/*mjytxdy!*/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) x.begin(),x.end() #define SZ(x) ((int)x.size()) #define pii pair<int,int> #define pil pair<int,ll> #define pli pair<ll,int> #define pll pair<ll,ll> #define inl inline... |
#include <bits/stdc++.h> using std::bitset; using std::cerr; using std::cin; using std::complex; using std::cout; using std::deque; using std::endl; using std::ios_base; using std::iterator; using std::map; using std::max; using std::max_element; using std::min; using std::min_element; usi... |
#include <bits/stdc++.h> struct event { int t, time, L, R, idx; event() {} event(int t, int time, int L, int R, int idx) : t(t), time(time), L(L), R(R), idx(idx) {} bool operator<(const event& a) const { return (time < a.time || (time == a.time && t < a.t)); } } e[200005 * 23]; i... |
#include <bits/stdc++.h> const int inf = 0x7FFFFFFF; using namespace std; int dep[2014], shortcut[20][2014]; struct Edge { int u, v, w; bool operator<(const Edge &A) const { return w < A.w; } } E[4000005]; int mp[2014][2014]; int fa[2014], d[2014]; int find(int x) { return x == fa[x] ? x : fa[x]... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long long mod = 1e9 + 7; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long q; cin >> q; ; for (long long i = (1); i <= (q); i++) { long long n; cin >> n; ; long l... |
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 10; long long x[mx], y[mx]; ifstream fin( input.txt ); ofstream fout( output.txt ); long long sum[5]; int main() { string b; cin >> b; int x = 0, y = 0; for (int i = 0; i < b.size(); i++) { if (b[i] == x ) x+... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int M = 1e9 + 7; const int MOD = 998244353; const double PI = 3.141592653589793238460; const int bs = 1e9 + 7; unsigned long long power(unsigned long long a, unsigned long long b) { unsigned long long res = 1; if (a == 0) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m; cin >> n >> m; if (n > 26) cout << m; else { n = pow(2, n); cout << m % n; } return 0; } |
#include <bits/stdc++.h> const long long INFLL = 1e18; using namespace std; const int MAXN = 2 * 100000; const int INF = 1000 * 1000 * 1000; int a[MAXN + 1], used[MAXN + 10]; int main() { int n; scanf( %d , &n); int ans = 1; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (u... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> segT; vector<int> lazy; long long n, m, l, r; string s; void buildT(int ss, int se, int si) { if (ss == se) { if (s[ss] == 4 ) segT[si][0] = 1; else segT[si][1] = 1; segT[si][2] = 1; segT[si][3] = ... |
#include <bits/stdc++.h> using namespace ::std; int main() { long long int temp, q, v1, v2, t, d, i, sum = 0; cin >> v1 >> v2 >> t >> d; long long int a[t]; sum = d * (t - 1); i = 0; temp = 0; bool ff = false; while (1) { if (!ff) { i += v1; a[temp] = i; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 1e5, inf = 3e18, mod = 1e9 + 7; long long tc, n, m, q, a, b, c, d, i, j, k; long long A[N]; vector<long long> vec; string s; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> tc; while (tc--) {... |
#include <bits/stdc++.h> using namespace std; const long long int N = 2e5 + 5; void solve() { long long int n; cin >> n; double ans, pi = 3.14159265358979323846; double rad = (2.0 * sin(pi / (2.0 * (double)n))); ans = (cos(pi / (4.0 * n))) / sin(pi / (2.0 * (double)n)); cout << fixed << se... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l[10], r[10], t = 1; double ans = 0, o = 1; cin >> n; for (int i = 0; i < n; i++) { t *= 2; cin >> l[i] >> r[i]; o *= r[i] - l[i] + 1; } if (n == 1) { cout << setprecision(10) << fixed << (r[0] + l[0]) ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; template <class T> inline T read() { T x = 0, f = 1; char s = getchar(); while (s < 0 || s > 9 ) { if (s == - ) f = -1; s = getchar(); }; while (s >= 0 && s <= 9 ) { x = (x << 3) + (x << 1) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; string cnv; cnv.reserve(62); for (char i = a ; i <= z ; ++i) { cnv.push_back(i); } for (char i = A ; i <= Z ; ++i) { cnv.push_bac... |
#include <bits/stdc++.h> using namespace std; int n, k, l[50 + 1]; void Answer() { int j = 1, s = n; for (int i = 1; i <= k; i++) { if (i > s) s += n - (++j) + 1; cout << j << ; for (int u = n - 1; u > n - j; u--) cout << l[u] << ; cout << l[s - i] << endl; } } int ma... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int power(int a, int b, int m, int ans = 1) { for (; b; b >>= 1, a = 1LL * a *... |
#include <bits/stdc++.h> using namespace std; double cal(int n, int *a, double x) { double ret = 0, t1 = 0, t2 = 0; for (int i = 0; i < n; i++) { t1 += a[i] - x; t2 += a[i] - x; t1 = max(0., t1); t2 = min(0., t2); ret = max(ret, t1); ret = max(ret, -t2); } return ... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; char g[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { long double h, c, t; cin >> h >> c >> t; if (t >= h) { cout << 1 n ; continue; } ... |
#include <bits/stdc++.h> using namespace std; int Day12[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int prime100[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103}; template <typename T> inline bool isLeap(T y) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; int x, y; int z = 1; cin >> n >> m; cin >> x >> y; cout << x << << y << n ; cout << 1 << << y << n ; for (int i = 1; i <= n; i++) { vector<pair<int, int>> v; for (int j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, q, a[N], node[4 * N]; vector<int> pos[N]; void init(int i, int l, int r) { if (l == r) { node[i] = (a[l] == 0 ? 1e9 : a[l]); return; } int m = (l + r) >> 1; init(i << 1, l, m); init(i << 1 | 1, m + 1, r... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void ckmax(T& x, T y) { x = (y > x ? y : x); } template <typename T> inline void ckmin(T& x, T y) { x = (y < x ? y : x); } namespace Fread { const int SIZE = 1 << 21; char buf[SIZE], *S, *T; inline char getchar() { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long a, f, sec, t = 0, h = 0; cin >> a; vector<long long> par; vector<long long> m; for (int i = 0; i < s.length(); i++) { if (s[i - 1] == s[i]) { h++; } par.push_back(h); } ... |
#include <bits/stdc++.h> using namespace std; long long dp[2]; void solve() { long long n; cin >> n; for (int i = 0; i < n; i++) { dp[i % 2] = dp[i % 2] + dp[!(i % 2)] + 1; if (dp[i % 2] > 1000000007) dp[i % 2] %= 1000000007; } cout << (dp[0] + dp[1] + 1000000007) % (1000000007); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; int* time = new int[n]; for (int i = 0; i < n; i++) { cin >> time[i]; } int sum = 0, count = 0; int ans = INT_MIN; for (int i = 0; i < n; i++) { if (sum + time[i] <= t) { sum += ti... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> a; int was[100100]; int t[100100]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= 2 * n; i++) { int x; cin >> x; a.push_back(x); } vector<int> an... |
#include <bits/stdc++.h> using namespace std; vector<int> tab[100100], ans; int n, ls[10]; bool used[100100]; bool chek(int a, int b) { for (int i = 0; i < 4; i++) if (tab[a][i] == b) return true; return false; } int main() { scanf( %d , &n); for (int i = 0; i < n + n; i++) { i... |
#include <bits/stdc++.h> using namespace std; long long n, q, sum, x; int main(void) { scanf( %lld%lld , &n, &q); while (q--) { scanf( %lld , &x); while (x % 2 == 0) { sum = (x + 1) / 2 + 1, sum = n - sum, x += sum + 1; } printf( %lld n , x / 2 + 1); } return 0; }... |
#include <bits/stdc++.h> using namespace std; set<pair<int, int> > s[2]; bool eq(pair<int, int> a, pair<int, int> b) { return (a.first == b.first && a.second == b.second); } int main() { int n, m, i, a, b, j; scanf( %d%d , &n, &m); for (i = 0; i < n; i++) { scanf( %d%d , &a, &b); i... |
#include <bits/stdc++.h> using namespace std; using LL = long long; const LL INF = 2000000000000000000L; struct Event { char c; LL v; int pos; }; void Dfs(int pos, vector<vector<pair<LL, int>>>& edge, vector<bool>& parallel, vector<LL>& ans) { if (edge[pos].size() == 0) { an... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int *arr = new int[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); reverse(arr, arr + n); cout << arr[k - 1]; return 0; } |
#include <bits/stdc++.h> using namespace std; int basecon(int n, int b); int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int basecon(int n, int b) { int sum = 0; while (n) { sum = sum + (n % b); n = n / b; } return sum; } int main(... |
#include <bits/stdc++.h> using namespace std; vector<int> v, ans; void op(int i) { int x = v[i + 2]; v[i + 2] = v[i + 1]; v[i + 1] = v[i]; v[i] = x; if (ans.size() >= 2 && ans[ans.size() - 1] == i + 1 && ans[ans.size() - 2] == i + 1) ans.pop_back(), ans.pop_back(); else ... |
#include <bits/stdc++.h> using namespace std; char a[5004][5004]; int vis[5004] = {0}; int fl = 0; int n; void dfs(int x, int par) { if (fl == 1) return; vis[x] = 1; for (int i = 0; i < n; i++) { if (a[x][i] == 1 && a[i][par] == 1 ) { printf( %d %d %d n , par + 1, x + 1, i + 1);... |
#include <bits/stdc++.h> using namespace std; int il[5]; int wyn = 0; void printState() {} int n; int main() { ios::sync_with_stdio(0); cin >> n; while (n--) { int tmp; cin >> tmp; il[tmp]++; } int tmp; if (il[1] > il[2]) { wyn += il[2]; il[3] += il[2]; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 20; bool A[maxn][maxn]; int d[maxn]; vector<pair<int, int> > ans; void solve(set<int> &a) { if ((int)a.size() == 1) { int k = *a.begin(); for (int i = 0; i < k + 1; i++) for (int j = i + 1; j < k + 1; j++) A[i][j] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, m, i; cin >> n >> m; long long int arr[n + 5]; map<long long int, long long int> ma; queue<long long int> q; for (i = 0; i < n; i++) { cin >> arr[i]... |
#include <bits/stdc++.h> using namespace std; const int MAX_H = 100; const int MAX_W = 100; int hs[MAX_H], vs[MAX_W]; int ps[MAX_H][MAX_W], as[MAX_H * MAX_W]; int main() { int h, w, q; scanf( %d%d%d , &h, &w, &q); for (int y = 0, p = 0; y < h; y++) for (int x = 0; x < w; x++, p++) ps[y][x]... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000000000; struct fun { long long a, b, nr; }; void Dodaj(deque<fun>& D, fun nowy) { while (D.size() >= 2) { fun ost = D.front(); D.pop_front(); fun przed = D.front(); if ((ost.b - nowy.b) * (ost.a - ... |
#include <bits/stdc++.h> using std::abs; using std::cerr; using std::cin; using std::cout; using std::map; using std::max; using std::min; using std::pair; using std::set; using std::string; using std::swap; using std::vector; using ll = long long; using uint = unsigned int; using pii = pa... |
#include <bits/stdc++.h> using namespace std; long long vis[80]; long long prime[80] = {0}; long long a[200000]; long long fc[80][200000] = {{0}}; int n; int pnum; int get_primes(int m) { memset(vis, 0, sizeof(vis)); int cnt = 1; for (int i = 2; i < m; i++) { if (!vis[i]) { pri... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long FastPower(long long x, long long y) { long long res = 1; x = x % MOD; while (y > 0) { if (y & 1) res = (res * x) % MOD; y = y >> 1; x = (x * x) % MOD; } return res; } int main() { ios::sy... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int b; map<int, long long> mp; long long a = -1; if (n > 1) { for (int i = 0; i < n; i++) { cin >> b; mp[b - i] += b; a = max(a, mp[b - i]); } cout << a; } else { c... |
#include <bits/stdc++.h> using namespace std; string s[100000]; int u = 0; char nonu[2][5] = { etr , etra }; int nonul[2] = {3, 4}; char adj[2][10] = { lios , liala }; int adjl[2] = {4, 5}; char ver[2][10] = { initis , inites }; int verl[2] = {6, 6}; bool isn(int v, int &u) { int len = s[v].l... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int to = 0, thr = 0; while (n % 2 == 0) { to++; n = n / 2; } while (n % 3 == 0) { thr++; n = n / 3;... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getchar(); } return ... |
#include <bits/stdc++.h> int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); } int main() { char str[100005]; int i, j, k; scanf( %s , str); int l = strlen(str); int cB = 0, cb = 0, cu = 0, ca = 0, cs = 0, cr = 0, cl = 0; for (i = 0; i < l; i++) { if (str[i] == B )... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; int a[n]; for (int j = 1; j <= n; j++) { a[j] = pow(2, j); } int f = 0, s = 0; for (int j = 1; j <= n; j++) { if (j < n / 2... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a[100], b[100]; scanf( %d %d , &n, &m), a[0] = n - 2, b[0] = m - 2; for (int i = 1; i < max(n, m); i++) a[i] = b[i] = 2; if (n == 1) a[0] = 1; else if (n == 2) a[0] = 3, a[1] = 4; if (m == 1) b[0] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 1111111; const int N = 105; const int M = 25; int cmp(int a, int b) { return a > b; } int n, m, s[N], c[M], t[M], dp[MAXN], st; void init() { memset(dp, INF, sizeof(dp)); scanf( %d , &n); for (int i = ... |
#include <bits/stdc++.h> using namespace std; long long a[] = {0, 1, 2, 9, 64, 625, 7776, 117649, 2097152}; const long long M = 1000000007ll; int main(void) { std::ios::sync_with_stdio(false); long long k, n, m, t; while (cin >> n >> m) { n -= m; t = 1; k = n; while (k) { ... |
#include <bits/stdc++.h> const long long N = 1e5 + 5; using namespace std; struct node { long long sum[10], lazy[10]; } lv[4 * N]; long long n, a[N], q; void init(long long i, long long l, long long r) { for (long long k = 0; k < 10; k++) lv[i].lazy[k] = k; if (l == r) { long long x = 1, z... |
#include <bits/stdc++.h> using namespace std; void init() { return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); init(); int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long int ans = 0ll, prev = 0ll; for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, t; cin >> n >> m; vector<int> f; for (int i = 0; i < m; i++) { cin >> t; f.insert(f.begin(), t); } for (int i = 0; i < m; i++) { t = i; for (int j = i + 1; j < m; j++) if (f[j] > f[t]) t = j;... |
#include <bits/stdc++.h> using namespace std; const int ALL = (1 << 30) - 1; int ans[(1 << 22) + 10]; int a[int(1e6) + 2]; int n; void add(int x, int val) { if (ans[x] != 0) return; ans[x] = val; for (int i = 0; i < 22; ++i) add(x & (ALL - (1 << i)), val); } void task() { scanf( %d , &n)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n; string s; cin >> s; int l = s.length(), ct = 1; for (int i = 1; i < l; i++) { if (s[i] != s[i - 1]) ct++; } if (ct >= (n - 1)) cout << n; else cout << ct + 2; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 10; const int inf = 1e9; int main() { ios::sync_with_stdio(false); string s; cin >> s; s = + s; int i; int ans = 0; int sum = 0; for (i = 1; i < (int)s.size(); i++) { if (s[i] == M ) { sum++; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; long long int minbcd; minbcd = min(b, min(c, d)); long long int cnt; cnt = minbcd * f; long long int x; x = d - minbcd; cnt = cnt + (min(x, a) * e); l... |
#include <bits/stdc++.h> using namespace std; char inp1[100005]; char inp2[100005]; char res[100005]; bool mk[100005]; bool mk1[100005]; char getDiff(char a, char b, char c) { for (int i = 0; i < 26; i++) if (a != ( a + i) && b != ( a + i) && c != ( a + i)) return ( a + i); return -1; ... |
#include <bits/stdc++.h> using namespace std; int m, n, k; pair<long long, long long> ptsx[100005]; pair<long long, long long> ptsy[100005]; bool removed[100005]; long long get(int l, int r, int u, int d, int dep) { while (removed[ptsx[l].second]) l++; while (removed[ptsx[r].second]) r--; while ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const ll MOD = 1e9 + 7; const int inf = (1 << 30) - 1; const ll INF = (1LL << 60) - 1; const ld EP... |
#include <bits/stdc++.h> using namespace std; set<long long> f, l, s; long long sf = 0, sl = 0; long long ksum = 0, cnt = 0, kmin = 0; void update(long long b, long long t) { int c = l.size(); if (t == 1) s.insert(b); else s.erase(b); if (c == 1 && cnt == 0) { ksum = kmin = *... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); int ji = 0; while (t--) { int n; scanf( %d , &n); int arr[n + 1]; int brr[n + 1]; memset(arr, 0, sizeof(arr)); memset(brr, 0, sizeof(brr)); int ls; int size = 0; f... |
#include <bits/stdc++.h> int n, k, m, c, arr[100005], ans; inline void check() { int i = 0; while (i < m) { if (arr[i] == i + 1) i++; else break; } if (i) c += (m - i + 1), ans += (m - i); else c += m, ans += (m - 1); } int main() { scanf( %d %d , ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class t, class u> void chmax(t& first, u second) { if (first < second) first = second; } template <class t, class u> void chmin(t& first, u second) { if (second < first) first = second; } template <class t> using v... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; struct point { double x, y; }; struct segment { double a, b, c; }; point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; } point operator-(point a, point b) { return (point){a.x - b.x, a.y - b.y}; } dou... |
#include <bits/stdc++.h> using namespace std; int n; int a[111]; int memo[111][1 << 17]; pair<pair<int, int>, int> child[111][1 << 17]; int bt[66]; class MathFunction { private: long long sieve_size; bitset<1010> bs; vector<int> primes; public: int primeid[1010]; bool isPrime(... |
#include <bits/stdc++.h> using namespace std; using namespace std; const long long mod2 = 998244353; long long fpow(long long x, long long y) { x = x % 1000000007; long long sum = 1; while (y) { if (y & 1) sum = sum * x; sum %= 1000000007; y = y >> 1; x = x * x; x %= 10... |
#include <bits/stdc++.h> #define int long long #define mod 1000000007 #define inv 500000004 using namespace std; int ksm(int a, int b) { int ans = 1, base = a % mod; while (b) { if (b & 1) ans = (ans * base) % mod; base = (base * base) % mod; b /= 2; } return ans % mod; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline bool umin(T1& x, const T2& y) { return x > y ? x = y, true : false; } template <typename T1, typename T2> inline bool umax(T1& x, const T2& y) { return x < y ? x = y, true : false; } const int N = (int)5e2 +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const long long INF = (long long)1 << 60; long long x[maxn], y[maxn], n; inline long long sqr(long long x) { return x * x; } long long p[maxn], cnt; long long ans; bool cmpy(int a, int b) { return y[a] < y[b]; } void solve(int l, i... |
#include <bits/stdc++.h> using namespace std; const int maxsize = 100005; const int inf = 1061109567; vector<int> edge[maxsize]; vector<pair<int, int> > base[maxsize]; int nnext[maxsize]; int n; int deepth[maxsize]; int siz[maxsize]; int last = 0; int ans[10 * maxsize]; int cnt = 0; void dfs1(... |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0, i; char str[10], o[5]; scanf( %d , &n); scanf( %s , o); for (i = 0; i < n; i++) { scanf( %s , str); if (str[5] == o[0] && str[6] == o[1] && str[7] == o[2]) cnt++; if (str[0] == o[0] && str[1] == o[1] && ... |
#include <bits/stdc++.h> using namespace std; void input(vector<long long>& v, long n) { for (long long i = 0; i < n; i++) { long long in; cin >> in; v.push_back(in); } } void output(vector<long long> v) { for (long long i = 0; i < v.size(); i++) cout << v[i] << ; } long lon... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int maxn = 100001, inf = 2147483647; const long long mod = 1 ? 998244353 : 1000000007, linf = 9223372036854775807; const double pi = acos(-1); inline long long mi(long long a, long long b, long long mm = mod) { a %= mm; long... |
#include <bits/stdc++.h> using namespace std; int N; int A[5005]; int DP[5005][5005]; void Read() { scanf( %d , &N); for (int i = 1; i <= N; i++) scanf( %d , &A[i]); } void precalcDP() { for (int i = 1; i <= N; i++) { for (int j = i; j <= N; j++) DP[i][j - i] = A[j]; for (int k = 0... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, t, s, x, y, h[100005], hh[100005], d, l; int main() { cin >> n; for (i = 0; i < n; i++) scanf( %d , h + i); m = h[n - 1]; for (i = n - 2; i >= 0; i--) { if (h[i] <= m) hh[i] = m - h[i] + 1; else m = h[i]; ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <bits/stdc++.h> using namespace std; int main() { int h, r, spheres = 0; cin >> r >> h; spheres = (h / r) * 2; if (h % r < r / 2.) spheres += 1; else { spheres += 2; if (h % r > 1.732 * r / 2.) spheres += 1; } cout << spheres; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 0, y = 0; string a, b; cin >> a >> b; if (a.size() > b.size()) { n = a.size(); } else { n = b.size(); } for (int i = 0; i < n; i++) { if (b[x] == a[y]) { x++; y++; } else { ... |
#include <bits/stdc++.h> long long x, n, d1, d2, now; int main() { scanf( %lld %lld , &n, &x); d1 = x; d2 = x; long long l, r, ans = 0l; for (int i = 1; i <= n; i++) { scanf( %lld %lld , &l, &r); if (l <= d1 && r >= d2) continue; if (r < d1) { ans += (d1 - r); d... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e10; void solve() { long long n, m, k; cin >> n >> m >> k; long long moves = (n + m - 2) + (n * m) - 1; for (long long i = 0; i < m + n; i++) { cin >> k; } cout << moves << n ; for (long long i = 0; i < n - 1;... |
#include <bits/stdc++.h> using namespace std; int X, Y; int n; int cnt; bool used[1000][1000]; bool edge[1000][1000][4]; const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1}; vector<int> ans; void dfs(int x, int y) { if (x < 0 || x >= X || y < 0 || y >= Y || used[x][y]) return; used[x][y] = tr... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; char s[100]; bool ops[256]; int relabel[N * 6]; int va[N * 6][2]; int typ[N * 6]; bool vis[N * 6], beres[N * 6]; string detail[N * 6]; map<string, int> ex; map<pair<pair<int, int>, int>, int> rel; vector<string> ans; char usea; ... |
#include <bits/stdc++.h> using namespace std; void read(vector<long long> &v) { for (int i = 0; i < v.size(); i++) cin >> v[i]; } void print(vector<long long> v) { for (int i = 0; i < v.size(); i++) cout << v[i] << ; } long long n, m, a, b, temp, x, y; string str; set<string> strings; unord... |
#include <bits/stdc++.h> using namespace std; long long x, y; int n; pair<long long, long long> a[200001]; vector<long long> numbers; map<long long, int> matchs; long long matchsReverse[400001]; int increase[400001]; int decrease[400001]; long long answer[400001]; int main() { cin >> n; fo... |
#include <bits/stdc++.h> using namespace std; int pos[200000 + 10], b[200000 + 10]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; if (x) { pos[x] = 0; } } for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238460; using namespace std; const int N = 200200; vector<int> g[N]; int w[N], vis[N], done[N]; int can_back[N]; int n, m, s; long long maximum = 0; void dfs(int u, int par) { vis[u] = 1; for (auto v : g[u]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> adjL(N, -1); for (int n = 0; n < N; n++) { cin >> adjL[n]; adjL[n]--; } bool c = false; for (int i = 0; i < N; i++) { int node = i; for (int x = 0; x < 3; x++) { if (ad... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; int n, ri[N]; char s[N]; struct node { int ch[26], par, val; } t[N]; int sz = 1, root = 1, last = 1; void extend(int c) { int p = last, np = ++sz; t[np].val = t[p].val + 1; ri[np]++; for (; p && !t[p].ch[c]; p = t[p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int64_t n, m; cin >> n >> m; if (n <= m) { cout << n << endl; } else { n -= m; int64_t l = 0, r = 2e9; while (l < r) { int64_t m = (l + r) / 2; int64_t val = m * (... |
#define _USE_MATH_DEFINES #include<iostream> #include<fstream> #include<string> #include<vector> #include<utility> #include<algorithm> #include<climits> #include<set> #include<map> #include<cmath> #include<iomanip> #include<iterator> #include<queue> #include<stack> #include<cctype> #incl... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 3; const int INF = 1e9; const int MOD = 1e9 + 7; int n; int a[MAXN]; long long seg[12][4 * MAXN]; void add(int j, int l, int r, long long val, int b = 0, int e = n, int k = 0) { if (l <= b && e <= r) { seg[j][k] += val; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; 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); } const int N = 2e5 + 5; int v[N], in[N]; vector<int> e[N]; bool cmp(int a, int b) { return in[a] < in[b]; } voi... |
#include <bits/stdc++.h> int cnt[111], ans, b, d, pr[111], v[111]; int main() { scanf( %d%d , &b, &d); int k = b; for (int i = 2; k > 1; i++) { if (k % i) continue; while (k % i == 0) cnt[i]++, k /= i; } bool flag = true; k = d; for (int i = 2; k > 1; i++) { if (k % i) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool res = false; for (int i = 0; i < s.size() - 1; ++i) { if (s[i] == A && s[i + 1] == B ) { for (int j = i + 2; j < s.size() - 1; ++j) { if (s[j] == B && s[j + 1] == A ) { cout ... |
#include <bits/stdc++.h> using namespace std; int N, M; string grid[1000]; vector<vector<pair<int, char>>> startAdj; vector<bool> visited; vector<int> merged; vector<vector<pair<int, char>>> adj; vector<int> value; vector<int> greaterCount; void flood(int start, int pos) { if (visited[pos]) retu... |
#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; vector<long long> arr(n); for (long long i = 0; i < n; i++) cin >> arr[i]; long long c = 0; for (long long i = 1; i < n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.