func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long x, y, z; cin >> x >> y >> z; long long sum = x + y + z; cout << (sum / 2) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double PI = acos(-1.0); const int MOD = 1000 * 1000 * 1000 + 7; const int INF = 2000 * 1000 * 1000; const int MAXN = 200010; template <typename T> inline T sqr(T n) { return n * n; } int n, k; vector<int> g[MAXN]; l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; int n, m, k; long long sum[maxn], dp[maxn]; int d[maxn]; pair<int, int> p[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); int cnt = 0; while (cnt <= 1e9) { ++cnt; } cin >> n >> m >> k; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void smn(T &a, const T &b) { if (b < a) a = b; } template <class T> inline void smx(T &a, const T &b) { if (b > a) a = b; } template <class T> inline T rev(const T &a) { T _ = a; reverse(_.begin(), _.end()); re... |
#include <bits/stdc++.h> using namespace std; int main() { int ans[30], tans[30], flot[30]; memset(flot, 0, sizeof(flot)); memset(ans, 0x3f3f3f3f, sizeof(ans)); int n, num[55], top = 0, m; string s, s1; cin >> n; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == * ) ... |
#include <bits/stdc++.h> using namespace std; int n, s, e; int x[5555], a[5555], b[5555], c[5555], d[5555]; long long dist(int from, int to) { return 1LL * abs(x[from] - x[to]) + (from < to ? d[from] + a[to] : c[from] + b[to]); } int main() { ios::sync_with_stdio(0); cin >> n >> s >> ... |
#include <bits/stdc++.h> using namespace std; int ar[100001]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t, n, m; cin >> t; while (t--) { cin >> n >> m; long long val = n / m; int a = m % 10, cnt = 0; ar[cnt++] = a; int b = 2; ... |
#include <bits/stdc++.h> using namespace std; int a[500500], n, len, ans; int main() { scanf( %d , &n); ans = 0; for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 0; i < n; i++) { int k = i; len = 0; while (a[k + 1] != a[k] && k < n - 1) { len++; k++; ... |
#include <bits/stdc++.h> using namespace std; int n, m; int r1, c1, r2, c2; char s[505][505]; bool dfs(int i, int j) { if (r2 == i && c2 == j && s[r2][c2] != . ) return 1; if (s[i][j] != . ) return 0; s[i][j] = X ; return dfs(i + 1, j) || dfs(i - 1, j) || dfs(i, j + 1) || dfs(i, j - 1); }... |
#include <bits/stdc++.h> using namespace std; int main() { string s, x; cin >> s; int p = 0, q = 0, r = 0, t = 0; for (int i = 0; i < s.length() - 1; i++) if (s[i] != s[i + 1]) x[t++] = s[i + 1]; if (t != 2) cout << NO ; else { if (x[0] != b || x[1] != c ) cout ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct S { int l, r, h; S() {} S(int l, int r, int h) : l(l), r(r), h(h) {} } Ss[100001]; struct E { int l, r, h, f; S s; E() {} E(int l, int r, int h, S s, int f = 0) : l(l), r(r), h(h), s(s), f(f) {} bool ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7, mod = 1e9 + 7, INF = 0x3f3f3f3f; int a[N]; int n; bool vis[N]; int num[N]; int b[N]; int f(int x) { return x == b[x] ? x : b[x] = f(b[x]); } void u(int x, int y) { x = f(x), y = f(y); if (x != y) b[x] = y; } int pre[N]; ... |
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { string s; in >> s; int n = s.size(); for (size_t i = 0; i < n; i++) { int x = (s[i] - 0 ); if (x % 8 == 0) { out << YES <... |
#include <bits/stdc++.h> using namespace std; long long x, k, col; vector<long long> d, g[10101]; void go(long long pos, long long K) { if (col == 100000) return; if (col == 10000) cerr << Ok ; if (pos == 0 || K == 0) { cout << d[pos] << ; col++; return; } for (int j = ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using ii = pair<int, int>; template <class A, class B> ostream& operator<<(ostream& os, pair<A, B> p) { return os << p.first << << p.second; } template <class A, class B> istream& operator>>(istream& is... |
#include <bits/stdc++.h> using namespace std; const int Max_N = 2e3, Mod = 998244353; int n, d[Max_N + 5], D[Max_N + 5], opt[Max_N + 5]; char a[Max_N + 5][Max_N + 5]; inline bool Chck() { sort(D + 1, D + n + 1); int sum = 0; for (int i = 1; i < n; i++) { sum += D[i]; if (sum == i * (i ... |
#include <bits/stdc++.h> using namespace std; int n, a[200003]; vector<int> v; int main() { cin >> n; for (int i = 2; i <= n; i++) cin >> a[i]; v.push_back(n); int j = n; while (j != 1) { v.push_back(a[j]); j = a[j]; } reverse(v.begin(), v.end()); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e3 + 10; int tim[maxn]; int ans[30][30]; set<int> q; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n * n; i++) { int t; cin >> t; q.insert(t); tim[t]++; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 20; const double eps = 1e-6; double p[maxn], ans[maxn], dp[1 << maxn], S[1 << maxn]; int Size[1 << maxn]; bool eq(const double &a, const double &b) { return abs(a - b) <= eps; } int main() { int n, k, zerCnt = 0; bool is0; scanf( %... |
#include <bits/stdc++.h> using namespace std; vector<long long int> as; set<long long int> s; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { long long int a; cin >> a; a -= i; as.push_back(a); s.insert(a); } vector<long long int> unique; for (lo... |
#include <bits/stdc++.h> using namespace std; long long a[10][10]; int d[10], b[10]; long long kq; void dequy(int k) { int i; long long sum; if (k == 6) { sum = a[d[1]][d[2]] + a[d[2]][d[1]] + a[d[3]][d[4]] + a[d[4]][d[3]]; sum += a[d[2]][d[3]] + a[d[3]][d[2]] + a[d[4]][d[5]] + a[d[5]]... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, cnt = 0; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.rbegin(), a.rend()); for (int i = 0; i < n; i++) { if (cnt <... |
#include <bits/stdc++.h> using namespace std; int const N = 1010; int const M = 1001000; int n, m; struct Graph { struct edges { int u, next; long long c; } e[M]; int p[N], idx; void addedge(int u, int v, long long c) { e[idx].u = v, e[idx].next = p[u], e[idx].c = c, p[u] = i... |
#include <bits/stdc++.h> using namespace std; const long long int maxn = 1e5 + 6; const long long int MOD = 1e9 + 7; vector<int> prim(1000005, 1); int fact[maxn]; long long int binomialCoeff(long long int n, long long int k) { long long int res = 1; if (k > n - k) k = n - k; for (long long int i... |
#include <bits/stdc++.h> int main() { int num, i, j, k, p; double prob[110], temp, tot, high, temp2; scanf( %d , &num); i = 0; while (i < num) { scanf( %lf , &prob[i]); i++; } i = 0; while (i < num) { p = i + 1; while (p < num) { if (prob[p] > prob[i]) {... |
#include <bits/stdc++.h> using namespace std; long long min_val(long long a, long long b) { if (a <= b) return a; else return b; } long long max_val(long long a, long long b) { if (a >= b) return a; else return b; } long long abs(long long a, long long b) { long l... |
#include <bits/stdc++.h> using namespace std; pair<pair<bool, long double>, string> a[13]; bool comp(pair<pair<bool, long double>, string> a, pair<pair<bool, long double>, string> b) { auto t1 = a.first, t2 = b.first; if (t1.first != t2.first) return t1.first; if (abs(t1.second - t2.second... |
#include <bits/stdc++.h> using namespace std; string s; int n; int main() { ios_base::sync_with_stdio(false); cin >> n >> s; for (long long i = 0; i < n; i++) { if (s[i] == * ) for (long long t = 1; t <= n - 1; t++) { bool check = true; for (long long j = 0; j < 5;... |
#include <bits/stdc++.h> using namespace std; int n, k, a, m, cur; set<int> S; int main() { cin >> n >> k >> a; cin >> m; S.insert(0); S.insert(n + 1); cur = (n + 1) / (a + 1); for (int i = 0; i < m; i++) { int x; cin >> x; auto prv = S.lower_bound(x); auto nxt = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; vector<int> G[maxn], a, b; int n, m, flag; int col[maxn]; bool bfs(int s) { queue<int> p; p.push(s); col[s] = 1; while (!p.empty()) { int from = p.front(); p.pop(); int len = G[from].size(); for (... |
#include <bits/stdc++.h> using namespace std; int a[2000010], b[1000010], n; int solve(int s) { int cnt = 0, cur = s; bool flag = 0; while (1) { cur = b[cur]; cnt++; if (cur >= s && flag) return cnt; if (cur >= n) { cur -= n; flag = 1; } if (cur >= s... |
#include <bits/stdc++.h> using namespace std; const long long UNDEF = -1; const long long INF = 1e18; template <typename T> inline bool chkmax(T& aa, T bb) { return aa < bb ? aa = bb, true : false; } template <typename T> inline bool chkmin(T& aa, T bb) { return aa > bb ? aa = bb, true : false; ... |
#include <bits/stdc++.h> using namespace std; int arr[100005]; int reduce(int n) { while (n % 2 == 0) n /= 2; while (n % 3 == 0) n /= 3; return n; } int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); } int r = reduce(arr[0]); bool... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; void err() { cout << 033[39;0m << endl; } template <class T, class... Ts> void err(const T& arg, const Ts&... args) { cout << arg << ; err(args...); } const int N = 100000 + 5; int n, h, m, k; int H[N]; pair<int,... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7, inf = 1e8; int read() { int s = 0, w = 1; char c; while (c = getchar(), c > 9 || c < 0 ) if (c == - ) w = -1; while (c >= 0 && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return s * w; } void write(int x) {... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; if (n % 2) { cout << black ; } else { cout << white << endl; cout << 1 2 ; } return 0; } |
#include <bits/stdc++.h> using namespace std; string s; long long int n, m, c, ans = 0; string x; void count() { int v = 0; for (long long int i = 0; i < n; i++) { if (s[i] == . ) { v++; } else { if (v > 0) { ans += (v - 1); v = 0; } } ... |
#include <bits/stdc++.h> int s, i, e; int main() { int t; scanf( %d , &t); while (t--) { int ans = 0; scanf( %d%d%d , &s, &i, &e); if (s > i + e) { printf( %d n , e + 1); } else if (s + e <= i) { printf( %d n , 0); } else { int k = e - (i + e - s) / ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; template <class T> inline void ckmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void ckmax(T &a, T b) { if (b > a) a = b; } template <class T> inline T sqr(T x) { retur... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 20; int xor_n[maxn]; int p[maxn]; int n; int q; void init() { xor_n[0] = 0; for (int i = 1; i < maxn; i++) { xor_n[i] = i ^ xor_n[i - 1]; } } int main() { init(); while (~scanf( %d , &n)) { q = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, x, y, a, ans = 0; cin >> n; int arr[n]; for (i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > ans) ans = arr[i]; } for (i = 2; i <= n; i++) { for (j = 0; j < n - i + 1; j++) { int a = arr[j];... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int p = s.find( . ); if (s[p - 1] == 9 ) { cout << GOTO Vasilisa. << n ; } else if (s[p + 1] < 5 ) { cout << s.substr(0, p) << n ; } else { string z = s.substr(0, p); z[p - 1]++; ... |
#include <bits/stdc++.h> using namespace std; int dp[1000007]; int main() { int n; scanf( %d , &n); dp[1] = dp[2] = 1; for (int i = 3; i <= n; i++) { int im = (i - 1) / 2; if (2 * im == (i - 1) && im % 2 == 0) dp[i] = dp[im]; else if ((2 * im + 1) == (i - 1)) dp[i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5500; const int INF = 1E9; int a[MAXN], b[MAXN], c[MAXN], d[MAXN]; int f[MAXN][MAXN]; vector<int> g[MAXN]; inline bool cmp(int a, int b) { return c[a] > c[b]; } int main() { int n, m, k, s; scanf( %d%d%d , &n, &m, &k); s = k; ... |
#include <bits/stdc++.h> using namespace std; vector<long long> a; int main() { int n; cin >> n; for (long long x, y, z, i = 1; i <= n; i++) { cin >> x >> y >> z; long long l = 0; if (x % 2 == 1) { l = y; x--; long long h = min(x * y, x / 2 * z); l = l... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; if (n % 2) cout << setprecision(0) << fixed << - << ceil((1.0 * n) / 2) << n ; else cout << fixed << n / 2 << n ; } int main() { solve(); } |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int cnt = 0; for (int i = 1; i < n + 1; i++) { if (i <= b + 1 && (n - i) >= a) cnt++; } cout << cnt << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const long double pi = acos(-1.0); int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } int xabs(int a) { return a > 0 ? a : -a; } struct spoint { double x; double y; int id; spoint(); spoint(double x, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; int mn = INT_MAX; for (int i = 1; i <= n; i++) { int x; cin >> x; if (i != m && x != 0 && x <= k) { mn = min(mn, abs(i - m)); } } ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7; const long long INF = 1LL << 60; const long long mod = 1e9 + 7; const long double eps = 1e-8; const long double pi = acos(-1.0); template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; ... |
#include <bits/stdc++.h> using namespace std; int n, a[20], st, tp, i; int main() { cin >> n; for (i = 0; i < n; i++) cin >> a[i]; for (st = 0; st < (1 << n); st++) { tp = 0; for (i = 0; i < n; i++) { if (st & (1 << i)) { tp += a[i]; tp %= 360; } else { ... |
#include <bits/stdc++.h> using namespace std; long long ans = 0; long long rootans = 0; vector<long long> dp1(200001, 1); vector<long long> dp2(200001, 1); vector<int> adj[200001]; void dfs(int u, int p) { for (int i : adj[u]) { if (i != p) { dfs(i, u); dp1[u] += dp1[i]; } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n % 2 == 0) { cout << n / 2 << endl; } else { cout << ((n / 2) - n) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; static const int maxn = 100012; int K1, K2, K3; int T1, T2, T3; int N; int C[maxn]; void Read() { int i; scanf( %d%d%d , &K1, &K2, &K3); scanf( %d%d%d , &T1, &T2, &T3); scanf( %d , &N); for (i = 0; i < N; ++i) { scanf( %d , &C[i]); ... |
#include <bits/stdc++.h> using namespace std; char s[100005]; long long int V[256]; map<pair<int, long long int>, int> M; int main() { int i, n; long long int prefixSum = 0, ans = 0; for (i = 0; i < 26; i++) scanf( %lld , &V[ a + i]); scanf( %s , s); n = strlen(s); for (i = 0; i < n; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int n, k; char g[3][100005]; bool f; bool isval(int i, int j) { if (j >= n) return true; if (j < 0) return false; if (g[i][j] == X ) return false; return true; } void dfs(int i, int j, int t) { ... |
#include <bits/stdc++.h> using namespace std; int n,i,j,k,a[5050],x[5050],y[5050]; long long scp(int i, int j, int k) { long long xa=x[i]-x[j]; long long ya=y[i]-y[j]; long long xb=x[k]-x[j]; long long yb=y[k]-y[j]; return xa*xb+ya*yb; } int main() { scanf( %d ,&n); for (i=0; i<n; ... |
#include <bits/stdc++.h> using namespace std; int n, ans[16]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; if (!(n & 1)) { cout << 0 << n ; return 0; } ans[1] = 1; ans[3] = 18; ans[5] = 1800; ans[7] = 670320; ans[9] = 7... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long infL = LLONG_MAX; struct psychotronic_induction { int electromagnetic_wave = 7; }; const int nmax = 1e5 + 10; int n, m, a[nmax]; ; int s[nmax], used[nmax]; vector<int> g[nmax]; pair<int, int> edge[nmax]; ... |
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e5 + 5; string s, t; int n, m, pos, l, r; int pre[Nmax]; int suf[Nmax]; int main() { cin >> s; cin >> t; n = s.size(); m = t.size(); s = + s; t = + t; pos = 1; for (int i = 1; i <= m; i++) { while... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int depth; cin >> depth; int n = (1 << (depth + 1)) - 1; vector<int> pre(n + 1, 0), add(n + 1, 0); for (int i = 2; i <= n; ++i) { cin >> pre[i]; } vector<int> way(n + 1, 0); for (int i ... |
#include <bits/stdc++.h> using namespace std; bool ispos(long long x, long long y, long long n, long long m) { if (x < 0 or x >= n or y < 0 or y >= m) return false; else return true; } signed solve() { long long n, m; cin >> n >> m; string s[n]; for (long long i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int N = 200005; int from[N], to[N]; stack<pair<int, int> > G[MAX]; stack<int> res; bool visited[2 * N]; void dfs(int src, int ind = -1) { if (ind != -1) { visited[ind] = true; } while (!G[src].empty()) { ... |
#include <bits/stdc++.h> const long long mod = 1000000007; long long qpow(long long v, long long st) { long long r = 1; while (st) { if (st & 1) { r *= v; r %= mod; } v = v * v; v %= mod; st = st / 2; } return r; } long long f[1024]; long long dp[1... |
#include <bits/stdc++.h> using namespace std; int frombase(int x, int base) { int i = 0; int ans = 0; while (x) { ans += ((x % base) * pow((double)10, i)); i++; x /= base; } return ans; } int tobase(int x, int base) { int i = 0; int ans = 0; while (x) { an... |
#include <bits/stdc++.h> int main() { int i, j, k, p, r, n, c = 0; scanf( %d , &n); char s[1000000]; scanf( %s , s); for (i = 0; i < n - 2; i++) { if (s[i] == s[i + 1]) { c++; if (s[i] == G ) { if (s[i + 2] == R ) s[i + 1] = B ; else if (s[i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, sum = 0; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < k; j++) { int c1 = 0, c2 = 0; for (int i = j; i < n; i += k) { if (a[i] == 1) c1++; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if ((int)s.size() < 26) { cout << -1; return 0; } char cur = a ; bool fg = 0; for (int i = 0; i < (int)s.size(); i++) { if (s[i] <= cur) { if (cur == z ) { s[i] = cur; ... |
#include <bits/stdc++.h> using namespace std; const int N = 5500; char s[N]; int ans[N], dp[N][N]; int main() { scanf( %s , s + 1); int n = strlen(s + 1); for (int i = 1; i <= n; i++) { dp[i][i] = 1; ans[1]++; if (i < n && s[i] == s[i + 1]) { dp[i][i + 1] = 2; ans... |
#include <bits/stdc++.h> using namespace std; template <typename T> T nextInt() { T x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ); if (ch == - ) { p = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + (ch - 0 ); ch = g... |
#include <bits/stdc++.h> using namespace std; int read() { int q = 0; char ch = ; while (ch < 0 || ch > 9 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) q = q * 10 + ch - 0 , ch = getchar(); return q; } const int N = 100005; double P[N][110], ans; int n, m, a[N], b[N]; double ... |
#include <bits/stdc++.h> int const INF = 2e9; int const MOD = 1000000007; int const MAXN = 100010; using namespace std; int n, m, sum1, sum2, ans; int a[MAXN], b[MAXN]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int j = 0; j < m;... |
#include <bits/stdc++.h> using namespace std; int a[100010], dp[100010], rec[100010]; int n; int main() { while (~scanf( %d , &n)) { int maxn = 0; for (int i = 1; i <= n; i++) { dp[i] = 1; scanf( %d , &a[i]); } for (int i = 1; i <= n; i++) { rec[a[i]] = 1; ... |
#include <bits/stdc++.h> using namespace std; long long zyo[114514], sum[114514], kai[114514]; long long mo = 1000000007; long long extgcd(long long a, long long b, long long &x, long long &y) { long long g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int h[n]; for (int i = 0; i < n; ++i) { cin >> h[i]; } vector<int> v(n, 0); int maxx = 0; for (int i = n - 1; i >= 0; i--) {... |
#include <bits/stdc++.h> int n, m, i, j; int ord[200000], a0[200000]; bool use[200000]; long long a[200000]; long long k, p, t, q, s; void qsort(int l, int r) { int i, j, t, x; i = l; j = r; x = ord[(l + r) / 2]; while (i < j) { while (a[ord[i]] < a[x]) i++; while (a[ord[j]] ... |
#include <bits/stdc++.h> int main() { int n, m; int a, b; int min1, min2; int s1 = 0, s2 = 0, k1 = 0, k2 = 0; scanf( %d%d , &n, &m); while (n--) { scanf( %d , &a); if (a % 2 == 0) s1++; else s2++; } while (m--) { scanf( %d , &b); if (b % 2 ... |
#include <bits/stdc++.h> using namespace std; long long pow_mod(long long x, long long y) { long long ret = 1; while (y) { if (y & 1) ret = (ret * x) % 1000000007; x = (x * x) % 1000000007; y >>= 1; } return ret; } long long f[2000010]; void init() { f[0] = 1; for (in... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, i; cin >> n; long long c1 = 0, c2 = 0; vector<long long> a(n); for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2) c1++; else ... |
#include <bits/stdc++.h> using namespace std; int casex, n, k; int num, hed[200010], nex[400010], vt[400010]; long long dp[200010][10], sum[200010], ans; int read() { int u = 0; char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) u = (u << 1) + (u << 3) +... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vector<int>>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 1e9 + 7; int main() { int n; cin >> n; vector<pii> v(n); for (int... |
#include <bits/stdc++.h> using namespace std; const int N = 1100; int n, m, l[N], u[N], dd, ll; double d[N][N], p = 1; vector<pair<int, int> > el; vector<int> eld; int main() { int i, j, x; cin >> n >> m; for (i = 1; i <= m; ++i) { cin >> l[i]; for (j = 1; j <= l[i]; ++j) { ... |
#include <bits/stdc++.h> using namespace std; int rec[40][40][40][40], con[40][40][40][40], r[40][40]; int main() { int n, m, q, a, c, b, d, i, j, k, l; string s[50]; scanf( %d %d %d , &n, &m, &q); for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < n; i++) { for (j = 0; j... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } const int maxn = 1e6 + 5; int n, k; int bsize; set<int> alive[maxn]; int cnt; char ask(int i) { cnt++; cout << ? << i + 1 << endl; cout.flush(); char res; ... |
#include<bits/stdc++.h> #define ll long long #define ri register int #define lowbit(x) x&(-x) #define lson rt<<1, l, mid #define rson rt<<1|1, mid+1, r using namespace std; const int p = 1e9+7; const int maxn = 4e5+10; int n, m, t, q; int a[maxn], vis[maxn], go[maxn], two; int dp[maxn][30]; void... |
#include <bits/stdc++.h> using namespace std; int sqr(int v) { return v * v; } int main() { int x1, y1, x2, y2, r1, r2; cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2; if (r1 < r2) swap(x1, x2), swap(y1, y2), swap(r1, r2); int t1 = sqr(x1 - x2) + sqr(y1 - y2); long double ans(0); if (t1 < sqr(r1 ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int c[80][80], m; struct tree { int n, ans[80], f[80][5000], g[80][5000]; int root, sum, siz[5000], w[5000], a[5000], tot; bool vis[5000]; vector<int> v[5000]; inline void getrt(int x, int fa) { siz[x] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 1e6 + 10; int n; long long cnt[4][20][20]; int dp[N][20][3]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; int lg2 = log2(n); dp[1][lg2][0] = 1; if (pow(2, lg2 - 1) *... |
#include <bits/stdc++.h> const int N = 400 + 10, MOD = 1000000007; inline void add(int &lhs, long long rhs) { lhs = (lhs + rhs) % MOD; } int n, f[N][N]; int main() { scanf( %d , &n); f[1][0] = f[1][1] = 1; for (int i = 2; i <= n; ++i) { for (int x = 0; x <= n; ++x) { for (int y = 0; x ... |
#include <bits/stdc++.h> using namespace std; long long power(int base, long long p) { long long res = 1; while (p) { if (p & 1) { res *= base; --p; } base *= base; p /= 2; } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 5000; long long n, a, b, c, d; pair<long long, long long> p[MAX]; bool cmp(pair<int, int> x, pair<int, int> y) { if (x.first > y.first) return 1; if (x.first == y.first) return x.second < y.second; return 0; } int main() { cin >... |
#include <bits/stdc++.h> template <class c> int popc(c a) { if (sizeof(c) == 8) return __builtin_popcountll(a); else return __builtin_popcount(a); } template <class c> int ctz(c a) { if (sizeof(c) == 8) return __builtin_ctzll(a); else return __builtin_ctz(a); } temp... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); struct Event { long long x, t, i; Event() {} Event(long long x, long long t, long long i) : x(x), t(t), i(i) {} }; bool cmpEvents(const Event &a, const Event &b) { return tie(a.x,... |
#include <bits/stdc++.h> using namespace std; int n, m, in[100010], sum1, sum2; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; in[x]++; in[y]++; } for (int i = 1; i <= n + 1; i++) if (in[i] == 1) sum1++; else if (in[i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long n, m, k, t; cin >> n >> m >> k >> t; pair<int, int> mp[k + 1]; long long x, y, a, b; for (int i = 0; i < k; i++) { cin >> mp[i].first >> mp[i].second; } sort(mp, mp + k); for ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; const int INF = int(1e9); int main() { int n; char str1[maxn], str2[maxn]; while (~scanf( %d , &n)) { scanf( %s %s , str1, str2); int h, m; h = (str1[0] - 0 ) * 10 + str1[1] - 0 ; m = (str2[0] - 0 ) *... |
#include <bits/stdc++.h> using namespace std; const long long INF = 9e18; const int inf = 2147483647; long long qpow(long long a, long long b, long long mod) { long long r = 1; for (; b; b >>= 1) { if (b & 1) r = (r * a) % mod; a = (a * a) % mod; } return r; } const int N = 1e5 +... |
#include <bits/stdc++.h> using namespace std; int main() { int a[1000], b, c, d; cin >> b >> c >> d; a[0] = b; a[1] = c; for (int i = 2; i <= d; i++) { a[i] = a[i - 1] + a[i - 2]; } cout << a[d]; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], i, j, k1 = 0, k2 = 0; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) k1++; else k2++; } int k3 = 0, k4 = 0; for (i = 0; i < n; i++) { if (a[i] == 1) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.