func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m, Q, ans[100005], t[265000]; vector<int> v[100005]; vector<pair<int, int> > vq[100005]; void build(int k, int l, int r) { t[k] = 1e9; if (l == r) return; int mid = (l + r) / 2; build(k * 2, l, mid); build(k * 2 + 1, mid + 1, r); } v... |
#include <bits/stdc++.h> using namespace std; long long int n, m; vector<long long int> ar[100001]; vector<long long int> res[2]; long long int vis[100001]; long long int col[100001]; bool dfs(long long int node, long long int c) { vis[node] = 1; res[c].push_back(node); col[node] = c; for ... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0 || b == 0) return a + b; if (a < b) return gcd(b % a, a); return gcd(a % b, b); } int a[111]; int main() { int n; cin >> n; int g = 0, max = 0; for (int i = 0; i < n; i++) { cin >> a[i]; g ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; vector<long long> p; int main() { int n, q; cin >> n >> q; string s; cin >> s; p.resize(1e5 + 1); p[0] = 1; for (int i = 1; i <= 1e5; i++) { p[i] = (p[i - 1] * 2) % MOD; } vector<long long> kum... |
#include <bits/stdc++.h> using namespace std; priority_queue<int> a, b; int c = 0; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; a.push(x); } cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; b.push(x); } w... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; int n, k; bool check(long long m) { long long sum = 0; for (int i = n / 2; i < n; i++) { sum += max(m - v[i], 0ll); } if (sum <= k) { return true; } return false; } int main() { cin >> n >> k; v.re... |
#include <bits/stdc++.h> using namespace std; void reverseStr(string& str); void reverseQueue(queue<int>& Queue); void print_queue(queue<int>& q); int n, a[250], sum, num; int main() { cin >> n; for (int i = 0; i < n * 2; i++) cin >> a[i]; for (int i = 0; i < n * 2; i++) { for (int j = i +... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 7; vector<long long> v[MX]; bool vis[MX]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n; cin >> n; pair<long long, long long> p[n]; for (long long i = 0; i < n; i++) cin >> p[i].first >> p[i].se... |
#include <bits/stdc++.h> using namespace std; int t, ans, tot, pus, a, b, c, d; int main() { register int i; scanf( %d , &t); while (t--) { scanf( %d%d%d%d , &a, &b, &c, &d); ans = a * (b - d - 1); ans = ((ans) > (a * d) ? (ans) : (a * d)); ans = ((ans) > (b * (a - c - 1)) ? (a... |
#include <bits/stdc++.h> using namespace std; vector<int> factor[100001]; void precal() { for (int i = (1); i < (100001); ++i) for (int j = (i); j < (100001); j += (i)) factor[j].push_back(i); } int expo(int a, int b) { if (b == 0) return 1; if (b == 1) return a % 1000000007; int c = exp... |
#include <bits/stdc++.h> using namespace std; struct inf { long long t, w; }; struct djk { long long n, v; bool operator>(const djk &i) const { return v < i.v; } bool operator<(const djk &i) const { return v > i.v; } } n; struct edge { long long n1, n2, t; bool operator<(const edge &... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; const int INF = 1 << 20; bool dp1[MAXN][MAXN][26] = {false}; bool dp2[MAXN][MAXN][26] = {false}; int dp[MAXN][MAXN]; char s1[MAXN], s2[MAXN]; string tr[MAXN]; int n; void cal(char* s, bool f[MAXN][MAXN][26]) { int len = strlen(s)... |
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long me(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t, n, k, c = 0, d = 0; cin >> n >> k; map<long long, long long> m; for (int i = 0; i < n; ++i) { cin >> t; m[t]++; } auto it2 = m.begin(); ... |
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T a) { return a * a; } int n; int a[21000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int best = -1000000000; for (int i = 3; i <= n; i++) if (n % i == 0) { int g = n / i; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFL = 0x3f3f3f3f3f3f3f3fLL; struct Edge { int src, dst; int weight; Edge(int src_, int dst_, int weight_) : src(src_), dst(dst_), weight(weight_) {} Edge(int dst_, int weight_) : src(-2), dst(dst_)... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << [ << *it << = << a << ] ; err(++it, args...); } template <typename Tk, typename Tv> ostream& o... |
#include <bits/stdc++.h> int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; else return b; } char s1[600000], s2[600000]; int z[600000], y[600000]; struct student { int l; int r; } a[600000]; int main() { int i;... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int sieve_size = 5e6; void solve() { int n; cin >> n; vector<int> a(n); for (int &x : a) cin >> x; vector<int> primes; vector<bool> sieve(sieve_size); for (int i = 2; i < int((siev... |
#include <bits/stdc++.h> using namespace std; long long n, h; long long l[200010], r[200010]; long long dsum[200010], rsum[200010]; int main() { scanf( %lld%lld , &n, &h); for (long long i = (long long)(0); i < (long long)(n); i++) scanf( %lld%lld , l + i, r + i); for (long long i = (long lo... |
#include <bits/stdc++.h> using namespace std; struct Act { int l, r; int mx; double pb; vector<Act *> son; static int dp_size; double dp[5005]; bool operator<(const Act &act) const { if (l < act.l) { return true; } else if (l > act.l) { return false; } e... |
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, n, a, b, ans = 0; int gcd(int a, int b) { if (a < b) swap(a, b); return (b == 0) ? a : gcd(b, a % b); } struct st { int first; long double second; }; int main() { std::ios_base::sync_with_stdio(0); string s; ci... |
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T &x) { return x * x; } template <class _T> inline string tostr(const _T &a) { ostringstream os( ); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795; const long d... |
#include <bits/stdc++.h> using namespace std; long long a[105], ans, n; int main() { scanf( %lld , &n); for (long long i = 1; i <= n; i++) { scanf( %lld , &a[i]); ans += a[i] * i; } printf( %lld n , ans); return 0; } |
#include <bits/stdc++.h> int main() { int n, q; std::cin >> n >> q; int ans[q], servers[n], server; for (server = 0; server < n; ++server) { servers[server] = 0; } int index, t, k, d, planner[n]; for (int i = 0; i < q; ++i) { server = 0; index = 0; std::cin >> t >> ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); vector<int> sml, big; for (int i = 1, j = n; i < j; i++, j--) { printf( ? %d %d n , i, j); fflush(stdout); char c[5]; scanf( %s... |
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void ipgraph(int m); void dfs(int u, int par); const long long mod = 1000000007 * 1LL * 1000000007; const int N = 1e6 + 3, M = N; vector<int> g[N]; int a[N]; long long h[N], val[N]; vector<pair<int, int> > E; long long r() ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; int card_to_person = n / k; if (card_to_person >= m) { cout << m << n ; continue; } int tmp = (m - card_to_person) / (k - 1); ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000005; int N; vector<int> G[MAX_N]; int cyid[MAX_N], Q[MAX_N]; vector<vector<int>> cycles, newcycles; void find_cycle(int s, int curid) { cyid[s] = curid; cycles.back().push_back(s); for (int i = 0; i < G[s].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; int mod = MOD; struct ModInt { unsigned val; ModInt() : val(0) {} M... |
#include <bits/stdc++.h> using namespace std; template <class T> using vv = vector<vector<T>>; template <class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; } const long long MOD = 1e9 +... |
#include <bits/stdc++.h> using namespace std; int main() { int N, M, x, y; cin >> N >> M >> x >> y; x--; y--; cout << x + 1 << << y + 1 << endl; for (int i = 1; i < x; i++) cout << i + 1 << << y + 1 << endl; for (int i = x + 1; i < N; i++) cout << i + 1 << << y + 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 20, inf = 1000 * 1000 * 1000; int i, n, ans, t, j, k, a[maxN], b[maxN], c[maxN], d[maxN], nul, h; bool f; string s; int main() { getline(cin, s); n = s.length(); for (i = 0; i < n; ++i) { ++a[s[i] - 0 ]; } j = 0; a... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int a[10]; int main() { int T, N, ans; scanf( %d , &T); while (T--) { scanf( %d , &N); ans = 1; for (int i = 0; i <= 30; i++) if (N & (1 << i)) ans *= 2; printf( %d n , ans); } return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n, m; scanf( %d%d , &n, &m); int x, ans = 0; for (int i = 0; i < n; i++) { scanf( %d , &x); ans += x; } if (ans == m) printf( YES n ); el... |
#include <bits/stdc++.h> using namespace std; const int maxN = 2000 * 100 + 10; map<int, int> val; int a[maxN]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; val[a[i]]++; } sort(a, a + n); n = unique(a, a + n) - a; cout << a[n - 1] - a[0] << ... |
#include <bits/stdc++.h> #define ff first #define ss second #define endl n using namespace std; const long long INF = (long long) 1e18; const int mod = (int) 1e9+7; const int MAXN = (int) 3.5e4+5; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<l... |
#include <bits/stdc++.h> using namespace std; void sort(int temp[2000], int start, int end) { int flag; for (int i = start; i < end - 1; i++) { for (int j = start; j < end - i - 1; j++) { if (temp[j] < temp[j + 1]) { flag = temp[j]; temp[j] = temp[j + 1]; temp[j +... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int m, n, t, ans; pair<int, int> a[N]; vector<pair<int, int>> v; int main() { scanf( %d , &t); while (t--) { scanf( %d%d , &n, &m); ans = 0; v.clear(); for (int i = 1; i <= n; i++) scanf( %d , &a[i].first),... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; cout << (a ^ b) << endl; } } |
#include <bits/stdc++.h> using namespace std; string A, B; bool is_divisor(const string &a, const string &b) { int sa = a.size(), sb = b.size(); for (int i = 0; i < sb; i += sa) { if (b.substr(i, sa) != a) return false; } return true; } int process(const string &a, const string &b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; scanf( %lld , &n); printf( 1 ); if ((n - 1) % 3 == 1) printf( 2 %lld , n - 3); else printf( 1 %lld , n - 2); return 0; } |
#include <bits/stdc++.h> using namespace std; map<string, string> mmap; map<string, string>::iterator it; int main() { int t; cin >> t; while (t--) { string a; string b; cin >> a >> b; if (mmap[b] != ) { for (it = mmap.begin(); it != mmap.end(); it++) { if... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100010]; long long int weight[100010], add[100010], sub[100010]; int n; void dfs(int mom, int u) { for (vector<int>::iterator v = g[u].begin(); v != g[u].end(); v++) if (*v != mom) { dfs(u, *v); add[u] = max(add[*v], add[u])... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long llinf = (long long)3e18; const int N = (int)1e5 + 111; const long double PI = (long double)acos(-1); int main() { int n, cur, num, ans = 0; scanf( %d , &n); vector<int> a(n); vector<char> us(n, 0); fo... |
#include <bits/stdc++.h> int x[10]; int cp, dp; using namespace std; void print() { for (int i = 0; i < 10; ++i) { cout << x[i]; if (i == 9) cout << n ; else cout << ; } } int pp(char a, int &dp) { if (a == < ) { dp = -1; return -2; } else ... |
#include <bits/stdc++.h> using namespace std; void Swap(int &a, int &b) { a = a ^ b; b = a ^ b; a = a ^ b; } int Max(int a, int b) { if (a > b) return a; return b; } int Scan() { int res = 0; char ch; ch = getchar(); if (ch >= 0 && ch <= 9 ) res = ch - 0 ; while (... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; cout << s[0]; for (int i = 1; i < s.size() - 1; i += 2) { cout << s[i]; } cout << s.back(); cout << n ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t... |
#include <bits/stdc++.h> using namespace std; long long r = 1000000007; int h[10]; int n, k, m, i, j; long long a[100001], b[100001]; long long ans, x, y, z, c1, c2; int main() { cin >> n >> k; for (i = 1; i <= n / k; i++) cin >> a[i]; for (i = 1; i <= n / k; i++) cin >> b[i]; h[0] = 1; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { while (b) { a = a % b; swap(a, b); } return a; } int pre[1000010]; int GetN(int n) { if (pre[n] > 0) return pre[n]; if (n < 10) { pre[n] = n; return n; } int temp = n... |
#include <bits/stdc++.h> using namespace std; const int N = int(3e5) + 228, mod = int(1e9) + 7; const long long inf = (long long)(1e16); int n; pair<int, int> p[N]; pair<long long, long long> t[2 * N], dp[N]; pair<long long, long long> merg(pair<long long, long long> a, p... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; while (a[i] % 2 == 0) a[i] /= 2; while (a[i] % 3 == 0) a[i] /= 3; } int flag = 1; int val = a[0]; ... |
#include <bits/stdc++.h> using namespace std; int mx = INT_MIN, n, a[10]; char x; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= 7; j++) { cin >> x; a[j] += x - 48; } } for (int i = 1; i <= 7; i++) if (mx < a[i]) mx = a[i]; cout <... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b; int t = n / 2; if (n % 2 == 1) { cout << t << << t + 1; } else if (n % 4 == 2) { cout << t - 2 << << t + 2; } else if (n % 4 == 0) { cout << t - 1 << << t + 1; } } |
#include <bits/stdc++.h> using namespace std; int as[10001]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i) as[i] = 1; as[n] = 0; for (int j = 0; j < k; ++j) { for (int i = 1; i <= n - (1 << (j + 1)); ++i) { if (as[... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long c[n], s[n]; for (int i = 0; i < n; i++) { cin >> c[i] >> s[i]; } long long dp[m + 1]; dp[m] = 0; for (int i = m - 1; i >= 0; i--) { dp[i] = m - i; for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; int a[] = {1, 2, 4, 3}; int b[] = {1, 3, 4, 2}; int c[] = {1, 4, 1, 4}; int d[] = {1, 1, 1, 1}; int main() { string s; cin >> s; int n = s.length(); int rem = 0; for (int i = 0; i < n; i++) { rem = (rem * 10 + s[i] - 0 ) % 4; } ... |
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1), eps = 1e-6, INF = 1e16; bool isEqual(long double x, long double y) { return fabs(x - y) < eps; } int sgn(long double sc) { if (isEqual(sc, 0)) return 0; if (sc < eps) return -1; return 1; } struct pnt { long doubl... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:1024000000,1024000000 ) long long ans; int son[100010][2], fa[100010], cnt[100010], val[100010]; int is[100010]; long long sumVal[100010], sumCnt[100010], sum[100010], all[100010], lazy[100010]; void up(int p) { sumCnt... |
#include <bits/stdc++.h> using namespace std; long long n, m, k, day, dep[1000010], arr[1000010], cost[1000010], cel, from, coss; long long mini[1000010], wylot[1000010], dolot[1000010], sum, inf = 1e7; vector<pair<long long, int> > tab; int ptr; int main() { ios_base::sync_with_stdio(0); cin.... |
#include <bits/stdc++.h> using namespace std; int n; int a[3][11]; int sum[11]; int x, len, i; int main() { scanf( %d , &n); for (i = 0; i < n; i++) for (int j = 0; j < 6; j++) { scanf( %d , &x); a[i][x]++; sum[x]++; } for (i = 1; i < 1000; i++) { if (i ... |
#include <bits/stdc++.h> using namespace std; int n, mem[100004][28]; char x, y; string s; map<pair<int, int>, int> m; int dp(int i = 0, int j = 27) { if (i == (int)s.size()) return 0; int& ret = mem[i][j]; if (~ret) return ret; if (m[{(int)(s[i] - a ), j}] != 1) { return ret = max(dp... |
#include <bits/stdc++.h> void answer(unsigned long long v) { std::cout << v << n ; } void solve(unsigned n, unsigned k) { const auto s = n * (n - 1ull) / 2; if (k > n / 2) return answer(s); const auto m = n - 2 * k; const auto d = m * (m - 1ull) / 2; answer(s - d); } int main() { unsig... |
#include <bits/stdc++.h> using namespace std; bool dp[1005][2005]; pair<long long int, long long int> prv[1005][2005]; char val[1005][2005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, k; cin >> n >> k; string s; cin >> s; ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long gcd(long long a, long long b) { if (a == 0) return b; if (b == 0) return a; if (a > b) return gcd(b, a % b); return gcd(a, b % a); } int main() { long long n, x, y; cin >> n >> x >> y; long long d =... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int ans, tot, head[N], ver[N], Next[N], val[N], n, m, deg[N]; queue<int> q[2]; bool vis[N]; inline void add(int x, int y) { ver[++tot] = y; Next[tot] = head[x]; head[x] = tot; deg[y]++; } int main() { cin >> n >> m; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 7050; int dp[2][maxn]; vector<int> g[2]; int state[2][maxn]; void dfs(int player, int cur, int n) { if (state[player][cur] == 1) return; state[player][cur] = 1; for (int i = 0; i < g[player].size(); i++) { int v = (cur + g[play... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } const int maxn = 1e6 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; int m; cin >> n >> m; int need = (n + 4 - 1) / 4; ... |
#include <bits/stdc++.h> using namespace std; int n, m, cnt; map<int, int> g[200005]; set<int> s, ns; void dfs(int x) { vector<int> v; v.clear(); ns.clear(); for (set<int>::iterator it = s.begin(); it != s.end(); it++) if (!g[x][*it]) v.push_back(*it); else ns.inser... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t, a, b, c, d, k; cin >> t; while (t--) { cin >> a >> b >> c >> d >> k; int x = a / c; int y = b / d; if (a % c) x++; if (b % d) y++; if (x + y <= k) { cout << x << << k... |
#include <bits/stdc++.h> using namespace std; long n, a[300000], b[300000]; long long s; map<long, long> x, y; map<pair<long, long>, long> t; int main() { cin >> n; for (long i = 0; i < n; i++) { cin >> a[i] >> b[i]; x[a[i]]++; y[b[i]]++; pair<long, long> p; p.first = a... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; scanf( %lld , &n); scanf( %lld , &k); long long a[k + 5], mn = -1, ans1, ans2, flag = 0; for (long long i = 1; i <= k; i++) { scanf( %lld , &a[i]); if (a[i] > n) { continue; } flag = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; vector<int> adj[N]; int n, st[N], sz[N], flat[N], tim = 1; int dfs(int u) { int s = 1; st[u] = tim; flat[tim] = u; for (int v : adj[u]) { tim++; s += dfs(v); } return sz[u] = s; } int main(int argc, cha... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; int in[n]; vector<pair<int, int>> c; in[0] = in[n - 1] = 0; for (int i = 1; i < n - 1; i++) cin >> in[i]; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; c.push_back({x, y}); ... |
#include <bits/stdc++.h> using namespace std; int r, c, w; char a[1005][1005]; int rows[1005], columns[1005]; int main() { scanf( %d%d , &r, &c); for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) { cin >> a[i][j]; if (a[i][j] == * ) { w++; rows[i]++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n; vector<int> id; int a[N]; int tr[N]; int find(int u) { return lower_bound(id.begin(), id.end(), u) - id.begin() + 1; } int lowbit(int x) { return x & -x; } void add(int x, int c) { for (int i = x; i <= n; i += lowbi... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[110]; int n, k; double p[110]; double dp[110][110]; int was[110][110]; double dist(pair<int, int> a, pair<int, int> b) { double x = a.first - b.first; double y = a.second - b.second; return sqrt(x * x + y * y); } double rec(int... |
#include <bits/stdc++.h> using namespace std; int n; int m; struct st { int go; long long int a; long long int b; st() { go = -1; a = 0; b = 0; } st(int a_, long long int b_, long long int c_) { go = a_; a = b_; b = c_; } }; vector<st> v[300002... |
#include <bits/stdc++.h> using namespace std; const int N = 300500; int T[N], L[N], C[N]; int m; int len = 0; const int inf = 100500; int A[N]; int fs = -1, pos = -1; void apply() { for (int i = 0; i < m; i++) { if (i == m - 1) { pos = len; fs = m - 1; goto end; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; string s1, s2, s3; cin >> t; map<string, int> mp; mp[ polycarp ] = 1; while (t--) { cin >> s1 >> s2 >> s3; transform(s1.begin(), s1.end(), s1.begin(), ::tolower); transform(s3.begin(), s3.end(), s3.begin(), :... |
#include <bits/stdc++.h> using namespace std; int main() { int vp, vd, t, f, c, ans = 0; double tempt; double curs = 0; cin >> vp >> vd >> t >> f >> c; curs = vp * t; if (vp >= vd) { cout << 0 << endl; return 0; } while (curs < c) { tempt = curs / (vd - vp); c... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const long long INFL = 1e18 + 123; const double PI = atan2(0, -1); mt19937 tw(960172); long long rnd(long long x, long long y) { static uniform_int_distribution<long long> d; return d(tw) % (y - x + 1) + x; } bool check(strin... |
#include <bits/stdc++.h> using namespace std; int main() { int t; int n; cin >> t; for (int i = 0; i < t; i++) { cin >> n; int arr[2 * n]; for (int j = 0; j < 2 * n; j++) { cin >> arr[j]; } sort(arr, arr + 2 * n); vector<int> left, right; for (int j ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int a[n]; for (int i = 0; i < n; ++i) { scanf( %d , a + i); } sort(a, a + n); if (n % 2) printf( %d n , a[n / 2]); else printf( %d n , a[n / 2 - 1]); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int q, n, x, y, f1, f2, f3, f4; cin >> q; for (int i = 0; i < q; ++i) { cin >> n; int minx = -100000, miny = -100000, maxx = 100000, maxy = 100000; for (int o = 0; o < n; ++o) { cin >> x >> y >> f1 >> f2 >> f3 >> f4; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int main() { int t; cin >> t; while (t--) { long long a, b; cin >> a >> b; int tmp = b + 1; long long len = -1; while (tmp != 0) { tmp /= 10; len++; } long long ans = a *... |
#include <bits/stdc++.h> using namespace std; bitset<7000> bit; int main() { int n, count = 0; cin >> n; while (n--) { int int1, int2; string stars; cin >> int1 >> int2; if (n >= 1) cin >> stars; int a = int1 / 10, b = int1 % 10, c = int2 % 10, d = int2 / 10; int i1... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)3e5, maxM = (int)2e3, intMax = INT_MAX, maxValue = (int)1e4, intInf = (int)1e9, mod = (int)1e9 + 7, www = 97; const long long llmax = LLONG_MAX, INF = (long long)1e9 + 1; long long nod(long long a, long long b) { while (a != 0 &... |
#include <bits/stdc++.h> int main() { unsigned long long int n; scanf( %llu , &n); printf( %llu , (n / 2) + 1); } |
#include <bits/stdc++.h> using namespace std; int dx[3] = {-1, 1, 0}; int dy[3] = {1, 1, 1}; int d[5][205]; char mp[5][205]; int n, k, flag; void dfs(int x, int y) { d[x][y] = 1; if (flag) return; if (y >= n) { flag = 1; return; } if (mp[x][y + 1] != . ) return; if (x ... |
#include <bits/stdc++.h> using namespace std; int cx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0}, cy[] = {0, -1, 1, 0, -1, 1, 1, -1, 0}; int ingrid(int ii, int jj, int R, int C) { if (ii < 0 || jj < 0 || ii >= R || jj >= C) return 0; return 1; } int main() { long long n; cin >> n; long long m... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; const int INF = ~0U >> 1; int N, idx[MAXN]; map<int, int> mp, o_cnt, ls; map<int, vector<int> > rs; int main() { scanf( %d , &N); int a; for (int i = 1; i <= N; ++i) { scanf( %d , &a); mp[a] = i; } int o... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long n, ans, dp[200005][3], sz[200005][3]; vector<int> gr[200005]; void dfs(int x, int p) { sz[x][0]++; for (int i = 0; i < gr[x].size(); i++) { int u = gr[x][i]; if (u == p) continue; dfs(u, x); dp[x][... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s, t; cin >> n >> s >> t; vector<int> a(n + 1); for (int i = 0; i < n; ++i) a[i] = (s[n - i - 1] - a ) + (t[n - i - 1] - a ); for (int i = 0; i < n; ++i) { if (a[i] >= 26) { ++a[i + 1]; a[i... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, l; cin >> n >> m >> k >> l; if (m > n || n - k < l) return cout << -1, 0; long long ans = k / m; k %= m; while (k > 0) { k -= m; ans++; } l += k; ans += (l + m - 1) / m; if (ans * m > n)... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:16777216 ) const string debug_line = yolo ; const long long linf = 1e15 + 5; const int BLOCK = 330; struct answerType { int val; vector<int> edges; public: answerType() { val = INT_MAX; edges.clear()... |
#include <bits/stdc++.h> using namespace std; const int N = 300 * 1000 + 9; const int LOGN = 19; const int M = 21; const long long INF64 = 1e18; int n, m, q; vector<pair<int, int> > g[N]; int p[LOGN][N]; int tin[N], tout[N], T; long long h[N]; set<pair<int, int> > badEdges; long long d[M + M][N]... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j; int n; scanf( %d , &n); if ((n * n) % 2 == 1) { printf( %d n , ((n * n) / 2) + 1); } else { printf( %d n , (n * n) / 2); } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if ((i + j) % 2 ... |
#include <bits/stdc++.h> using namespace std; bitset<20> a; vector<int> w; int sol = 0; void verific(int &l, int &r, int &x) { int sum = 0, i, minim = INT_MAX, maxim = INT_MIN; for (i = 0; i < w.size(); ++i) { if (a[i]) { sum += w[i]; minim = min(minim, w[i]); maxim = max... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string s; cin >> s; int arr[10] = {0}; for (int i = 0; i < s.size(); i++) { if (s[i] == L ) { int i = 0; for (; i < 10; i++) { if (arr[i] == 0) break; } arr[i] = 1; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.