func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m, x, ans, h[5010], a[5010][5010], b[5010][5010]; int main() { scanf( %d , &n); m = (n + 1) / 2; for (int i = (1); i <= (n); i++) scanf( %d , &h[i]); for (int i = (0); i <= (n); i++) for (int j = (0); j <= (m); j++) a[i][j] = b[i][j] = 100... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; queue<int> q; priority_queue<pair<int, int> > Q; vector<pair<int, int> > V[maxn]; struct edge { int obj, last; } e[maxn]; int n, N, m, p, top, cnt, point[maxn], in[maxn], ord[maxn], L[maxn], H[maxn], ans[maxn]; bool vis[m... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {0, 0, -1, -1, -1, 1, 1, 1}; const int dy[8] = {-1, 1, -1, 0, 1, -1, 0, 1}; int r, c, n, res, a, b, f[18000005]; bool vis[3001][6001], g[3001][6001]; stack<pair<int, int> > stk; void init() { for (int i = 0; i < r * c; ++i) f[i] = i; } ... |
#include <bits/stdc++.h> using namespace std; inline bool check_diags(int x0, int y0, int x, int y) { return abs(x0 - x) == abs(y0 - y); } inline bool check_lines(int x0, int y0, int x, int y) { return x - x0 == 0 || y - y0 == 0; } vector<int> a, b, c, d; int n, x, s, m, k; void read() { for... |
#include <bits/stdc++.h> using namespace std; const int M = 3333; const int mod = 998244353; long long dp[M][M]; char s[M], t[M]; int main() { scanf( %s%s , s + 1, t + 1); int n = strlen(s + 1), m = strlen(t + 1); for (int i = 1; i <= n + 1; i++) dp[i][i - 1] = 1; for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) struct Edge { int to, w; }; const int N = 3e5 + 5, L = 20; vector<Edge> v[N]; int a[N], tin[N], tout[N], p[N][L]; long long maxPath[N], maxUpPath[N], sum[N], pt[N], ancw[N]; int timer = 0; bool upper(int a, int b) { re... |
#include <bits/stdc++.h> using namespace std; long long i, sum, a, b, c; int main() { for (i = 0; i < 4; i++) { cin >> a; if (i == 0) { b = a; c = a; } if (a < b) { b = a; } if (a > c) { c = a; } sum += a; } if (sum % 2 ==... |
#include <bits/stdc++.h> using namespace std; int main() { int l; cin >> l; string s; cin >> s; if (l < 26) { cout << NO n ; return 0; } int f[26] = {}; for (int i = 0; i < l; i++) f[tolower(s[i]) - a ]++; for (int i = 0; i < 26; i++) if (f[i] == 0) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010, LOG = 20; int n, m, k, q, u, v, x, y, ... |
#include <bits/stdc++.h> using namespace std; inline long long sqr(int a) { return a * 1ll * a; } int main() { int k; cin >> k; int len = k; int cnt = 0; int x = 0; long long res = 0; while (x <= 2 * k) { if (!(cnt & 1)) { int best = 0; int l = 1, r = k; w... |
#include <bits/stdc++.h> using namespace std; bool comp(string a, string b) { return a.size() < b.size(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string arr[n]; for (int i = 0; i < n; ++i) cin >> arr[i]; sort(arr, arr + n, co... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; struct Hash { const long long int mod = 1791791791; const long long int base = 255; vector<long long... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000010; int n, m, tot, ans; int mx[maxn], mn[maxn], fir[maxn]; struct edge { int a, b, l, r; } p[maxn << 1]; queue<int> q; vector<int> v[maxn]; inline void add(int a, int b, int c, int d) { p[++tot].a = a, p[tot].b = b, p[tot].l =... |
#include <bits/stdc++.h> const int MAX_CITIES = 1e5; int n, m, c, q; int dsu[MAX_CITIES + 1] = {0}; std::set<int> adj[MAX_CITIES + 1]; std::map<int, int>* city_rainbows; int getDsuRoot(int v) { int root = v; while (dsu[root] != 0) { root = dsu[root]; } while (v != root) { int p =... |
#include <bits/stdc++.h> using namespace std; unordered_map<char, long long> store; class thisway { public: bool operator()(const char& a, const char& b) { if (store[a] > store[b]) return true; return false; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ... |
#include <bits/stdc++.h> using namespace std; int N, M; vector<int> edge[300010]; vector<int> ve[300010]; int parent[300010]; int hap1[300010], hap2[300010]; int pwp1[300010], pwp2[300010]; int id[300010]; int ite = 300010; map<int, bool> used; int find_parent(int u) { if (parent[u] == u) { ... |
#include <bits/stdc++.h> using namespace std; int INTlog2(unsigned long long number) { int logval = 0; while (number >>= 1) logval++; return logval; } int main() { unsigned long long n, k; cin >> n >> k; if (k == 1) cout << n << endl; else cout << (1LL << (INTlog2(n) + 1L... |
#include <bits/stdc++.h> using namespace std; long A[1048576]; long long B[30]; long long C[30]; long P[30]; void f(long n, long o) { if (n > 1) { f(n - 1, o); f(n - 1, o + P[n - 1]); } sort(A + o, A + o + P[n - 1]); sort(A + o + P[n - 1], A + o + P[n]); long i = o; long ... |
#include <bits/stdc++.h> using namespace std; bool helper(pair<int, int>* arr, int x, int y, int m) { if (m == 0) { return true; } int res = false; if (x != -1) { if (arr->first == x || arr->second == x) res = true; } if (y != -1) { if (arr->second == y || arr->first == y) ... |
#include <bits/stdc++.h> using namespace std; const int mn = 1010000, mm = 10100; int n, m, i, j, k, t, a[mm], la[30], sa[30]; map<int, int> ans; char s[mn], c[30]; bool cmp(int i, int j) { return la[i] > la[j]; } int main() { scanf( %s , s + 1); n = strlen(s + 1); scanf( %d , &m); for (i ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int nn = 1; for (int i = 1; i < n; i++) { int c = 0; for (int j = 0; (1 << j) <= nn; j++) c++; nn += c; } vector<int> P; for (int i = 0; i < nn; i++) { bool f = false; for (i... |
#include <bits/stdc++.h> using namespace std; int m1[4] = {1, 1, 1, 1}; int m2[4] = {1, 2, 4, 3}; int m3[4] = {1, 3, 4, 2}; int m4[4] = {1, 4, 1, 4}; int main() { string s; cin >> s; int b = s[s.size() - 1] - 0 ; int a; if (s.size() > 1) a = s[s.size() - 2] - 0 ; else a... |
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr LL LINF = 334ll << 53; constexpr int INF = 15 << 26; constexpr LL MOD = 1E9 + 7; struct Problem { LL n; vector<LL> p; Problem(LL n) : n(n), p(n){}; void solve() { LL ans = 0, minsum = LINF, sum = 0; for... |
#include <bits/stdc++.h> using namespace std; int n, t, tt, sz, res = 1e9, a[55][100005], out[100005], cnt[100005], mul[100005], que[1000005]; int read() { int x = 0, fl = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) fl = -1; ch = getchar(); ... |
#include <bits/stdc++.h> typedef struct smirror { int left, right, score; } mirror; int max(int a, int b) { return a > b ? a : b; } int shoot_in(double x, mirror a[]) { for (int i = 1; i <= a[0].score; ++i) if (a[i].left <= x && x <= a[i].right) return i; return -1; } int deal(int n, mirro... |
#include <bits/stdc++.h> using namespace ::std; const int maxn = 1e5 + 5; map<long long, int> mp; long long sum[maxn], ans; int n, k; void solve() { long long maxx = 0, minn = 0; scanf( %d%d , &n, &k); mp[0] = 1; for (int i = 1; i <= n; i++) { long long tmp; scanf( %I64d , &tmp);... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2e5 + 9; void test_case(int tc) { int k; cin >> k; int n = 12; int arr[12]; for (int i = 0; i <= 11; ++i) cin >> arr[i]; sort(arr, arr + 12, greater<int>()); int ans = 0; int temp = 0; if ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m; long long ans, a[N], b[N]; char c; long long read() { long long x = 0; int sig = 1; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) if (c == - ) sig = -1; for (; c >= 0 && c <= 9 ; c = getchar()) x... |
#include <bits/stdc++.h> using namespace std; long long read() { long long x = 0, f = 1; char ch = ; while (!isdigit(ch)) { ch = getchar(); if (ch == - ) f = -1; } while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch - 48), ch = getchar(); return x * f; } const int mod = 998... |
#include <bits/stdc++.h> using namespace std; long long n, i, j, k, x, y, col; vector<long long> ans; long long last[100100]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> x >> y; col = 0; j = 1; while (j * j <= x) { if (x % j == 0) { k = x / j; ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, i, j = -100, k, *a, cnt = 0, cnt1 = 0; cin >> n; a = new int[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n - 2; i++) { if (a[i] == 1 && a[i + 1] == 0 && a[i + 2] == 1) { if (i - j > 2) ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j; char map[9][9]; bool ok = false, ok1 = false; for (i = 0; i < 8; ++i) { scanf( %s , map[i]); for (j = 1; j < 8; ++j) { if (i == 0 && map[i][j] == W ) ok1 = true; if (map[i][j] == map[i][j - 1]) ok = tru... |
#include <bits/stdc++.h> using namespace std; const int N = 200007, inf = 0x3f3f3f3f; vector<int> edges[N]; int d[N]; void bfs(int s) { queue<int> q; q.push(s); memset(d, -1, sizeof d); d[s] = 0; while (q.size()) { int u = q.front(); q.pop(); for (int v : edges[u]) { ... |
#include <bits/stdc++.h> using namespace std; long long n, i, j, a, b, c, t, cnt; int main() { cin >> a >> b >> c; n = 0; t = 0; cnt = 0; while ((a > 0) || (b > 0) || (c > 0)) { switch (t) { case 0: { if (a > 0) a -= 2; break; } case 1: { ... |
#include <bits/stdc++.h> using namespace std; vector<bool> prime(1001, true); void sieve() { prime[0] = false; prime[1] = false; for (int i = 2; i <= 1000; i++) { if (prime[i]) { int j = 2; while (i * j <= 1000) { prime[i * j] = false; j++; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == 0 && b == 0) { cout << NO ; return 0; } if (abs(a - b) <= 1) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; int n, arr[300000]; double cord[3], best[3]; int main() { cin >> n; for (int i = 0; i < n; i++) scanf( %d , &arr[i]); sort(arr, arr + n); int l = 0, r = 2000000000, res = -1; while (l <= r) { int mid = (l + r) / 2; int idx = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n], y[n], h[n], a[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } for (int i = 0; i < n; i++) { h[i] = n - 1; a[i] = 0; } int home[1000000] = {0}, away[1000000] = {0}; for... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; long long a[MAXN], b[MAXN]; long long n, s; bool check(long long k) { for (int i = 1; i <= n; i++) b[i] = 0; long long sum = s - 1, p = 2, q = 1, h = 1; a[1] = b[1] = 1; while (p <= n) { q *= k, h++; for (int i ... |
#include <bits/stdc++.h> using namespace std; const int N = 1505; const int MOD = 1000000007; inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; } inline int sub(int x, int y) { return x - y < 0 ? x - y + MOD : x - y; } inline int mul(int x, int y) { return 1ll * x * y % MOD; } inli... |
#include <bits/stdc++.h> using namespace std; inline int read_int() { int x; scanf( %i , &x); return x; } inline int endline() { return printf( n ); } inline int space() { return printf( ); } inline int write_int(const int x) { return printf( %i , x); } class color_ice_cream : public pair<b... |
#include <bits/stdc++.h> template <class T> T _diff(T a, T b) { return (a < b ? b - a : a - b); } template <class T> T _abs(T a) { return (a < 0 ? -a : a); } template <class T> T _max(T a, T b) { return (a > b ? a : b); } template <class T> T _min(T a, T b) { return (a < b ? a : b)... |
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<char, int>& x, const pair<char, int>& y) { int u = max(x.first - a , z - x.first); int v = max(y.first - a , z - y.first); return u > v; } int main() { if (0 & 1) freopen( input , r , stdin); if (0 & 2) freopen( output ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int M = 998244853, maxn = 4005; int n, m; void madd(int& a, int b) { a += b; if (a >= M) a -= M; } int ch[maxn][maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; ch[0][0] =... |
#include <bits/stdc++.h> using namespace std; const int NAX = 3e5 + 1; const int INF = 1e9 + 1; const long long UMAX = 2e18 + 1; long long sm(long long n) { int res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } void solve() { long long n; cin >> n; ve... |
#include <bits/stdc++.h> using namespace std; int main() { long long T; cin >> T; while (T--) { long long n; cin >> n; long long i, j = 1; cout << 2 ; for (i = 1; i < n; i++) { j += 2; cout << j << ; } cout << endl; } return 0; } ... |
#include <bits/stdc++.h> using namespace std; struct Node { vector<Node*> edges; bool term; vector<int> last; Node() { edges.resize(5); fill(edges.begin(), edges.end(), nullptr); term = false; } }; void add_string(Node* root, string s) { for (char c : s) { c -= a... |
#include <bits/stdc++.h> using namespace std; long long n, m; long long a[510]; long long dp[510][510]; long long stt[510]; long long mod = 998244353; long long solve(long long st, long long en) { if (st >= en) { return 1; } if (dp[st][en] != -1) return dp[st][en]; long long c = 1e9;... |
#include <bits/stdc++.h> #pragma GCC target( sse4,avx ) void run(std::istream &in, std::ostream &out) { int n; in >> n; std::vector<int> as(n); int sum = 0; for (int i = 0; i < n; i++) { in >> as[i]; sum += as[i]; } if (sum % 2 == 0) { for (int j = 2; j <= sum; j += 2) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i, n, fl = 0; cin >> n; int *a = new int[n]; for (i = 0; i < n; ++i) { cin >> a[i]; } sort(a, a + n); for (i = 1; i < n; ++i) { if (a[i] == a[i - 1]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int i = s.size() - 1; i >= 0; i--) { int x = s[i] - 0 ; if (x >= 5) printf( -O| ); else printf( O-| ); x = x % 5; if (x == 0) printf( -OOOO n ); else if (x == ... |
#include <bits/stdc++.h> using namespace std; std::mt19937 rnd( (int)std::chrono::steady_clock::now().time_since_epoch().count()); long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 250000; struct P { int x, y; P() {} P(int x, int y) : x(x), y(y) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 16, inf = 2e8 + 10; ; int n, m, dis[maxn][maxn], deg[maxn], ans, dp[1024 * 33]; vector<int> veci; void find(int a) { int cnt = 0; for (int i = 0; i < n; i++) if ((a >> i) & 1) cnt++; if (cnt % 2 == 1) return; for (int i = 0... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) #pragma GCC optimize( unroll-loops ) using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; const ld PI = acos(-1); ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 7; const int mxn = 3e5 + 9; inline long long in() { long long _; scanf( %lld , &_); return _; } int n, m, k; struct node { int len; int link; int firstpos; map<char, int> nxt; void ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; s = $ + s; int n = s.length(); vector<vector<int>> c(n, vector<int>(26, 0)); for (int i = 1; i < n; i++) { for (int j = 0; j < 2... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; unordered_map<long long, long long> mymap; long long maxval = INT_MIN, minval = INT_MAX; for (int i = 0; i < n; i++) { long long temp; cin >> temp; ... |
#include <bits/stdc++.h> using namespace std; int n, a, ans; int main() { cin >> n; int sq; ans = -1e9; for (int i = 0; i < n; i++) { cin >> a; if (a < 0) { ans = max(ans, a); continue; } sq = sqrt(a); if (sq * sq != a) { ans = max(ans, a); ... |
#include <bits/stdc++.h> using namespace std; struct nom { int i, a, l; }; long long po(int a, int n) { if (n == 0) return 1; if (n == 1) return a; if (n & 1) return a * po(a * a, n / 2); else return po(a * a, n / 2); } struct rec { int x, y, x1, y1; }; int main() { ... |
#include <bits/stdc++.h> using namespace std; int n, a, b, k; long long MOD = 1000000007; long long pref[5005][2], dp[5005][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b >> k; for (int i = 0; i < n + 5; i++) { pref[i][0] = pref[i][1] = dp[... |
#include <bits/stdc++.h> using namespace std; int main() { char tab[100], znak; int konik, insekt, dlugosc, skok; cin >> dlugosc; cin >> skok; for (int i = 0; i < dlugosc; i++) { cin >> znak; tab[i] = znak; if (znak == G ) konik = i; if (znak == T ) insekt = i; } ... |
#include <bits/stdc++.h> using namespace std; long long ceiling(long long a, long long b) { if (a % b != 0) { return (a / b) + 1; } else return (a / b); } void solve() { long long n, k; cin >> n >> k; long long a[n * k]; for (long long i = 0; i < n * k; i++) { cin >> a[... |
#include <bits/stdc++.h> using namespace std; const long long MOD = (long long)1e9 + 7; string substrs(string s, int i, int j) { string a; for (int h = i; h < j + 1; h++) { a.push_back(s[h]); } return a; } int main() { int T; cin >> T; for (int zz = 0; zz < T; zz++) { s... |
#include <bits/stdc++.h> using namespace std; long long arr[200005], sh[200005], sp[200005]; int main() { long long i, j, k, n, m, p, q, t, cnt = 0, mn; scanf( %lld , &n); scanf( %lld , &k); for (i = 0; i < n; i++) { scanf( %lld , &arr[i]); ; } sort(arr, arr + n); for (i = ... |
#include <bits/stdc++.h> using namespace std; vector<int> v[205]; vector<int> h(205, 0); void doit(int s, int par) { if (par != -1) { h[s] = 1 + h[par]; } for (int i = 0; i < v[s].size(); i++) { if (v[s][i] == par) continue; doit(v[s][i], s); } } string pre(string s) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int Begin[N], Next[N], to[N], cost[N], e; void Add(int u, int v, int w) { to[++e] = v, Next[e] = Begin[u], Begin[u] = e, cost[e] = w; } int n, m; long long dis[N]; bool vis[N]; struct Vertex { int o; long long d; bool ... |
#include <bits/stdc++.h> using namespace std; string mat[24]; int n, m; bool che(int i, int j) { map<string, bool> mp; for (int ii = 1; ii <= n; ii += i) { for (int jj = 1; jj <= m; jj += j) { string s2 = ; for (int k = ii; k < ii + i; k++) { for (int l = jj; l < jj + j... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 20], *p1, *p2; template <class T> inline void read(T &n) { char ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? 0 : *p1++); T w = 1, x = 0; while (!isdigit(ch)) { if (c... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long int num, num_backup; long long int a[2], j = 0; cin >> num; num_backup = num; for (long long int i = 2; i * i <= num; i++) { if (num % i == 0) { a[j++] = i; if (j == 2) break; num /= i; ... |
/* Author: Zhikun Wang */ #include <bits/stdc++.h> using namespace std; template <typename A, typename B>string to_string(pair<A, B> p);template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p);template <typename A, typename B, typename C, typename D>string to_string(tuple... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n, m; cin >> a >> b >> n >> m; if (max((3 * a) / 10, a - (a / 250) * n) > max((3 * b) / 10, b - (b / 250) * m)) cout << Misha ; if (max((3 * a) / 10, a - (a / 250) * n) < max((3 * b) / 10, b - (b / 250) * m))... |
#include <bits/stdc++.h> using namespace std; long long res, mx, r1, r2; int main() { long long h, w, p, q; cin >> h >> w; p = 1; while (p <= h) { if (p > h) break; q = (long long)(p / 4.0 * 5.0); if (q > w) q = w; if ((long long)(q / 4.0 * 5.0) < p) break; if (p * q ... |
#include <bits/stdc++.h> using namespace std; struct Pair { long long f, s; Pair() { f = s = 0; } Pair(long long f, long long s) { this->f = f; this->s = s; } }; const int maxn = 36 + 100; Pair d[maxn][maxn]; int pr[maxn][maxn]; long long _10(int); void print(int, int); int... |
#include <bits/stdc++.h> using namespace std; vector<long long> vec; int main(void) { long long n1, n2, i, j, k, n, d; cin >> n >> d; for (i = 0; i < n; i++) vec.push_back(i + 1); long long Min, Max = 0, sum; do { sum = 0; for (i = 0; i < n; i++) { for (j = i; j < n; j++) {... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int n, m; struct node { int from, to, w; } edge[maxn]; int in[maxn]; vector<int> e[maxn]; int top[maxn]; bool topsort(int mid) { memset(in, 0, sizeof(in)); int cnt = 0; queue<int> q; for (int i = 1; i <= n; ++... |
#include <bits/stdc++.h> #pragma GCC optimize(3) #pragma GCC optimize( inline ) using namespace std; long long n; double ans; struct dt { double x; double y; } a[1 << 11]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (register long long i =... |
#include <bits/stdc++.h> int min(int a, int b) { if (a < b) return a; else return b; } int main() { int n, pos, l, r; scanf( %d %d %d %d , &n, &pos, &l, &r); if (l == 1 && r == n) printf( 0 n ); else if (l == 1) printf( %d n , abs(pos - r) + 1); else if (r == n)... |
#include <bits/stdc++.h> using namespace std; const char nl = n ; const long long inf = 1e9 + 10; const long long inf2 = 1e18 + 99LL; const long double inf3 = 1e17; const long long mod = 1e9 + 7, mod2 = 998244353; const long double eps = 1e-9; const bool local = false; const int logn = 17, maxn = 10... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1108864220 ) using namespace std; const int MOD = 1000000007; const int INF = 1000000000; const double EPS = 1e-9; const int HASH_POW = 29; const long double PI = acos(-1.0); mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().c... |
#include <bits/stdc++.h> using namespace std; string to_string(string s) { return + s + ; } string to_string(char c) { return + string(1, c) + ; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } template <typename A... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; template <class T> void show(vector<vector<T>> &a) { for (auto &i : a) { for (T &j : i) cout << j << ; cout << endl; } } template <class T> void show(vector<T> &a) { for (T i : a) cout << i << ; cout <<... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[10], b[10]; int main() { for (int i = 1; i <= 3; i++) scanf( %d %d , &a[i].first, &a[i].second); for (int i = 0; i < 8; i++) { for (int j = 1; j <= 3; j++) b[j] = a[j]; for (int j = 1; j <= 3; j++) if (i >> (j - 1) & 1) swa... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int maxn = 505, maxm = 1005; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long powermod(long long a, long long b, long long c) { a = a % c; long long ans = 1; while (b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; bool sym = false; for (int i = 0; i < n; i++) { int a, b, c, d; cin >> a >> b >> c >> d; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; pair<long long, long long> p[maxn]; long long m[maxn][2], mm[maxn][2], ycords[maxn], xcords[maxn]; int n; bool can(long long l) { for (int i = 0; i < n; i++) { if (i > 0 && p[i - 1].second == p[i].second) continue; lon... |
#include <bits/stdc++.h> using namespace std; int main() { int a, m, p, k = 0; cin >> a >> m; p = a + m; while (1) { if ((k % 2) == 0) { p = p - 2; a--; m--; if (p == 1 || p == 0 || a == 0 || m == 0) { cout << Akshat ; break; } ... |
#include <bits/stdc++.h> using namespace std; bool containsr(int x21, int y21, int x22, int y22, int x11, int y11, int x12, int y12) { return x21 >= x11 && y21 >= y11 && x22 <= x12 && y22 <= y12; } int main() { int n; cin >> n; int found = 0; int x11 = -1, y11 = -1, x12 = -1... |
#include <bits/stdc++.h> using namespace std; int f(string s1, string s2) { int k = 0; while (s2 != s1) { s2 += s2[0]; s2 = s2.substr(1); k++; if (k > s2.length()) return 1000000; } return k; } int main() { int n; cin >> n; vector<string> V(n); for (int i ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using graph = vector<vector<int>>; const ll mod = 1e9 + 7; const int MAX = 2e5; int n; map<pii, ll> memo; int size[MAX]; void dfs1(int v, int prev, const graph& G, const vector<ll>& V) { pii p(prev, v... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a, b; int n, m; cin >> n; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a.push_back(tmp); } cin >> m; for (int i = 0; i < m; i++) { int tmp; cin >> tmp; b.push_back(tmp); }... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T b, T p, T M) { long long ret = 1; for (; p > 0; p >>= 1) { if (p & 1) ret = (ret * b) % M; b = (b * b) % M; } return (T)ret; } template <class T> inline T lcm(T a, T b) { return (a * b) / __gcd... |
#include <bits/stdc++.h> using namespace std; int n, k, x, y; int main() { cin >> n >> k; int l = 1, r = n, mid; while (l <= r) { if (l == r) { x = l; break; } mid = l + r >> 1; cout << 1 << mid << << mid + 1 << endl; fflush(stdout); string s;... |
#include <bits/stdc++.h> using namespace std; int r; bool check(int x, int y) { return 1ll * x * x + 3ll * y * y <= 4ll * r * r; } int main(void) { scanf( %d , &r); int i = 1, j = 1; long long ans = 1; while (check(i, j + 2)) { ans += 2; j += 2; } do { i += 3; ++j... |
#include <bits/stdc++.h> using namespace std; const int N = 110000; const int B = 60; int n, q, mc; int aint[4 * N][B]; void update(int nod, int pozx, int pozy, int poz, int val) { int i; if (pozx == pozy) { for (i = 0; i < B; ++i) { aint[nod][i] = 1; if (i % val == 0) aint[nod... |
#include <bits/stdc++.h> using namespace std; int64_t a[4][4] = {0}; int64_t b[4][4] = {0}; int64_t chk(int64_t aa, int64_t bb) { if (aa == bb) return 0; if (aa == 3 && bb == 2) return 1; if (aa == 2 && bb == 1) return 1; if (aa == 1 && bb == 3) return 1; return 2; } int64_t ma[4][4] = {... |
#include <bits/stdc++.h> using namespace std; int pow_mod(int a, long long k, int mod) { if (k == 0) { return 1; } int sub = pow_mod(a, k / 2, mod); if (k % 2 == 0) { return ((long long)sub * sub) % mod; } else { return (((long long)sub * sub) % mod * a) % mod; } } int ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int mod = 1e9 + 7; long long a[N], n, mx, cnt; vector<int> v, e; long long ans = 1; long long pw(long long a, long long b) { if (b == 0) return 1; long long res = pw(a, b / 2); res = res * res % mod; if (b % 2) res ... |
#include <bits/stdc++.h> using namespace std; map<int, int> s; int a[2000]; int main(int argc, char const *argv[]) { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { int sum = a[i] + a[j]; if (s.find(s... |
#include <bits/stdc++.h> using namespace std; void solve(const vector<int>& pearl) { vector<pair<int, int>> ans; ans.reserve(pearl.size()); set<int> app; int l = 0; for (int i = 0; i < pearl.size(); i++) { int cur = pearl[i]; if (app.find(cur) != end(app)) { ans.push_back(mak... |
#include <bits/stdc++.h> const int MAXN = 5E5 + 10; int n; int a[MAXN << 1]; int main() { scanf( %d , &n); for (int i = 1; i < n; ++i) { int t = i + 1 >> 1; if (i & 1) a[t] = a[n - t + 1] = i; else a[n + t] = a[n * 2 - t] = i; } a[2 * n] = n; if (n & 1) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.