func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m, ans; int x[100010], y[100010]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &x[i]); } for (int i = 1; i <= m; i++) { scanf( %d , &y[i]); } long long sum1 = 0, sum2 = 0; for (int r1 =... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; char ch; int arr[5001], brr[5001], mdays[5001], fdays[5001]; cin >> n; for (int i = 1; i <= n; i++) { cin >> ch >> arr[i] >> brr[i]; if (ch == M ) { for (int j = arr[i]; j <= brr[i]; j++) mdays[j]++; ... |
#include <bits/stdc++.h> using namespace std; const int sq = (int)sqrt((int)1e6); const int maxnb = (int)1e9 + 7; const double pi = acos(-1.0); const int maxnl = 100500; const double eps = 1e-9; set<pair<long long, int> > se; int n, pos[50500]; char c[50500]; long long price; string s; int main(... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; string s; int n, len; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> s; len = s.size(); for (int i = 0; i < len; i++) if (s[i] == a ) n++; if (len / 2 < n) { c... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, ans(0); bool flg = true; cin >> n >> m >> k; int ar[n * m]; for (int a = 0; a < n * m; a++) cin >> ar[a]; sort(ar, ar + n * m); int median = (n * m % 2) ? ar[n * m / 2] : ar[(n * m + 1) / 2]; for (int a = 0; a < ... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); int a[5005], ans = 1, max = 0; for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 1; i < n; i++) for (int j = 0; j < n - i; j++) if (a[j] > a[j + 1]) { int t = a[j]; a[j] = a[j + 1]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<string> a(n + 1), b(n + 1); vector<int> c(n + 1); vector<long long> f1(n + 1), f2(n + 1); for (int i = 1; i <= n; ++i) { cin >> c[i]; } for (int i = 1; i <= n; +... |
#include <bits/stdc++.h> using namespace std; const int NN = 1010; const int MM = 101010; struct Node { int id; int x, y; } Q[MM]; int a[NN][NN]; vector<int> adj[MM]; int ans[MM], f[MM]; int n, m, k; void dfs(int u, int fa = 0, int crr = 0) { if (Q[u].id == 1) { int x = Q[u].x, y =... |
#include <bits/stdc++.h> using namespace std; int n, m, q; vector<int> gr[300001]; int par[300001], comp[300001]; int mx[300001][2]; int dfs(int s, int k) { comp[s] = k; mx[s][0] = mx[s][1] = 0; for (int i = 0; i < gr[s].size(); i++) { if (comp[gr[s][i]] == -1) { int p = dfs(gr[s][... |
#include <bits/stdc++.h> const int p = 1000000007; int c[12][15], e[12][15], g[12][5000], h[12][5000]; int edge1[3000], next1[3000], first1[3000], deg1[3000], sum_edge1; int edge2[30], next2[30], first2[30], deg2[30], sum_edge2; int i, n1, n2, r, s, t, x, y; inline int power(int x, int y) { int s = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i, n, d, e; cin >> n >> d >> e; e *= 5; int min = n % e; for (i = 0; i <= n / d; i++) { if ((n - (i * d)) % e < min) min = (n - (i * d)) % e; } if ((n % e) % d < ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 30; struct edge { int to, next; } G[maxn << 1]; int h[maxn], si; void add(int u, int v) { G[si].to = v; G[si].next = h[u]; h[u] = si++; } vector<int> p; void dfs(int u, int f, int d) { int is = 0; for (int i =... |
#include <bits/stdc++.h> using namespace std; int K[3]; long long T[3]; queue<long long> waiting[3]; queue<pair<long long, long long> > events[3]; long long res = 0; void ServeSomeone(long long t) { for (int i = 0; i < 3; i++) if (K[i] && !waiting[i].empty()) { K[i]--; events[i].... |
#include <bits/stdc++.h> using namespace std; int trie[64 * 100005][2], uni; inline long long int bin_to_int(vector<long long int> vt) { long long int ans = 0, hudai = 1; while (vt.size()) { ans += (hudai * vt[vt.size() - 1]); hudai *= 2; vt.pop_back(); } return ans; } inline... |
#include <bits/stdc++.h> using namespace std; int n, st, dr, mij, r, l12, l11, c12, c11; int l21, l22, c21, c22; int nr; void getldrept(int li, int ls, int ci, int cs) { int st, dr; int l1, c1, l2, c2; st = li; dr = ls; while (st < dr) { mij = (st + dr) / 2; cout << ? << li ... |
#include <bits/stdc++.h> using namespace std; int rev(int a) { bitset<8> bs(a); string s = bs.to_string(); reverse((s).begin(), (s).end()); return bitset<32>(s).to_ulong(); } int main() { string line; getline(cin, line); for (int i = 0; i < (int)(line.length()); i++) { int p = ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx ) using namespace std; template <class U, class V> istream& operator>>(istream& is, pair<U, V>& p) { is >> p.first >> p.second; ret... |
#include <bits/stdc++.h> using namespace std; int pr(int n) { for (int i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; } int near(int n) { int i = 0; for (i = n - 2; i >= 2; i--) { if (pr(i)) break; } return i; } int main() { int i, n, s1, j = 0, s2 = 0, c... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n, ans = 0, a[30], cur, deg = 20, countOfPair = 1; cin >> n; memset(a, 0, sizeof(unsigned long long) * 30); for (int i = 0; i < n; ++i) { cin >> cur; ++a[cur + 10]; } for (int i = 0; i < 10; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; map<int, int> mp; for (int i = 0; i < n; i++) { int curr; cin >> curr; mp[curr]++; } vector<int> nums(mp.size()); int counter = 0; ... |
#include <bits/stdc++.h> using namespace std; struct Edge { int u; int v; Edge() {} Edge(int u, int v) : u(u), v(v) {} }; struct WeightedEdge : Edge { int w; }; struct EdgeGroup { int q; vector<Edge> edges; EdgeGroup() { q = -1; } EdgeGroup(int q) : q(q) {} }; const i... |
#include <bits/stdc++.h> using namespace std; int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar(); return s * w; } ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100 * 1000 + 5; const int mod = 1000 * 1000 * 1000; int a[maxN]; int n; string make(string s, int t) { string res; res.resize(n); for (int i = t; i < n; i++) res[i] = s[i - t]; for (int i = 0; i < t; i++) res[i] = s[i + n - t]; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int M = 10005; inline int read() { int ret = 0, f = 0; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = 1; c = getchar(); } while (isdigit(c)) { ret = ret * 10 + c - 48; c = getchar(... |
#include <bits/stdc++.h> using namespace std; double n, m, k, r; double f(int x, int y) { x++; y++; return (min(n + 1, x + r) - max((double)x, r)) * (min(m + 1, y + r) - max((double)y, r)); } int main() { cin >> n >> m >> r >> k; double ans = 0; double nbpos = (n - r + 1) * ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c, e; char s[100]; scanf( %d%d%*d.%d , &n, &m, &c); map<string, int> u; for (int i = 0; i < n; i++) { scanf( %s%d , s, &e); if (e * c / 100 >= 100) u[s] = e * c / 100; } for (int i = 0; i < m; i++) { s... |
#include <bits/stdc++.h> using namespace std; vector<int> a[1000100], b[1000100], ans; stack<int> st; int n, m; bool del[1000100], used[1001000]; int main() { scanf( %d%d , &n, &m); int i; for (i = 1; i <= m; i++) { int u, v; scanf( %d%d , &u, &v); a[u].push_back(v); b[v]... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; long long i, j, n; int ar[N]; int main() { for (int i = 2; i < N; i++) { for (int j = i + i; j < N; j += i) { ar[j] += j / i; } } cin >> n; long long sum = 0; for (int i = 2; i <= n; i++) sum += ar[i]; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int trie[5000005][2]; int n, cnt; inline int read() { int t = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { ch = getchar(); } while (ch >= 0 && ch <= 9 ) { t = (t << 3) + (t << 1) + (ch ^ 4... |
#include <bits/stdc++.h> inline long long read() { long long x = 0; char ch = getchar(), w = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * w; } void... |
#include <bits/stdc++.h> #define mid (tl+tr)/2 #define mod 1000000007 #define fain(arr) for(ll i=0;i<n;i++)cin>>arr[i]; #define all(x) x.begin(),x.end() #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define bugv(n1) if(DEBUG)cout<<#n1<< is <<n1<< n ; #define buga(A) cout<<#A<< is... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; int n; int t[2][N]; vector<int> vals[N]; vector<pair<int, int>> G[N]; bool vis[N]; int color[N]; vector<int> C[2]; bool cycle; void dfs(int v) { vis[v] = true; C[color[v]].push_back(v); for (auto it : G[v]) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const double PI = 2.0 * acos(0.0); const int MAXN = 33; int n, m; string s; bool d1[26]; bool d2[700]; int encode(char x, char y) { return (x - a ) * 26 + (y - a ); } int main() { memset(d1, false, sizeof(... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; if (k > n) cout << k; else for (int i = 2;; i++) { if (k * i > n) { cout << k * i; break; } } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, m, t; scanf( %d %d %d %d , &n, &k, &m, &t); for (int i = 1; i <= t; ++i) { int x, y; scanf( %d %d , &x, &y); if (x) { if (y <= k) { k++; } n++; printf( %d %d n , n, k); ... |
#pragma GCC optimize(2) #include <bits/stdc++.h> #define all(n) (n).begin(), (n).end() #define se second #define fi first #define pb push_back #define mp make_pair #define sqr(n) (n) * (n) #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define per(i, a, b) for (int i = (a); i >= (b); --i) #de... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; using namespace std; int n, m; string s; int prime(int x) { if (x == 1) return 0; for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0; return 1; } int check(int x, int y) { if (x > n || x < 1 || y >= m || ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); long long int n, m, i, j, x; cin >> n >> m; long long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < m; i++) { cin >... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 86400; long long t, a; cin >> n >> t; for (int i = 1; i <= n; i++) { cin >> a; if (s - a >= t) { cout << i; break; } else t -= s - a; } return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize -O3 using ll = long long; using ull = unsigned long long; using ld = long double; using namespace std; const int MX = 7007; ll f[MX]; bool better(ll x, ll y) { return ((x ^ y) & x) != 0; } ll x[MX], y[MX]; bool ok[MX]; int main() { ios_base::sync... |
#include <bits/stdc++.h> using namespace std; vector<int32_t> dp(1, 0); void solve() { int64_t n; cin >> n; int64_t x3 = 0, x2 = 0; while (n % 3 == 0 && n != 1) { n /= 3; x3++; } while (n % 2 == 0 && n != 1) { n /= 2; x2++; } if (x3 >= x2 && n == 1) { ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 20010; int lf[max_n]; int rf[max_n]; int main() { long long sum = 0; int n; int x, y; memset(lf, 0, sizeof(lf)); memset(rf, 0, sizeof(rf)); scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d%d , &x, &y); ... |
#include <bits/stdc++.h> using namespace std; long long int r, j, l, x, y, m, c, n, s, f, q, i, z, p, k, d, t, u, e, g, w; string s1, s2, s3, s4, str; vector<long long int> v; int main() { cin >> n >> x; long long int a[n]; for (long long int i = 0; i < n; i++) { cin >> a[i]; v.push_ba... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long maxn = 2001; long long h[maxn], dp[maxn][2 * maxn]; signed main() { long long n, k; scanf( %lld%lld , &n, &k); for (long long i = 1; i <= n; i++) scanf( %lld , &h[i]); dp[0][2001] = 1; for (long ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 900; struct edge { int v, w, b; double c; }; vector<edge> adj[maxn]; int n, k; int s, t; double dis[maxn]; int bk[maxn], bki[maxn]; bool inq[maxn]; long long x[maxn], y[maxn]; inline void ae(int u, int v, int w, double c) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int st = 0; cin >> s; int cnt[4] = {0}; for (int i = 0; i < s.size(); i++) { if ( 1 <= s[i] && s[i] <= 3 ) { ++cnt[s[i] - 0 ]; } } for (int i = 1; i <= 3; i++) { for (int j = 0; j < cnt[i]; ... |
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <map> #include <queue> #define int long long #define mod 998244353 using namespace std; int n,c[505],a[505],f[505][505],pos,ans; char s[15]; int dfs(int now,int nowd){ i... |
#include <bits/stdc++.h> using namespace std; long long x[300009]; int main() { long long n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); long long a = x[0], b = 1, ans = 0; for (int i = 1; i < n; i++) { ans = (ans + x[i] * (2 * b - 1) - a) % 1000000007; a... |
#include <bits/stdc++.h> using namespace std; int N, arr[1000000]; set<int> st; int main() { cin >> N; if (N % 2 == 0) { cout << NO ; return 0; } for (int i = 1, b = 1, e = N * 2; i <= N; b += 2, e -= 2) arr[i] = b, i++, arr[i] = e, i++; for (int i = N + 1; i <= N * 2;) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const double eps = 1e-8; int N; long long K; double pi; int X[maxn], Y[maxn]; struct Seg { double radl, radr; void correct() { if (radl > 2 * pi) radl -= 2 * pi; if (radr > 2 * pi) radr -= 2 * pi; if (radl ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int a[maxn], b[maxn]; int n, k; bool check(int x, int state) { if (state == 1) { int c = 0, right = 0; for (int i = 1; i <= n; i++) { if (a[i] <= x) { right = i; c++; i++; } ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class T> inline void amin(T &x, const T &y) { if (y < x) x = y; } template <class T> inline void amax(T &x, const T &y) { if (x < y) x = y; } template <class Iter> void rprintf(const char *fmt, Iter begin, Ite... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 5; long long dp[105], cnt[105], b[N], a[N]; void add(long long &a, long long b) { a += b; if (a >= mod) a -= mod; } struct Mat { long long t[101][101]; Mat() { memset(t, 0, sizeof t); } } I; int ... |
#include <bits/stdc++.h> using namespace std; long long int variables[3001][3001]; long long int cost[3001][3001]; int n; long long int a[3001]; void inicjuj() { for (int i = 0; i < n; ++i) { variables[0][i] = a[i] - i; } sort(variables[0], variables[0] + n); for (int i = 0; i < n; ++i... |
#include <bits/stdc++.h> using namespace std; namespace IO { template <typename T> inline void read(T &x) { x = 0; long long f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -f; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch ... |
#include <bits/stdc++.h> using namespace std; char a[11]; bool ok = true; bool check(char a[]) { for (int i = 0; i < 7; i++) if (a[i] == a[i + 1]) return false; return true; } int main() { for (int i = 1; i <= 8; i++) { scanf( %s , a); ok &= check(a); } if (ok) pu... |
#include <bits/stdc++.h> int st, h, t, r, n, m, tot; int f[200 + 10][200 + 10] = {0}, g[200 + 10][200 + 10] = {0}; int a[200 + 10][2] = {0}, b[200 + 10][2] = {0}; bool hash[200 + 10][200 + 10] = {0}; int td = 0, top = 0, sum = 0; int totm[2] = {0}, e[2][10000000 + 10] = {0}, last[2][10000000 + 10] = {0}, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); long long arr[41] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, ... |
#include <bits/stdc++.h> using namespace std; const int N = 100050; const int M = 10050; long long mn[M], h; int ord[M], tmp[M], que[M], k, n, m; bool was[M]; long long a[N]; int c[N]; stack<int> stk[M]; struct cmp { bool operator()(int i, int j) { return c[i] > c[j] || (c[i] == c[j] && i ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long n, k; long long a[N]; priority_queue<tuple<long long, long long, long long> > pq; inline long long sq(long long x) { return x * x; } long long cost(long long len, long long pieces) { long long each = len / pieces; ... |
#include <bits/stdc++.h> using namespace std; long long n, h, m, data[55]; int main() { cin >> n >> h >> m; for (int i = 1; i <= n; i++) { data[i] = h; } for (int i = 1; i <= m; i++) { long long l, r, x; cin >> l >> r >> x; for (int j = l; j <= r; j++) { data[j] = m... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b, c, d; cin >> a >> b >> c >> d; cout << b << << c << << c << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; long n, m, l, r, T, mid; bool check(long long x) { long long p = x * m, s = 1, d = n, t; for (long i = 0; i <= x && p >= 0 && d; i++) { d -= (t = min(s, d)); p -= t * i; s = s * (x - i) / (i + 1); } return p >= 0 && !d; } int main... |
#include <bits/stdc++.h> using namespace std; int n, m; struct Vec { long long x, y; Vec operator+(const Vec &o) const { return (Vec){x + o.x, y + o.y}; } Vec operator-(const Vec &o) const { return (Vec){x - o.x, y - o.y}; } long long operator*(const Vec &o) const { return 1ll * x * o.y - 1l... |
#include <bits/stdc++.h> using namespace std; struct frnd { int w; int h; frnd(int w, int h) : w(w), h(h) {} }; bool cmp(frnd a, frnd b) { return a.h < b.h; } int main() { int n; cin >> n; vector<frnd> friends; int sum = 0; int height = 0; int prevH = 0; for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; struct query { int id, l, x, ans; } qrs[100009]; bool idcomp(query a, query b) { return a.id < b.id; } bool lcomp(query a, query b) { return a.l < b.l; } int N, Q, a[100009], killer[20]; int modExp(int a, int b) { if (b == 0) return 1; int c = modE... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; const int N = 1007; int n; vector<int> ans, l, r, p1, p2, p3, p4; long long dis[N]; long long qry(int t, int i, int j, int k) { printf( %d %d %d %d n , t, i... |
#include <bits/stdc++.h> using namespace std; const int N = 110, size = 1 << 20, mod = 998244353, inf = 2e9; const long long INF = 1e15; template <class o> void qr(o& x) { char c = getchar(); x = 0; int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } whi... |
#include <bits/stdc++.h> using namespace std; struct r { int p, t; } a; vector<r> v; bool sss(const r& i, const r& j) { if (i.p > j.p) return true; else if (i.p == j.p) return i.t < j.t; else return false; } int main() { int n, k; cin >> n >> k; map<pair<int, ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 5e5 + 3, M = 2e5 + 3; int MOD; string s, t, ts; int n, m, pw[N], hs[N], ht, Z[N + M]; bool check_prime(int x) { for (int i = 2; i * i <= x; ++i) { if (x % i == 0) retu... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500; const int dr[] = {0, 1, 0, -1}; const int dc[] = {1, 0, -1, 0}; bool vis[MAXN + 5][MAXN + 5]; char grid[MAXN + 5][MAXN + 5]; int W, H; vector<pair<char, pair<int, int> > > ans; inline void put(char ch, int i, int j) { ans.push_bac... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 19; int n, k, m, e, a[N], b[N], g[N], c[N], d[N], f[N], t[N], w[N], p[N]; vector<int> v[N]; void upd(int k) { if (t[k << 1] > t[k << 1 | 1]) t[k] = t[k << 1] + w[k], p[k] = p[k << 1]; else t[k] = t[k << 1 | 1] + w[k], p[k] = ... |
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector<std::vector<std::pair<int, int>>> g(n); for (int i = 1; i < n; ++i) { int u, v, w; std::cin >> u >> v >> w; --u; --v; g[u].push_back(st... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; void sherlock(int t) { int n; cin >> n; string s; cin >> s; string t1, t2, ans; int mink = 1; ans = s; for (int k = 1; k <= n; k++) { t1 = s.substr(k - 1, n - k + 1); t2 = s.substr(0, k - 1)... |
#include <bits/stdc++.h> using namespace std; struct dato { int i, j, val; }; int main() { int n, m, k; cin >> n >> m >> k; vector<dato> input(k); for (int t = 0; t < k; t++) { dato &d = input[t]; cin >> d.i >> d.j >> d.val; d.i--; d.j--; } long long int p; ... |
#include <bits/stdc++.h> using namespace std; const int mo = 1000000007; int x, k, X, Y, n, m, u[100005]; long long ans[2]; int f[2], g[2][2][2], G[2][2][2], vis[100005]; vector<int> a[100005], A[100005], e[100005], w[100005]; void dfs(int x) { if (vis[x]) return; vis[x] = 1; memset(G, 0, size... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3f; const int NINF = -INF - 1; const long long int mod = 1e9 + 7; int pre[MAXN]; int find(int x) { return pre[x] == x ? x : pre[x] = find(pre[x]); } int T, n,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 16; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); vector<int> ans(maxn, -1); ans[0] = 0; for (int i = 1; i < maxn; ++i) { for (auto j : vector<int>{4, 6, 9}) { if (i >= j && ans[i - j] != -1) { ... |
#include <bits/stdc++.h> using namespace std; long long n, by, ay; double mxy, l, r, m, D, x1[100005], x2[100005], x[100005], y[100005], mx1, mx2; bool b; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; if (y[i] > 0) ay = 1; if (y[i] < 0) by = 1; y[i] ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000000 + 7; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; n -= 10; if (n >= 1 && n <= 11 && n != 10) { cout << 4; } else if (n == 10) { cout << 15; } else { cout <... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n]; long long i, j, k, l; for (i = 0; i < n; i++) { cin >> a[i]; } ... |
#include <bits/stdc++.h> using namespace std; int f[55], s[55]; long double p[55]; long double dp[55][5005]; bool vis[55][5005]; int main() { int n, r; scanf( %d%d , &n, &r); for (int i = 1; i <= n; i++) { scanf( %d%d%Lf , &f[i], &s[i], &p[i]); p[i] /= 100; } long double lo =... |
#include <bits/stdc++.h> using namespace std; long long n, x, d; int sad; string s; int main() { cin >> n >> x; while (n--) { string s; long long d; cin >> s >> d; if (s[0] == + ) { x += d; } else { if (d <= x) { x -= d; } else ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, s; scanf( %I64d%I64d%I64d , &n, &k, &s); if (k * (n - 1) < s || s < k) printf( NO n ); else { long long sum = s, step = k; long long dis = n - 1; printf( YES n ); long long now = 1; for (in... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n; cin >> n; if (n % 2 == 0) return cout << NO , 0; long long int arr[2 * n + 1]; long long int a = 1, b = n + 1; for (long long int... |
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; int main() { int i, j, n, p, k; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } sort(b + 1, b + 1 + n); for (i = 1; i <= n; i++) { if (b[i] != a[i]) break; } p =... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = numeric_limits<int>::max() / 2 - 1; inline int run() { int n, a, b, k; cin >> n >> a >> b >> k; string s; cin >> s; int cur = 0; vector<int> ans; for (int i = 0; i < n; ++i) { if (s[i] =... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; string s; cin >> s; bool ans = true; for (long long i = 0; i... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; vector<int>::iterator j; int n, i; cin >> n; n = 2 * n; int cnt = 0; int x[n]; int cnt2 = 0; for (i = 0; i < n; i++) { cin >> x[i]; if (i % 2 == 0) { if (x[i] < 0) { cnt++; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; char s[MAXN]; int lst = 1, cnt = 1, len[MAXN]; int fa[MAXN], ch[MAXN][26]; int siz[MAXN], c[MAXN], ord[MAXN]; inline int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch))... |
#include <bits/stdc++.h> using namespace std; vector<vector<pair<int, int>>> g; vector<int> used; vector<int> tout; int timer = 0; bool dfs(int v, int cost) { timer++; used[v] = 1; for (auto to : g[v]) { if (to.second > cost) { if (used[to.first] == 0) { if (!dfs(to.first... |
#include <bits/stdc++.h> using namespace std; const int N = 210, M = 50 * 1000 + 10; int G, S, n, m, par[N]; int get_par(int v) { return par[v] == v ? v : par[v] = get_par(par[v]); } struct edge { int v = 0, u = 0, g = 0, s = 0; bool operator<(edge b) const { return make_pair(make_pair(s, v), u)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a[100001], b[100001], flag = 1; cin >> n; vector<int> v(2, 0); for (int i = 0; i < n; i++) cin >> a[i]; for (int j = 0; j < n; j++) cin >> b[j]; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; int arr[10005]; bool readl[10005]; int read_pages(int ini) { int curr = ini; readl[ini] = 1; while (curr != arr[curr]) { curr = arr[curr]; readl[curr] = true; } return curr; } int main() { int n; cin >> n; for (int i =... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; string s; cin >> s; set<char> ST; for (char x : s) ST.insert(x); if (k > n) { for (int i = 0; i < n; i++) cout << s[i]; for (int i = n; i < k; i++) cout << *ST.begin(); return; } ... |
#include <bits/stdc++.h> using namespace std; template <class T> void print(const T niz[], const int siz) { for (int i = 0; i < siz; i++) cout << niz[i] << ; cout << endl; } const long long p = 103; long long add(long long x, long long y) { return (x + y) % 1000000007; } long long mul(long long... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, i; cin >> n >> k; long long int a[n + 1], b[n + 1]; pair<long long int, long long int> d[n + 1]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) cin >> b[i]; for (i = 0; i < n; i++) d[i] = make_pa... |
#include <bits/stdc++.h> int arr[400][400]; void f(int x, int y) { if (arr[x][y] < 4) return; arr[x][y + 1] += arr[x][y] / 4; arr[x][y - 1] += arr[x][y] / 4; arr[x + 1][y] += arr[x][y] / 4; arr[x - 1][y] += arr[x][y] / 4; arr[x][y] %= 4; f(x, y + 1); f(x, y - 1); f(x + 1, y); ... |
#include <bits/stdc++.h> using namespace std; int main() { int k, w; long long n; cin >> k >> n >> w; int l{}; for (int i = 1; i <= w; i++) { l = l + i; } int s = (l * k) - n; if (s > 0) cout << s; else cout << 0; return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.