func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, flag = 0; int matrix[2505][2505]; int parent[2505]; vector<int> graph[2505]; int vis[2505], num[2505]; struct Edge { int u, v, w; Edge() {} Edge(int u, int v, int w) : u(u), v(v), w(w) {} }; vector<Edge> edge; bool cmp(const Edge &a, c... |
#include <bits/stdc++.h> using namespace std; int main() { int already = 0; int n, k; cin >> n >> k; int ans = 0; for (int i = 0; i < k; ++i) { int cnt; cin >> cnt; int first; cin >> first; if (first == 1) { int good = 1; already = 1; --ans; ... |
#include <bits/stdc++.h> using namespace std; long long t, x, y, p, q; bool check(long long mid) { long long pp = p * mid; long long qq = q * mid; if (pp - x < 0 || qq - y < 0) return false; return (pp - x <= qq - y); } int main() { scanf( %lld , &t); while (t--) { scanf( %lld %l... |
#include <bits/stdc++.h> using namespace std; int main() { int t, i, x; cin >> t; while (t--) { int angle; cin >> angle; x = 360 % (180 - angle); if (x == 0) { cout << YES << endl; } else cout << NO << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; const int N = 3e5 + 7; const int K = 5e3 + 7; int n, k; int a[N]; int dp[K][K]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int top = (n + k - 1) / k; ... |
#include <bits/stdc++.h> using namespace std; int main() { int h1, t1, h2, t2, ansh, anst; scanf( %2d:%2d , &h1, &t1); scanf( %2d:%2d , &h2, &t2); if (t1 < t2) { h1--, t1 += 60; } anst = t1 - t2; ansh = h1 - h2; if (ansh < 0) ansh += 24; printf( %02d:%02d n , ansh, anst); ... |
#include <bits/stdc++.h> int n; int a[105], l[105]; int id[105]; int dp[105][105][2]; int main() { scanf( %d , &n); for (int i = 0; i < (int)(n); ++i) scanf( %d %d , &a[i], &l[i]); for (int i = 0; i < (int)(n); ++i) id[i] = i; std::sort(id, id + n, [&](int x, int y) { return a[x] < a[y]; }); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 111, K = 26; int n; string name[MAX]; namespace G { struct V : vector<int> { V() : odw(false) {} bool odw; int wyj; }; V g[K]; void krawedz(char a, char b) { g[int(a) - int( a )].push_back(int(b) - int( a )); } int t = 0... |
#include <bits/stdc++.h> using namespace std; long long Pow(int a, int b) { long long ans = 1; for (int i = 0; i < b; i++) { ans = (ans * a) % 1000000007; } return ans; } int main() { long long n, k; cin >> n >> k; cout << (Pow(n - k, n - k) * Pow(k, k - 1)) % 1000000007 << end... |
#include <bits/stdc++.h> using namespace std; vector<int> v[200005]; int CR, n, k, sz[200005], target[200005], cented[200005]; void getsize(int now, int pre) { sz[now] = (target[now] == 1); for (int i = 0; i < v[now].size(); i++) { int next = v[now][i]; if (next == pre || cented[next]) conti... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; vector<int> A, B[MAX], C, D; int visited[MAX]; int n, m; void DFS(int u) { visited[u] = 1; C.push_back(u); for (int i = 0; i < B[u].size(); i++) { int current = B[u][i]; if (visited[current] == 0) DFS(current); ... |
#include <bits/stdc++.h> using namespace std; int n, m, s, ans = 0, f[2 * 200005]; inline int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); } int main() { scanf( %d%d%d , &n, &m, &s); for (register int i = 1; i <= m + n; i++) f[i] = i; for (register int i = 1; i <= s; i++) { register... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) const double eps = 1e-7; const int maxn = 3e5 + 10; const int prime[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}; const int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1}; int spgcd(int a, int b) { while (b ^= a ^= b ^= a %= b) ; ... |
#include <bits/stdc++.h> using namespace std; const int sz = (1 << 22); bool ar[sz], us[2][sz]; int n, m, bg; void dfs(int v, int t) { us[t][v] = 1; if (t == 0) { if (us[1][bg ^ v] == 0) dfs(bg ^ v, 1); } else { if (ar[v] and us[0][v] == 0) dfs(v, 0); for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long a[50]; long long inv[50]; long long Finv[50]; long long n, s; void init() { inv[1] = 1; for (int i = 2; i <= 50; i++) { inv[i] = (mod - mod / i) * inv[mod % i] % mod; } Finv[0] = 1; for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N % 2 == 0) cout << -1 << endl; else { for (int i = 0; i < N; i++) cout << i << (i == N - 1 ? n : ); for (int i = 0; i < N; i++) cout << ((long long)(N - 2) * i) % N << (i == N - 1 ? n ... |
#include <bits/stdc++.h> using namespace std; int sqrt_maxn = 505; const int maxsqrt_n = 205; const int maxn = 100005; int a[maxn]; struct node { int val; node* next; node* front; }; node* front[maxsqrt_n]; node* rail[maxsqrt_n]; int dp[maxsqrt_n][maxn]; node* new_node() { static n... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int M = 80; const int N = 4100; long long c[M][M], m; struct Tree { struct Node { int ne, to; } e[2 * N]; int vis[N], tot = 0, he[N], sz[N], mx[N], q[N], n, rp, mn; long long step[M], f[N][M], g[N][M], tmp[M... |
#include <bits/stdc++.h> using namespace std; struct trie { struct tree { long long al[26]; bool ex; } nxt[100005]; long long cnt, dep[100005]; void insert(char *s) { long long l = strlen(s), rt = 0; for (register long long i = 0; i < l; i++) { long long c = s[i] - a... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, T, ans; int t[N]; priority_queue<int> pq; int main() { scanf( %d%d , &n, &T); for (int i = 1; i <= n; ++i) { scanf( %d , &t[i]); t[i] = t[i] > i ? t[i] - i : 0; } for (int i = 1; i <= n; ++i) { pq.p... |
#include <bits/stdc++.h> int main() { int a, b, i, j, c = 0; int fil, col; scanf( %d , &a); scanf( %d , &b); char myChar; int aux[2][3]; for (i = 0; i < a; i++) { for (j = 0; j < b; j++) { scanf( %c , &myChar); if (myChar == * ) { aux[0][c] = i + 1; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const char nl = n ; const int MX = 100001; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; for (int tt = 0; tt < (t); tt++) { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e18 + 1; const ll mod = 1e9 + 7; vector<vector<ll> > adj; vector<ll> desc, max_n; ll gmnc = INF; void print_vec(vector<ll> vec) { for (int i = 0; i < vec.size(); ++i) { cout << vec[i] << ; } cout << ... |
#include <bits/stdc++.h> using namespace std; char s[400010]; int a[200]; vector<int> S; vector<int> d, q; int main() { int n; scanf( %d %s , &n, s); for (int i = 0; i < n; i++) a[s[i]]++; int p = 0; for (int i = 0; i < 128; i++) { if (a[i] % 2) p++, a[i]--, S.push_back(i); i... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6, SZ = 800, INF = 1 << 29; const long long LINF = (1LL << 60), mod = 1e9 + 7; const long double eps = 1e-8, PI = acos(-1.0); inline int dcmp(double x, double y = 0.0) { return abs(x - y) < eps; } template <typename Type> inline Type ru(Type &v... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int kq = 0; vector<pair<int, int> > res; int n, k; cin >> n >> k; vector<bool> used(2 * n + 1, false); for (int i = 1; i <= k; i... |
#include <bits/stdc++.h> int main() { long n, k, x, a, y; scanf( %ld %ld , &n, &k); a = n; x = n; while (x >= k) { y = x % k; x = x / k; a = a + x; x = x + y; } printf( %ld n , a); return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int power(int a, int b, int m, int ans = 1) { for (; b; b >>= 1, a = 1LL * a *... |
#include <bits/stdc++.h> using namespace std; const int N = 505; int n, now, siz[N], f[N]; bool vis[N]; vector<int> g, ans[N]; inline bool cmp(int x, int y) { return siz[x] < siz[y]; } void divide(int l, int r) { if (l > r) return; cout << 1 << endl << 1 << endl << r - l + 1 << endl; for (int ... |
#include <bits/stdc++.h> using namespace std; long long n, k; long long c[100006], freq[100006], people[100006], h[100006]; long long catche[5005][505]; long long dp(long long left, long long pep) { if (left == 0 || pep == 0) return 0; long long &ans = catche[left][pep]; if (ans != -1) return ans;... |
#include <bits/stdc++.h> using namespace std; const long long int N = 100005; void solve() { long long int m, n; cin >> n >> m; long long int count = 0; for (long long int i = 1; i <= n; i++) { count += (m + i % 5) / 5; } cout << count << endl; return; } int32_t main() { ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> bool uax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int MAXN = 1100000; ... |
#include <bits/stdc++.h> using namespace std; int cnt[15]; string a[100009]; const long long mod = 998244353LL; int main() { int i, len1, len2, n, j; long long p, sum, val; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; reverse(a[i].begin(), a[i].end()); cnt[a[i].size()]++... |
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template <typename T> int SIZE(const T(&t)) { return t.size(); } string to_string(char b) { return + string({b}) + ; } string to_string(bool b) { return (b ? true : f... |
#include <bits/stdc++.h> using namespace std; ifstream fin( fisier.in ); ofstream fout( fisier.out ); int v[1000000], minl[1000000], minr[1000000]; int main() { int n, i; cin >> n; for (i = 1; i <= n; ++i) cin >> v[i]; for (i = 1; i <= n; ++i) minl[i] = min(minl[i - 1] + 1, v[i]); for (i =... |
#include <bits/stdc++.h> using namespace std; long long dx[] = {1, 0, -1, 0}; long long dy[] = {0, 1, 0, -1}; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } long long expo(long long n, long long m, long long p) { long long r = 1; n = ... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y, z, k, w, ans; int A[400], B[400]; char c[2]; int main() { scanf( %d , &n); for (int i = (0); i < (n); i++) { scanf( %s%d%d , &c, &x, &y); if (c[0] == M ) { for (int j = (x); j <= (y); j++) A[j]++; } else { ... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; struct edge { int u, v; int flow; int cost; edge() {} edge(int u, int v, int f, int c) : u(u), v(v), flow(f), cost(c) {} }; struct MinCostMaxFlow { int N; vector<vector<int> > G; vector<edge> E; int num... |
#include <bits/stdc++.h> using namespace std; int main() { long long int l, r; cin >> l >> r; if (l == r) { cout << l; return 0; } cout << 2 << endl; } |
// author: xay5421 // created: Mon May 3 17:34:21 2021 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define per(i,a,b) for(int i=(a);i>=(b);--i) using namespace std; typedef long long LL; const LL INFLL=0X3F3F3F3F3F3F3F3FLL; const int N=200005; int n,Q,_w[N],_v[N],id[N],_id[N]... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-10; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int ax, ay, bx, by, cx, cy; cin >> ax >> ay >> bx >> by >> cx >> cy; complex<long double> a(ax, ay), b(bx, by), c(cx, cy); long double d1 = abs(b - a), d2 = abs(c ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a >> b >> c; cout << (a / c + (a % c != 0)) * (b / c + (b % c != 0)); return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void upmin(T &x, T y) { y < x ? x = y : 0; } template <typename T> inline void upmax(T &x, T y) { x < y ? x = y : 0; } const long double pi = acos(-1); const int oo = 1 << 30; const long long OO = 1e18; const int N ... |
#include <bits/stdc++.h> int a[100006]; int vis[100006]; int visyu[100006]; int main() { int n, x; scanf( %d%d , &n, &x); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); vis[a[i]]++; if (vis[a[i]] == 2) { printf( 0 n ); return 0; } } int mans = -1; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void Read(T &cn) { char c; int sig = 1; while (!isdigit(c = getchar())) if (c == - ) sig = -1; cn = c - 48; while (isdigit(c = getchar())) cn = cn * 10 + c - 48; cn *= sig; } template <typename T> void Write(T... |
#include <bits/stdc++.h> using namespace std; const int maxn = 400010; int c[maxn]; int ans[maxn]; void upd(int n, int k) { n++; while (n < maxn) c[n] += k, n += n & (-n); } int get(int n) { n++; int ans = 0; while (n) ans += c[n], n -= n & (-n); return ans; } int BS(int n) { ... |
#include <bits/stdc++.h> using namespace std; class SegmentTree { public: SegmentTree(int _n) : n(_n), N(_n << 1), data(N, INT_MAX) { h = 0; while (1 << h <= N) { ++h; } } void build(vector<int>& nums) { copy(nums.begin(), nums.end(), data.begin() + n); for (int ... |
#include <bits/stdc++.h> using namespace std; long long n, l, x, y; long long a[100100]; int main() { cin >> n >> l >> x >> y; for (int i = 0; i < n; i++) cin >> a[i]; bool fx = false, fy = false; for (int i = 0; i < n; i++) { if (binary_search(a, a + n, a[i] + x)) { fx = true; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 500010; int n, m; int seg[MAX]; int vis[MAX]; int p[MAX]; int in[MAX], out[MAX]; int aux = 0; vector<int> adj[MAX]; set<int> s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int x, s; cin >> x >> s; if (!s) ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long n, k; long long a[N]; bool check(long double x) { long double ans1 = 0, ans2 = 0; for (long long i = 0; i < n; i++) { if (a[i] > x) ans1 += (long double)(a[i] - x); if (x > a[i]) ans2 += (long double)(x - ... |
#include <bits/stdc++.h> using namespace std; long long a[100000]; int main() { long long n; long long cnt = 0; scanf( %I64d , &n); for (long long i = 0; i < n; i++) { scanf( %I64d , &a[i]); for (long long j = 0; j < i; j++) if (a[j] > a[i]) cnt++; } cout << (cnt % 2 + ... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> v; map<int, int> a, b; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; int m = n / 2; if (n % 2 != 0) { m++; } for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; ... |
#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; int arr[n]; int count = 0; int count1 = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] & 1) { count++; } ... |
#include <bits/stdc++.h> using namespace std; int mnt[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int mntl[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int y1, y2, m1, m2, d1, d2, i, j, k, l, ans = 0; scanf( %d:%d:%d , &y1, &m1, &d1); scanf( %d:%d:%d , &y2, &m2, &d2);... |
#include <bits/stdc++.h> using namespace std; inline void io() { freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); } long long I() { long long a; cin >> a; return a; } void PV(vector<long long> v) { for (long long i = 0; i < (long long)v.size(); i++) cout << v[i] ... |
#include <bits/stdc++.h> using namespace std; stack<int> sk; int main() { int T; string s; cin >> T; while (T--) { while (sk.size()) sk.pop(); cin >> s; int cnt = 0; for (int i = 0; i < s.size(); ++i) { if (sk.empty()) { sk.push(s[i] - 0 ); cont... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, k, chng_cnt; cin >> n >> m; int ara1[n + 1], ara2[n + 1], cnt[m + 1], maximizedMin; memset(cnt, 0, sizeof(cnt)); memset(ara1, 0, sizeof(ara1)); memset(ara2, 0, sizeof(ara2)); for (i = 1; i <= n; i++) { cin >... |
#include <bits/stdc++.h> using namespace std; const int N = 1111; const int M = 33333; const int INF = 2e9 + 9; int n, m; int s, t; int erased_edge; struct Edge { int u, v, c; Edge() {} Edge(int u, int v, int c) { this->u = u; this->v = v; this->c = c; } int to(int ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, n, arr[200010]; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; long long sum = arr[n - 1]; for (i = n - 1; i > 0; i--) { if (arr[i] <= arr[i - 1] && arr[i - 1] != 0) { if (arr[i] == 0) arr[i -... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int SIZE = 1e6 + 10; const int INF = 2147483647; template <class T> void maa(T& x, T y) { if (x < y) x = y; } template <class T> void mii(T& x, T y) { if (x > y) x = y; } int a[SIZE]; int record[SIZE][3], rn; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; string s; cin >> s; if (k == 0) { cout << s; return 0; } if (s.length() == 1) { if (k > 0) { cout << 0 ; return 0; } } if (s[0] != 1 ) { s[0] ... |
#include <bits/stdc++.h> using namespace std; int main() { int test; scanf( %d , &test); while (test--) { int fuck; string str; scanf( %d , &fuck); cin >> str; string ans = ; for (auto &x : str) { if ((x - 0 ) % 2 == 1) { ans += x; if (a... |
#include <bits/stdc++.h> using namespace std; map<long long, int> MP; int Q = 1; vector<pair<int, int> > adj[500005]; long long C[500005]; set<int> S; int p[500005]; long long pw(int x) { if (!x) return 1LL; if (x & 1) return 2 * pw(x - 1) % 1000000007; long long hf = pw(x / 2); return h... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename L> bool smax(T &x, L y) { return x < y ? (x = y, true) : false; } struct Q { int p, id; }; int get(int, int); void dfs(int); void sack(int, bool); const int MAXN = 1e5 + 15, LG = 20; int h[MAXN], cnt[MAXN]; int ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g, tr, comp; vector<int> us, vis, whr, col; void dfs(int v) { us[v] = 1; for (int i = 0; i < g[v].size(); i++) { int j = g[v][i]; if (!us[j]) dfs(j); } vis.push_back(v); return; } void dfstr(int v) { comp[... |
#include <bits/stdc++.h> using namespace std; const long long int conv[][3] = {{1, 2, 3}, {2, 3, 1}, {3, 1, 2}}; void solve(long long int n) { int r = n % 3; if (r != 0) n = (n / 3 + 1) * 3; if (r == 0) r = 2; else r = r - 1; int k = 0; long long int cnt = 3; while (cnt < n... |
#include <bits/stdc++.h> using namespace std; const long long inf = 9.2e18; const int maxn = 1e6 + 70; const int INF = 2.1e9; const int maxm = 1e6 + 70; const int MOD = 1e9 + 7; const double eps = 1e-7; const double PI = acos(-1.0); int n, m, k; vector<int> G[maxn]; int dep[maxn], mind[maxn], dp[m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, d, a, b, x, y; cin >> n >> d >> a >> b; pair<long long, long long> arr[n]; for (int i = 0; i < n; i++) { cin >> x >> y; x *= a; y *= b; arr[i] = {x + y, i... |
#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); } const int maxn = 5e4 + 9; int p[1009], a[1009]; bool vis[1009]; int dfs(int i) { if (vis[i]) return i; vis[i] = 1; int id = dfs(p[i]); ... |
#include <bits/stdc++.h> using namespace std; const long long int M = 1e3 + 7; map<long long int, long long int> value, visit; long long int n, m, points[M][M]; long long int bfs(long long int node) { long long int i; for (i = 1; i < n + 1; i++) { if (points[node][i] == 1) { if (value[i]... |
#include <bits/stdc++.h> using namespace std; const long long N = 1 << 17; const long long MN = N; long long s[MN]; long long m[MN]; long long rr[MN]; bool st[2 * N]; long long tme[2 * N]; long long lz[2 * N]; long long nn; vector<pair<long long, pair<long long, long long> > > manaFull[2 * N]; s... |
#include<bits/stdc++.h> #define pb(x) push_back(x) #define all(x) x.begin(), x.end() #define N 200005 #define FIFO ios::sync_with_stdio(false) #define cout3(x, y, z) cout << x << << y << << z << endl #define cout2(x, y) cout << x << << y << endl #define INF (1<<30) #define MOD 1000000007 #... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long mod1 = 998244353; long long power(long long a, long long b) { long long res = 1; while (b > 0) { if (b % 2 == 1) { res = (res * a) % mod; } a = (a * a) % mod; b >>= 1; } r... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( -fgcse ) #pragma GCC optimize( -fgcse-lm ) #pragma GCC optimize( -fipa-sra ) #pragma GCC optimize( -ftree-pre ) #pragma GCC optimize( -ftree-vrp )... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; const int mod = 1e9 + 7; int n, m, f[N], jc[N], njc[N], ans; int qpow(int x, int y) { if (!x) return 0; int res = 1; for (; y; x = 1ll * x * x % mod, y >>= 1) if (y & 1) res = 1ll * res * x % mod; return res; } int ... |
#include <bits/stdc++.h> #pragma 03 using namespace std; int main() { cout << INTERCAL n ; return 0; } |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[26]; int b[26]; int main() { for (int i = 0; i < 26; i++) a[i].second = i; string s; cin >> s; int d; cin >> d; for (int i = 0; i < int(s.size()); i++) a[int(s[i] - a )].first++; sort(a, a + 26); int tmp = 0; for... |
#include <bits/stdc++.h> using namespace std; int main() { long long int res = 0; int a[200005], n, i, mm = INT_MAX; scanf( %d , &n); for (i = 1; i <= n; ++i) { scanf( %d , &a[i]); mm = min(mm, a[i]); } set<int> second; for (i = 1; i <= n; ++i) if (a[i] == mm) second.in... |
#include <bits/stdc++.h> using namespace std; int points[11] = {0, 25, 18, 15, 12, 10, 8, 6, 4, 2, 1}; struct T { vector<int> a; string name; T() { for (int i = (1); i <= (55); i++) a.push_back(0); } bool operator<(const T &b) const { return a > b.a; } } ma[1100]; int n, games; map... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; while (cin >> n) { int pos, val; multimap<int, int> mp1, mp2; while (n--) { cin >> pos >> val; pos < 0 ? mp1.insert(pair<int, int>(pos, val)) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; vector<int> G[maxn]; int p[maxn], d[maxn], vis[maxn], mx, rt; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } void dfs(int u, int fa, int dep, int tp) { vis[u] = 1; if (dep > mx) { mx = dep; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1010, Maxm = 20; const unsigned long long Seed = 19990213; const long long Mod = 1000000007; int n, m, cnt, tot1, fst1[Maxn], pre1[Maxn << 1], to1[Maxn << 1], tot2, fst2[Maxm], pre2[Maxm << 1], to2[Maxm << 1], bel[Maxm], tot[Maxm], sta... |
#include <bits/stdc++.h> using namespace std; int a[300005]; int lastone[300005]; int nextone[300005]; long long sum[300005]; vector<int> vt[3]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); sum[i] = sum[i - 1] + a[i]; lastone[i] = (a... |
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000000000; long double eps = 1e-12; long long t, n, m, a; vector<long long> vec; void Stefan() { cin >> n >> m; long long cur = 1; for (int i = 0; i < n; i++) { cin >> a; vec.push_back(a); } if (n >... |
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define ar array #define all(x) x.begin(), x.end() #define siz(x) (int)x.size() #define FOR(x, y, z) for(int x = (y); x < (z); x++) #define ROF(x, z, y) for(int x = (y-1); x >= (z); x--) #define... |
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; const int maxN = n; int r[maxN]; int c[maxN]; int a[maxN][maxN]; for (int i = 0; i < n; i++) { r[i] = 0; for (int j = 0; j < n; j++) { cin >> a[i][j]; r[i] = r[i] + a[i][j]; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T f = 0, x = 0; char c = getchar(); while (!isdigit(c)) f = c == - , c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); return f ? -x : x; } namespace run { const int mod = 998244353... |
#include <bits/stdc++.h> using namespace std; int n, m, dx, dy; int a[1000001]; int cnt[1000000] = {}; bool vis[1000000] = {}; inline int gcd(int a, int b) { while (b) a %= b, swap(a, b); return a; } int main() { ios_base::sync_with_stdio(false); cin >> n >> m >> dx >> dy; int g = gc... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T checkmin(T &a, T b) { return (a < b) ? a : a = b; } template <class T> inline T checkmax(T &a, T b) { return (a > b) ? a : a = b; } template <class T> T GCD(T a, T b) { if (a < 0) return GCD(-a, b); if (b < 0) re... |
#include <bits/stdc++.h> using namespace std; bool ansnull(int a, int b, int c, int d) { int ans = 0; if (a != 0) ++ans; if (b != 0) ++ans; if (c != 0) ++ans; if (d != 0) ++ans; if (ans >= 2) return true; else return false; } int main() { int a[100010][5]; int n, ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, k; cin >> a >> b >> c >> k; if (k >= a + b + c - 3) { cout << a * b * c << endl; } else { long long res = 1; for (int x1 = 0; x1 < a; x1++) { long long help = (-k + x1) / (-2); for (int n ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; scanf( %d , &n); int arr[n]; for (i = 0; i < n; i++) scanf( %d , &arr[i]); int t = 0; int index = -1; for (i = 0; i < n; i++) if (arr[i] - arr[(i + 1) % n] > 0) { t++; index = i; } if ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { int x; cin >> x; cout << x - !(x & 1) << ; } } |
#include <bits/stdc++.h> using namespace std; struct node { int x, y, z; }; node q[200001]; int n, m; bool ok[2][100001]; char s[100005]; int main(void) { scanf( %d %d , &n, &m); for (int i = 0; i < 2; ++i) { scanf( %s , s + 1); for (int j = 1; j <= n; ++j) if (s[j] == -... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, cnt[2000000]; scanf( %d , &n); for (int i = 0; i < 2000000; ++i) cnt[i] = 0; for (int i = 0; i < n; ++i) { scanf( %d , &t); cnt[t]++; } long long ans = 0; for (int i = 0; i < 2000000 - 1; ++i) { cnt[i ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native ) using namespace std; namespace _c { const double pi = acos(-1.0); namespace min { const int i8 = -128; const int i1... |
#include <bits/stdc++.h> using namespace std; auto random_address = [] { char *p = new char; delete p; return (uint64_t)p; }; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1)); const int INF = 1e9 + 5; struct edge { int a, b, color, in... |
#include <bits/stdc++.h> using namespace std; #pragma GCC diagnostic warning -Wall int main() { int n; scanf( %d , &n); vector<vector<int> > sec(n); for (typeof(n) i = (0); i < (n); i++) { int k; scanf( %d , &k); sec[i].resize(k); for (typeof(k) j = (0); j < (k); j++) sca... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, g; cin >> n >> g; vector<long long> v, ans; map<long long, long long> m; map<long long, long long>::iterator it; for (int i = 0; i < n; i++) { long long a; cin >> a; m[a]++; } for (it = m.begin(... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cout << fixed << setprecision(15); int N, M, S, K; cin >> N >> M >> S >> K; vector<int> type(N); for (int i = 0; i < N; i++) { cin >> type[i]; --type[i]; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.