func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <class T> inline T euclide(T a, T b, T& x, T& y) { if (a < 0) { T d = euclide(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = euclide(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while ( 0 <= ch && ch <= 9 ) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar(); r... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M, Dx, Dy; cin >> N >> M >> Dx >> Dy; vector<pair<int, int>> way(N); way[0].first = way[0].second = 0; for (int i = 1; i < N; ++i) { way[i].first = (way[i - 1].first +... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, c = 0; cin >> n; int a, f[7]; for (int j = 0; j < 7; j++) f[j] = 0; for (int i = 0; i < n; i++) { cin >> a; for (int j = 0; j < 7; j++) { if (a % (int)pow(10, 1) == 1) f[j]++; a = a / 10; } ... |
#include <bits/stdc++.h> using namespace std; int o, O, f, z, i, d; string t, s[6] = { lios , liala , etr , etra , initis , inites }; int V[ zz ]; int main() { while (cin >> t) { for (i = O = 0; i < 6; i++) if ((d = t.size() - s[i].size()) < 0 ? 0 : t.substr(d) == s[i]) { if (... |
#include <bits/stdc++.h> using namespace std; int n, x, y, son[100005], q; int fir[100005], nxt[200005], to[200005], cnt; long long wi[200005], z, dp[100005][2], f[100005]; struct node { int id; long long val; } c[100005]; int size[100005], fa[100005], Fa[100005]; long long read() { long lon... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 20], *p1 = buf, *p2 = buf; template <typename T> void read(T &x) { x = 0; bool f = 1; char c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++); for (; !isdigit(c)... |
#include <bits/stdc++.h> using namespace std; const int N = 150, M = 65; int n; int dist[N][N], g[N][N]; vector<long long> v[M]; map<long long, int> mp; int main() { memset(g, 0x3f, sizeof g); memset(dist, 0x3f, sizeof dist); cin >> n; for (int i = 0; i < n; i++) { long long t, x; ... |
#include <bits/stdc++.h> int n, k, a, b, c, d; std::vector<int> first_path; std::vector<int> second_path; bool first_reversed = false; bool second_reversed = false; bool failed = false; void read() { scanf( %d %d n%d %d %d %d , &n, &k, &a, &b, &c, &d); --a; --b; --c; --d; first_pat... |
/* author: Maksim1744 created: 10.03.2021 16:47:29 */ #include bits/stdc++.h using namespace std; #define ll long long #define ld long double #define mp make_pair #define pb push_back #define eb emplace_back #define sum(a) ( accumulate ((a).begin(), (a).end(... |
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } long long int gcd(long... |
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch()... |
#include <bits/stdc++.h> using namespace std; void solve() { string number; cin >> number; int n = number.length(); int answer; vector<vector<int> > remainders = { {}, {1}, {1, 2, 4, 3}, {1, 3, 4, 2}, {1, 4}}; int last_digit = number[n - 1] - 0 ; if (n == 1) { answer = (re... |
#include <bits/stdc++.h> using namespace std; const int N = 500005, mod = 1000000007; long long int a, b, c, d, e, f, g, h[N], arr[N]; string s; vector<long long int> v; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> a; long long int ans = 0, tek = 0... |
#include <bits/stdc++.h> using namespace std; int n, m; int cnt = 1e8; int main() { cin >> n >> m; cout << (n >= 27 ? m : m % (1 << n)); } |
#include <bits/stdc++.h> using namespace std; const int N = 31; int a[1000010]; long long cnt1[N + 10]; long long cnt2[N + 10]; long long cnt3[N + 10]; long long cnt4[N + 10]; int b[1000010]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = (0); i < (n); ++i) scanf( %d , &a[i]); ... |
#include <bits/stdc++.h> using namespace std; int movei[] = {0, 0, 1, -1, 1, 1, -1, -1}; int movej[] = {1, -1, 0, 0, 1, -1, 1, -1}; const int MXN = 1e5 + 7; int can(vector<int> &FRQ, int k) { int mx = 1; while (true) { bool makable = true; int total = 0; for (int x : FRQ) total += x ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k; cin >> n >> k; long long arr[n], arr1[n], arr2[n]; long long F1 = INT_MIN, F2 = INT_MIN; for (int i = 0; i < n; ++i) { cin >> arr[i]; F1 = max(F1, arr[i... |
#include <bits/stdc++.h> long long int gcd(long long int a, long long int b) { return a ? gcd(b % a, a) : b; } long long int power(long long int a, long long int b) { long long int ans = 1; long long int s = a; long long int t = b; while (t) { if (t % 2 == 1) ans *= s, ans %= 998244353; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cout << 2000 << endl; for (int i = 1; i <= 1000; ++i) cout << i << << 1 << << i << 2 n ; for (int i = 1000; i >= 1; --i) cout << i << << 1 << << i << 2 n ; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10; int n, a[N], k, dp[N]; void bsearch() { long long l = -1, r = 2e9 + 1; while (l + 1 < r) { long long mid = (r + l) / 2; bool check = false; for (int i = 0; i < n; i++) { dp[i] = i; for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; template <typename first, typename second> ostream &operator<<(ostream &os, const pair<first, second> &p) { return os << ( << p.... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 600005; int minx[Maxn], tip[Maxn]; int a[Maxn], b[Maxn], c[Maxn]; int n, m, i, h, L, R, t, ans; void ins(int p, int l, int r, int pos, int data) { if (l == r) { minx[p] = data; return; } int mid = (l + r) >> 1; if (po... |
#include <bits/stdc++.h> using namespace std; int len(char* a) { int count; for (int i = 0; a[i] != 0 ; ++i) { ++count; } return count; } int main() { char a[101], b[101], c[101]; int found = 0, i, j; fscanf(stdin, %s%s%s , a, b, c); if (len(a) + len(b) != len(c)) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e6; const int Linf = 1e9; const long long LLinf = (long long)1e18; const int maxn = 1e5 + 5; int n, a[maxn]; long long k, res = 0; int sum[maxn], sum1[maxn], cnt; map<int, int> mmap; set<int> s; void Enter() { cin >> n >> k; fo... |
#include <bits/stdc++.h> using namespace std; char getDiffColor(char a, char b) { map<char, bool> mp; mp[a] = true, mp[b] = true; if (mp.find( R ) == mp.end()) return R ; else if (mp.find( G ) == mp.end()) return G ; else return B ; } int main() { int cnt = 0; st... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } void setI... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; const int maxm = 100000 + 10; vector<int> adj[maxn]; int fa[maxn][18], dep[maxn]; void trans(int prev, int u) { dep[u] = dep[prev] + 1; fa[u][0] = prev; for (int i = 1; (1 << i) <= dep[u]; i++) { fa[u][i] = fa[fa[u... |
#include <bits/stdc++.h> using namespace std; int gd(const string &a, const string &b) { int d = 0; for (int i = 0; i < (int)a.size(); i++) if (a[i] != b[i]) d++; return d; } string a[1005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } ... |
#include <bits/stdc++.h> using namespace std; bool a[4111][4111]; int n; bool v[4111] = {0}; int p[4111] = {0}; int cnt = 0; int ans[4111] = {0}; bool dfs_find(int i, int lt) { v[i] = true; for (int j = 1; j <= n; j++) { if (a[i][j] > 0 && lt != j && i != j) { if (v[j]) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 501000; const int INF = 0x3f3f3f3f; vector<int> v[MAX_N], w[MAX_N]; struct skt { int x, y; }; int dis[MAX_N][2]; int tox[MAX_N][2], toy[MAX_N][2]; int n; int b[MAX_N]; void bfs() { int i; queue<int> q; skt t; memse... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; long long sum = 0; for (int i = 0; i < n; ++i) sum += a[i]; long long cntWhite = 0; for (... |
#include <bits/stdc++.h> using namespace std; string s; map<string, int> mp; const int N = 1e5 + 5; int a[N]; int cost[N]; int g[N]; int main() { int n, k, m; cin >> n >> k >> m; for (int i = 1; i <= n; i++) { cin >> s; mp[s] = i; } for (int i = 1; i <= n; i++) { sc... |
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; int n, k, ans, mx, edg[1010][1010], dis[1001]; vector<int> v, gr[100000]; bool vis[1001]; void dfs(int x, int l) { vis[x] = true; dis[x] = 0; for (int i = 0; i < gr[x].size(); i++) { int u = gr[x][i]; if (vis... |
#include <bits/stdc++.h> using namespace std; ifstream fin( abc.in ); string str[2]; long long let[26][500001]; long long a, b, sum, m; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { cin >> a >> b; cin >> str[0] >> st... |
#include <bits/stdc++.h> using namespace std; int a[40] = {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}; int main() { int t; cin >> t; cout << a[t] << endl; ... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long prod = 1; while (b) { if (b & 1) prod = (prod * a); a = (a * a); b >>= 1; } return prod; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long maxn = 60; const long long mod = 1e9 + 7; const long double PI = acos((long double)-1); long long pw(long long a, long long b, long long md = mod) { long long res = 1; w... |
#include <bits/stdc++.h> using namespace std; long long Set(long long N, long long pos) { return N = N | (1 << pos); } long long reset(long long N, long long pos) { return N = N & ~(1 << pos); } bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); } void CI(long long &_x) { scanf( %I64d , &... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double PI = acos(-1.0); long long f[555], n; string g[] = { < , ^ , > , v }; string s, t; int main() { cin >> s >> t; cin >> n; if (n % 2 == 0) { cout << undefined ; return 0; } for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; struct node { int v, id, tag; } a[100010]; int cmp1(node x, node y) { return x.v < y.v; } int cmp2(node x, node y) { return x.id < y.id; } int ccount[100010]; int main() { int n, tt; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[... |
#include <bits/stdc++.h> using namespace std; const int N = 501; int n, k; int C[N]; bool Dp[N][N][N]; vector<int> Ans; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , C + i); Dp[n][0][0] = true; for (int idx = n - 1; idx >= 0; idx--) for (int Sum = 0; Sum... |
#include <bits/stdc++.h> using namespace std; int n, m, x, f[5005][5005], g[5005], h[5005], cnt[5005]; long long ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &x); ++cnt[x]; } m = 5000; for (int i = 1; i <= m; ++i) { memcpy(f[i], f[i - 1], si... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int n, m, k, par[N], portal[N]; long long dist[N]; vector<pair<int, int> > gr[N]; vector<pair<int, pair<int, int> > > edges; vector<pair<long long, pair<int, int> > > new_edges; inline int get(int x) { if (par[x] < 0) return x; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; int i, j; cin >> n >> k; int arr[n]; for (i = 0; i < n; i++) cin >> arr[i]; int one, two; int m = 0; for (i = 0; i < k; i++) { one = 0, two = 0; for (j = i; j < n; j = j + k) { if (arr[j] == 1) ... |
#include <bits/stdc++.h> using namespace std; long long inf = numeric_limits<long long>::max(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int cases; cin >> cases; while (cases--) { int n; cin >> n; if (n % 2 == 0) cout << 1; else cout... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5010; vector<int> ne[maxn]; int cnt[maxn], n; int dp[maxn], res[maxn]; void dfs(int v, int prev = -1) { cnt[v] = 1; vector<int> w; int last = n - 1; for (int i = 0; i < (int)ne[v].size(); i++) { int u = ne[v][i]; if (... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, x; cin >> a >> b >> x; string s = ; if (a >= b) { s.push_back( 0 ); a--; } else { s.push_back( 1 ); b--; } while (x) { if (x == 1) { if (s.back() == 1 ) { while (b) s.p... |
#include <bits/stdc++.h> using namespace std; vector<int> a[2222]; int dis[2222]; int main() { for (int i = 0; i < 2222; ++i) dis[i] = -1; dis[0] = 0; int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { char c; cin >> c; if (c == ... |
#include <bits/stdc++.h> using namespace std; vector<int> ans; int b; queue<pair<int, int> > qu; void OUT() { if (ans.size() == 201) ans.pop_back(); printf( %d n , ans.size()); for (int i = 0; i < ans.size(); i++) printf( %d , ans[i]); } int solve(int last, int i) { if (last == 0) return ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long r, x1, x2, y1, y2, ans; cin >> r >> x1 >> y1 >> x2 >> y2; double d1, d2; x1 -= x2; y1 -= y2; d1 = sqrt(1.0 * (x1 * x1 + y1 * y1)); d2 = d1; d2 /= (2 * r * 1.0); if (floor(d2) == ceil(d2)) { ans = d2; ... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void _DBG(const char *s, _T x) { cerr << s << = << x << n ; } template <typename _T, typename... args> void _DBG(const char *s, _T x, args... a) { while (*s != , ) cerr << *s++; cerr << = << x << , ; _DBG... |
#include <bits/stdc++.h> const int MaxN = 100000, MaxLog = 17; struct graph_t { int cnte; int head[MaxN + 5], to[MaxN * 2 + 5], next[MaxN * 2 + 5]; inline void clear() { cnte = 0; memset(head, 0, sizeof head); memset(to, 0, sizeof to); memset(next, 0, sizeof next); } inli... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; map<string, long long int> month; void Month() { month[ January ] = 1, month[ February ] = 2, month[ March ] = 3, month[ April ] = 4, month[ May ] = 5, month[ June ] = 6; month[ July ] = 7, month[ August ] = 8, month[ Septem... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; const int BSZ = 600; const int N = 100228; const int LG = 17; int n, m; vector<vi> g; vi pred; vi in, out; int timer; int up[LG][N]; vi ts; v... |
#include <bits/stdc++.h> using namespace std; void ex() { cout << NO n ; exit(0); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<pair<bool, int> > q(2 * n); for (int i = 0; i < 2 * n; ++i) { char t; cin >> t; if (t ==... |
#include <bits/stdc++.h> using namespace std; int n, deg[51]; long long dp[2][51][51][51][51]; inline void add(long long &a, long long b) { a += b; } void transition3(int b, int p1, int p2, int c1, int c2) { long long from = dp[b][p1][p2][c1][c2] % 1000000007; b ^= 1; if (p1 > 0) add(dp[b][p1 - 1]... |
#include <bits/stdc++.h> using namespace std; int num = 1001; struct node { long long l, r; int t; } a[1008611]; long long ans[1008611], tm[1008611]; int main() { long long n, m; cin >> n >> m; for (long long i = 0; i < m; i++) { cin >> a[i].t >> a[i].l >> a[i].r; if (a[i].t)... |
#include <bits/stdc++.h> using namespace std; long long w1, h1, w2, h2, ans = 0; int main() { cin >> w1 >> h1 >> w2 >> h2; ans += (h1 + h2) + 2; ans += w2 + 1; ans += (h1 + h2) + 1; ans += w1 - w2; ans += w1; cout << ans << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5; int t; int n, m, k; vector<int> graph[NMAX + 5]; int gr[NMAX + 5]; bool active[NMAX + 5]; bool in[NMAX + 5]; bool exists(int i, int j) { vector<int>::iterator it = lower_bound(graph[i].begin(), graph[i].end(), j); if (it != gr... |
#include <bits/stdc++.h> using namespace std; string t = abacaba ; int get(string a) { int cnt = 0; for (int i = 0; i < a.size(); i++) { if (a.substr(i, t.size()) == t) cnt++; } return cnt; } int main() { int T; scanf( %d , &T); while (T--) { int n; string a; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; assert(1 <= n && n <= (int)(2e5)); string sex; cin >> sex; assert(sex.size() == n); for (int i = 0; i < n; ++i) { assert(sex[i] == B || sex[i] == G ); } vector<int> a(n); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; bitset<100015> A[4096]; int n, m, k, q, lp, S, a[12][100015], t[100015], x[100015], y[100015], p[100015]; int main() { int i, j, l; scanf( %d %d %d , &n, &k, &q); for (i = 0; i < k; i++) for (j = 1; j <= n; j++) scanf( %d , &a[i][j]); for... |
#include <bits/stdc++.h> using namespace std; int n, q, x, y; int a[200005]; long long lazy[200005 * 4], S[200005 * 4]; void push(int node, int bas, int son) { S[node * 2] += lazy[node]; S[node * 2 + 1] += lazy[node]; lazy[node * 2] += lazy[node]; lazy[node * 2 + 1] += lazy[node]; lazy[nod... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int x, y, z; cin >> x >> y >> z; int x1, y1, z1; cin >> x1 >> y1 >> z1; int a[6]; for (auto &z : a) cin >> z; int sum = 0; if (x < 0) sum += a... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int M = 1000005; const long long INF = (long long)(1e15); long long a[N][N]; long long retc[M], retr[M]; priority_queue<pair<long long, int> > sc, sr; int main() { int n, m, k, p; scanf( %d%d%d%d , &n, &m, &k, &p); for (... |
#include <bits/stdc++.h> using namespace std; long double PI = 3.14159265359; long long inf = 1000000000000000007; long long mod = 1000000007; long long mod1 = 998244353; const bool multi = 0; long long DP[500007]; long long s[500007]; vector<long long> G[500007]; long long ans = inf, n; void dfs(... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1)); int K, N; vector<int> A, B, Z; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> K; N = 1 << K; Z.resize(N); ... |
#include<bits/stdc++.h> #define PI acos(-1.0) #define eps 1e-8 #define fi first #define se second #define m_p make_pair //#define int long long #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; typedef long long ll; typedef unsigned int uint; const double E_num ... |
#include<bits/stdc++.h> using namespace std; #define lc cout<< n #define f1(a) for(int i=0;i<a;++i) int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t;cin>>t; while(t--){ int n;cin>>n; int a[n],b[n]; std::vector<int> pos_index,pos_dif; std::vector... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c< 0 | c> 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x *= sg... |
#include <bits/stdc++.h> using namespace std; int a[1000004]; int main() { int n, x; long long sum; int cnt; while (scanf( %d , &n) == 1) { sum = 0LL; cnt = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] % 2 == 1) cnt++; sum += a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, l[3], k[3], z = 0, j; cin >> n >> m; char a[n][m]; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { cin >> a[i][j]; if (a[i][j] == * ) { k[z] = i + 1; l[z] = j + 1; z++; ... |
#include <bits/stdc++.h> using namespace std; double a[220005]; double b[220005]; int n; double check(double x) { double q1 = 0.0, q2 = 0.0, q3 = 0.0; for (int i = 1; i <= n; i++) b[i] = a[i] - x; for (int i = 1; i <= n; i++) q1 = max(b[i], b[i] + q1), q3 = max(q1, q3); for (int i = 1; i <= n;... |
#include <bits/stdc++.h> using namespace std; int n, Q, l, r; int a[5000], b[5000][5000], c[5000][5000]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) b[i][i] = c[i][i] = a[i]; for (int L = 1; L < n; L++) for (int i = 1; i + L <... |
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 5; const long long INF = 1e18; const long long MOD = 1e9 + 7; int seg[2][8 * maxN], lzy[2][8 * maxN]; int lt[maxN], rt[maxN], Q[2][2 * maxN], N; vector<int> vec; long long two_to_the_power_of(long long x) { if (x == 0) return 1; ... |
#include <bits/stdc++.h> using namespace std; long long ar[500005 + 5]; int main() { long long i, j, k, n; cin >> n; if (n <= 2) cout << 1 << endl; else if (n == 3) cout << 2 << endl; else { long long lo = 1LL, hi = n, ans = 1LL; while (lo <= hi) { long long md ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e18; int n, m; int edges[22][2]; bool used[6][6]; int arr[7]; void init() {} void input() { cin >> n >> m; for (int i = 0; i < m; i++) { cin >> edges[i][0] >> edges[i][1]; edges[i][0]--; edges... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, t, n; double x, y; cin >> t; while (t--) { cin >> n; switch (n) { case 1: j = 0; break; case 2: j = 1; break; case 3: j = 2; ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > edge; int flo[120][120], flo2[120][120], dp[120][120], menda[120][120], com; int st[120], en[120]; vector<int> vc[120]; void sho(int n) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == j) continue... |
#include <bits/stdc++.h> const size_t Size = 1e5 + 5; const size_t SqrtS = 775 + 5; int f[Size]; int sum[Size]; int cost[Size]; std::vector<int> d[Size]; int n, k; int main(void) { std::scanf( %d%d , &n, &k); for (int i = 1, x, y; i <= k; ++i) { std::scanf( %d%d , &x, &y); d[y].push_... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2) cout << -1 ; else for (int i = 1; i <= n; i += 2) cout << i + 1 << << i << ; return 0; } |
#include <bits/stdc++.h> using namespace std; long long small = 1298173; int n, m, a = 1, b = 2; void step() { if (a == 1 and b == n - 1) { a++; b = a + 1; } else if (b < n) { b++; } else { a++; b = a + 1; } } int main() { ios_base::sync_with_stdio(0); c... |
#include <bits/stdc++.h> using namespace std; int a[100000 + 10]; int b[100000 + 10]; int main() { int n, x, m, y; scanf( %d%d%d%d , &n, &m, &x, &y); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (int i = 1; i <= m; i++) { scanf( %d , &b[i]); } printf( %s , a[x... |
#include <bits/stdc++.h> using namespace std; int main() { unordered_map<int, int> nums; int n; cin >> n; while (n--) { int dummy; cin >> dummy; nums[dummy]++; } int res = 0; for (auto p : nums) res = max(res, p.second); cout << res << endl; } |
#include <bits/stdc++.h> using namespace std; const int N=2e5+7; int n; int x=-1,y=-1,z=-1; int a[N], t[N*4]; vector<int> suff(N), pref(N); void build(int v=1, int tl=1, int tr=n){ if(tl==tr) t[v]=a[tl]; else { int tm = (tl+tr)/ 2; build(v*2, t... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int x; cin >> x; if (x % 4 == 0) printf( 1 A ); else if (x % 4 == 1) printf( 0 A ); else if (x % 4 == 2) printf( 1 B ); else if (x % 4 == 3) p... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, a, b, flag = 0, check = 1; cin >> n >> a >> x >> b >> y; for (int i = a, j = b; check != 0; i++, j--) { if (i == n + 1) { i = 1; } if (j == 0) { j = n; } if (i == j) { flag = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; cout << 9 * n << << 8 * n << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int a[1005][10]; int main() { int n, s = 0; cin >> n; for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < 3; j++) { cin >> a[i][j]; if (a[i][j]) c++; } if (c >= 2) s++; } cout << s; } |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; int n = 5e5, f[N], s[N]; vector<int> v[N]; int q, a[N], c[N]; int main() { int i, j, t; long long ans; for (i = 1; i <= n; i = i + 1) { if (i == 1) f[i] = 1; for (j = i; j <= n; j = j + i) { v[j].push_back(i... |
#include <bits/stdc++.h> using namespace std; struct Line { double kx; double b; double x1; double x2; }; double CONST = pow(10, 12); long long n, k, ai; double bi; vector<double> pre, summ, resumm; vector<double> data; double intersec(Line f, Line s) { return (s.b - f.b) / (f.kx - s.k... |
#include <bits/stdc++.h> using namespace std; void solve() { int x, y, z; cin >> x >> y >> z; if (x > 0) { cout << 0 ; for (int i = 1; i <= x; i++) cout << 0 ; } if (y > 0) { if (x == 0) cout << 0 ; cout << 1 ; y--; } else if (z > 0 && y == 0 && x == 0) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; const int oo = maxn; int n; int a[maxn], b[maxn], c[maxn], it[maxn * 8], itmin[maxn * 8]; int findit(int u, int v, int l, int r, int i) { if (r < u || v < l) return oo; if (u <= l && r <= v) { return (itmin[i]); } ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int neg = 1, num = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) neg = -1; for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - 0 ; return neg * num; } struct node { int x,... |
#include <bits/stdc++.h> using namespace std; struct Node { int x, y, t; Node(int x = -1, int y = -1, int t = 0) : x(x), y(y) {} }; Node a[1005]; string G[1005]; int row[1005], col[1005]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> G[i]; G[i]... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 17; vector<int> adj[N]; int n, k; int cnt[N]; bool mark[N]; long long int ans = 0; int findCentroid(int v, int n, int &ans, int par = -1) { int sum = 1; int mx = 0; for (int u : adj[v]) { if (u != par && !mark[u]) { ... |
#include <bits/stdc++.h> using namespace std; char a[105][105]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cout << a[j][i] <... |
#include <bits/stdc++.h> using namespace std; using lint = long long; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_; template <typename T, ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, test, n, m, value; cin >> test; while (test--) { int s = 0; cin >> n >> m; for (i = 1; i <= n; i++) { cin >> value; s += value; } if (s == m) { printf( YES n ); } else { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.