func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); char ch[105][105], ss[105][105]; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> ch[i]; } for (int i = 0; i < n; i++) { string s = ch[i], gu; if (i... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e9 + 7, N1 = 1e7 + 5, N2 = 1e6 + 3, N3 = 1e5 + 3; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; } void solve() { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 12 | 5, Q = 1 << 16 | 5; int n, q, B, a[N], p[N], cnt, id[Q]; vector<pair<int, int>> opt; struct node { int n; vector<int> pos; vector<vector<int>> id; node(int _n = 0) { n = _n; pos.resize(n); id.resize(n); ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, o = 0, e = 0; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; ++i) { cin >> a[i]; } for (long long i = 0; i < n; ++i) { if (a[i] % 2 != i % 2) { if (a[i] % 2 == 0) e++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 18; bool a[N]; vector<int> res; int x, n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin >> n >> x; res.push_back(0); a[0] = true; for (int i = 1; i <= int((1 << n) - 1); i++) { ... |
#include <bits/stdc++.h> using namespace std; vector<long long> adj[100005]; long long sn[100005], an[100005], level[100005]; long long got = 1; void dfs(long long u, long long par, long long carry) { if (sn[u] != -1 && sn[u] < carry) got = 0; level[u] = level[par] + 1; if (sn[u] != -1) { an... |
#include <bits/stdc++.h> using namespace std; class Graph { vector<int>* adjList; vector<bool> init; vector<bool> goal; bool* visited; int n; vector<int> operate; public: Graph(int n) { adjList = new vector<int>[n]; visited = new bool[n](); this->n = n; } ... |
#include <bits/stdc++.h> using namespace std; int countdigits(int n) { int i, b = 0; while (n) { b++; n = n / 10; } return b; } int main() { int t, i, n, x, cnt = 0; cin >> t; for (i = 0; i < t; i++) { cin >> n; cnt = countdigits(n); n = n % 10; if... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { static char _c; static bool _f; x = 0; _f = 0; _c = getchar(); while (_c < 0 || 9 < _c) { if (_c == - ) _f = true; _c = getchar(); } while ( 0 <= _c && _c <= 9 ) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, a, b; int used[100005], d[100005]; vector<int> g[100005]; void bfs(int node) { memset(used, 0, sizeof(used)); memset(d, 0, sizeof(d)); queue<int> q; q.push(node); used[node] = 1; while (!q.empty()) { int cur = q.front(); ... |
#include <bits/stdc++.h> using namespace std; struct targ { long long x, r; int id, s; } tar[10004]; bool _x(targ a, targ b) { return a.x < b.x; } bool _id(targ a, targ b) { return a.id < b.id; } int fd(int l, int r, long long x) { if (l == r) return l; int m = l + r >> 1; if (tar[m].x <... |
#include <bits/stdc++.h> using namespace std; long long f[2][1000005]; long long h[1000005]; int n; int main() { scanf( %d , &n); for (int i = (0); i < (n); i++) scanf( %lld , h + i); long long res = 0; for (int i = (1); i < (n + 1); i++) { long long mx = h[i - 1] - 1; f[1][i] = h[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, mod = 998244353; int add(int a, int b) { a += b; if (a >= mod) { a -= mod; } return a; } int sub(int a, int b) { a -= b; if (a < 0) { a += mod; } return a; } int mul(long long a, int b) { retu... |
#include <bits/stdc++.h> using namespace std; const int sz = 1e5 + 10, mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, i, j; long long k, cost = 0; string s; cin >> n >> k >> s; int last[n + 1][26]; long long dp[n][n + 1], f[n + 1]; memset(last, -1,... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; cin >> n >> m >> a >> b; if (m * a <= b) cout << n * a << n ; else cout << (n / m) * b + min((n % m) * a, b) << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, d, m, A[101]; while (cin >> n >> d) { int sum = 0; for (int i = 0; i < n; i++) { cin >> A[i]; } cin >> m; sort(A, A + n); if (m > n) { for (int i = 0; i < n; i++) { sum += A[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int res[100000]; memset(res, -1, sizeof(res)); cin >> n; vector<pair<pair<long long, long long>, int> > v; for (int(i) = 0; (i) < (n); (i)++) { long long x, r; cin >> x >> r; v.push_back(pair<pair<long long, ... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793238463; int x[1009], y[1009], t[1009]; double p[1009]; double dp[1009][1009]; int n; double sol(int i, int prev) { if (i == n) return 0; if (dp[i][prev] == dp[i][prev]) return dp[i][prev]; bool can = true; if ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100005; int cnt[MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> vec(n); for (int i = 0; i < (int)(n); ++i) { cin >> vec[i]; } int m1 = -1, m2 = -2; int id1 = -1, i... |
#include <bits/stdc++.h> using namespace std; struct data1 { long long sum, index, position; }; bool comp(data1 a, data1 b) { return a.sum < b.sum; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); long long k; cin >> k; vector<data1> arr; long lo... |
#include <bits/stdc++.h> using namespace std; bool f[200000] = {0}; string ans, s; multiset<int> g[66000]; int n, in[66000] = {0}, out[66000] = {0}, kol1 = 0, kol2 = 0, start = 0; void dfs(int v) { while (!g[v].empty()) { int tmp = *g[v].begin(); g[v].erase(g[v].begin()); dfs(tmp); ... |
#include <bits/stdc++.h> using namespace std; void solve() { string s, a = , b; cin >> s; unordered_map<string, int> m; m[s]++; for (int i = s.length() - 1; i >= 0; i--) { a += s[i]; b = a; reverse(b.begin(), b.end()); m[b + s.substr(0, i)]++; } cout << m.size()... |
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; int k = 0; if (n == 1 || n == 2) cout << -1; else if (n == 3) cout << 210; else for (int i = 4; i <= n; i++) { k++; if (k == 7) k = 1; } if (k == 1) { cout << 1; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; int minn[MAX], maxx[MAX], h[MAX]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> h[i]; int block = 1; minn[1] = h[1]; maxx[1] = h[1]; for (int i = 2; i <= n; ++i) { if (maxx[block] <= h[i]... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, SQRT = 550, Q = 100005; struct Query { int l, r, id; Query() {} Query(int l, int r, int id) : l(l), r(r), id(id) {} bool operator<(const Query& q) const { if (l / SQRT != q.l / SQRT) return l / SQRT < q.l / SQRT; retur... |
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; reverse(n.begin(), n.end()); int k = n[0] + 10 * n[1]; if (k % 4 == 0) { cout << 4 << endl; } else { cout << 0 << endl; } } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; ; vector<int> v(n); long long x = 0; for (int i = 0; i < n; i++) { char x; cin >> x; if ((x - 0 ) % 2 == 0) { v.push_back(i + 1); } } for (int i = 0; i < v.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int P[N], ar[N]; long long c[N]; vector<int> v[N]; bool used[N]; void init() { P[1] = 1; int i, j; for (i = 1; i < N; ++i) for (j = (i * 2); j < N; j += i) P[j] -= P[i]; } int main() { int tt, q, x, n, i, j; ... |
#include <bits/stdc++.h> using namespace std; void debug() {} int const N = 1e3 + 9, OO = 1e9; int main() { int n, q, type, a; char b; bool prd = 0; scanf( %d , &n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { scanf( %c , &b); if (j == i && b == 1 ) pr... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)1e6 + 10; int mod = (int)1e9 + 7; int sum(int a, int b) { int s = a + b; if (s >= mod) s -= mod; return s; } int n; int mult(int a, int b) { return (1LL * a * b) % mod; } int a[maxN]; int inv[maxN]; int fact; void calc... |
#include <bits/stdc++.h> using namespace std; clock_t timeStart, timeFinish; void timeBegin() { timeStart = clock(); } void timeEnd() { timeFinish = clock(); } void timeDuration() { timeEnd(); double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC); cout << Time taken by progr... |
#include <bits/stdc++.h> using namespace std; using lint = long long; int main(void) { lint Q, N; cin >> Q; vector<lint> ans(Q); for (int i = 0; i < Q; i++) { cin >> N; lint sum = 0; for (int k = 0; k < N; k++) { int x; cin >> x; sum += x; } an... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX_N = 1e3 + 9; int par[MAX_N], rankv[MAX_N]; vector<pair<int, int>> cycles; vector<array<int, 4>> ans; void init(int n) { for (int i = 1; i <= n; i++) par[i] = i, rankv[i] = 1; } int find_set(int u) { if (par[u] ==... |
#include <bits/stdc++.h> using namespace std; int N; long long arr[100020]; long long prefix[100020]; multiset<long long> s; set<int> ded; long long range(int i, int j) { if (i == 0) { return prefix[j]; } else { return prefix[j] - prefix[i - 1]; } } int32_t main() { ios_bas... |
#include <bits/stdc++.h> using namespace std; int n, m; string s; int main() { cin >> n >> m >> s; if (m - 1 < n - m) { while (m > 1) { cout << LEFT n ; --m; } for (int i = 0; i < (int)(n); i++) { cout << PRINT << s[i] << n ; if (i != n - 1) cout <... |
#include <bits/stdc++.h> using namespace std; int main() { int cnt = 0; bool flag = true; int low = -2000000000, high = 2000000000; bool lset = false; bool hset = false; cin >> cnt; for (int i = 1; i <= cnt; i++) { string str1, str2, str3; cin >> str1 >> str2 >> str3; s... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; long long n, x, y, nr; long long cx, cy; int ans[2000002]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> x >> y; int xx = 0; while (xx <= x + y) { long long pa =... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int MAX = 1e9 + 5; int i, j, w1, w2, k, n, m, a[N], b[N], calca[N], calcb[N], temp; vector<pair<int, int> > ans, adasd; bool ctr(int s) { int set = 0; int p1 = 0; int p2 = 0; int last1 = 0; int last2 = 0; int ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, k, l, maxx, minn, c = 1, c2 = 0, cnt = 0, a1 = 0, a2 = 0; cin >> n; long long a[n], b[n]; cnt = n; for (i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); maxx = b[n - 1]; minn... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int q[N]; int n; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n; for (int i = 1; i <= n; i++) cin >> q[i]; if (n & 1) { cout << YES << n ; cout << n - 1 << n ... |
#include <bits/stdc++.h> using namespace std; bool mayorigual(const string &s, int i, int ifin, int j, int jfin) { if (ifin - i > jfin - j) return true; if (ifin - i < jfin - j) return false; int len = ifin - i; for (int k = 0; k < len; k++) { if (s[k + i] > s[k + j]) return true; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 131072, P = 998244353, inv2 = (P + 1) / 2; int n, m, ans, a[maxn], b[maxn], fact[maxn], finv[maxn]; int lim, l, r[maxn], w[maxn]; vector<int> V; vector<int> f[maxn << 2][2][2]; int qp(int x, int y) { int z = 1; for (; y; y >>= 1, x = 1... |
#include <bits/stdc++.h> using namespace std; int n, k; int arr[200005]; int brr[200005]; priority_queue<int, vector<int>, greater<int> > q; stack<int> s; int vis[200005]; int main() { while (cin >> n >> k) { while (!q.empty()) q.pop(); while (!s.empty()) s.pop(); memset(vis, 0, si... |
#include <bits/stdc++.h> using namespace std; long long f[50]; int main() { int n; cin >> f[0] >> f[1] >> n; for (int i = 2; i <= n; i++) f[i] = f[i - 1] + f[i - 2]; cout << f[n]; return 0; } |
#include <bits/stdc++.h> using namespace std; char ans[444444], a[444444]; long long h1[444444], h2[444444], p[444444]; int d1, d2, n; bool check(int i, int e) { if (i > n) return e; int s = e ? a : a[i]; for (char x = s; x <= z ; ++x) { h1[i] = h1[i - 1] * 241 + x; h2[i] = h2[i - 1... |
#include <bits/stdc++.h> using namespace std; string s; char zh[125], ch, sw; int n, m; int main() { cin >> n >> m >> s; for (int i = 97; i <= 122; i += 1) { zh[i] = i; } for (int i = 1; i <= m; i += 1) { cin >> ch >> sw; for (int j = 97; j <= 122; j += 1) { if (zh[j]... |
#include <bits/stdc++.h> using namespace std; long long n, res, dpa[4005][4005], s[4005], c[4005][4005]; long long combo(long long x, long long y) { if (c[x][y] != 0) return c[x][y]; if (y == 0 || x == y) return c[x][y] = 1; if (x == 0 || x < y) return 0; return c[x][y] = (combo(x - 1, y - 1) + co... |
#include <bits/stdc++.h> using namespace std; vector<pair<string, long long> > Name(1010); long long n; vector<vector<pair<string, long long> > > a(1010); map<string, long long> already; map<string, long long>::iterator ii; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; l... |
#include <bits/stdc++.h> using namespace std; int n; int dat[100000 + 10]; int vis[100000 + 10]; int dfs(int x) { vis[x] = 1; if (vis[dat[x]] == 0) return dfs(dat[x]) + 1; return 1; } int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> dat... |
#include <bits/stdc++.h> using namespace std; const int maxx = (int)1e7; long long SOD(long long n) { long long ans = 0; while (n) { ans += (n % 10); n /= 10; } return ans; } int main() { int T; cin >> T; while (T--) { vector<int> num; long long n, s, nnn; ... |
#include <bits/stdc++.h> using namespace std; const int mx = 100100; int n, m, k; int a[mx]; int pos[mx]; int main() { ios::sync_with_stdio(0); cin >> n >> m >> k; long long ans = 0; for (int i = 1; i <= k; i++) { cin >> a[i]; pos[a[i]] = i; } while (n--) { for (int... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, t; cin >> n >> t; long long int i, a, c, ans, k = 0, f = 0; for (i = 0; i < n; i++) { cin >> a; c = 86400 - a; if (a == 0) { c = 86400; } k += c; if (k >= t && f == 0) { an... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e6; int st[MX * 4], la[MX * 4], tin[MX], tout[MX], t, n; vector<int> chd[MX]; void dfs(int u) { tin[u] = ++t; for (auto c : chd[u]) { dfs(c); } tout[u] = t; } void push(int v) { st[v * 2] += la[v]; la[v * 2] += la[... |
#include <bits/stdc++.h> using namespace std; int maxPrime[10000005]; long long cnt_prime[10000005]; int primes[10000005]; int cnt_p; void init() { for (int i = 2; i < 10000005; i += 2) maxPrime[i] = 2; for (int i = 3; i * i < 10000005; i += 2) { if (maxPrime[i] == i || maxPrime[i] == 0) { ... |
#include <bits/stdc++.h> using namespace std; long long DP[1000000]; long long counter[1000000]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; counter[x]++; } DP[0] = 0; DP[1] = counter[1]; for (int i = 0; i < 1000000; i++) { DP[... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } const long long maxn = 100; long long mas[maxn], mas2[maxn]; vector<pair<long long, long long> > cur; vector<pair<long long, long long> > ans[maxn]; void split... |
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } signed long long GETi() { signed long long i; scanf( %lld , &i); return i; } int N, A[100001]; void solve() { int f, i, j, k, l, x, y; cin >> ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g; vector<int> vis, d; void dfs(int v, int c) { d[v] = c; vis[v] = true; for (int u : g[v]) { if (!vis[u]) dfs(u, c + 1); } } void solve() { int n, m; cin >> n >> m; g.resize(n + 1, vector<int>()); vis.re... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; int n, m; pair<int, pair<int, int> > a[100010]; pair<int, int> g[100010]; int r[100010]; void solve() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i].first >> a[i].second.first; a[i].sec... |
#include <bits/stdc++.h> #define endl n #define fi first #define se second #define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k)) #define forn(i,n) for (int i = 0; i < int(n); i++) #define forr(i,a,b) for (int i = a; i <= b; i++) #define all(v) v.begin(), v.end() #define pb push_back using namespace... |
#include <bits/stdc++.h> using namespace std; long long l; long long calc(long long a, long long b, long long c) { long long sum = b + c; long long t = max(a, sum); long long ret = 0; while (t - a + sum - (b + c) <= l) { long long rem = l - (t - a + sum - (b + c)); ret += (rem + 1) * (... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; string s1; cin >> s >> s1; map<char, int> m; m.insert(make_pair( a , 1)); m.insert(make_pair( b , 2)); m.insert(make_pair( c , 3)); m.insert(make_pair( d , 4)... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long double EPS = 1e-11; const long long INFL = 1e16; const int INF = 2e9 + 7; mt19937 rnd((unsigned)chrono::steady_clock::now().time_since_epoch().count()); void add(long long& a, long long b) { a += b; while (a... |
#include <bits/stdc++.h> using namespace std; const long long rev_6 = 166666668ll; const long long rev_2 = 500000004ll; const long long MOD = 1000000007ll; long long pow(long long A, long long n) { long long r = 1ll; while (n) { if (n & 1ll) r = r * A % MOD; A = A * A % MOD; n >>= 1;... |
#include <bits/stdc++.h> using namespace std; int mod = 998244353; const int M = 1e6 + 10; const int N = 3e5 + 10; inline long long read() { long long b = 1, sum = 0; char c = getchar(); while (!isdigit(c)) { if (c == - ) b = -1; c = getchar(); } while (isdigit(c)) { sum... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const int MAXT = 2e5 + 10; long long a[MAXN]; long long cnt[MAXN]; long long ans[MAXT]; int L, R; long long res; struct node { int l, r, bid, id; bool operator<(const node &other) const { if (other.bid == bid) return... |
#include <bits/stdc++.h> using namespace std; const long double E = 2.71828182845904523536; const long double pi = acos(-1); const double eps = 1e-9; const long long mod = 1e9 + 7; const long long inf = 1LL << 30; long long a[400], b[400], n, x; map<long long, long long> mem[301]; long long gcd(long l... |
#include <bits/stdc++.h> using namespace std; char a[100100]; char b[100100]; int na, nb; int main() { cin >> a >> b; na = 0; nb = 0; for (int i = 0; a[i]; i++) if (a[i] == 1 ) na++; for (int i = 0; b[i]; i++) if (b[i] == 1 ) nb++; if (na % 2) na++; if (na >= nb) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, m, k; cin >> t; for (int i = 1; i <= t; i++) { cin >> n >> m >> k; if (m < n - 1 || m > n * (n - 1) / 2) { puts( No ); continue; } if (n == 1) { if (k > 1) puts( Yes ); ... |
#include <bits/stdc++.h> uint32_t readu32() { int c; while ((c = getchar()) < 0 ) ; uint32_t n = c & 15U; while ((c = getchar()) >= 0 ) n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while ((c = getchar()) < 0 ) ; uint64_t n = c & 15U; while ((c ... |
#include <bits/stdc++.h> using namespace std; long long n, a, b, dp[300][300]; long long s; vector<pair<long long, long long> > v; long long r, tr; long long gs(long long a, long long b, long long c) { long long s = 0; s = (v[b].first - v[a].first) * (v[c].second - v[a].second) - (v[b].secon... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y) { long long res = 1; while (y > 0) { if (y & 1) res = (res * x) % 998244353; y = y / 2; if (y != 0) x = (x * x) % 998244353; } return res; } int main() { ios_base::sync_with_stdio(false)... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100 * 1000 + 10, Max = 17; int n, m, k, moal[Maxn], st[Maxn], par[Maxn], stt = 1, lca[Max][Maxn], h[Maxn], cnt; vector<int> adj[Maxn], ind[Maxn], adj2[Maxn]; struct edge { int u, v; } e[Maxn]; ... |
#include <bits/stdc++.h> using namespace std; int n, l, k, a[200], p[200]; double memo[200][201][201]; bool seen[200][201][201]; double solve(int idx, int kk, int ll) { if (kk < 0) { return 0; } if (idx == n) { return ll >= l; } if (seen[idx][kk][ll]) { return memo[idx][k... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; bool ok = true; set<char> vowel; vowel.insert( a ); vowel.insert( e ); vowel.insert( i ); vowel.insert( o ); vowel.insert(... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v, v1; char a[8][8]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) cin >> a[i][j]; for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { if (a[i][j] == B ) { int b = 0; bool ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3fll; const long double pi = acos(-1); const int MOD = 1e9 + 7; int v[250]; void calc() { double media = 0; for (int i = 0; i < 250; i++) media += v[i]; media /= 250.0; doub... |
#include <bits/stdc++.h> using namespace std; struct greater { template <class T> bool operator()(T const &a, T const &b) const { return a > b; } }; unsigned long long subV(unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long l) { i... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 998244353; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; inline void sum(int &a, int b) { a += b; if (a >= mod) a -= mod; } const int NN = 1000100; char A[NN], L[NN], R[NN]; ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-8; const long double PI = 3.1415926535897932384626433832795; const long double E = 2.7182818284; const int INF = 1000000000; const int inf = 100000; int main(void) { int n, m, i, j; char c; scanf( %d%d , &n, &m); char... |
#include <bits/stdc++.h> using namespace std; const long long N = 200000 + 5; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long n, ma, sum, gc, a[N]; signed main() { scanf( %lld , &n); for (long long i = 1; i <= n; i++) { scanf( %lld , &a... |
#include <bits/stdc++.h> using namespace std; map<long long int, vector<pair<long long int, long long int> > > mapp; bool cmp(pair<long long int, long long int> &p1, pair<long long int, long long int> &p2) { if (p1.second != p2.second) return p1.second < p2.second; return p1.first < p2.first; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, h, k, i, j, a[100100], pkp = 0, tmp, p, ans = 0; double d; scanf( %lld %lld %lld , &n, &h, &k); for (i = 0; i < n; i++) scanf( %lld , &a[i]); for (i = 0; i < n; i++) { if (pkp + a[i] <= h) { pkp += a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k, num, count = 0, i, j; cin >> n >> k; bitset<32> b[6]; for (i = 1; i < 3; i++) { for (j = i + 1; j <= 3; j++) { cout << or << i << << ... |
#include <bits/stdc++.h> using namespace std; const int maxk = 999 + 5; int a[maxk]; vector<int> vec; int main() { int n, k, p, x, y; scanf( %d%d%d%d%d , &n, &k, &p, &x, &y); for (int i = 0; i < k; i++) scanf( %d , a + i); if (y > p) { printf( -1 n ); return 0; } sort(a, a ... |
#include <bits/stdc++.h> using namespace std; struct point { point() : x(0), y(0){}; point(long long x, long long y) : x(x), y(y){}; long long x; long long y; }; 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... |
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 5; const int mod = (int)1e9 + 7; const int logN = 17; const int inf = 1e9; const int N = 2e5 + 5; int main() { int n, t; vector<pair<int, int> > ans; scanf( %d , &n); queue<int> q; for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; int n, q, a[maxn], bit[maxn][22] = {0}, pos[maxn][22] = {0}; int main() { int i, j, l, r; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; l = i, r = a[... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class T> inline void RST(T &A) { memset(A, 0, sizeof(A)); } template <class T> inline void FLC(T &A, int x) { memset(A, x, sizeof(A)); } template <class T> inline void CLR(T &A) { A.clear(); } const in... |
#include <bits/stdc++.h> using namespace std; template <class T> inline string itos(T n) { return (n) < 0 ? - + itos(-(n)) : (n) < 10 ? (string)( ) + (char)( 0 + (n)) : itos((n) / 10) + itos((n) % 10); } string name[60]; map<string, int> mp; int point[60], _plus... |
#include <bits/stdc++.h> using namespace std; int main() { int ar[105] = {0}; int n; int r; cin >> n; int tc = n, a; while (tc--) { cin >> r; for (int i = 0; i < r; i++) { cin >> a; ar[a]++; } } for (int i = 1; i <= 100; i++) if (ar[i] == n) co... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int T; cin >> T; while (T--) { int n; int number[200005], dis[10] = {0}; char c; cin >> n; for (int a = 1; a <= n; a++) { cin >> c; number[a] = c - 0 ; dis[numbe... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; int px[105], py[105]; int main() { int x, y, Sz, d, z; bool f = 0; string s; cin >> x >> y >> s; Sz = s.size(); px[0] = py[0] = 0; for (int i = 0; i < Sz; i++) { if (s[i] == U )... |
#include <bits/stdc++.h> using namespace std; void hehe() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.rbegin(), arr.rend()); vector<long long int> rem; for (int i = 0; i < n - 1; i++) { if (arr[i] - arr[i + 1] < 2) { ... |
#include <bits/stdc++.h> using namespace std; long long n, k, cnt; int A[10]; long long FE(long long n, long long m) { if (!m) return 1; long long t = FE(n, m >> 1); t = (t * t) % (1000000007); if (m & 1) t = (t * n) % (1000000007); return t % (1000000007); } bool ctrl() { bool H[10]... |
#include <bits/stdc++.h> using namespace std; long long int i, t = 1, j, temp; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long t = 1; while (t--) { long long int n, k = 0; cin >> n; long long int a[n]; map<int, long long int> m; ... |
#include <bits/stdc++.h> using namespace std; int n; string transo(int n) { switch (n) { case 0: return zero ; break; case 1: return one ; break; case 2: return two ; break; case 3: return three ; break; case 4: ... |
#include <bits/stdc++.h> using namespace std; long long ts, tf, t, n, x, ans, lim = 1000000000007; int main() { cin >> ts >> tf >> t; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (x <= tf - t) { if (max(ts, x - 1) <= tf - t && ts - (x - 1) < lim) { lim = ts - (x -... |
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); if (n == 1 || n == 2 || n == 4) { printf( -1 n ); continue; } if (!(n % 3)) printf( %d %d %d n , (n / 3), 0, 0); else if (n % 3 == 1) prin... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); long long n, h, a, b, k; cin >> n >> k >> a >> b >> k; while (k--) { long long tower1, tower2, source, destination; cin >> tower1 >> source >> tower2 >> destination; long long ans = 0;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.