func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> double vp, vd, t, f, c; int main() { scanf( %lf%lf%lf%lf%lf , &vp, &vd, &t, &f, &c); double x = vp * t; int ans = 0; if (vp > vd) { puts( 0 ); return 0; } while (x + 1e-6 < c) { double needtime = x / (vd - vp); double willx = x + needtime * vp... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5; long long n, m; map<long long, long long> mp; long long ans[N], top; signed main() { cin >> n >> m; for (long long i = 1; i <= n; ++i) { long long x; cin >> x; mp[x] = 1; } for (long long i = 1; 26 > 30 ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } int main() { long long t, i, r, c, k, j, n, cnt, x, y, p, q, l, flag; vector<string> a; ... |
#include <bits/stdc++.h> int in[101], od[101], fa[101], n; int f[101], f2[102]; inline int find(int a) { if (fa[a] != a) fa[a] = find(fa[a]); return fa[a]; } inline void u(int x, int y) { x = find(x); y = find(y); fa[y] = x; } signed main() { scanf( %d , &n); for (register int ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, M = (1 << 20) + 5; template <typename T> void read(T &x) { bool neg = false; unsigned char c = getchar(); for (; (c ^ 48) > 9; c = getchar()) if (c == - ) neg = true; for (x = 0; (c ^ 48) < 10; c = getchar()) x = (x << 3... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> A; for (int i = 0; i < n; i++) { int x; cin >> x; A[x]++; } int mx = 0; for (auto x : A) { if (x.second > mx) mx = x.second; } cout << mx; } |
#include <bits/stdc++.h> using namespace std; int main() { const string t = RGB ; int q; cin >> q; for (int i = 0; i < q; ++i) { int n, k; string s; cin >> n >> k >> s; int ans = 1e9; for (int j = 0; j < n - k + 1; ++j) { for (int offset = 0; offset < 3; ++offs... |
#include<bits/stdc++.h> using namespace std; const int N=500; int n,mod,xn[N]; long long dp[N*N]; #define id(x,y) *(xn+x)+y int main(){ cin>>n>>mod; dp[id(1,1)]=1; for(int i=2;i<=n;++i) xn[i]=xn[i-1]+n; xn[n+2]=(xn[n+1]=xn[n]+n)+n; for(int i=1;i<n;i++){ long long a=(dp[id(i,... |
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == - , ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f ? x : -x; } std::mt19937 rnd(time(NULL)); template <class T> void cxk(T& a, T b) {... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; const long long mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long a[n], b[n]; for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i = 0; i ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1e9; const long long IINF = 1e18; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const char dir[4] = { D , R , U , L }; template <typename T> istream &operator>>(istream &is, vector<T> &v... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 10; int cnt[maxn]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int a, b; scanf( %d%d , &a, &b); --a, --b; cnt[a]++; cnt[b]++; } long long tot = 1LL * n * (n - 1) * (... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; getline(cin, a); getline(cin, b); long long i = 0, j = 0; while (a[i] == 0 ) i++; while (b[j] == 0 ) j++; if (a.size() - i > b.size() - j) { cout << > << endl; return 0; } else if (a.size() - i < ... |
#include <bits/stdc++.h> using namespace std; const int n = 100000, i = 700; long long a[n], s[n], d[n], h[1000]; long long *g1, *g2, *g3, *g4; int *g5, *g6, *g9; int my, ans = 0, a1[n], h1[6], h2[6]; long long gcd(long long e, long long r) { if (e < 0) e = -e; while ((e) && (r)) if (e > r) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, i, n; cin >> t; for (i = 1; i <= t; i++) { cin >> n; cout << n / 2 << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int mat[1001][1001][2]; int dp1[1001][1001]; int dp2[1001][1001]; int dx[2] = {0, 1}; int dy[2] = {1, 0}; vector<pair<int, int> > vx; void findxx1(int i, int j); void findxx2(int i, int j); int chk(int x, int y, int n) { if (x >= n || y >= n || y < 0... |
#include <bits/stdc++.h> using namespace std; long long N, M, K, ans; long long a[105][21005]; long long sum[105][21005]; long long tree[21005 * 8]; long long lazy[21005 * 8]; long long dp[21005 * 8]; void updLazy(long long x, long long l, long long r) { if (!lazy[x]) return; tree[x] += lazy[x];... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; int main() { int n, co = 1; std::vector<pair<long long, long long>> v; cin >> n; for (int i = 0; i < n; i++) { long long a, b; cin >> a >> b; v.push_back(make_pair(a, b)); } for (int i = 1; i < n; i+... |
#include <bits/stdc++.h> using namespace std; long long n, m; vector<long long> a(30005); bool check(long long v) { long long i, val = 0; for (i = 0; i < n; i++) { long long x = a[i]; long long y = (a[i] + v) % m; if (y >= x) { if (x > val) val = x; if (y < val) return ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200009; vector<pair<int, int> > grafo[MAXN]; int upth[MAXN], dis[MAXN]; int Build(int u, int p, int upd, int gd) { upth[u] = upd; dis[u] = gd; int ct = 0; for (int i = 0; i < grafo[u].size(); ++i) { int v = grafo[u][i].first;... |
#include <bits/stdc++.h> int A[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; int main() { char a, b; scanf( %c%c , &a, &b); printf( %d n , A[a - 0 ] * A[b - 0 ]); return 0; } |
#include <bits/stdc++.h> using namespace std; template <class A> void read(vector<A>& v) { for (auto& x : v) cin >> x; } template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cout <<... |
#include <bits/stdc++.h> int min(int a, int b) { return (a < b ? a : b); } int max(int a, int b) { return (a > b ? a : b); } int main() { char a[10], b[10]; int x, y; scanf( %s n%s , a, b); if (strcmp(a, sunday ) == 0) x = 0; else if (strcmp(a, monday ) == 0) x = 1; else if (... |
#include <bits/stdc++.h> using namespace std; string s, c; vector<string> v, s1, s2; bool b1(string &d) { if (d.size()) { if (d[0] == 0 && d.size() == 1) { return true; } else if (d[0] == 0 ) { return false; } else { bool ans = true; for (int i = 0; i < d... |
#include <bits/stdc++.h> using namespace std; map<long long, int> m; int main() { int n; scanf( %d , &n); long long count = 0; int flag = 0; for (int i = 0; i < n; i++) { long long c; cin >> c; if (c > 0) { m[c] += 1; if (m[c] == 2) count++; if (m[c] >... |
#include <bits/stdc++.h> using namespace std; int vis[100005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int dis[n][n]; vector<int> arr(n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> dis[i][j]; for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { long long n = 1, k = 1; int t; cin >> t; for (int i = 1; i <= t; i++) { n %= mod; k %= mod; n *= 27; k *= 7; } while (n < k) n += mod; n -= k; cout << n % mod << endl; } |
#include <bits/stdc++.h> using namespace std; long long int arr[2005]; long long int dp[2005][2005]; long long int n, h; long long int calc(long long int id, long long int prev) { if (id == n + 1) { return !prev; } long long int ans = dp[id][prev]; if (ans != -1) { return ans; ... |
#include <bits/stdc++.h> int n, m, H, T, x, y, l, Mark; int son[200005], ed[200005], next[200005], v[200005], d[200005]; void work(int x, int y) { ++Mark; int h = 0, t = 0; for (int p = son[x]; p; p = next[p]) if (ed[p] != y) v[ed[p]] = Mark, h++; for (int p = son[y]; p; p = next[p]) i... |
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 51; LL f[maxn][2][maxn * maxn]; int n, mod; void solve() { scanf( %d%d , &n, &mod); int M = n * (n - 1) / 2; memset(f, 0, sizeof f); f[0][0][M] = 1 % mod; for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, xx; cin >> n >> m >> xx; map<char, long long int> mp; vector<char> v[n]; for (long long int i = 0; i < n; i++) { string s; cin >> s; for (auto j : s) v[i].push_back(j); for (long long int j = 0... |
#include <bits/stdc++.h> using namespace std; void make_unique(vector<long long> vec) { sort((vec).begin(), (vec).end()); vec.resize(unique((vec).begin(), (vec).end()) - vec.begin()); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while... |
#include <bits/stdc++.h> using namespace std; const int nmax = 52, inf = int(1e9), mod = int(1e9) + 7; int n, K; int dp[2][nmax][nmax], ways[2][nmax][nmax]; int comb[nmax][nmax]; int t[2]; int main() { cin >> n >> K; int w; for (int i = 0; i < (int)n; ++i) { cin >> w; t[w != 50]++;... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, y; map<long long, long long> mx, my; map<tuple<long long, long long>, long long> mt; scanf( %lld , &n); for (int i = 0; i < n; i++) { scanf( %lld%lld , &x, &y); tuple<long long, long long> a = make_tuple(x, y)... |
#include <bits/stdc++.h> using namespace std; string str; void push(stack<pair<bool, int>>& stk, int offset) { if (offset == 0) return; pair<bool, int> cur; if (stk.size() && stk.top().first) cur = stk.top(), stk.pop(), stk.push({1, cur.second + offset}); else stk.push({1, offset}); ... |
#include <bits/stdc++.h> using namespace std; int cp[1000010], n; int dfs(int first) { int second = 0; for (int i = 1;; i++) if ((1 << i) - 1 >= first) { return (1 << i) - 1 ^ first; } } int main() { scanf( %d , &n); for (int i = n; i >= 1; i--) if (!cp[i]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, c, b; cin >> n >> c >> b; int a[n]; for (int i = 0; i < n; i++) { a[i] = i + 1; } if (n - 2 < c + b || abs(c - b) > 1) { cout << -1 ; } else { ... |
#include <bits/stdc++.h> using namespace std; int n; int ar[50][50]; int dp[51][51]; bool leaf[50]; vector<int> adj[50]; vector<int> leafs; int bad; vector<int> pos; int go(int rem, int now) { if (rem == 0) { return 0; } if (dp[rem][now] != -1) { return dp[rem][now]; } ... |
#include <bits/stdc++.h> using namespace std; int n, m, k, a[100001][6], ans[6]; multiset<int> st[6]; long long sum() { long long ret = 0; for (int i = 1; i <= m; i++) ret += *st[i].rbegin(); return ret; } int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) for (... |
#include <bits/stdc++.h> using namespace std; void think() { long long n; cin >> n; vector<long long> a(n); for (long long i = 0; i < n; i++) { cin >> a[i]; } long long ans = 0; unordered_map<long long, long long> mp; mp[a[0]]++; for (long long i = 1; i < n; i++) { lo... |
#include <bits/stdc++.h> using namespace std; const int M = 11, L = 11, N = 1002; const int Mod = 1e9 + 9; char a[L], to[99]; int n; int dp[2][M * L][N], ch[M * L][4], fail[M * L]; int len[N]; int ans = 0; inline void mo(int& x) { x = (x >= Mod ? x - Mod : x); } struct AC_automaton { int cnt; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, y = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) y = 1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return y ? -x ... |
#include <bits/stdc++.h> using namespace std; int dp[30006][205][4]; int a[30006]; int n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) for (int t = 0; t < 4; t++) dp[i][j][t] = -1e9 - 1e7; for (... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, q, i, s, j, k, u, dis[N][350], lazy[350], W[N]; long long sum[N], arr[N], x, Y[350]; char c; vector<int> G[N], F[N]; bool H[N], is[N][350]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >>... |
#include <bits/stdc++.h> using namespace std; long long odd[200005], even[200005]; int main() { long long n, t, x, y; cin >> n; long long ara[n + 3]; long long sum = 0, cnt = 0; for (int i = 1; i <= n; i++) { cin >> ara[i]; sum += ara[i]; if (i % 2 == 0) { even[i] = e... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); string s; cin >> s; long long dp[s.length() + 1], mod = 1e9 + 7, f = 0; dp[0] = 1; dp[1] = 1; if (s[0] == m || s[0] == w ) f = 1; for (long long i = 2; i <= s.... |
#include <bits/stdc++.h> using namespace std; int main() { int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; if (r1 == r2 || c1 == c2) cout << 1; else cout << 2; cout << ; if ((r1 + c1) % 2 != (r2 + c2) % 2) cout << 0; else { if (r1 + c1 == r2 + c2 || r1 - c1 ==... |
#include <bits/stdc++.h> #pragma GCC optimize(2, Ofast , inline , -fgcse , -fgcse-lm , -fipa-sra , -ftree-pre , -ftree-vrp , -fpeephole2 , -ffast-math , -fsched-spec , unroll-loops , -falign-jumps , -falign-loops , -falign-... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, s3; cin >> s1 >> s2 >> s3; int i; s1 = s1.append(s2); sort(s1.begin(), s1.end()); sort(s3.begin(), s3.end()); if (s1.length() != s3.length()) { cout << NO ; return 0; } else { for (i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; const int N = 55; char str[N][N]; int vis[N]; int n, m; long long msk[N]; int main() { scanf( %d %d , &n, &m); for (int i = 0; i < int(n); i++) scanf( %s , str[i]); for (int i = 0; i < int(n); i++) for (int j = 0; j < int(m); j++) if ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, n; cin >> n; char a[n]; for (i = 0; i <= n - 1; i++) { cin >> a[i]; } if (a[0] == S && a[n - 1] == F ) cout << YES ; else cout << NO ; return 0; } |
#include <bits/stdc++.h> using namespace std; struct ac { int x, y, z; } p[3000]; int mo[3000]; vector<pair<int, int> > pr; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d%d%d , &p[i].x, &p[i].y, &p[i].z); } for (int i = 1; i <= n; ++i) { int... |
#include <bits/stdc++.h> using namespace std; long long K = 1000000007; long long gcd(long long a, long long b, long long& x, long long& y) { if (a == 0) { x = 0; y = 1; return b; } long long x1, y1; long long d = gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 30; int a[MAX_N], s[MAX_N]; int main() { ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; s[i] = a[i]; } sort(s, s + n); map<int, int> spos; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, n, l, r; cin >> t; while (t--) { cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 640; int h, w; int matr[SIZE][SIZE]; int main() { int q; scanf( %d , &q); for (int tt = 0; tt < q; tt++) { scanf( %d%d , &h, &w); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf( %d , &matr[i][j]); ... |
#include <bits/stdc++.h> using namespace std; const unsigned long long P = 239017, MaxN = 2100000, INF = 1000000000; int a, arr[1000000], sum[1000000], have[1000000]; char s[1000000]; int main() { scanf( %d%s , &a, s); int len = strlen(s); for (int i = 0; i < len; ++i) arr[i] = s[i] - 0 ; sum... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; int main() { long long int t, n, ans = 0, count0 = 0, count1 = 0, count2 = 0, num0 = 0, num1 = 0, num2 = 0; t = 1; while (t--) { cin >> n; vector<long long int> A(n, 0); for (int ... |
#include <bits/stdc++.h> double A[1005][1005]; void guass(int n) { int i, j; for (i = 0; i < n - 1; i++) { double f = A[i + 1][i] / A[i][i]; for (j = i; j < n; j++) { if (j > i + 2) break; A[i + 1][j] -= f * A[i][j]; } A[i + 1][n] -= f * A[i][n]; } for (i = n ... |
#include <bits/stdc++.h> using namespace std; unsigned long long mod = 1e9 + 7; unsigned long long ncr(long long int n, long long int k) { unsigned long long res = 1; if (k > n - k) k = n - k; for (int i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); res = res % mod; } re... |
#include <bits/stdc++.h> using namespace std; long long bin_pow(long long x, long long e, long long MOD) { long long res = 1; while (e) { if (e & 1) res = res * x % MOD; e >>= 1; x = x * x % MOD; } return res; } long long p, a, b, x, ans; vector<long long> m[1123456]; long ... |
#include <bits/stdc++.h> using namespace std; int n, m, q, ans[600005]; bitset<505> a[505][505], b[505][505]; char mp[505][505]; struct ccf { int x1, y1, x2, y2, id; }; void solve(int l, int r, vector<ccf> qus) { if (!qus.size()) return; int mid = (l + r) >> 1; for (int i = mid; i >= l; i-... |
#include <bits/stdc++.h> using namespace std; int t, n, ans, lcp[5009][5009], dp[5009]; char a[5009]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); scanf( %s , a + 1); ans = 0; for (int i = n; i >= 1; i--) for (int j = n; j >= 1; j--) lcp[i][j] = ... |
#include <bits/stdc++.h> using namespace std; const int M = 1010; int n; vector<pair<int, int> > pt; vector<int> vx, vy; vector<int> gx[M], gy[M]; vector<tuple<int, int, int> > sh, sv; int pa[M], pb[M], ln, lm; vector<int> v[M]; bool used[M], used1[M]; vector<int> dx[M], dy[M]; bool dfs(int p) {... |
#include <bits/stdc++.h> using namespace std; const int maxn = int(5e5) + 100; int n, m; vector<pair<int, int> > out[maxn]; int fa[maxn]; long long f[maxn], g[maxn], a[maxn]; void read() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) out[i].clear(); for (int i = 1; i < n; ++i) { i... |
#include <bits/stdc++.h> inline int read() { int f = 1, x = 0; char ch = getchar(); while (!(ch >= 0 && ch <= 9 )) { if (ch == - ) f *= -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return f * x; } int q, n, ... |
#include <bits/stdc++.h> using namespace std; int n, k; pair<long long, long long> a[100007]; int r[100007]; int c[100007]; int used[100007]; long long ans = -1; bool cmp1(int x, int y) { return (a[x].first < a[y].first); } bool cmp2(int x, int y) { return (a[x].second < a[y].second); } void input()... |
#include <bits/stdc++.h> char s[100005]; std::vector<int> v; int main() { scanf( %s , s); int n = strlen(s); bool pc = 0; long long now = 0, pre = 0; bool first = true; for (int i = 0; i < n; i++) { if (s[i] <= 9 && s[i] >= 0 ) { now = now * 10 + s[i] - 0 ; } else {... |
#include <bits/stdc++.h> using namespace std; map<long long, string> dic; int main() { long long n; scanf( %lld , &n); for (long long i = 2; (long long)i * i <= n; i++) { for (long long j = i * i, p = 2; j <= n; j *= i, p++) { string str = to_string(i) + ^ + to_string(p); if (d... |
#include <bits/stdc++.h> using namespace std; list<int> adjList[200002]; int depth[200002]; int sz[200002]; class LCA_binary { int logn, timer; vector<int> tin, tout; vector<vector<int>> up; public: void innerdfs(int v, int p) { tin[v] = ++timer; up[v][0] = p; for (int ... |
#include <bits/stdc++.h> using namespace std; int arr[1000], ans = 0; int cnt[1000]; int main() { int n; scanf( %d , &n); priority_queue<int> pq; for (int i = 0; i < n; ++i) { int x; scanf( %d , &x); pq.push(-x); } for (int i = 0; i < 1000; ++i) { arr[i] = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 100010; int n, m, k; map<int, vector<pair<int, int> > > a, b; int s = 0; void deal(map<int, vector<pair<int, int> > > &a, int n, int m) { if ((m + 1 - a.size()) % 2) s ^= n; for (map<int, vector<pair<int, int> > >::iterator it = a.begin(... |
#include <bits/stdc++.h> int n, m, i, j; char s[110], p = - ; bool q = true; int main() { scanf( %d%d , &n, &m); gets(s); for (i = 0; i < n; i++) { gets(s); if (s[0] < 0 || s[0] > 9 || s[0] == p) q = false; else p = s[0]; for (j = 1; j < m; j++) i... |
#include <bits/stdc++.h> using namespace std; int main() { char str[10000]; cin >> str; if (str[0] >= a && str[0] <= z ) str[0] = str[0] - 32; cout << str; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 10007; int n, m, d, p[maxn], k[maxn], c[maxn], ans[maxn], vis[maxn], match[maxn]; vector<int> adj[maxn]; bool dfs(int u) { for (int i = 0; i < adj[u].size(); i++) { int v = adj[u][i]; if (!vis[v]) { vis[v] = 1; if (... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; map<int, int> mmp; long long qpow(long long a, long long b, long long m) { long long ans = 1, aa = a; while (b) { if (b & 1) ans = ans * aa % m; aa = aa * aa % m; b >>= 1; } return ans; } int a[200010]... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vpii = vector<pair<int, int>>; using vc = vector<char>; using vvc = vector<vc>; long long binpow(long long a, long long n) { long long res = 1; while (n) { if (n & 1) r... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = 0x7f7f7f7f; const int maxn = 1e3 + 5; int n, u, v, root, cnt[2], S; vector<int> vec[maxn]; int sz[maxn], msz[maxn]; void dfs1(int x, int par) { for (int i = 0; i <= (int)vec[x].size() - 1; i++) { if (vec[x][... |
#include <bits/stdc++.h> using namespace std; #define _ ios_base::sync_with_stdio(0);cin.tie(0); #define endl n typedef long long ll; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; int main(){ _ int n; cin >> n; vector<int> a(n); for(int& i : a) cin >> i; ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int m) { if (y == 0) return 1; long long int p = power(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } long long int nCr(long long int n, long long int r, lon... |
#include <bits/stdc++.h> int main() { char a[100]; int i, j, k, low = 0, high = 0; gets(a); for (i = 0; a[i] != 0 ; i++) { if (a[i] >= 65 && a[i] <= 90) high++; else low++; } if (high == low) { for (i = 0; a[i] != 0 ; i++) { if (a[i] >= 65 && a[i] ... |
#include <bits/stdc++.h> using namespace std; int main() { long n, d = 0, e = 0, a[10000] = {0}, c = 0; cin >> n; for (long i = 0; i < n; i++) { cin >> a[i]; c = c + a[i]; } for (long j = 0; j < n; j++) { d = c - a[j]; if ((d % 2) == 0) { e = e + 1; } } ... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int N = 100005; const double PI = 4 * atan(1); const double eps = 1e-7; const long long oo = 1e10; const int K = 26; vector<int> sort_cyclic_shifts(string const& s) { int n = s.size(); const int alphabet = 256; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; string s[3003], t[3003]; long long hhs[3003][3003], hht[3003][3003], pp[3003], hhts[3003], hhtt[3003]; pair<int, int> cseg[3003]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); pp[0] = 1; for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long MOD = 1e9 + 7; vector<int> ans1, ans2; int a[N]; bool work(bool c[], int n) { vector<int> p1, p2; for (int i = 0; i < n; ++i) { if (c[i]) p1.push_back(a[i]); else p2.push_back(a[i]); ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, i; long long a[102]; long long dp[102][102][2]; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { cin >> n; string s[2]; ci... |
#include <bits/stdc++.h> template <class T> class three { T _first, _second, _third; public: T &first, &second, &third; three(T f, T s, T t) : first(_first), second(_second), third(_third) { _first = f; _second = s; _third = t; } three(const three& other) : first(_first),... |
#include <bits/stdc++.h> using namespace std; const int N = 200018; int arr[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; map<long long, int> mp; long long sum1 = 0; for (int i = 1; i <= n; i++) { cin >> arr[i], sum1 += arr[i]; mp[sum1... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 10; const long long INF = 2e9; const double PI = acos(-1); long long n, m, p, pi = 1; long long fa[MAXN], k; long long siz[MAXN]; template <typename T> inline void read(T &a) { a = 0; char c = getchar(); long long f... |
#include <bits/stdc++.h> using namespace std; long long len(long long x, long long y) { return x * x + y * y; } long long scal(long long x1, long long y1, long long x2, long long y2) { if (x1 * y2 == x2 * y1) return -1; return x1 * x2 + y1 * y2; } bool in(long long x1, long long y1, long long x2, long... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long double pi = acos(-1.0); const long double eps = 1e-9; const int MAX_SIZE = 50; const int dX[] = {-1, 1, 0, 0, -1, 1, -1, 1}; const int dY[] = {0, 0, -1, 1, 1, -1, -1, 1}; template <class S, class T> ostream& operat... |
#include <bits/stdc++.h> using namespace std; int n, x, s, d, t, a, b, r[5000], l, res1, res2, k; int main() { cin >> n >> k; for (int i = 0; i < k; i++) { cin >> t; if (t == 1) { cin >> a >> b; r[a] = r[b] = 1; l += 2; } else { cin >> a; r[a] = 1;... |
#include <bits/stdc++.h> using namespace std; const int maxx = 1e5 + 20; int n, c[maxx], sz[maxx], rang[maxx], okd[maxx], oku[maxx], t[maxx]; bool vis[maxx], takrang[maxx]; vector<int> adj[maxx]; void dfs(int root) { vis[root] = true; int tedad = t[c[0]]; if (c[0] == c[root]) tedad--; bool b... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; bool isPrime[N], vst[N]; int frq[26]; vector<int> adj[N]; vector<int> cc; vector<vector<int>> vcc; void dfs(int u) { cc.push_back(u); vst[u] = 1; for (auto v : adj[u]) { if (!vst[v]) dfs(v); } } bool cmp(vecto... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5, INF = 1e9; int a[N], n, x, y, res = 0; int main() { int t; ios::sync_with_stdio(false); cin >> t; while (t--) { cin >> n >> x >> y; int res = INF; int rs = 0, rc = 0; for (int i = 1; i <= x; i++) { f... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int n, m, k, a[N][N]; const int mod = 1e9 + 7; int f[N][N], used[15]; int ans = 0; inline void Plus(int &x, const int &y) { x += y; if (x >= mod) x -= mod; } inline int dfs(int x, int y) { if (y > m) y = 1, ++x; if (x... |
#include <bits/stdc++.h> #pragma GCC diagnostic push #pragma GCC diagnostic ignored -Wunused-variable using namespace std; using ll = long long; const ll N = 1e6 + 3LL; const int inf = 1e9 + 3; const ll M = 1e9 + 7; const ll T = 998244353; const double pi = 3.14159; ll n, m; ll t[4 * N]; ll xl... |
#include <bits/stdc++.h> using namespace std; int n; int t = 0, x = 0, ans = 0; int a, b; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d%d , &a, &b); x -= a - t; if (x < 0) x = 0; x += b; ans = max(ans, x); t = a; } printf( %d %d , t ... |
#include <bits/stdc++.h> using namespace std; int n, p = (1 << 19); pair<pair<int, int>, pair<int, int> > w[(1 << 20)]; int rmax[(1 << 20)]; priority_queue<pair<int, int> > pq; int rpush[(1 << 20)]; int loc[(1 << 20)]; int best = 0, bestx = 0, besty = 0; void push(int a) { rmax[a] += rpush[a]; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.