func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; set<pair<string, string> > m; int n, z[2000], d, k, ans; string a[2000], b[2000], zx[2000][5]; int main() { cin >> n >> d; for (int i = 0; i < n; i++) { cin >> a[i]; cin >> b[i]; cin >> z[i]; } for (int i = 0; i < n; i++) fo... |
#include <bits/stdc++.h> using namespace std; int n; int x[100111]; int num[100111], numl; int ans[100111]; map<int, int> HASH; int main() { int i, temp; scanf( %d , &n); memset(num, 0, sizeof(num)); numl = 0; for (i = 0; i < n; i++) { scanf( %d , &temp); if (HASH.count(tem... |
#include <bits/stdc++.h> using namespace std; void debug(int n) { printf( %d n ); } bool cmp(pair<int, pair<int, int> > &a, pair<int, pair<int, int> > &b) { if (a.second.first == b.second.first) { return a.first < b.first; } return a.second.first < b.second.first; } int main() { int n, u... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 2e9; const long long INFLL = 1e18; const int MAX_N = 100000; vector<int> gp[MAX_N + 1]; int N; int p[MAX_N + 1]; int cnt[MAX_N + 1]; int lv[MAX_N + 1]; void dfs(int x) { cnt[lv[x]]++; for (int i : gp[... |
#include <bits/stdc++.h> using namespace std; const int N = 100002; const int logN = 22; vector<int> c; map<int, int> m; void solve() { int n; cin >> n; while (n--) { int x; cin >> x; m[x]++; } int ans = 0; for (const pair<int, int> &x : m) { bool f = false; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000050; int go[N][2], a[N], b[N], n, i, j, p, sz[N], tsz; long long k, x[N]; int main() { scanf( %i %lld , &n, &k); for (i = 2; i <= n; i++) scanf( %i %lld , &p, &x[i]), x[i] ^= x[p]; for (i = 1; i <= n; i++) a[i] = b[i] = 1; long lo... |
#include <bits/stdc++.h> using namespace std; long long n, m, p; long long A[5001]; long long a[5001]; long long l[1000005]; long long dp[2][5001]; long long s[5001][5001]; void work(long long *prev, long long *nxt) { long long total = 0, prev_total = 1; for (int i = 1; i <= n; i++) { for ... |
#include <bits/stdc++.h> using namespace std; const long long N = 100005, LOG = 25; long long n, f[N][LOG + 5], cnt = 0, head[N], dep[N]; long long size[N]; struct CLANNAD { long long to, nxt; } a[N << 1]; inline void add(long long u, long long v) { a[++cnt].to = v; a[cnt].nxt = head[u]; h... |
#include <bits/stdc++.h> using namespace std; long long A[5 * 1000 + 3][5 * 1000 + 3]; long long sum[5 * 1000 + 3]; int main() { int n, a, b, k; cin >> n >> a >> b >> k; if (a > b) { a = n - a + 1; b = n - b + 1; } for (int j = 1; j <= b / 2; j++) A[j][1] = b - 2; A[b - 1][1]... |
#include <bits/stdc++.h> const int N = 50005; char s[N]; int main() { scanf( %s , s); int i, j, n = strlen(s); for (j = 1; j <= n / 2; j++) { int t = 0, cnt = 0; for (i = 0; i + j < n; i++) { s[t++] = s[i]; if (s[i] == s[i + j]) cnt++; else cnt =... |
#include <bits/stdc++.h> using namespace std; int n; int r; int done = 1; pair<int, int> tempo(int x, int y) { if (x >= y) { if (x % y == 0) { if (y == 1) return make_pair(x, x - 1); else return make_pair(1000000100, 1000000100); } pair<int, int> next ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const in... |
#include <bits/stdc++.h> template <class _, class __> bool checkmax(_ &a, __ b) { return a < b ? a = b, true : false; } template <class _, class __> bool checkmin(_ &a, __ b) { return a > b ? a = b, true : false; } using namespace std; const int INF = 1e9; struct node { int x, p; bool ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int len, star = 0, question = 0, k = 0, n = 0; cin >> s; cin >> k; len = s.length(); for (int i = 0; i < len; i++) { if (s[i] == ? ) { question++; } if (s[i] == * ) { star++; } ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const long double PI2 = atan2(1.L, 0.L); int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; long double r; cin >> n >> r; long double res = r * r * n * sin(PI2 / n) * sin(2 * PI2 / n) / sin(3 * PI2 / n... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, A[100], B[100]; cin >> n >> k; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < k; i++) cin >> B[i]; if (k > 1) { cout << Yes n ; return 0; } for (int i = 0; i < n; i++) if (!A[i]) A[i] = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; string num; cin >> num; num = num.substr(num.length() - x, x); cout << count(num.begin(), num.end() - y - 1, 1 ) + count(num.end() - y, num.end(), 1 ) + (*(num.end() ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 7; int n; long long dp[2][maxn]; int main() { cin >> n; int now = 1; dp[0][1] = 1; dp[0][2] = 1; long long ans = 0; ans += dp[0][n]; for (int i = 1; i <= 19; i++) { memset(dp[now], 0, sizeof(dp[now])); ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; const int N = 2020; namespace Gause { static const int N = ::N; int equ, var; bitset<N> a[N]; int x[N]; int free_x[N]; int free_num; int l[N]; void ini(... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const long double EPS = 0.000000001; const long long INF64 = 1000000000000000000; const long long INF32 = 2000000000; bool iss_pt_in_triangle(pair<long long, long long> a, pair<long long, long long> b, ... |
#include <bits/stdc++.h> const int maxn = 2e5 + 5; using namespace std; int rd() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) x = (x << 3) + (x << 1) + c - 0 , c = getchar(); return x * f; } int n, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed; long long q; cin >> q; for (int i = 0; i < (int)(q); ++i) { long long n, ans = 0; cin >> n; vector<int> a(n); for (int j = ... |
#include <bits/stdc++.h> double A[200000], B[200000], C[200000], p[200000], F[200000]; int i, j, n, m; int main() { scanf( %d , &n); double now, last = 0; C[0] = 1; for (i = 1; i <= n; i++) { if (i <= n) scanf( %lf , &now); C[i] = now * (C[i - 1]) + 1 - now; B[i] = now * (B[i - 1... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int> > arr; bool fun(pair<long long int, long long int> fi, pair<long long int, long long int> se) { if (fi.first < se.first) { return true; } else return false; } void solve() { long long int... |
#include <bits/stdc++.h> using namespace std; int n, i, b, a[105]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; b += a[i]; } if (b != 0) { cout << YES n1 n1 << n; return 0; } for (i = 1; i <= n; i++) { if (a[i] != 0) { break; ... |
#include <bits/stdc++.h> using namespace std; int n, CountDog[400]; char x[100005]; int main() { scanf( %d , &n); if (n == 1) { printf( Yes ); return 0; } for (int i = 1; i <= n; i++) { cin >> x[i]; CountDog[x[i]]++; } for (int i = 1; i <= n; i++) if (CountD... |
#include <bits/stdc++.h> using namespace std; string to_string(string s) { return + s + ; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } template <typename A, typename B> string to_string(pair<A, B> p) { return ( + ... |
#include <bits/stdc++.h> using namespace std; long long int a[200001]; long long int q[200001]; long long int pre[200001]; long long int binarysearch(long long int n, long long int p) { long long int low = 1, high = n; while (low <= high) { long long int mid = (low + high) / 2; if (pre[mid... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, cost = 0, r, min = 100000000; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 1; i <= a[n - 1]; i++) { t = i; for (int j = 0; j < n; j++) { if (a[j... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; if (m == 0) { cout << YES << endl; return 0; } vector<long long int> v(m); for (long long int i = 0; i < m; cin >> v[i++]) ; sort(v.begin(), v.end()); if (v[0] == 1 || v[... |
#include <bits/stdc++.h> using namespace std; int dp[1010][1010]; vector<int> arr; int m; int solve(int idx, int mod) { if (idx == (int)arr.size()) return (mod == 0); else if (dp[idx][mod] != -1) return dp[idx][mod]; int ret = solve(idx + 1, mod); if (ret) return (dp[idx][mod] = re... |
#include <bits/stdc++.h> using namespace std; int n, q; int b[100000][2]; int a[100000]; int c[5]; int main() { cin >> n >> q; for (int i = 0; i < n; i++) { b[i][0] = 0; b[i][1] = 0; a[i] = 0; } c[0] = n - 1; int s = 0; for (int i = 0; i < q; i++) { int y, x; ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } long long bigmod(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % 1000000007; b >>= 1; a = (a * a) % 100000... |
#include <bits/stdc++.h> using namespace std; using Long = long long; vector<vector<int>> G(100010); int D[100010]; int dist[100010]; int P[100010]; int ep1 = -1, ep1lvl = -1, ep2 = -1, ep2lvl = -1; void dfs(int u, int p, int lvl) { if (lvl > ep1lvl) { ep1lvl = lvl; ep1 = u; } fo... |
#include <bits/stdc++.h> using namespace std; int main() { int ans[] = {0, 1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0}; int n; cin >> n; cout << ans[n] << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { if (e == 0) return 1; if (e % 2 == 0) { long long t = bigmod(p, e / 2, M); return (T)((t * t) % M); } return (T)(((long long)bigmod(p, e - 1, M) * (long long)(p)) % M); } template <cla... |
#include <bits/stdc++.h> using namespace std; int row[1008], col[1008], n, m, a, b, cnt; int main() { cin >> n >> m; for (int i = 0; i < n + 1; i++) row[i] = col[i] = true; while (m--) { cin >> a >> b; row[a] = col[b] = false; } for (int i = 2; i < n; i++) cnt += (row[i] + col[i]);... |
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { out << ( << p.first << , << p.second << ) ; return out; } template <class T1, class T2> istream& operator>>(istream& in, pair<T1, T2>& p) { in >> p.first >> p.seco... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize(2) using namespace std; const int maxn = 2e5 + 10; char s[maxn]; int N, K; long long T; int A[22][22]; long long DP[1 << 22]; long long t[22]; int mask[22]; int main() { scanf( %d %d %lld , &N, &K, &T); scanf( %s , s +... |
#include <bits/stdc++.h> using namespace std; int i, j, k, l, m, n, x, y, z, ans, counting; int ara[2000]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> ara[i]; } sort(ara, ara + n); for (i = 0; i < n; i++) { if (ara[i] != 0) break; } for (j = i + 1, counting = ... |
#include <bits/stdc++.h> using namespace std; int isWinning(string str) { int n = str.length(); int arr[n + 1][n + 1]; for (int i = 0; i <= n; i++) arr[i][i] = 1; return arr[1][n]; } int main() { int n; cin >> n; int arr[n]; long long ans; long long sum = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; char st[1000010]; int n, K; int main() { int i, j; scanf( %d%d , &n, &K); scanf( %s , st + 1); for (i = 1; i < n && K; ++i) if (st[i] == 4 && st[i + 1] == 7 ) { if (i % 2) st[i + 1] = 4 ; else { st[i] = ... |
#include <bits/stdc++.h> using namespace std; vector<int> go(int x, int d) { long long mx = 0; for (int i = 1; i <= d; i++) mx += 1ll << i; if (mx < x) return vector<int>(); return vector<int>(); } void solve() { int n; cin >> n; long long x = n - 1; long long curr = 1; vecto... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int INF = 0x3f3f3f3f; int a[110][110]; int dp[100][2]; const int M = 1e5 + 10; int vis[M], prime[M]; void prim() { memset(vis, 0, sizeof(vis)); memset(prime, 0, sizeof(prime)); int cun = 1; for (int i = 2; i <... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 350009; long long Q, N, currentS[NMAX], s[NMAX], t[NMAX], l[NMAX], r[NMAX], v[NMAX], type[NMAX]; vector<long long> ts; map<long long, long long> inverseT; void read() { scanf( %I64d , &Q); for (int i = 1; i <= Q; i++) { scanf... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5; int d[maxn]; std::vector<int> G[maxn]; int dp(int u) { if ((int)G[u].size() == 0) { return d[u] = 1; } else if (d[u]) { return d[u]; } for (int i : G[u]) { d[u] += dp(i); } return d[u]; } int c[ma... |
#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> int abss(int x) { return x > 0 ? x : -x; } int main() { int n, m, x1, y1, x2, y2; while (scanf( %d %d %d %d %d %d , &n, &m, &x1, &y1, &x2, &y2) == 6) { int chax = abss(x1 - x2); int chay = abss(y1 - y2); bool ansflag = 0; if (x1 == x2 && y1 == y2) ans... |
#include <bits/stdc++.h> using namespace std; string obj; bool solve(int x) { string s = to_string(x); string ans; for (int i = 0; i < s.size(); i++) if (s[i] == 7 || s[i] == 4 ) ans.push_back(s[i]); return ans == obj; } int main() { ios::sync_with_stdio(false); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0; char c; while ((c = getchar()) < 0 || c > 9 ) ; do { s = s * 10 + c - 0 ; } while ((c = getchar()) >= 0 && c <= 9 ); return s; } bool descending(int a, int b) { return a > b; } string toStr(... |
#include <bits/stdc++.h> using namespace std; long long a[501][501]; bool visited[501]; int main() { long long n; cin >> n; for (long long i = 0; i < n; i++) { visited[i] = false; for (long long j = 0; j < n; j++) { cin >> a[i][j]; } } vector<long long> order(n); ... |
#include <bits/stdc++.h> using namespace std; template <class T> class Node { public: Node<T> *prev; Node<T> *next; T data; Node(T data); }; template <class T> Node<T>::Node(T data) { this->data = data; } template <class T> class Stack { public: Node<T> *top; int size... |
#include <bits/stdc++.h> using namespace std; int cekTanda(char ch) { switch (ch) { case > : return 8; case < : return 9; case + : return 10; case - : return 11; case . : return 12; case , : return 13; case [ : ... |
#include <bits/stdc++.h> using namespace std; const int a[] = {0, 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}; int main() { int n; cin ... |
#include <bits/stdc++.h> const long long N = 500005; const long long mod = 1e9 + 7; using namespace std; std::vector<long long> adj[N]; std::vector<bool> vis(N); void solve() { long long n, m, k, x = 0, y = 0, c = 0, q, ans = 0; cin >> n >> m; for (long long i = 0; i < m; ++i) { cin >> x >... |
#include <bits/stdc++.h> using namespace std; int main() { int nb; scanf( %d , &nb); int arr[nb]; for (int i = 0; i < nb; i++) scanf( %d , arr + i); sort(arr, arr + nb); int occ[3] = {0}; for (int i = 0; i < nb; i++) { for (int j = 0; j < 3; j++) if (arr[i] == arr[j]) occ[j... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; void solve() { int n, k, d; cin >> n >> k >> d; vector<int> a(n); map<int, int> used; for (int i = 0; i < n; i++) cin >> a[i]; int cnt = 0, ans = INF; for (int i = 0; i < d; i++) { if (used[a[i]] == 0) cnt++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int *arr = new int[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int j, k; for (int i = 0; i < n; i++) { if... |
#include <bits/stdc++.h> using namespace std; long long n, m, d, bd[4]; vector<long long> pst[4][100069]; int main() { long long i, j, ii, k, l, z = 1, y, x, p; bool ft = 1; scanf( %lld%lld%lld , &n, &m, &d); for (i = 0; i < d; i++) { scanf( %lld%lld , &k, &l); for (ii = 0; ii < 4; i... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; void SieveOfEratosthenes(long long n) { bool prime[n + 1]; memset(prime, true, sizeof(prime)); for (long long p = 2; p * p <= n; p++) { if (prime[p] == true) { for (long long i = p * p; i <= n; i += p) prime[i] = false; ... |
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } struct sp { int x, y; bool operator<(const sp &a) const { return x < a.x || x == a.x && y < a.y; } bool operator==(const sp &a) const { return x == a.x && y == a.y; } }; namespace std { template... |
#include <bits/stdc++.h> using namespace std; constexpr int kN = int(4E3 + 10), kInf = int(1E9 + 10); int a[kN]; void solve() { int n, m, k, lft, ans = 0, tmp; scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); m--; k = min(k, m); lft = m - k; for (int i = ... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; const long long int MOD = 1000000007; const long long int MAXN = 1000005; const long long int INF = 100000000000005; void solve() { long long int n; cin >> n; vector<long long int> a(n), pos, neg; for (long long int i = 0;... |
#include <bits/stdc++.h> using namespace std; int num[200005]; int lis[200005]; int main() { int n1, n2, n3; cin >> n1 >> n2 >> n3; for (int i = 1; i <= n1 + n2 + n3; i++) { cin >> num[i]; } sort(num + 1, num + 1 + n1); sort(num + 1 + n1, num + 1 + n1 + n2); sort(num + 1 + n1 +... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { long long ans = 0; for (int i = 0; i <= 8 && i <= n; i++) { for (int j = 0; j <= (i == 0 ? 8 : 4) && i + j <= n; j++) { ans += n + 1 - i - j; } } cout << ans << endl; } ... |
#include <bits/stdc++.h> using namespace std; string a, ar, b, fi; int i, j, ans, o1[3000], o2[3000]; int main() { ios_base::sync_with_stdio(0); cin >> a >> b; ar = a; reverse(ar.begin(), ar.end()); for (; i < b.size(); ++i) { if (a.find(b[i]) == string::npos) { cout << -1 n ;... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) 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(con... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; pair<long long, long long> dp[20][1 << 10]; int a[20]; long long pw[20]; int change(long long n) { int cnt = 0; while (n) { if (n & 1) cnt++; n /= 2; } return cnt; } int k; long long pow(int e, i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> ans(n); int a1, a2, a3; cout << ? 1 2 << endl; fflush(stdout); cin >> a1; cout << ? 1 3 << endl; fflush(stdout); cin >> a2; cout << ? 2 3 << endl; fflush(stdout); cin >> ... |
#include <bits/stdc++.h> using namespace std; int n, k, a, ok, ans, occ[10]; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , &a); int total = k + 1; memset(occ, 0, sizeof(occ)); while (a) { if (!occ[a % 10] && (a % 10 <= k)) { total-... |
#include <bits/stdc++.h> using namespace std; const int R = 1000; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, s, d; cin >> n >> s >> d; vector<bitset<R>> a(s); for (int i = 0, k, x; i < s; ++i) { cin >> k; while (k--) cin >> x, a[i][x - 1] = 1; } vector<pa... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 10000 + 10; int n, m; int second[200], a[200]; bool vis[200]; int main() { scanf( %d %d , &n, &m); for (int i = 0; i < m; i++) scanf( %d , &second[i]); for (int i = 0; i < m; i++) second[i]--; bool win = true; for (in... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 10; int n, a[MAXN], k, dp[MAXN]; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; long long l = -1, r = 2e9 + 1; while (l + 1 < r) { long long mid = (r + l) / 2; bool flag = false; for (int... |
#include <bits/stdc++.h> using namespace std; long long* parent; long long* size; void make_set(long long v) { parent[v] = v; size[v] = 1; } long long find_set(long long v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]); } void union_set(long long u, long long v) ... |
#include <bits/stdc++.h> const int MAX_N = 3e5 + 2; struct Ant { int id; long long pos, speed; Ant(){}; Ant(int id, long long pos, long long speed) { this->id = id; this->pos = pos; this->speed = speed; } }; bool comparePosition(Ant a, Ant b) { return (a.pos < b.pos); } l... |
#include <bits/stdc++.h> using namespace std; const int N = 810; int gi() { int x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<int> v(n); vector<int> c(m + 5, 0); for (int i = 0; i < n; i++) { cin >> v[i]; } int l = 0, r = 0; int res = 1; c[v[0] - 1]++; int maxC = 1; int maxI = v[0] - 1; w... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const int MOD = 1e9 + 7; const int N = 0, BAR = 1e6, LIM = 5e6; int x, y, n; int main() { scanf( %d , &n); int xa = inf, xb = -inf, ya = inf, yb = -inf; while (n--) { scanf( %d%d , &x, &y); x += BAR, y += BAR; x... |
#include <bits/stdc++.h> using namespace std; ifstream fin( lol.in ); ofstream fout( lol.out ); char c; int m[10][10], ok; int main() { ios::sync_with_stdio(false); for (int i = 1; i <= 6; ++i) { m[1][i] = m[6][i] = 100; m[i][1] = m[i][6] = 100; } for (int i = 2; i <= 5; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x7f7f7f7f; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; vector<int> arr; int main() { int n; string st; int x; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &x); arr... |
#include <bits/stdc++.h> using namespace std; int n, k, f[101][50001], a[101], b[101]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) scanf( %d , &b[i]); for (int i = 0; i <= 100; i++) for (int j = 0; j <= 50000; j++) f[i][j]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, x, t; char card, ha; map<int, pair<int, int> > mh; map<int, pair<int, int> > ma; map<int, pair<int, int> >::iterator it; string h, a; cin >> h >> a; cin >> n; for (i = 0; i < n; i++) { cin >> t >> ha; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 101000; struct p { long long x, y; } a[N]; long long n, m; long long pro(p o, p b, p c) { return (b.x - o.x) * (c.y - o.y) - (c.x - o.x) * (b.y - o.y); } int main() { scanf( %I64d , &n); for (long long i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; char s[60]; cin >> n >> s; for (i = 0, j = 0; i < n; i += ++j) cout << s[i]; return 0; } |
#include <bits/stdc++.h> using namespace std; #pragma optimize( -O3 ) string to_string(string s) { return + s + ; } string to_string(const char* s) { return to_string((string)s); } string to_string(const bool& b) { return (b ? true : false ); } template <typename A, typename B> string to_string(... |
#include <bits/stdc++.h> using namespace std; const int N = 300005, INF = 9999999; const long long P = 1e9 + 7; template <typename T> inline void read(T& first, char s = getchar()) { first = 0; while (s > 9 || s < 0 ) s = getchar(); while (s <= 9 && s >= 0 ) first = first * 10 + s - 0 , s =... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> t >> s; set<char> b(t.begin(), t.end()); int n; cin >> n; for (int k = 0; k < n; ++k) { cin >> t; int i = 0; int j = 0; while (i < s.size() || j < t.size()) { if (s[i] == ? ) { ... |
#include <bits/stdc++.h> using namespace std; const int mo = 998244353, N = 2e5 + 5, M = 59, S = 32771; inline int poww(int x, int y) { int ans = 1; for (; y; y >>= 1, x = 1ll * x * x % mo) if (y & 1) ans = 1ll * ans * x % mo; return ans; } int n, m, i, j, k, mi[N], C[M][M], ct[M]; long lo... |
#include <bits/stdc++.h> using namespace std; const int Inf = (int)1e9 + 7; const long long LongInf = (long long)1e18 + 7; namespace { const int N = 1007; const int MOD = (int)1e9 + 7; int k, pa, pb; long long dp[N][N]; long long pw(long long x, int m) { if (m == 0) return 1; long long y = pw(... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); char str[n]; scanf( %s , &str); int count = 0; for (int i = 0; i < n; i++) if (str[i] == str[i + 1]) count++; printf( %d , count); return 0; } |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1e4 + 10; int n, b, q; pair<int, int> h[MaxN]; unordered_map<int, int> e[MaxN]; vector<int> c[MaxN]; int flow, parent[MaxN], mini, curr; void dfs(int x) { if (parent[q + 6] != -1) return; for (int i = 0; i < c[x].size(); i++) { ... |
#include <bits/stdc++.h> int main() { const int maxN = 3002; bool tests[maxN] = {0}; int n(0); scanf( %d , &n); for (int k = 0; k < n; k++) { int temp; scanf( %d , &temp); tests[temp] = 1; } for (int index = 1; index < maxN; index++) { if (!tests[index]) { p... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0; cin >> n; bool isLR = false; char a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == L || a[i] == R ) isLR = true; } bool flag = false; int count = 0; for (int i = 0; i < n; i++) {... |
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 5, inf = 1e16; long long a[N], p[N], b[N], seg[N << 2], m; void shift(long long id) { if (seg[id] == 0) return; seg[id << 1] += seg[id], seg[id << 1 | 1] += seg[id]; seg[id] = 0; } void add(long long l, long long r, long lon... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y; point(int x = 0, int y = 0) : x(x), y(y) {} }; point p[305]; int n; point operator-(point a, point b) { return point(a.x - b.x, a.y - b.y); } int cp(point a, point b) { return a.x * b.y - a.y * b.x; } double work() { int ... |
#include <bits/stdc++.h> #define debug(x) cout << #x << = << x << endl #define REP(i, n) for (Long i = 0; i < (Long)n; i++) using namespace std; typedef long long Long; const int MX = 3e5; vector<Long> adj[MX]; set<pair<Long,Long>> queries[MX]; Long saved[MX]; Long single[MX]; Long cnt[2 *... |
#include <bits/stdc++.h> using namespace std; int MOD = 1e9 + 7; long long int power(long long int a, long long int b) { long long int res = 1; a = a % MOD; while (b > 0) { if (b & 1) { res = (res * a) % MOD; b--; } a = (a * a) % MOD; b >>= 1; } return r... |
#include <bits/stdc++.h> using namespace std; char str; int n, m, g; int num[20480]; struct edge { int to; int nxt; int val; } nd[8 * 20480]; int head[20480], cnt; int cur[20480], dep[20480]; queue<int> q; int ans; template <class X> inline void read(X &x) { x = 0; X f = 1; ... |
#include <bits/stdc++.h> int main() { int n, m, min_m, max_n, min_n, x; scanf( %d%d , &n, &m); scanf( %d , &max_n); min_n = max_n; n--; while (n--) { scanf( %d , &x); if (x > max_n) { max_n = x; } else if (x < min_n) { min_n = x; } } scanf( %d , ... |
#include <bits/stdc++.h> using namespace std; const int N = 25, INF = 1e9 + 5; inline int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; c = getchar(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.