func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, a, flag = 0; vector<int> A, B; map<int, int> store; store.clear(); scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a); if (store[a] < 2) { if (store[a] == 0) { A.push_back(a); ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 2; int n, a[N]; long long pref[N]; int get(int pos) { int lo = 0, hi = min(pos - 1, n - pos); while (hi - lo > 3) { int m1 = (lo + lo + hi) / 3; int m2 = (lo + hi + hi) / 3; long double r1 = (pref[pos] - pref[pos - m1 ... |
#include <bits/stdc++.h> using namespace std; vector<vector<pair<long long, long long>>> adj; vector<long long> d; long long n; vector<bool> mark; vector<long long> trains; void dijktras(long long s) { d[s] = 0; priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, ... |
#include <bits/stdc++.h> const long long INF = (long long)1e9 + 9; const long long maxn = (long long)1e9 + 6; using namespace std; signed main() { long long t; cin >> t; while (t--) { long long n, cnt = 0; cin >> n; map<string, long long> mp; vector<string> s(n), answer(n); ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b) { return gcd(b, a % b); } else return a; } int main() { long long int l, r; cin >> l >> r; if (abs(l - r) < 2) { cout << -1 << endl; return 0; } long l... |
#include <bits/stdc++.h> const int inf = 1039074182; using namespace std; int n; long long a[100005]; void fi() { cout << sjfnb n ; exit(0); } void se() { cout << cslnb n ; exit(0); } int main() { cin >> n; for (int i = 0; i < n; i++) { scanf( %I64d , a + i); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int b, p, f; int h, c; cin >> b >> p >> f >> h >> c; if (b >= p * 2 + f * 2) cout << p * h + f * c << endl; else { if (c >= h) { cout << min(b / 2, f) * c + m... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long MOD = 1000000007; long double EPS = 1e-9; mt19937 rng(chrono::steady_clock::now().time_since_epoch().coun... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <ll mod> struct ModInt { ll v; ll mod_pow(ll x, ll n) const { return (!n) ? 1 : (mod_pow((x * x) % mod, n / 2) * ((n & 1) ? x : 1)) % mod; } ModInt(ll a = 0) : v(a >= mod ? a % mod : a) {} ModInt operator+(con... |
#include <bits/stdc++.h> using namespace std; const long long T = 200002; const long long MAXD = T * T * T; int n, s; int N[T]; int PREFP[T]; int SUFL[T]; int main(void) { cin >> n; for (int i = (int)1; i <= (int)n; i++) { cin >> N[i]; } for (int i = (int)1; i <= (int)n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 1e6 + 1; const long long PRIME = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } void solve() { long long n; cin >> n; string s; bool flag = 1; cin >> s; long ... |
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) ans = ans * 2 + (s[i] == 4 ? 1 : 2); cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int inf = 0x3c3c3c3c; const long long infl = 0x3c3c3c3c3c3c3c3c; const int MAX_N = 2e5 + 9; const ll MAX_R = 2 * 1e15 + 9; int a[MAX_N]; int px[MAX_N], py[MAX_N]; int main() { cin.tie(NULL); cin... |
#include <bits/stdc++.h> using namespace std; long l[101][101], n, i, j; int main() { cin >> n; int x1, y1, x2, y2; while (n--) { cin >> x1 >> y1 >> x2 >> y2; for (i = x1; i <= x2; i++) for (j = y1; j <= y2; j++) l[i][j]++; } long long res = 0; for (i = 1; i <= 100; i++... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N], x[N << 1], y[N << 1]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); int cnt = 0; stack<int> st1, st2; bool flag = 1; for (int i = n; i >= 1; --i) { if (a[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { long long xa, ya; long long xb, yb; long long xc, yc; cin >> xa >> ya >> xb >> yb >> xc >> yc; long long x = xa; long long y = ya; long long X = xb; long long Y = yb; for (int i = 0; i < 4; ++i) { if (i == 0) { ... |
#include <bits/stdc++.h> using namespace std; int mx[4005], S[4005]; int n, l[4005], r[4005], a[4005]; bool inter(int i, int j) { if (l[i] >= l[j] && l[i] <= r[j]) return 1; if (r[i] >= l[j] && r[i] <= r[j]) return 1; if (l[j] >= l[i] && l[j] <= r[i]) return 1; if (r[j] >= l[i] && r[j] <= r[i]) ... |
#include<bits/stdc++.h> #define ll long long using namespace std; ll t1,n,a[500010],mn[500010][2],f[2],sum[2],z[2]; int main(){ ll i,j,op,flag; scanf( %lld ,&t1); while(t1--){ scanf( %lld ,&n); for(i=1;i<=n;i++)scanf( %lld ,&a[i]); mn[n+1][0]=mn[n+1][1]=1e18; for(i=n;i;i--){ mn[i][... |
#include <bits/stdc++.h> using namespace std; const int N = 310; long long xh, yh, xu, yu; int n; long long a[N], b[N], c[N]; int main() { scanf( %I64d%I64d , &xh, &yh); scanf( %I64d%I64d , &xu, &yu); scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %I64d%I64d%I64d , a + i, b + i,... |
#include <bits/stdc++.h> using namespace std; int main() { int r, h; scanf( %d %d , &r, &h); int res = ((2.0 * h + r) / 2.0 / r); res *= 2; int res2 = 1 + 2 * (int)((((h + r) - r * 0.5 * sqrt(3.0))) / r); printf( %d , max(res, res2)); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<pair<int, int> > h; vector<int> d(n), s(n); for (int i = 0; i < n; i++) { cin >> d[i] >> s[i]; if (d[i]) { h.insert({d[i], i}); } } vector<pair<int, int> > ans; while (!h.empty()... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, i, m, s = 0, d = 0; cin >> n >> m; long long a[n], b[n], c[n]; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; s += a[i]; c[i] = a[i] - b[i]; } sort(c, c + n); for (i = 0; i < n; i++) if (s >... |
#include <bits/stdc++.h> using namespace std; struct pInfo { int idx; long long reach; pInfo(int i, long long r) { idx = i, reach = r; }; }; long long n, pos[200005], len[200005], R[200005], U[200005][19], S[200005][19], q, a, b; int main() { ios_base::sync_with_stdio(0); cin.tie(0);... |
#include <bits/stdc++.h> using namespace std; int main() { int N(0), aSum(0), bSum(0), cap(0), last(0), out(0); cin >> N; for (int i = 0; i < N; i++) { int a(0), b(0); cin >> a >> b; aSum += a; bSum += b; cap = bSum - aSum; if (cap >= out) out = cap; } cout <<... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int INF = 1e7; const long long Mod = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; a %= Mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % Mod; a = a * a % Mod... |
#include <bits/stdc++.h> using namespace std; int n, l, r, x, res = 0; vector<int> subset; void search(int k, const vector<int>& v) { if (k == n) { long long count = accumulate(subset.begin(), subset.end(), 0); if (count >= l && count <= r && (subset.back() - subset.front()) >= x) ++res;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x, y; cin >> x; int c = 1; bool ch = true; for (int i = 0; i < n - 1; i++) { cin >> y; if (y > x) { if (c != 1) ch = false; } else if (x == y) { if (c > 2) { ch = f... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> ans{1}, pr{2, 3, 5, 7, 11}; int main() { cin >> n; for (int p : pr) { if (ans.size() > n) break; for (int i = 0; i < (int)ans.size(); i++) { if (ans[i] * p <= 2 * n * n) ans.emplace_back(ans[i] * p); } } r... |
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int n,k1,k2; cin>>n>>k1>>k2; int w,b; int y1,y2; y1=n-k1; y2=n-k2; cin>>w>>b; if((min(k1,k2)+(k1+k2-2*min(k1,k2))/2)>=w && (m... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, -1, 1}; int n, m; char grid[1005][1005]; int startX, startY, endX, endY; int cost[1005][1005]; int lookDir[1005][1005]; bool vis[1005][1005]; bool isValid(int i, int j) { return i >= 0 && i < n && j >= 0 &&... |
#include <bits/stdc++.h> using std::abs; using std::cerr; using std::cin; using std::cout; using std::endl; using std::make_pair; using std::max; using std::min; using std::pair; using std::string; using std::vector; template <typename T> inline T input() { T ans; cin >> ans; retur... |
#include <bits/stdc++.h> using namespace std; const int N = 1000006; const int MOD = 1000000007; int bpow(int a, int b){ int res = 1; while(b){ if(b&1) res = 1ll*res*a%MOD; a = 1ll*a*a%MOD; b >>= 1; } return res; } int inv(int a){return bpow(a, ... |
#include <bits/stdc++.h> using namespace std; int n, k, a[200005 / 2], ans = -1, cnt = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n >> k; for (int i = 1; i <= n + 1; i++) { if (i < n + 1) cin >> a[i]; else a[i] = a[i - 1]; ... |
#include <bits/stdc++.h> using namespace std; long long pw(long long a, long long k, long long p) { if (k == 0) return 1; return (k % 2 == 0 ? pw((a * a) % p, k / 2, p) : (a * pw(a, k - 1, p)) % p); } int main() { int n; cin >> n; if (n == 1) { cout << 0 << endl; return 0; } ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100 + 5; const int mod = 1000 * 1000 * 1000 + 7; const int maxM = 400000; char a[102][102]; int c[maxN], cnt[maxN], p[maxN]; int main() { ios::sync_with_stdio(0); cin.tie(); srand(time(NULL)); int n; cin >> n; for (int ... |
#include <bits/stdc++.h> using namespace std; const int oo = int(2e9) + 9; const double eps = 1e-9; const double pi = 3.14159265358979323846264338327950; int main() { string str; cin >> str; char X[5]; int cnt[200]; cnt[ R ] = 0, cnt[ G ] = 0, cnt[ B ] = 0, cnt[ Y ] = 0; for (int i = 0... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300 * 1000 + 10; pair<int, int> c[MAX_N]; int t[MAX_N]; int main() { ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> c[i].first, c[i].second = i; se... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; struct ft_t { long long d[N], t[N]; void init() { memset(d, 0, sizeof(d)); memset(t, 0, sizeof(t)); } void put(long long x, long long k) { for (int i = x + 1; i < N; i += -i & i) d[i] ^= k; for (int i = x... |
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<int, int> > vneg, vpos; int n, a, b, neg = 0, pos = 0, sum = 0, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; if (a < 0) { neg++; vneg.push_back({a, b}); } else { pos++;... |
#include <bits/stdc++.h> using namespace std; int main() { int N, M; scanf( %d %d , &N, &M); int beat[N + 5], i; memset(beat, 0, sizeof(beat)); set<int> S; for (int i = 1; i <= N; i++) S.insert(i); int L, R, W; set<int>::iterator it; while (M--) { scanf( %d %d %d , &L, &R, ... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) const int MAXN = 7200; const int INF = 0x3f3f3f3f; bool vis[MAXN]; char s[55][55]; struct Edge { int x, y, z, nxt; } e[MAXN << 1]; int dx[5] = {0, 0, 1, -1}; int dy[5] = {1, -1, 0, 0}; int n, m, cnt, tot, ans = INF, head[MAXN], ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; inline int sgn(int x) { if (x > -eps || x < eps) return 0; if (x > 0) return 1; else return -1; } struct point { double x, y; point(double a = 0, double b = 0) { x = a; y = b; } point op... |
#include <bits/stdc++.h> const int mod = 1e9 + 7; const int N = 1010; const int inf = 0x3f3f3f3f; using namespace std; long long sum[N]; int n, a[N], b[N], v, e; int p[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } vector<int> vt[N]; bool vis[N]; struct Data { ... |
#include <bits/stdc++.h> using namespace std; long long c[110], k; int n, a[110]; int main() { c[0] = c[1] = 1LL; for (int i = 2; i < 100; i++) c[i] = c[i - 1] + c[i - 2]; scanf( %d%I64d , &n, &k); for (int i = 1; i <= n;) { if (k > c[n - i]) { k -= c[n - i]; a[i] = i + 1; ... |
#include <bits/stdc++.h> using namespace std; int s, t; int psum[100005]; vector<int> pos[2][2]; int cost[100005]; long long dp[100005]; int chosen[100005]; int mx; bool ok(int c) { dp[0] = 0; chosen[0] = 0; for (int i = (1); i <= (s); i += (1)) { dp[i] = dp[i - 1]; chosen[i] =... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops ) #pragma GCC target( avx,avx2,fma ) using namespace std; long long arr1[1000000], arr2[1000000], mp[2000000]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) cout << k << ; else cout << 0 ; } cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, a[500005]; int st[500005], num[500005], top; long long s[500005], pre[500005], suf[500005]; long long ans, pos; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { long long now =... |
#include <bits/stdc++.h> const int N = 100005; const int MOD = 1000000009; int f[N]; int find(int x) { if (x != f[x]) f[x] = find(f[x]); return f[x]; } int main() { int i, n, m, x, y, a, b, r = 0; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) f[i] = i; while (m--) { scanf( %d... |
#include <bits/stdc++.h> using namespace std; typedef struct { double d; int num; } node; node no[1005]; int cmp(node a, node b) { return a.d < b.d; } double dis(int x, int y) { return sqrt(x * x + y * y); } int main() { int n, s; scanf( %d%d , &n, &s); for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = v * 10 + c - 0 ; while (isdigit(c = getchar())) v = v * 10 + c - 0 ; x = v * f; } void r... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; long long dp[n + 3][2 * t + 3][5]; for (int i = 1; i <= 4; i++) { dp[n][2 * t - 1][i] = 1; for (int j = 0; j < 2 * t - 1; j++) { dp[n][j][i] = 0; } for (int j = 1; j <= n; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 22; const int MX = 1 << N; int n; bool has[MX]; bool vis[MX]; bool num[MX]; void bfs(int node) { vis[node] = true; queue<pair<int, int> > nd; nd.push(make_pair(node, 1)); int tt; int rem; while (!nd.empty()) { node... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d = 1440, e = 0, f = 2, g = 0, h[1001], i, j, k, p[1001]; string s, t, x; cin >> a >> b; for (i = 1; i <= a; i++) { cin >> p[i]; } sort(p + 1, p + a + 1); for (i = 1; i < a; i++) { for (j = i + 1; j... |
#include <bits/stdc++.h> using namespace std; const int NUM = 2e5 + 10; struct node { int index, q; bool operator<(const node &a) const { return index + q < a.index + a.q; } } no[NUM]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d%d , &no[i].index, &no[i].q); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n]; unordered_set<long long> st; unordered_map<long long, long long> mp; vector<long long> V; for (long long i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) { if (st.find(abs... |
#include <bits/stdc++.h> using namespace std; long long int const mod = 1e9 + 7; long long int const inf = 1e18; long long int const mxn = 2e9 + 1; inline void file() {} int main() { file(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; { long long int n, a... |
#include <bits/stdc++.h> const int inf = (1 << 29) - 1; const int maxn = (int)3e5 + 10; const int mod = (int)1e9 + 7; using namespace std; int n, m, k; vector<int> g[2020]; int col[2020][1010]; pair<int, int> e[maxn]; int ans[maxn]; void dfs(int v, int cur, int nxt) { if (col[v][cur] == 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y = 0; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char ch; cin >> ch; if (ch == * ) { x ^= i; y ^= j; } } } cout <<... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m = 1, a, t1 = 1, tong = 0; cin >> n; while (1) { tong += t1; if (tong > n) { cout << --m; return 0; } t1 += ++m; } return 0; } |
#include <bits/stdc++.h> using namespace std; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; void file() {} void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); } const int N = 2e5 + 9; int arr[N], qi[N], qs[N], qe[N]; long long qans[N], cnt; int f... |
#include <bits/stdc++.h> using namespace std; long long a[500000]; long long b[500000]; long long c[500000]; long long d[500000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, i; cin >> n; for (i = 1; i <= n; i++) { long long x; ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 3; int ToInt[4][4]; int FromIntI[6]; int FromIntJ[6]; vector<int> costs[4][4]; vector<int> g[4]; int take[6]; vector<int> cost, from, to; struct dsu { vector<int> p; dsu(int n) : p(n, -1) {} void Clear() { p.assign(p.... |
#include <bits/stdc++.h> using namespace std; int a, ta; int b, tb; int h, m; bool read() { if (!(cin >> a >> ta)) return false; assert(cin >> b >> tb); assert(scanf( %d:%d , &h, &m) == 2); return true; } void solve() { int x1 = h * 60 + m; int y1 = x1 + ta; int ans = 0; fo... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e; while (e--) { long long int A, B, C, D; cin >> A >> B >> C >> D; if (A == C) { cout << max(B, D) - min(B, D) << endl; } else { if (B <= c && D ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<long long> v; long long t, p; char c; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { p = 0ll; cin >> t >> c; p = ((p << 8) | t); cin >> t >> c; p = ((p << 8) | t); cin >> t >> c; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; bool on[N]; int n, m, x, par[N]; char c; int chk(int x) { int d = 2; if (par[x] && x != 1) return par[x]; while (d * d <= x) { if (x % d == 0) { if (par[x / d]) return par[x / d]; if (par[d]) return par[d]... |
#include <bits/stdc++.h> using namespace std; char s[5050], t[5050], goal[5050]; int cnt[200], l, l2; bool dfs(int p, bool v) { if (p == l2) { if (v) return puts(goal), 1; else return 0; } if (v) { for (int i = a ; i < z + 1; i++) if (cnt[i] > 0) { ... |
#include <bits/stdc++.h> using namespace std; static const int INF = 500000000; template <class T> void debug(T a, T b) { for (; a != b; ++a) cerr << *a << ; cerr << endl; } int n; double p[100005]; double get(int i) { if (i == -1) return 0; return p[i]; } int main() { scanf( ... |
#include <bits/stdc++.h> using namespace std; const int mx = 200100; const int md = 1000000007; bool compare(const pair<int, int>& a, const pair<int, int>& b) { return a.first < b.first || (a.first == b.first && a.second > b.second); } int main() { int n, m; map<int, int> visit; vector<int> ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-10; const long long MOD = 1e9 + 7; const long double PI = 3.1415926535897932384626433832795028841; long long powmod(long long a, long long b) { long long res = 1; a %= MOD; for (; b; b >>= 1) { if (b & 1) res = res * a ... |
#include <bits/stdc++.h> using namespace std; int t, n, i, k, j, lg, el, maxi, ok2; int ok[5010][5010]; char v[5010], sol[5010]; int main() { cin >> t; for (; t--;) { cin >> v + 1; n = strlen(v + 1); int st = 1, dr = n; while (st <= dr && v[st] == v[dr]) st++, dr--; if (s... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx2 ) using namespace std; long long one = 1; const long long INF = 1e18; const long long MOD = 1e9 + 7; const long long N = 2e5; vector<vector<long long> > c, gr; vector<long long> res; bool flag = 1; long long dfs1(long lon... |
#include <bits/stdc++.h> int a[52], b[52]; int main() { int x, max, k, n, m, i, j, c1; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } scanf( %d , &m); for (i = 0; i < m; i++) { scanf( %d , &b[i]); } max = 0; for (i = 0; i < m; i++) { for (j = 0... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[2001]; int f[2000], ok, n, px, ok2; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].first; a[i].second = i; f[a[i].first]++; if (f[a[i].first] == 2) ok++; if (f[a[i].first] == 3) ok2++; } ... |
#include <bits/stdc++.h> using namespace std; const int L = 500; const int N = 220000; const int M1 = 1e9 + 7; const int M2 = 1e9 + 9; int chd[N][26], go[N][26]; int len[N], q[N], p[N]; int s[N], dp[N], f[17][N], t[N]; char str[N], _str[N]; int st[N], en[N], wh[N], fr[N], to[N], cur[N], state[N], id... |
#include <bits/stdc++.h> using namespace std; ifstream f( dima1.in ); ofstream g( dima1.out ); int n, a[200005], b[200005], b2[200005], k, ap[200005], ap2[200005], ok, m, p, spos[200005], sol = 0; vector<int> r[200005]; vector<int> ps[200005]; int Cbin(int x) { int i, j, st = 1, dr = k, mid; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = long double; using str = string; using pi = pair<int, int>; template <class T> using V = vector<T>; template <class T, size_t SZ> using AR = array<T, SZ>; using vi = V<int>; using vb = V<bool>; using vpi = V<pi>; co... |
#include<bits/stdc++.h> #define fre(x) freopen(#x .in , r ,stdin);freopen(#x .out , w ,stdout) #define ll long long 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(); re... |
#include <bits/stdc++.h> using namespace std; int n, k; int d[100015]; char baca[100015]; int main() { scanf( %d %d , &n, &k); scanf( %s , baca); for (int i = (int)1; i <= (int)n; ++i) d[i] = (int)(baca[i - 1] - 0 ); d[0] = d[n + 1] = 0; for (int i = (int)1; i <= (int)n; ++i) { if (... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; int v[N], c[N]; int n, k; vector<int> z; void input() { scanf( %d %d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &v[i]); for (int i = 1; i <= n; i++) scanf( %d , &c[i]); z.push_back(min(100 * v[n], c[n])); for (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<int> v(n, 0); for (int i = 0; i < n; i++) { cin >> v[i]; } m--; int p = -1; for (int i = m + 1; i < n; i++) { if (v[i] != 0 && v[i] <= k) { if (p == -1 || abs(m - i)... |
#include <bits/stdc++.h> using namespace std; int a; int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } void solve() { int temp, sum = 0, m, i; for (i = 2; i < a; i++) { temp = a; while (temp) { sum += temp % i; temp = temp / i; ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long res1, res2, f[5][5]; string s; int main() { std::ios::sync_with_stdio(false); cin >> s; n = s.size(); for (int i = 0; i < (n); i++) { f[s[i] - a ][i % 2]++; res1 += f[s[i] - a ][1 - (i % 2)]; res2 += f[s[i] -... |
#include <bits/stdc++.h> using namespace std; const int mxn = 3e5 + 5; const long long MOD = 1e9 + 7; const int BASE = 100000000; const int INF = 1e9 + 8; long long g[mxn], cnt[mxn], a[mxn]; void up_g(int x, const long long &val) { while (x < mxn) { g[x] += val; x += x & (-x); } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; cin >> n >> m; for (i = 1; i <= n; i++) { for (j = 0; j < m; j++) { if (i % 4 == 0) { if (j == 0) cout << # ; else cout << . ; } else if (i % 4 == 2) { ... |
#include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <iostream> #include <set> #include <map> #include <vector> #include <string> #include <cmath> #include <queue> #include <stack> #include <unordered_set> #include <unordered_map> #... |
#include <bits/stdc++.h> int main() { int c, input[100010]; int i = -1, j, k; while ((c = getchar()) != n ) { if (i < 0 || input[i] != c) input[++i] = c; else i--; } if (i < 0) printf( Yes n ); else printf( No n ); return 0; } |
#include <bits/stdc++.h> using namespace std; const int SIZE = 1 << 10; int pointer = SIZE; char buffer[SIZE]; char Advance() { if (pointer == SIZE) { fread(buffer, 1, SIZE, stdin); pointer = 0; } return buffer[pointer++]; } int Read() { int answer = 0; char ch = Advance();... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[200010], b[200010]; int nxt[200010]; void make_next() { int i = 0, j = -1; nxt[0] = -1; while (i < m) { if (j == -1 || b[i] == b[j]) { i++; j++; if (b[i] == b[j]) nxt[i] = nxt[j]; else ... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 1e5 + 5; long long n, m, s; vector<pair<long long, long long> > bug; vector<pair<long long, long long> > stud; vector<long long> pass; long long allot[SIZE]; struct cmp { bool operator()(pair<long long, long long> const& lhs, ... |
#include <bits/stdc++.h> using namespace std; int mat[100001], mat2[100001]; long long k, suma, a, b, s, c; int n; map<int, int> mapa; long long ct; int main() { cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> mat[i]; mapa[mat[i]]++; } sort(mat, mat + n); suma = 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxm = 1e5 + 5; vector<int> g[maxm]; int n, q; int sz[maxm]; int d[maxm]; int f[maxm][25]; const int maxd = 20; void dfs(int x, int fa) { sz[x] = 1; for (int j = 1; j <= maxd; j++) { f[x][j] = f[f[x][j - 1]][j - 1]; } for (i... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) const double PI = acos(-1); template <class A, class B> std::ostream& operator<<(std::ostream& st, const std::pair<A, B> p) { st << ( << p.first << , << p.second << ) ; return st; } using namespace std; const int MAX = 100 * 1000 + 10; mt... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( no-stack-protector ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native ) #pragma GCC optimize( fast-math ) const long long N = 1e6 + 5; const long doubl... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, *a, *b, times, i, day; while (cin >> n >> m) { a = new int[m]; b = new int[m]; times = 1; for (i = 0; i < m; i++) cin >> a[i] >> b[i]; for (i = 0; i < m - 1; i++) { if (b[i] != a[i + 1] - 1) break; ... |
#include <bits/stdc++.h> const int a[] = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 8... |
#include <bits/stdc++.h> using namespace std; int main() { int n; char m[11], digit[10] = { 0 }, digitcount(0); scanf( %d%s , &n, &m); while (n != 0) { digit[digitcount++] = 0 + n % 10; n /= 10; } sort(digit, digit + digitcount); if (digit[0] == 0 ) { for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1000 + 10; int n, flag, a[maxN], i, j, m; int main() { cin >> n; for (i = 2; i <= n; i++) { for (j = 2; j * j <= i; j++) { if (i != j && i % j == 0) flag = 1; } j = i; while (flag == 0 && j <= n) { a[m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.