func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int N, C, cnt; int A[33], P[33]; double dp[33][33][222], sol; inline int f(int l, int r, int i) { if (i < l || i > r) return i; int ret = i - l + 1; int len = r - l + 1; ret = len - ret + 1; ret = l + ret - 1; return ret; } int main() {... |
#include <bits/stdc++.h> const int inf = INT_MAX; const int MAX = 1e6 + 8; const long long MOD = 998244353; const int TOT_PRIMES = 1e6 + 9; const int MAX_A = 71; const int LN = 20; using namespace std; vector<int> adj[MAX]; int vis[MAX]; long long c = 0; void dfs(int u) { vis[u] = 1; c = c... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; long long mod = 1000000007; void solve() { long long n; cin >> n; long long a[n]; long long k0 = 0; long long k1 = 0; for (long long i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) k0++; if (a[i] ... |
#include <bits/stdc++.h> const long long inf = std::numeric_limits<long long>::max(); const int infint = std::numeric_limits<int>::max(); const long long mod = 1e9 + 7; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> g[500100]; long long a[500100]; l... |
#include <bits/stdc++.h> using namespace std; template <typename _T> void read(_T &x) { _T f = 1; x = 0; char s = getchar(); while (s > 9 || s < 0 ) { if (s == - ) f = -1; s = getchar(); } while ( 0 <= s && s <= 9 ) { x = (x << 3) + (x << 1) + (s ^ 48); s = ge... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; int x1, y1, x2, y2; cin >> n; long long ans = 0; for (int i = 1; i <= n; i++) { cin >> x1 >> y1 >> x2 >> y2; ans += (long long)(x2 - x1 + 1) * (y2 - y1 + 1); ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e13, Mo = 998244353; const int N = 1000000; const double eps = 1e-6; namespace slow_IO { long long read() { long long x = 0; int zf = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); i... |
#include <bits/stdc++.h> using namespace std; const int N = 109; int n; int a[N]; map<int, int> m; set<int> s[2]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; m[a[i]]++; } int pos = 0; for (auto p : m) if (p.second == 1) { s[pos... |
#include <bits/stdc++.h> bool comp(const int& a, const int& b) { return a < b ? false : true; } using namespace std; int main() { long long int k, a, b, m, n; cin >> k >> m >> n; a = max(m, n); b = min(m, n); long long int ans = 0; if (a > 0 && b > 0) { ans = a / k - (b - 1) / k; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2000 + 11; const int MOD = 1e9 + 7; int dp[N][2][2][N]; int m, d; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> m >> d; string s1, s2; cin >> s1 >> s2; s1 = . + s1; s2 = . + s2; d... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; long long int a[n][2]; for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1]; long long int l[n][2], r[n][2]; long long int mi = a[0][0]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(10); ; int n; cin >> n; vector<int> deg(n); int ones = 0; vector<int> others, ops; long long total = 0; for (int i = 0; i < (int)n; i++) {... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int dx[] = {1, -1, 0, 0, -1, 1, -1, 1}; int dy[] = {0, 0, 1, -1, -1, -1, 1, 1}; void file() {} int main() { cout << setprecision(20) << fixed; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int k; cin >> k... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; bool w = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) w = 0; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } x = w ... |
#include <bits/stdc++.h> using namespace std; long long read() { char ch = getchar(); long long x = 0, ff = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) ff = -ff; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return x * ff; } void... |
#include <bits/stdc++.h> using namespace std; int main() { int k; scanf( %d , &k); if (k % 2 == 1) { printf( -1 n ); return 0; } char a[k][k]; memset(a, 0, sizeof(a)); for (int layer = 0; layer < k / 2; layer++) { char c; if (layer % 2) c = w ; else... |
#include <bits/stdc++.h> using namespace std; int main() { string a, s; cin >> a; cin >> s; long la = 0, ls = 0, i = 0, ps = 0, pv = 0; la = a.length(); ls = s.length(); vector<int> v; for (i = 0; i < ls; i++) v.push_back(s[i]); sort(v.rbegin(), v.rend()); while (ps < la && p... |
#include <bits/stdc++.h> using namespace std; int n, k; int n1; vector<long long> v; int c[20]; int a[20]; bool viz[20]; int f[20]; inline void get(int i) { int cif = 0; long long zece = 1; long long r = 0; for (zece = 1; i > 0; i >>= 1, zece *= 10LL) { ++cif; if ((i & 1) !... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, i, j, e, ar[105]; scanf( %d , &a); while (a--) { scanf( %d , &b); if (b == 1) { scanf( %d , &c); if (c % 2 == 0) printf( 1 n1 n ); else printf( -1 n ); } else { ... |
#include <bits/stdc++.h> using namespace std; double mn = 1e20, mx, t; int n, low, high; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> t; mn = min(mn, (t + 1 - 1e-8) / i); mx = max(mx, t / i); } n++; low = (int)(n * mx + 1e-9), high = (int)(n * mn + 1 - 1e-9)... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int arr[26] = {}; int n = s.length(); int count = 0; for (int i = 0; i < n; i++) { arr[s[i] - a ]++; if (arr[s[i] - a ] == 2) { arr[s[i] - a ] = 0; count--; } else co... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 400100; vector<int> grafo[MAXN]; int a[MAXN], b[MAXN]; pair<int, int> p[MAXN]; int q[MAXN]; bool vis[MAXN]; int n; vector<int> vec; void dfs(int x) { vis[x] = true; vec.push_back(x); if (x > n) vis[x - n] = true; el... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int read() { int s = 0; char c = getchar(), lc = + ; while (c < 0 || 9 < c) lc = c, c = getchar(); while ( 0 <= c && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return lc == - ? -s : s; } void write(int x) { ... |
#include <bits/stdc++.h> int n, m, k, s, a[1000000], b[1000000]; int amin[1000000]; int bmin[1000000]; struct Gadget { long long cost; int id; Gadget(long long cost, int id) : cost(cost), id(id) {} bool operator<(const Gadget &other) const { return cost < other.cost; } }; int main() { sc... |
#include <bits/stdc++.h> using namespace std; int to1[1000010], w[1000010], begin1[1000010], next1[1000010], v[1000010], p[1000010], d[1000010], e; void add(int x, int y, int z) { to1[++e] = y; next1[e] = begin1[x]; begin1[x] = e; w[e] = z; } void ins(int x) { int i; for (i = 30;... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000000; const long long INF = 1LL * inf * inf; const double eps = 1e-9; const int md = (int)1e9 + 7; const double EPS = 1e-7; const long long maxll = numeric_limits<long long>::max(); const double PI = acos(-1.0); template <typename nam... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k; cin >> n >> k; string ans = ; for (long long i = 0; i < n; i++) { ans.push_back( a ); } for (long long i = n - 2; i >= 0; i--) { if (k <= n - i - 1) { ans[i] = b ; ans[n - k] = b ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, c, d, x, y, x1, x2, y1, y2; scanf( %d , &t); while (t--) { scanf( %d%d%d%d , &a, &b, &c, &d); int t1 = a - b; int t2 = c - d; scanf( %d%d%d%d%d%d , &x, &y, &x1, &y1, &x2, &y2); if (x - t1 >= x1 && x - t... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin.tie(0), cout.tie(0); ; long long int a, b, t, n, m, k, i, j, l, sum = 0, sum1 = 0, ans = 0; vector<long long int> v; cin >> n; for (i = 0; i < n; i++) { cin... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c; cin >> a; b = a - 1; c = a - 2; if (a >= 3) { if (b % 2 != 0) { if (a % 3 == 0) { long long e = a * b * c / 2; long long r = a * b * (c - 1) / 3; long long t = a * b * (c - 2... |
#include <bits/stdc++.h> using namespace std; int h; int edge[5000]; int extend[5000]; int maximum; int v[5000]; bool flag = 0; void dfs_m(int p, int value) { v[p] = value; if (edge[p * 2] != 0) dfs_m(p * 2 + 0, value + edge[p * 2]); else { if (maximum < value) maximum = value; ... |
#include <bits/stdc++.h> using namespace std; map<pair<long long int, long long int>, int> m; long long int comb(long long int n, long long int r) { int k1, k2; if (m[make_pair(n, r)] != 0) return m[make_pair(n, r)]; if (r > n) return 0; if (n == r) return 1; if (r == 0) return 1; if (r ==... |
#include <bits/stdc++.h> using namespace std; int a[123], p[123]; signed main() { int t; scanf( %d , &t); while (t--) { int n, m; scanf( %d %d , &n, &m); memset(p, 0, sizeof(p)); for (int i = 1; i <= n; ++i) scanf( %d , a + i); for (int i = 1, x; i <= m; ++i) scanf( %d , ... |
#include <bits/stdc++.h> using namespace std; long long fac[3000060]; void pre() { fac[0] = 1; for (int i = 1; i < 3000060; i++) fac[i] = fac[i - 1] * i % 1000000007; } long long powermod(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while... |
#include <bits/stdc++.h> using namespace std; long long inf = 1e18; vector<long long> a; map<long long, bool> p; int binp(long long x) { int l = 0, r = 1e9 + 1; while (r - l > 1) { int m = (l + r) / 2; if (1LL * m * m <= x) l = m; else r = m; } return l; } ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) void read(int &a) { a = 0; char c = getchar(); while (c < 0 || c > 9 ) { c = getchar(); } while (c >... |
#include <bits/stdc++.h> using namespace std; int n, m; long long sum[1505][1505]; long long ans[1505]; long long t[1505]; int main() { int i, j, x; long long val, now, res; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf( %I64d , &val), sum[i][j]... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, a[105], cnt = 0, i; fill_n(a, 105, 0); for (cin >> m >> n; n; n /= m) a[cnt++] = n % m; if (cnt > 100) { cout << NO ; return 0; } for (i = 0; i < 105; ++i) { if (a[i] <= 1) continue; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100 * 1000 + 10, M = 300 + 10; int a[N], dp[N][M]; vector<int> p[N]; int main() { ios_base::sync_with_stdio(false); int n, m, s, e; cin >> n >> m >> s >> e; for (int i = (0); i <= (n - 1); i++) cin >> a[i]; for (int i = (1); i <= ... |
#include <bits/stdc++.h> using namespace std; struct Node { int val; int op; int cl; Node(int x, int y, int z) { val = x; op = y; cl = z; } Node() { Node(0, 0, 0); }; }; string s; vector<Node> ST; Node temp; int n, t, x, y, t1, t2; void update(int root, int l, i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int i, j, t, n, a[150], b[150], sum1 = 0, sum2 = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; } for (i = 1; i <= n; i++) { cin >> b[i]; } for (i = 1; i <= n; i++) { if (a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, pos, l, r, diff, rflag = 1, lflag = 1; cin >> n >> pos >> l >> r; diff = r - l; if (l == 1) lflag = 0; if (r == n) rflag = 0; if (lflag == 0 && rflag == 0) cout << 0; else if (lflag == 0) cout << abs(r - pos) +... |
#include <bits/stdc++.h> using namespace std; double maxoo(double, double); int main() { int p1, p2, t1, t2; cin >> p1 >> p2 >> t1 >> t2; double p11, p12, p21, p22, misha, vasya; p11 = (3 * p1) / 10; p12 = (p1 - (p1 / 250) * t1); p21 = (3 * p2) / 10; p22 = p2 - (p2 / 250) * t2; mis... |
#include <bits/stdc++.h> using namespace std; struct SuffixArray { char* T; int n; vector<int> RA, tempRA; vector<int> SA, tempSA, c; vector<int> phi, pLCP, LCP; SuffixArray(string& t) { n = t.length(); T = new char[n + n]; for (int i = 0; i < n; T[i] = t[i], i++) ;... |
#include <bits/stdc++.h> using namespace std; long long sum[500]; int deep[500]; int in1[500]; int out1[500]; int in2[500]; int out2[500]; vector<int> maps1[500]; vector<int> maps2[500]; long long dp[150000]; long long n, m, t; int cnt = 0; void topo2() { queue<int> q; for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; int wyn[1024]; int odp[1024]; int n; int pyt; vector<pair<int, int> > v[2]; void pytaj(vector<int>& skad, vector<int>& gdzie) { if (skad.size() == 0) return; printf( %d n , int(skad.size())); for (int i = 0; i < skad.size(); i++) printf( %d , skad... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } vector<double> p(n); vector<int> powers(n, 1); vector<double> curval(n); using pdi = pair<double, int>; priority_queue<pdi, vector<pdi>> q; ... |
// Problem: A. Robot Program // Contest: Codeforces - Educational Codeforces Round 98 (Rated for Div. 2) // URL: https://codeforces.com/contest/1452/problem/A // Memory Limit: 256 MB // Time Limit: 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> usi... |
#include <bits/stdc++.h> using namespace std; using namespace std; int k; string ad; vector<string> c(string s) { vector<string> ans; int last = 0; for (long long i = 0; i < (s.size()); i++) { if (s[i] == || s[i] == - || i == s.size() - 1) { ans.push_back(s.substr(last, i - las... |
#include <bits/stdc++.h> using namespace std; long long a, b, r, x; int main() { cin >> a; b = 45 * 17 * 10000000000000000LL; r = 100000000000000000LL - 1; x = b % a; cout << a - x << << a - x + r; return 0; } |
#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; template <class T> inline void getar(T a, int n, int m) { for (int i = 0; i < n; i++) for (int j = 0; j < m; ++j) { scanf( %d , &a[i][j]); } } inline void getar(int *a, int n) { for (int ii = 0; ii < n; ii++) { scanf( %d , a + ii)... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) { fu = -1; } c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int legs[N]; bool hide[N]; vector<vector<int> > adj; void dfs(int v, int par = 0) { if (adj[v].size() <= 2u) { hide[v] = true; for (int i : adj[v]) { if (i != par) { dfs(i, v); } } } } ... |
#include <bits/stdc++.h> using namespace std; int parent[5001][5001]; int dp[5001][5001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, m, t; cin >> n >> m >> t; vector<int> u(m + 1), v(m + 1), tm(m + 1); for (int i = 1; i <= m; i++) { cin >> u[i] >> v[i] ... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> dp[1100][20]; int bitcnt[1100]; long long p10[21]; string a; int n, k; pair<long long, long long> dfs(int bi, int pos, int flag, int leading) { if (pos == -1) return make_pair(0, 1); if (dp[bi][pos].second != -1 && !flag && !... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int b[200005]; vector<int> a; cin >> n; a.push_back(31); a.push_back(28); a.push_back(31); a.push_back(30); a.push_back(31); a.push_back(30); a.push_back(31); a.push_back(31); a.push_back(30); a... |
#include <bits/stdc++.h> #pragma GCC target( sse4,avx ) const double pi = 3.14159265358979323; struct dpoint { double x, y; dpoint() : x(0), y(0) {} dpoint(double x, double y) : x(x), y(y) {} }; void run(std::istream& in, std::ostream& out) { int n; dpoint p; in >> n >> p.x >> p.y; ... |
#include <bits/stdc++.h> using namespace std; void fastInOut() { ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); } int dx[] = {0, 0, 1, -1, -1, -1, 1, 1}; int dy[] = {1, -1, 0, 0, -1, 1, -1, 1}; int main() { double m, n, total = 0.0; cin >> m >> n; for (double i = 1; i <= m;... |
#include <bits/stdc++.h> using namespace std; const int _1e5 = 100000; const int _1e7 = 10000000; const int _1e9 = 1000000000; template <typename A, typename B> ostream& operator<<(ostream& str, const pair<A, B>& p) { return str << ( << p.first << , << p.second << ) ; } template <typename T> ... |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; long long qpow(long long a, long long b, long long m) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % m; a = a * a % m, b >>= 1; } return ans; } long long qpow(long long a, long long b) { long... |
#include <bits/stdc++.h> using namespace std; int w[2][2]; int kb[2], kc[2]; int size[10][10]; string s; int main() { ios_base::sync_with_stdio(0); for (int i = 0; i <= (int)(2) - 1; i++) { cin >> s; w[i][0] = s[0] - a ; w[i][1] = s[1] - 1 ; } cin >> s; kb[0] = s[0] -... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 10; int a[MAX_N]; vector<pair<int, int>> scanCuts[2][MAX_N]; pair<int, int> cuts[MAX_N]; int tree[2 * MAX_N], d[2 * MAX_N]; void push(int i) { d[2 * i + 1] += d[i]; d[2 * i + 2] += d[i]; tree[2 * i + 1] += d[i]; tree[2 *... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n == 1) return false; if (n == 2) return true; for (long long i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } long long poww(long long b, long long e) { if (e ... |
#include <bits/stdc++.h> using namespace std; const int C = 10005, N = 1005; int n, w, b, x, c[N], cost[N]; long long dp[2][C]; template <class T> void maxz(T &a, T b) { if (a < b) a = b; } int main() { int i, j, k, ub; long long mn; scanf( %d%d%d%d , &n, &w, &b, &x); for (i = 1; i <... |
#include <bits/stdc++.h> using namespace std; int r = 2, g = 5, b = 8, n, k; int h, j, p; int main() { cin >> n >> k; h = r * n; j = g * n; p = b * n; h = (h + k - 1) / k; j = (j + k - 1) / k; p = (p + k - 1) / k; cout << p + j + h; } |
#include <bits/stdc++.h> int sw, sw1, sw2; int main() { char a[1000]; scanf( %s , a); int n; scanf( %d , &n); for (int i = 0; i < n; i++) { char b[10]; scanf( %s , b); if (b[0] == a[0] && b[1] == a[1]) sw = 1; if (b[1] == a[0]) sw1 = 1; if (b[0] == a[1]) sw2 = 1; ... |
#include <bits/stdc++.h> using namespace std; vector<vector<long long>> dp(10, vector<long long>(1000005, 0)); long long g(long long n) { if (n < 10) return n; long long ans = 1; while (n) { if (n % 10) ans *= (n % 10); n /= 10; } return g(ans); } signed main() { ios_base::... |
#include <bits/stdc++.h> const int MOD = 1e9; const int N = 100003; using namespace std; vector<int> ans; int main() { int n; cin >> n; int p, q; p = q = 0; for (int i = 0; i < n; i++) { char c; int x, y; cin >> c; scanf( %d , &x); scanf( %d , &y); if (x... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 69; const int inf = 1e9 + 5; const long long mod = 1e9 + 7; const long double eps = 1e-10; vector<int> v[MX]; int par[24][MX]; int depth[MX]; void dfs(int x, int p) { for (auto g : v[x]) { if (g == p) { continue; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int>> g(n); vector<pair<int, int>> e(n - 1); for (int i = 0; i < n - 1; ++i) { int u, v; cin >> u >> v; --u; --v; g[u].push_back(v); g[v].push_back(u); e[i] = make_... |
#include <bits/stdc++.h> int cnt; int n, m, k; char s[1111][1111]; int c[1111][1111], vis[1111][1111]; int b[1111]; int tot; void dfs(int p, int q) { c[p][q] = cnt; vis[p][q] = 1; if (s[p - 1][q] == . && !vis[p - 1][q]) dfs(p - 1, q); if (s[p - 1][q] == * ) tot++; if (s[p + 1][q] ==... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; } template <typename T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; } int readint() { int x = 0, f = 1; char ch = getchar(); while (ch < ... |
#include <bits/stdc++.h> int main() { long long int a, b; scanf( %lld%lld , &a, &b); if (a > b) { printf( %lld %lld , b, (a - b) / 2); } else { printf( %lld %lld , a, (b - a) / 2); } } |
#include <bits/stdc++.h> int main() { int a, b, c, ab = -1, min; scanf( %d %d %d , &a, &b, &c); min = b; if (a < b) min = a; for (int i = 0; i <= min; i++) { if (b + a - 2 * i == c) { ab = i; break; } } if (ab == -1) printf( Impossible ); else pr... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; set<int> fang[400001]; map<int, int> cishu[400001]; int n, m, q, to1[400001], Nxt[400001], first1[400001], dfn[400001], low[400001]; int to[500001], nxt[500001], first[500001], cnt, e1, x2, fa[400001]; int sum, tot = 0, ss[400001], heavy[4... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, b, d; cin >> n >> b >> d; int cur ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9 + 7; const int N = (int)1e5 + 10; struct qq { int l, r, i, w; }; int t[4 * N], ans[2 * N]; pair<int, int> p[2 * N]; vector<qq> qx[N], qy[N]; void upd(int pos, int val, int v = 1, int l = 1, int r = N - 10) { if (l == r) { ... |
#include <bits/stdc++.h> using namespace std; const long long int N = 3e5 + 10, N2 = 2e5, delta = 10499, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300; const long double PI = 3.141592653589793; pair<pair<long long int, long long int>, long long int> p[N]; int32_t main() { ios::sync_wi... |
#include <bits/stdc++.h> using namespace std; int main() { fixed(cout); cout << setprecision(10); ; long long int n, h; cin >> n >> h; for (int i = 1; i <= n - 1; i++) { double x = (h * h * i) / double(n); x = sqrt(x); if (i == n) break; cout << x << ; } co... |
#include <bits/stdc++.h> using namespace std; int tipo[100000 + 5]; int main() { int n, x, y, z, m; cin >> n >> m; memset(tipo, -1, sizeof(tipo)); for (int i = 0; i < m; ++i) { cin >> x >> y >> z; x--, y--, z--; bool enc = 0; if (tipo[x] != -1) { enc = 1; ti... |
#include <bits/stdc++.h> using namespace std; int vis[10] = {0}; int main() { int c = 0, n = 0, i, flag = 0; long long ans = 1; string s; cin >> s; for (i = 0; i < s.size(); i++) { if (s[i] == ? ) { if (i == 0) flag = 1; c++; } if (s[i] >= A && s[i] <= J )... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int32_t main() { c_p_c(); long long t; cin >> t; while (t--) { long long n, r; cin ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; const int inf = 0x3f3f3f3f; vector<int> ve[maxn]; int a[maxn], c[maxn]; struct node { int pos, val; } nod[maxn]; bool cmp(node a, node b) { return a.val < b.val; } bool cmp1(int x, int y) { return nod[a[x]].val > nod[a[y]]... |
#include <bits/stdc++.h> using namespace std; long long int mod_expo(long long int x, long long int y) { long long int res = 1; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } int main() { long long int t; c... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long A, B; cin >> A >> B; if (A < B) { puts( -1 ); return 0; } if ((A - B) % 2 != 0) { puts( -1 ); return 0; } unsigned long long C = (A - B) / 2; unsigned long long X = 0, Y = 0; for... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)1e4 + 10; int n, w, b, x; long long dp[1005][maxN]; int c[maxN]; int cost[maxN]; int main() { cin >> n >> w >> b >> x; for (int i = 1; i <= n; i++) cin >> c[i]; for (int i = 1; i <= n; i++) cin >> cost[i]; memset(dp, -1, s... |
#include <bits/stdc++.h> using namespace std; int T, n, b[100010], mp[100010], hah[100010]; struct qwq { int v, id; } a[100010]; bool cmp(qwq x, qwq y) { return x.v < y.v; } int main() { scanf( %d , &T); while (T--) { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> struct SegmentTree { struct Node { bool hasCarry = 0; int b = 0, e = 0; U carry = U(); T val = T(); Node() {} void join(const Node &l, const Node &r) { val = l.val + r.val; b = l.b; ... |
#include <bits/stdc++.h> using namespace std; const int p = 1000003; const int n = 10; int inv[1000005], a[15][15], ans[15]; int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 + 10; int n, d[MAXN], id[MAXN]; bool b[MAXN][MAXN]; bool cmp(int a, int b) { if (d[a] > d[b]) return true; if (d[a] < d[b]) return false; return a < b; } int main() { scanf( %d , &n); if (n == 4) puts( -1 ), exit(0); ... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == - ) f = -1LL; } while (ch < 0 || ch > 9 ); do { x = x * 10 + ch - 0 ;... |
#include <bits/stdc++.h> int q, t, l, r, x, last; std::map<int, int> dsu, val; int root(int x) { int cur = dsu[x]; if (cur < 0) return x; else { dsu[x] = root(dsu[x]); val[x] ^= val[cur]; return dsu[x]; } } void connect(int x, int y, int v) { int a = root(x), b = ro... |
#include <bits/stdc++.h> using namespace std; long long pl, pr, vl, vr; int k; long long Inter(long long x1, long long x2, long long y1, long long y2) { long long a = max(x1, y1); long long b = min(x2, y2); if (a > b) return 0.0; else return b - a + 1; } long long GetProb(long lo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 205; int a[maxn]; int main() { ios::sync_with_stdio(false); int n, k; scanf( %d %d , &n, &k); int m = n + n + 1; for (int i = 0; i < m; ++i) scanf( %d , &a[i]); for (int i = 1; k && i < m; i += 2) { if (a[i] > max(a[i -... |
#include <bits/stdc++.h> using namespace std; int dp[10][300]; int s[10][10]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < int(n); ++i) for (int j = 0; j < int(m); ++j) cin >> s[i][j]; int *cur = dp[0], *next = dp[1]; for (int i = n - 1; i >= 0; --i) { for (int j = m... |
#include <bits/stdc++.h> int main() { int ele, n, x[110], y[110], p, q, e = 0, f = 0, i, e1 = 0, e2 = 0, o1 = 0, o2 = 0; char s1[300], s2[300]; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d%d , &x[i], &y[i]); for (i = 1; i <= n; i++) { if (x[i] % 2... |
#include <bits/stdc++.h> using namespace std; long long a[100001], flag[100001]; vector<pair<long long, long long> > ans; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, sum = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; sum += a[i]... |
#include <bits/stdc++.h> using namespace std; int n, m; long long f(const string& s) { long long res = 0; for (int i = 0; i + 1 < s.size(); ++i) { if (s[i] != s[i + 1]) { res += (m - 1) * (n - i - 1); } } return res; } long long g(const string& s) { long long res = 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.