func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& out, const vector<T>& vec) { out << [ ; for (int x : vec) out << x << , ; out << ] ; return out; } int main() { int M; long long N, A, D; cin >> N >> M >> A >> D; vector<long lo... |
#include <bits/stdc++.h> using namespace std; const long long M = 1000 * 1000 * 1000 + 7; const int INF = 0x3f3f3f3f; const int MAX = 200009; long long n, f1, f2, f3, c; vector<vector<long long> > operator*(const vector<vector<long long> > &a, const vector<vector<long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; int a[(int)(pow(2.0, (double)(n + 1)) - 2)]; int x = (int)pow(2.0, (double)(n + 1)) - 2; for (int i = 0; i < x; i++) { cin >> a[i]; } int y = (int)(pow(2.0, (double)(n + 1)) - pow(2.0, (d... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 4; char s[maxn]; int a[maxn]; void get(bitset<maxn> &B) { scanf( %s , s); int m = strlen(s); int x = 12; for (int i = 0; i < m; i++) a[m - 1 - i] = s[i] - 0 ; m--; for (int i = 0; i < maxn && x >= 0; i++) { in... |
#include <bits/stdc++.h> long long mpow(long long a, long long n, long long mod) { long long ret = 1; long long b = a; while (n) { if (n & 1) ret = (ret * b) % mod; b = (b * b) % mod; n >>= 1; } return (long long)ret; } using namespace std; int main() { cin.sync_with_st... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 400, LOGN = 19; int n, q, a[N], dpLCA[LOGN][N], lca[N], kraw[N], dist[N]; vector<pair<int, int> > G[N]; long long dp[N], dp2[N], tree[N], odl[N], wynik[N], pom[N]; vector<int> zapytania[N]; void insert(int v, long long x) { while (v <= ... |
#include <bits/stdc++.h> using namespace std; int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; int main() { int tc = 1; cin >> tc; for (int cs = 1; cs <= tc; cs++) { string s; cin >> s; vector<int> v; for (int i = (int)s.size() - 3; i >= 0; i-... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; const long long MAX = -1000000000000000000; const long long MIN = 1000000000000000000; const long long inf = 1000000000; const long long KOK = 100000; const long long LOG = 30; const long long li = 5000... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int a[MAXN], b[MAXN]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 0; i < n / k; ++i) { scanf( %d , &a[i]); } for (int i = 0; i < n / k; ++i) { scanf( %d , &b[i]); } long long ans = 1; ... |
#include <bits/stdc++.h> using namespace std; const int inft = 1000000009; const int MAXN = 1000006; const int T = 1024 * 1024; int drz[2][2 * T]; vector<int> X; pair<int, int> Q[MAXN]; char C[MAXN]; bool used[MAXN]; int ask(int a, int nr) { int ans = -1; a += T; while (a) { ans = ... |
#include <bits/stdc++.h> using namespace std; bool compare(long long &x, long long &y) { return x >= y; } long long mode = pow(10, 9) + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n + 1]; a[0] = 0; for (int i = 1; i <= n; i++) { cin >... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int k; cin >> k; string second, t; int freq[130]; while (k--) { memset(freq, ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int main() { ios::sync_with_stdio(false); int n; while (cin >> n) { int a, b, c, d, sum = 0, i = 0, mx = -1, my = -1, mix = N, miy = N; for (i = 0; i < n; i++) { cin >> a >> b >> c >> d; sum += abs(a - c)... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-12; pair<long long, long long> save[200005]; long long cnt[50]; int main(void) { long long n; cin >> n; if (n & 1) { char ch; while (cin >> ch) ; cout << no ; return 0; } for (long lon... |
#include <bits/stdc++.h> using namespace std; const int N = 51; const long long MOD = 1e9 + 7; const double eps = 1e-8; int n, a[N], b[N]; vector<pair<int, int> > v; double dp[N][N][N], thresh; bool vis[N][N][N]; double calc(int i, int g, int e) { if (i == n) return 0.0; double &r = dp[i][g][e... |
#include <bits/stdc++.h> using namespace std; int a[100004], d[32]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int j = 0; j < n; j++) { int x = a[j]; for (int i = 0; x > 0; i++) { d[i] += x % 2; x /= 2; } } in... |
#include <bits/stdc++.h> using namespace std; int n, m; const int mxN = 2e5 + 10; vector<int> arr(mxN); vector<pair<int, int> > offers(mxN); bool isPossible(int day) { vector<int> lst(n, -1); for (int i = 0; i < m; i++) { if (offers[i].first <= day) { lst[offers[i].second] = max(lst[of... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int M = 100005; int n, m; int in_degree[N]; bool visited[N]; bool tree_edge[M]; bool directed[M]; vector<int> choose[N]; vector<pair<int, int> > adj[N]; inline void dfs(int u, int p) { visited[u] = true; for (auto ed... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int n, m; long long c[maxn], ans, s; vector<int> g[maxn]; bool v[maxn]; void dfs(int a) { s = min(s, c[a]); v[a] = 1; for (int i = 0; i < g[a].size(); i++) { int b = g[a][i]; if (!v[b]) dfs(b); } } int m... |
#include <bits/stdc++.h> using namespace std; bool mul_overflow(long long a, long long b) { return (a > (LLONG_MAX / b)); } bool add_overflow(long long a, long long b) { return (a > (LLONG_MAX - b)); } const int N = 1e6 + 5; int n; long double a[N][3]; bool sol(long double mid) { long double l = -1e8,... |
#include <bits/stdc++.h> using namespace std; char str[1000005]; int main() { while (scanf( %s , str) != EOF) { int i, len = strlen(str); long long m, l = 0, r = 0; for (i = 0; i < len; i++) if (str[i] == ^ ) m = i; for (i = 0; i < len; i++) if (str[i] >= 1 && str[i... |
#include <bits/stdc++.h> using namespace std; int from[101], to[101], p; int main() { int n, m, x, y; cin >> n >> m; memset(to, -1, sizeof to); for (int i = 1; i <= n; i++) { cin >> x >> y; for (int j = x; j <= y; j++) to[j] = max(to[j], y); } int now = 0; for (; now <= m;)... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; scanf( %I64d , &a); scanf( %I64d , &b); if (a == b) { printf( 1 n ); return 0; } long long cnt = 0, ans = 1; for (long long i = b; i >= a + 1; i--) { cnt++; if (i % 10 == 0) { print... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; struct Edge { long long int from, to, cap, flow, index; Edge(long long int from, long long int to, long long int cap, long long int flow, long long int index) : from(from), to(to), cap(cap), flow(flow), index(inde... |
#include <bits/stdc++.h> using namespace std; int X[] = {1, 0, -1, 0, 1, -1, -1, 1}; int Y[] = {0, 1, 0, -1, 1, 1, -1, -1}; void MN(long long int &a, long long int b) { if (a > b) a = b; } void MX(long long int &a, long long int b) { if (a < b) a = b; } void MN(int &a, int b) { if (a > b) a ... |
#include <bits/stdc++.h> using namespace std; double a, b, c, s, r; double A, B, C; double eps = 1e-3; double pi = acos(-1.0); struct Point { double x, y; } p[10]; double disP2P(Point a, Point b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } int sgn(double x) { ... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int Max = 35010; const ll INF = 1e17 + 10; bool sw; ll dp[2][Max]; int A[Max]; int L , R , F; deque<int> dq[Max]; void moveto(int l , int r) { //cout << to << l << , << r << n ; while(L > l) { L--;... |
#include <bits/stdc++.h> using namespace std; int countnode(map<int, vector<int>> m, int x, int parent) { int count = 1; for (auto i : m[x]) { if (i != parent) count += countnode(m, i, x); } return count; } int main() { int t; cin >> t; while (t--) { int n, x; cin >... |
#include <bits/stdc++.h> using namespace std; long long cumdp[2005]; long long cumpd[2005]; long long dp[2005][2005]; long long pd[2005][2005]; const long long mod = 1e9 + 7; int main() { long long n, m; cin >> n >> m; for (int width = 2; width <= m; width++) { dp[1][width] = 1; pd... |
#include <bits/stdc++.h> using namespace std; int C[200005], L[200005], N[200005]; inline int findSet(int i) { return (N[i] == i) ? i : (N[i] = findSet(N[i])); } inline void unionSet(int i, int j) { N[findSet(i)] = findSet(j); } int main() { int n, m; scanf( %d , &n); for (int i = 0; i < n; ++i) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n; for (int i = 0; i <= n; i++) cin >> a >> b; cout << 0.5 * (n - 4) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int M = 200179; int n, q, k, t; int p[M], b[M]; vector<int> pb[M]; set<int> last; int main() { scanf( %d , &n); for (int t = 0; t < n; t++) { scanf( %d%d , &p[t], &b[t]); pb[p[t]].push_back(t); } last.insert(-1); for (int ... |
#include <bits/stdc++.h> using namespace std; long long x[200001], y[200001], dp[200001], n; bool s[200001]; long long find_upper_bound(long long l, long long r, long long value) { long long mid, index = 1; while (l <= r) { mid = l + (r - l) / 2; if (x[mid] >= value) { index = mid; ... |
#include <bits/stdc++.h> using namespace std; long long xa, xb, ya, yb, xc, yc, t; long long cp(long long x1, long long x2, long long y1, long long y2) { return x1 * y2 - x2 * y1; } int main() { cin >> xa >> ya >> xb >> yb >> xc >> yc; t = cp(xc - xa, xb - xa, yc - ya, yb - ya); if (t == 0) { ... |
#include <bits/stdc++.h> using namespace std; char c[2000007]; set<int> s; int main() { int n; scanf( %d , &n); for (int i = 0; i < 2000007; i++) { s.insert(i); } set<int>::iterator it; int maxy = 0; for (int i = 0; i < n; i++) { string l; cin >> l; int k; ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int inf = 0x3f3f3f3f; inline long long read() { register long long x = 0, f = 1; register char c = g... |
#include <bits/stdc++.h> using namespace std; const int m = 10000 * 100000 + 7; int main() { string s; cin >> s; int n = s.length(); long long p = 0, q = 1; for (int i = n - 1; i > 0; --i) { if (s[i] == 1 ) p = (p + q) % m; q = q * 2 % m; } if (s[0] == 1 ) p = (p + q) % m... |
#include <bits/stdc++.h> using namespace std; int main(void) { int count; int n; int rub; int a[100000]; int b[100000]; int a_1234[4] = {0, 0, 0, 0}; int sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> rub; a_1234[rub - 1]++; } sum = a_1234[3] + a_1234... |
#include <bits/stdc++.h> using namespace std; struct $ { $() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } } $; const int N = 100002; int n, m; vector<int> a[N]; vector<int> pri[N]; vector<int> ans; vector<tuple<int, int>> where[N]; const int NPR = 20; int primes[NPR]... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; int nrg, nrv; string s; bool gg(int pos) { if (pos < 2) return 0; return ((s[pos] >= 0 && s[pos] <= 9 ) && (s[pos - 1] >= 0 && s[pos - 1] <= 9 ) && (s[pos - 2] == . )); } deque<int> dg; int main() { i... |
#include <bits/stdc++.h> using namespace std; long long read() { char c; long long num, f = 1; while (c = (char)getchar(), !isdigit(c)) if (c == - ) f = -1; num = (long long)(c - 0 ); while (c = (char)getchar(), isdigit(c)) num = num * 10 + (long long)(c - 0 ); return num * f; } ... |
#include <bits/stdc++.h> using namespace std; int i, j, x, y, z, m, n, k, l, r, f, mi = 1e9; int a[200]; bool pr(int n) { for (int i = 2; i * i <= n; i++) if (n % i == 0) return true; return false; } int main() { scanf( %d , &n); a[1] = a[2] = a[3] = -1; a[4] = 1; for (int i = ... |
#include <bits/stdc++.h> using namespace std; const long long dx[] = {-2, -1, 1, 2, -2, 1, -1, 2}; const long long dy[] = {-1, -2, 2, 1, 1, -2, 2, -1}; const long long Mod = 1e9 + 7; const long long N = 5e5; const long long inf = 1e9 + 1; const long long N_N = 1e2; long long n, m, x, y, cnt; int main(... |
#include <bits/stdc++.h> using namespace std; int a[50]; int main() { int f = 2, ct[110]; ct[0] = 0; ct[1] = 0; ct[2] = 1; for (int i = 3; i <= 101; i++) { ct[i] = ct[i - 1] + f; f++; } string s; int n, m; cin >> n; for (int i = 0; i < n; i++) { cin >> s; ... |
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <queue> #include <set> #include <sstream> #include <stack> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<int... |
#include <bits/stdc++.h> using namespace std; inline int read() { static int r, sign; static char c; r = 0, c = getchar(), sign = 1; while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) sign = -1, c = getchar(); while (c >= 0 && c <= 9 ) r = r * 10 + (c - 0 ), c = getcha... |
#include <bits/stdc++.h> using namespace std; int sim(vector<int> s, int p, int x) { s.insert(s.begin() + p, x); int l = p, r = p; int acum = 0; int ans = 0; for (;;) { while (l >= 0 && s[l] == x) l--; while (r <= (int)s.size() - 1 && s[r] == x) r++; int dis = r - l - 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); char c = 0; int n = str.length(); for (int i = n - 1; i >= 0; i--) { if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122)) { c = str[i]; break; } } if (c... |
#include <bits/stdc++.h> using namespace std; int main() { int M[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cin >> M[i][j]; } } for (int i = 0; i < 3; i++) { int c = 0; for (int j = 0; j < 3; j++) { c = (i > 0 ? M[i - 1][j] : 0); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); int m; cin >> m; string s; cin >> s; int n = s.size(); vector<int> cnt(26); vector<int> have(n); for (int c = 0; c < 26;... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { if (x < 0) return -x; else return x; } int main() { double A, B, C, D; scanf( %lf%lf , &A, &B); scanf( %lf%lf , &C, &D); if (A * D > B * C) { swap(A, B); swap(D, C); } double l... |
#include <bits/stdc++.h> using namespace std; int n, k; const int maxn = 300000 + 500; const int maxk = 5005; const int INF = 2e9 + 100; int a[maxn]; int d[maxk][maxk]; int main() { scanf( %d %d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } int large = n % k; ... |
#include <bits/stdc++.h> using namespace std; const int N = 5005; int n, k, x, arr[N]; long long tree[2][17000]; void build(int pos, int l, int r, int dim) { if (l == r) { if (l <= k) tree[dim][pos] = arr[l]; else tree[dim][pos] = -1e18; return; } int mid = (l + r... |
#include <bits/stdc++.h> char a[1001][1001]; int n, m; int findG(int r) { int i; for (i = 0; i < m; i = i + 1) if (a[r][i] == G ) return i; } int findS(int r) { int i; for (i = 0; i < m; i = i + 1) if (a[r][i] == S ) return i; } int main() { scanf( %d%d , &n, &m); int... |
#include <bits/stdc++.h> using namespace std; double dpsm[200001][26] = {0}; double dpfm[200001][26] = {0}; double ans = 0; int main() { int n; cin >> n; string s, f; cin >> s >> f; dpsm[0][s[0] - A ] = 1; dpfm[0][f[0] - A ] = 1; for (int i = 0; i < 26; ++i) { char c = A ... |
#include <bits/stdc++.h> using namespace std; string a, b; int rs, p; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> a >> b; if (a.size() != b.size()) return cout << NO , 0; for (int i = 0; i < a.size(); i++) if (a[i] != b[i]) rs++, p = i; if (rs !=... |
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) { if (p1.first == p2.first) { return p1.second < p2.second; } return p1.first > p2.first; } int main() { int n, m, e, x, y; cin >> n >> m; std::vector<pair<int, int> > E; ... |
#include <bits/stdc++.h> using namespace std; bool Prime(int a) { if (a == 1) return true; for (int i = 2; i * i <= a; i++) if (a % i == 0) return false; return true; } int main() { int t; cin >> t; while (t--) { string s; cin >> s; int count = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; int INF = 1234567890; int t, T; int fa[100000], opp[100000]; int l[100000], r[100000]; int col[100000]; set<pair<int, int> > rp; set<pair<int, int> > lp; int find(int a) { if (a == -1) return -1; if (fa[a] == -1) return a; return fa[a] = find(f... |
#include <bits/stdc++.h> using namespace std; const int MAXL = 40000; pair<int, int> p[MAXL]; int Init() { for (int i = 0; i * i < MAXL; i++) { for (int j = i; j * j + i * i < MAXL; j++) { int now = i * i + j * j; p[now].first = i; p[now].second = j; } } return 0;... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:134217728 ) using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } int n; int m; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; string s[5001]; vector<int> t[5001]; string ss[5001]; vector<pair<int, int>... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, ans = 0; cin >> n; long long boy[n]; for (long long i = 0; i < n; i++) cin >> boy[i]; cin >> m; long long girl[m]; for (long long i = 0; i < m; i++) cin >> girl[i]; sort(boy, boy + n); sort(girl, girl + ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000 * 1000 * 1000 + 7; const int mod = 1000 * 1000 * 1000 + 9; const int num = 1000 * 1000 + 7; const int N = 1000 + 7; const double PI = 3.1415926535897932384626433832795; int ux_x[5] = {0, 0, 1, -1}; int ux_y[5] = {1, -1, 0, 0}; in... |
#include <bits/stdc++.h> using namespace std; inline int getidx(const vector<int>& ar, int x) { return lower_bound(ar.begin(), ar.end(), x) - ar.begin(); } inline long long GCD(long long a, long long b) { long long n; if (a < b) swap(a, b); while (b != 0) { n = a % b; a = b; b ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, col[N], maxx, cnt[N], p[N], eid, Son, mx[N], sz[N]; long long sum, ans[N]; struct edge { int v, nxt; } e[N << 1]; inline void addedge(int u, int v) { e[++eid] = (edge){v, p[u]}, p[u] = eid; } inline void dfs0(int u, int fa) ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int main() { double d, h, v, e; while (scanf( %lf%lf%lf%lf , &d, &h, &v, &e) != EOF) { double t = v / (PI * (d / 2) * (d / 2)); if (t > e) { printf( YES n ); double ti = h / (t - e); printf( %lf n... |
#include <bits/stdc++.h> using namespace std; long long n, p, w, d; int main() { cin >> n >> p >> w >> d; for (long long i = 0; i < w; i++) { if ((p - i * d) % w == 0) { long long x = (p - i * d) / w; if (x >= 0 && x + i <= n) { printf( %lld %lld %lld n , x, i, n - x - i); ... |
#include <bits/stdc++.h> const int N = 3e5; int t, n, m, h[N], val[N]; std::set<int> adj[N], jda[N], res; std::map<int, std::set<int>> map; void reset() { for (int i = 1; i <= n; ++i) { adj[i].clear(); jda[i].clear(); h[i] = 0; val[i] = 0; } map.clear(); res.clear(); ... |
#include <bits/stdc++.h> using namespace std; struct el { long long hp, dmg, i; }; bool comp(el a, el b) { return (a.hp - a.dmg) > (b.hp - b.dmg); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n, a, b, i = 0; cin >> n >> a >> b; el sol[n]; for (i = (0); i <... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; void sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } } _sync_stdio; int intersect(pair<int, int> a, ... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; vector<long long> arr; arr.push_back(0); int sz = 1; long long max_ele = -1; long long pre_ind = 0; while (q--) { int x; cin >> x; if (x == 1) { long long v; cin >> v; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, n; cin >> a >> n; int tilln = (1LL * n * (n - 1) / 2) % 1000000007, tilla = (1LL * a * (a + 1) / 2) % 1000000007; cout << ((((((1LL * tilln) % 1000000007) * tilla) % 1000000007) * n) % 1000000007 + ... |
#include <bits/stdc++.h> using namespace std; vector<int> big; vector<int> s[100010]; vector<int> pos[100010]; unsigned int h[100010], n, m, q; int same[320][100010]; unsigned int BND; long long a[100010], sum[100010], add[100010]; void Debug() { unsigned int i, j; printf( light: n ); for ... |
#include <bits/stdc++.h> using namespace std; struct Comm { int first; int second; Comm(int a, int b) { first = a; second = b; } bool operator<(const Comm& other) const { if (this->first == other.first) return this->second < other.second; return this->first < other.first;... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; const long long INF = 1e7; signed main() { cin.tie(0), ios_base::sync_with_stdio(false); ; long long n, s; cin >> n >> s; vector<long long> arr(n); long long su = 0, mi = 1e... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 2e5 + 10; int per(int tot, int cur) { return (cur * 100 + tot / 2) / tot; } int main() { int n, k; cin >> n >> k; map<pair<int, int>, int> mc; queue<int> q; for (int i = 1; i <= n; i++) { int x... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; int ara[200005], dist[200005], ans[200005]; vector<int> even, odd, ad[200005]; bool vis[200005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, i, j; cin >> n; for (i = 1; i <= n; i++) { c... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50, maxm = 5e3, inf = 1e8; int n, m, q, k, tot, ter[maxm + 3], cap[maxm + 3], wei[maxm + 3], nxt[maxm + 3], lnk[maxn + 3], dist[maxn + 3], pre[maxn + 3], f[maxn + 3]; bool in[maxn + 3]; long long g[maxn + 3], h[maxn + 3]; void add(int u, i... |
#include <bits/stdc++.h> using namespace std; using lint = long long int; int main() { lint n; cin >> n; vector<lint> v(n); for (lint i = 0; i < n; i++) { cin >> v[i]; } lint val = 2 * accumulate(v.begin(), v.end(), 0ll) / n; vector<lint> visited(n); for (lint i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int n; int f[55][55][55][55]; string s[100]; bool dfs(int n, int a, int b, int c) { if (n == 1) return 1; if (f[n][a][b][c]) return 0; if (s[c][0] == s[b][0] || s[c][1] == s[b][1]) if (dfs(n - 1, n - 3, a, c)) return 1; if (n > 3 && (s[c][0] ... |
#include <bits/stdc++.h> using namespace std; const int M = (int)1e4 + 5, N = (int)1e5 + 5; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int n, m, p; int a[M], b[N]; vector<int> fac, dp; int fast(int a, int b) { int re = 1; while (b) { if (b & 1) re = (long... |
#include <bits/stdc++.h> using namespace std; const int kMaxN = 1010; struct Cell { int x, y, val; bool operator<(const Cell &p) const { return val > p.val; } } cell[kMaxN * kMaxN]; vector<int> vec[kMaxN]; int g[kMaxN][kMaxN]; int n, m; void init() { scanf( %d%d , &n, &m); for (int i = 0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 5; long long a[maxn]; long long pre[maxn]; map<long long, long long> mp; int main() { int n, l; scanf( %d%d , &n, &l); for (int i = 0; i < n; i++) { scanf( %I64d , &a[i]); mp[a[i]]++; } sort(a, a + n); l... |
#include <bits/stdc++.h> using namespace std; char x[105]; bool g; int main() { scanf( %s , x); for (int i = 0; x[i]; i++) if (x[i] == a || x[i] == e || x[i] == i || x[i] == o || x[i] == u ) g = 0; else if (g) { puts( NO ); return 0; } else if (x[i] != ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> a[100005], b[100005], all; void solve() { for (int i = 1; i <= n; i++) { a[i].resize(m + 1); b[i].resize(m + 1); for (int j = 1; j <= m; j++) a[i][j] = (i - 1) * m + j; } bool bswap = 0; if (n > m) bswap = 1; ... |
#include <bits/stdc++.h> using namespace std; bool flag = false; long long n; long long mat[1000][1000]; bool vis[1000][1000]; long long ans[1000][1000]; bool isSol() { long long s = 0; for (int i = 0; i < n; i++) { s += ans[i][i]; } long long s2 = 0; for (int i = 0; i < n; i++) ... |
#include <cstdio> #include <algorithm> using namespace std; #define ADD(x) ((x>=mod)?x-mod:x) const int mod=1e9+7; int n,c[110],b[110],sum[110],sum1[110],sumc[110],dp[110][10010],ans,Min,T,x; int main() { scanf( %d ,&n); for (int i=1;i<=n;i++) scanf( %d ,&c[i]),sumc[i]=sumc[i-1]+c[i]; for (int i=... |
#include <bits/stdc++.h> using namespace std; int gcd(int i, int j) { if (j == 0) return i; else return gcd(j, i % j); } template <typename T> inline T getint() { T val = 0; char c; bool neg = false; while ((c = getchar()) && !(c >= 0 && c <= 9 )) { neg |= c == - ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int> data(n), ans(n); long long suma = 0; for (auto &i : data) cin >> i; for (int i = 0; i < n; ++i) { vector<int> data1; ... |
#include <bits/stdc++.h> using namespace std; long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1}; long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1}; class pa3 { public: long long x; long long y, z; pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {} bool operator<(const pa3& p... |
#include<bits/stdc++.h> using namespace std; #define sz(x) (int)(x).size() #define int long long int #define loop(i,a,b) for(int i=a;i<b;i++) #define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i] #define vi vector<int> #define si set<int> #define pii pair <int, int> #define sii set<pii> #de... |
#include <bits/stdc++.h> using namespace std; string st; vector<long> v; long r; int main() { ios_base::sync_with_stdio(0); cin >> st; st += + ; for (int i = 0; i < st.size(); i++) { if (st[i] == + ) { v.push_back(r); r = 0; } else r = r * 10 + st[i] - 48;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 2500; struct P { int x, y; P() {} P(int x, int y) : x(x), y(y) {} }; long long operator^(const P& a, const P& b) { return (long long)a.x * b.y - (long... |
#include <bits/stdc++.h> using namespace std; double p[22], f[(1 << 20) + 10], ans[22]; int n, m; int main() { int cnt = 0; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %lf , &p[i]); if (p[i] > 1e-7) cnt++; } if (cnt <= m) { for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int n, a[100002]; int b[100002]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i); int ret = 0; for (int i = n - 1; i >= 0; i--) { int mx = 1; for (int j = 1; j * j <= a[i]; j++) if (a[i] % j == 0) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int count[2] = {0, 0}; bool all_even = 1; for (int i = 0; i < n; i++) { static string s; cin >> s; if (static_cast<int>(s.size()) & 1) all_even = 0; for (const char &c : s) count[c - 0 ]++; ... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; const int maxn=1111111,mod=998244353; #define MP make_pair #define PB push_back #define lson o<<1,l,mid #define rson o<<1|1,mid+1,r #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define ROF(i,a,b) for(int i=... |
#include <bits/stdc++.h> using namespace std; long long n, x, k, lb, ub, ans = -1; void init() { long long l, r; scanf( %lld%lld%lld%lld , &n, &l, &r, &k); x = (r >= l ? r - l + 1 : r + n - l + 1) % n; } void solve() { for (long long i = k, j, r; i; i = j) { j = k / (k / i + 1); r ... |
#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; } int cur_sum, del... |
#include <bits/stdc++.h> using namespace std; const int N = 1e9; const int M = 1e9; int ix, iy, fx, fy; map<pair<int, int>, int> pres; map<pair<int, int>, int> dist; map<pair<int, int>, bool> vis; int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; bool check(int x,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.