func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int inf = 1000000009; int i, j, k, l, m, n, q; int ans; int a[4][1000][1000], h[4][1000][1000], W[4], H[4]; void prec(int k, int i) { for (int j = 0; j < H[k]; j++) { if (h[k][i][j] == 0) a[k][i][j] = 0; ... |
#include <bits/stdc++.h> using namespace std; int N; string s; string result; int main() { cin >> N; cin >> s; result = s; result[(N - 1) / 2] = s[0]; int sign = N % 2 == 0 ? 1 : -1; int val = 1; int start = (N - 1) / 2; for (int i = 1; i < N; ++i, sign *= -1, val++) star... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; struct edge { int u, v, id; edge(int a = 0, int b = 0, int c = 0) { u = a, v = b, id = c; } }; vector<edge> S, M, E; struct dsu { int par[N]; vector<edge> ed; dsu() { memset(par, -1, sizeof par); } int get_par(int u... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e9 + 10; const ll inf_ll = 1e18 + 10; ll qry(ll t, ll i, ll j, ll k) { cout << t << << i << << j << << k << endl; ll r; cin >> r; return r; } int main() { ll n; cin >> n; ll b = 2; ... |
#include <bits/stdc++.h> int main() { int n; int x; int sum = 0; std::cin >> n; std::cin >> x; unsigned int t1 = 0, t2 = 0, tcurr = 1; for (int i = 0; i < n; i++) { std::cin >> t1; std::cin >> t2; sum += (t1 - tcurr) % x + t2 - t1 + 1; tcurr = t2 + 1; } std:... |
#include <bits/stdc++.h> using namespace std; vector<int> A; vector<int> d; vector<int> P; vector<int> g; vector<vector<int>> G; int bestu, bestv, bestw, bestvv; void dfs(int x, int v, int n) { for (int i = 0; i < G[x].size(); ++i) { int y = G[x][i]; int u = g[y]; if (u >= 0) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:300000000 ) #pragma warning(disable : 4800) using namespace std; const double pi = 3.1415926535897932384626433832795; template <class T> T abs(const T &a) { return a >= 0 ? a : -a; }; template <class T> T sqr(const T &x) { return x * x; ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0; bool pos = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) pos = 0; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; return pos ? x : -x; } const int N = 1... |
#include <bits/stdc++.h> using namespace std; const long long MAX_N = 3e5 + 7; const long long MOD = 998244353; long long n; long long deg[MAX_N], fac[MAX_N]; long long f_pow(long long base, long long b, long long mod) { long long res = 1; while (b) { if (b & 1) res = res * base % mod; b... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, inf = 998244353; long long n, k, i; long long A[N], B[N]; long long in[N], f[N]; inline long long expo(long long n, long long k, long long p = inf) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100 * 1000 + 10; int n, m, l[Maxn], ans1, ans2; long double a, b; pair<long double, int> arr[Maxn], brr[Maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> a >> b; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; unsigned long long h[100010], bin[100010]; inline unsigned long long hsh(const int l, const int r) { return h[r] - h[l - 1] * bin[r - l + 1]; } inline int find(const int l1, const int r1, const int l2, const int r2) { int l = 0... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 4e5 + 5; struct edge { int v, nx; } e[Maxn << 1]; int n, m, ne = 1, f[Maxn], dfn[Maxn], low[Maxn], scc[Maxn]; int rt, tot, cnt, top, st[Maxn]; int ans, cu[Maxn], cv[Maxn], nx[Maxn], ansu[Maxn], ansv[Maxn]; bool vis[Maxn]; void read(int... |
#include <bits/stdc++.h> using namespace std; void Solve() { string s; cin >> s; int n = s.size(); int cnt1 = 0, cnt2 = 0; for (int i = 0; i < n - 1; i++) { string t = s.substr(i, 2); if (t == ab ) { cnt1++; } else if (t == ba ) { cnt2++; } } if ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 5; int a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN], ans[MAXN]; pair<int, pair<char, int> > p[3 * MAXN]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >>... |
#include <bits/stdc++.h> using namespace std; int n, m, l[103], a[103]; int num[103]; vector<int> v; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) scanf( %d , &l[i]); for (int i = 1; i < m; i++) { int t = l[i + 1]; while (t <= l[i]) t += n; if (a[l[i]] && a[l[i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int x[maxn], y[maxn]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x[i]; } for (int i = 1; i <= m; i++) { cin >> y[i]; } int u = 0, d = 0, ans = 0; int sumu = 0, sum... |
#include <bits/stdc++.h> using namespace std; string lower(string second) { for (int i = 0; i < second.size(); i++) if (second[i] >= A && second[i] <= Z ) second[i] = second[i] - A + a ; return second; } char reg(char c, char t) { if (c >= A && c <= Z ) return t - a + A ; retur... |
#include <bits/stdc++.h> using namespace std; long long n, m, i = 0, j = 0, x, t, w, p, q, l, r, count1 = 0, count2 = 0, k = 0, first = 0, second = 0, last, sum = 1e9; const long long mod = 1000003, num = 0; bool compare(pair<string, int> a, pair<string, int> b) { if (a.second == b.second)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; if (t == 10) { if (n == 1) cout << -1 << endl; else { for (int i = 0; i < n - 1; i++) { cout << 1; } cout << 0 << endl; } } else { for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(322179); } signed main() { doRoutine(); long long n; cin >> n; long long res = 0; while (n > 0) { ++res; n /= 2; } ... |
#include <bits/stdc++.h> int n, fac[1000005], inv[1000005], ans; int qpow(int a, long long b) { int s = 1; for (; b; b >>= 1, a = 1ll * a * a % 998244353) if (b & 1) s = 1ll * s * a % 998244353; return s; } int C(int n, int m) { return 1ll * fac[n] * inv[n - m] % 998244353 * inv[m] % 99824... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); char input[n + 5][n + 5]; for (int i = 0; i < n; i++) scanf( %s , input[i]); int row[n], col[n], count_row = 0, count_col = 0; for (int i = 0; i < n; i++) row[i] = -1; for (int j = 0; j < n; j++) col[j] = ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=4e2+2,p=998244353; vector<int> lj[N]; int dis[N][N],dl[N],ans[N][N],rd[N][N],cnt[N],pre[N][N],lb[N*3][2]; int n,m,s,t,i,j,tou,wei,x,y,r; bool ed[N]; int main() { scanf( %d%d ,&n,&m); for (i=1;i<=m;i++) scanf( %d%d ,&... |
#include <bits/stdc++.h> using namespace std; int n; int a[1001], b[1001], c[1001], d[1001]; void solve() { cin >> n; int r = 1; int i = 1; cin >> a[i] >> b[i] >> c[i] >> d[i]; int sum = a[1] + b[1] + c[1] + d[1]; for (int i = 2; i <= n; i++) { cin >> a[i] >> b[i] >> c[i] >> d[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a[100]; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); vector<int> v; int dif = 0; for (int i = 1; i < n; i++) { dif = a[i] - a[i... |
#include <bits/stdc++.h> #pragma optimize( Ofast ) using namespace std; void solve() { int n, k; string s; cin >> n >> k >> s; vector<int> cnt(27); for (char &c : s) { cnt[c - a ]++; } int t = 0; for (int d = 1; d <= n; d++) { vector<int> ncnt = cnt; int curr = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; while (b) { int c = b % a; if (c == 0) b /= a; else if (c == 1) b--; else if (c == a - 1) b++; else return cout << NO , 0; } cout << YES ; retur... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> nums(n); vector<vector<int> > pos(n); for (int i = 0; i < (int)n; i++) { cin >> nums[i]; ... |
#include <bits/stdc++.h> using namespace std; long long a, b, x; int n; int main() { scanf( %d , &n); scanf( %lld%lld , &a, &b); while (n--) { scanf( %lld , &x); printf( %lld , ((x * a) - b * ((x * a) / b)) / a); } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, logN = 20; const int M = 350; int d[N], h[N], floorlog[N << 1]; long long D[N], F1[N], F2[N], lft[N], rgt[N], total = 0; map<pair<int, int>, long long> st; vector<pair<int, int> > queries, q; pair<int, int> rmq1[logN][N], rmq2[logN][N... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v(4); int total = 0; for (int i = 0; i < 4; i++) { scanf( %d , &v[i]); total += v[i]; } sort(v.begin(), v.end()); do { int sum = 0; for (int i = 0; i < 4; i++) { sum += v[i]; if (2 ... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5; int ans[N], all, u, v, n, m, num, color[N], cnt[2]; vector<int> adj[N], radj[N]; bool used[N]; void output() { printf( YES n ); for (int i = 0; i < n; ++i) printf( %d%c , ans[i] + 1, n [i == n - 1]); exit(0); } void dfs... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int ans = 0, a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; if (e < f) { int now = min(d, min(b, c... |
#include <bits/stdc++.h> using namespace std; const long long int INF = (long long int)1e9 + 10; const long long int INFLL = (long long int)1e18 + 10; const long double EPS = 1e-8; const long long int MOD = 1e9 + 7; template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <... |
#include <bits/stdc++.h> using namespace std; long long int m, nn, o, p; int main() { long long int n; cin >> n; string a, b; cin >> a >> b; for (int i = 0; i < n; i++) if (a[i] == 0 ) { if (b[i] == 0 ) m++; else nn++; } else { if (b[i]... |
#include <bits/stdc++.h> using namespace std; int n, tms; void upd(int &x, int y) { x = min(x, y); } struct trietree { int node[505][12]; int sum[505]; int dp[505][505][12]; int dp2[505][505][12][12]; bool vis[505][505][15]; int dep[505]; int tot; void insert(char ch[], int val) ... |
#include <bits/stdc++.h> int main(void) { char a[3][3]; scanf( %3s , a[0]); scanf( %3s , a[1]); scanf( %3s , a[2]); for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (a[i][j] != a[((((i)-1) * -1) + 1)][((((j)-1) * -1) + 1)]) { puts( NO ); return EXIT_SUCC... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100005; const int Maxm = 500; int T; int n, m, k; vector<int> un; int my[Maxn]; bool has[Maxm][Maxm]; set<int> neigh[Maxn]; void Solve(priority_queue<pair<int, int> > &Q) { bool assigned = false; int inside = n; while (!Q.emp... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (1 << 20) + 5; bool used[MAXN]; vector<int> adj[MAXN]; int a[MAXN]; int n; vector<int> ans; vector<int>::iterator it[MAXN]; void dfs(int x) { while (it[x] != adj[x].end()) { int p = *(it[x]); if (!used[p / 2]) { int... |
#include <bits/stdc++.h> using namespace std; const int M = 200 * 1000 + 11; int main() { int q; cin >> q; vector<int> pos(M); int curl = 0; int curr = 0; for (int i = 0; i < q; ++i) { string type; int id; cin >> type >> id; if (i == 0) { pos[id] = curl; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e7; int n; int m[100], r[100]; bool am[MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> m[i]; for (int i = 1; i <= n; i++) cin >> r[i]; for (int i = 1; i <= n;... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) #pragma warning(disable : 4996) using namespace std; int main() { int Lpos1, Lpos2; bool p[9][9]; memset(p, true, sizeof(p)); for (int i = 0; i < 2; i++) { char k[3]; scanf( %s , &k); int pos1 = k[0] - a + 1;... |
#include <bits/stdc++.h> using namespace std; long long fast_pow(long long x, long long y, long long p); void solve() { long long a, b, c; cin >> a >> b >> c; long long ans = INT_MAX; long long ansA = -1, ansB = -1, ansC = -1; for (long long ta = 1; ta <= 2 * a; ta++) { for (long long tb... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f; } ... |
#include <bits/stdc++.h> void sort(int a[], int begin, int mid, int end) { int i = begin, j = mid + 1, k = 0, temp[end - begin + 1]; while (i <= mid && j <= end) { if (a[i] <= a[j]) temp[k++] = a[i++]; else temp[k++] = a[j++]; } for (; i <= mid; ++i) temp[k++] = a[i]; f... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); struct debugger { static void call(string::iterator it, string::iterator ed) {} template <typename T, typename... aT> static void call(string::iterator it, string::iterator ed, T a, aT... rest) { string b; for (; *... |
#include <bits/stdc++.h> using namespace std; const long long Mxn = 1e6 + 7; const long long Mod = 1e9 + 7; const long long Inf = 1e16 + 7; const long long Module = 998244353; int N; long long Ans, A[Mxn], B[Mxn], Val[Mxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; vector<long long> v, v1; map<long long, long long> m; for (long long i = 0; i < n; i++) { long long a; cin >> a; v.push_back(a); } long long a, c = 0; cin >> a; for (long l... |
#include <bits/stdc++.h> using namespace std; int n, nc, a[111], b[111]; string c[111]; struct Node { int lab; Node *left, *right; Node(int x) { lab = x; left = NULL; right = NULL; } }; void printfalse() { cout << IMPOSSIBLE ; exit(0); } Node *solve(int x, int ... |
#include <bits/stdc++.h> using namespace std; int a[300000], b[300000]; int tree[1 << 21], lazy[1 << 21]; int prop(int s, int e, int i) { tree[i] += lazy[i]; if (s != e) lazy[2 * i + 1] += lazy[i], lazy[2 * i + 2] += lazy[i]; lazy[i] = 0; return 0; } int update(int s, int e, int as, int ae, ... |
#include <bits/stdc++.h> using namespace std; const string problemName = ; const string inputFile = problemName + .in ; const string outputFile = problemName + .out ; const int INF = (1LL << 31) - 1; const long long int LINF = (1LL << 62) - 1; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, vector<T> V) { os << [ ; for (auto v : V) os << v << ; return os << ] ; } template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> P) { return os << ( << P.first << , <<... |
#include <bits/stdc++.h> using namespace std; double L, R; int n, i; int a[10000]; double jami; long long ans1, ans2, ans; int main() { L = 10.0; R = 1000000000; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= n; i++) { L = max(L, (double)((double)a[i] / i) * 10.... |
#include <bits/stdc++.h> using namespace std; struct query { long long l, r, x; }; int n, a[109]; long long m; int main() { cin >> n >> m; vector<query> v; vector<long long> cp = {1LL << 60}; for (int i = 0; i < n; i++) { cin >> a[i]; int pr = sqrt(a[i]); for (int j = 1... |
#include <bits/stdc++.h> using namespace std; const long long maxs = 1e6 + 5; long long root[maxs]; class cmp { bool operator()(const long long &a, const long long &b) { return a < b; } }; void init() { iota(root, root + maxs, 0); } long long find(long long u) { long long f; if (root[u] == u) ... |
#include <bits/stdc++.h> using namespace std; long long n, i, sz, j; map<char, int> m; vector<long long> v; vector<string> v2; string s, ss; int main() { cin >> n >> s; for (int i = 0; i < s.length(); i++) { m[s[i]]++; if (m[s[i]] == 1) { v.push_back(i); } } if (v... |
#include <bits/stdc++.h> using namespace std; template <class T> void checkmax(T& a, T b) { if (a < b) a = b; } bool judge_taxi(string name) { vector<char> vc; for (int i = 0; i < (name.size()); i++) if (isdigit(name[i])) vc.push_back(name[i]); sort(vc.begin(), vc.end()); vc.erase(un... |
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<int> w; cin >> n; for (int i = 0; i < 2 * n; i++) { int x; cin >> x; w.push_back(x); } long long int m = INT_MAX; for (int i = 0; i < w.size(); i++) { for (int j = i + 1; j < w.size(); j++) {... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; const int P = 1e9 + 7; char s[N + 10]; int dp[N + 10][4]; int main() { int n; cin >> n >> (s + 1); dp[0][0] = 1; for (int i = 1; i <= n; i++) { if (s[i] != ? ) { memcpy(dp[i], dp[i - 1], sizeof(dp[i])); (... |
#include <bits/stdc++.h> using namespace std; long long d[25]; int main() { long long t; cin >> t; while (t--) { long long n, s; cin >> n >> s; long long len = 0, sum = 0, num = n; fill(d, d + 25, 0); while (num > 0) { d[++len] = num % 10; sum += d[len]; ... |
#include <bits/stdc++.h> using namespace std; int w[int(1e5) + 10], id[int(1e5) + 10]; int m; bitset<1010> primes, aux; struct segtree { bitset<1010> values; int start, end, mid, lazy; segtree *left, *right; segtree(int start, int end) : start(start), end(end) { lazy = 0; if (start... |
#include <bits/stdc++.h> int main() { int n, i, j; scanf( %d , &n); long long int a[n][2], x, y, max1, max2, min1, min2; for (i = 0; i < n; i++) for (j = 0; j < 2; j++) scanf( %I64d , &a[i][j]); min1 = max1 = a[0][0]; min2 = max2 = a[0][1]; for (i = 0; i < n; i++) { if (min1 > ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 150000; int b[maxn]; long long a[maxn]; int main(void) { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &b[i]); b[0] = b[n]; int id = 0; for (int i = 1; i <= n; i++) if (b[i] > b[i - 1]) { id... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > ans; int deg[400001]; int tot; int flag; int n, d, k; int name() { flag++; return flag; } void f(int x, int curr) { if (tot <= 0 or x == 0) return; while (deg[curr] < k and tot > 0) { if (tot <= 0) return; ... |
#include <bits/stdc++.h> using namespace std; int N, M; int w[401][401]; int last[401], K; double P1[401], P2[401], mxp[402]; int main() { scanf( %d%d , &N, &M); for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) w[i][j] = i == j ? 0 : 1e9; for (int i = 1; i <= M; i++) { int a... |
#include <bits/stdc++.h> bool FLAG = 1; using namespace std; const long long MOD = (long long)1e9 + 7, N = (long long)2e6 + 222; const long long INF = (long long)1e18; long long n, k, p[N], a[N], b[N], b1[N]; string s; void clear() { for (long long i = 1; i <= n; ++i) { p[i] = a[i]; } } ... |
#include <bits/stdc++.h> using namespace std; struct str { int sum, poz; }; str v[100000]; int cmp(str a, str b) { if (a.sum == b.sum) return a.poz < b.poz; else return a.sum > b.sum; } int main() { int n, x; scanf( %d , &n); for (int i = 1; i <= n; i++) { int s =... |
#include <bits/stdc++.h> using namespace std; int a[2006]; int Gcd(int m, int n) { if (n == 0) return m; return Gcd(n, m % n); } int main() { int n; scanf( %d , &n); int yi = 0; int flag = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] == 1) yi++; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int x = (n + 3) / 4; int p = n - x; while (p--) cout << 9 ; while (x--) cout << 8 ; cout << endl; } } |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; int INF = 2000000000; long long INFF = 8000000000000000000LL; double PI = acos(-1); int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1}; int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1}; inline string IntToString(int a) { char x[100]; sprintf(x, %... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 1000 + 20; int a[N], x[N], y[N], visited[N], h[N], mark[N], n, t = 0, dady[N]; vector<int> ans, adj[N]; void dfs_mark(int v) { visited[v] = 1; for (int i = 0; i < adj[v].size(); i++) { int u = adj[v][i]; if (visited[u] == 0... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, counter = 0; cin >> x >> y; int m = max(x, y); while (m != 6) { m++; counter++; } string arr[6] = { 1/6 , 1/3 , 1/2 , 2/3 , 5/6 , 1/1 }; cout << arr[counter] << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; pair<pair<double, double>, double> circ[3]; vector<pair<double, double> > points; double eps = 0.0000001; double dist(pair<double, double> x, pair<double, double> y) { return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long MAXN = 1e+5 + 7; const long long MOD = 1e+9 + 7; const long long INF = 0x7f7f7f7f7f7f7f7f; const int INFi = 0x7f7f7f7f; vector<long lo... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[1000 + 10][1000 + 10]; bitset<1024> bs[1000 + 10], temp; bool testAns(int ans) { for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) { for (int(j) = (0), _n = (m - 1); (j) <= _n; (j)++) { if (a[i][j] >= ans) bs[i].set(j, ... |
#include <bits/stdc++.h> using namespace std; int t, n, m; long long ans; int main() { scanf( %d%d , &n, &m); if (n == 1) ans = m; else if (m == 1) ans = n; else if (n == 2) ans = ((m / 4) * 2 + min(m & 3, 2)) * 2ll; else if (m == 2) ans = ((n / 4) * 2 + min(n & 3, 2)... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; string a, b; vector<long long int> v1, v2; for (long long int i = 0; i < n; i++) { long long int x, y; cin >> x >> y; v1.push_back(x); v2.push_back(y); a += 0 ; b += 0 ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 99999; int arr[102], tmp[102]; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 1; i < n - 1; i++) { int cnt = 0; for (int j = 0; j < n; j++) { if (j != i) tmp[cnt++] = arr[... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; cout << 1 << n - 1; cout << n ; } } |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long rev2 = (mod + 1) / 2; long long mas[300300]; long long pow2[300300]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lld , &mas[i]); sort(mas, mas + n); pow2[0] = 1; for (int i =... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10; const int mod = 1e9 + 7; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + c - 0 , c ... |
#include <bits/stdc++.h> using namespace std; vector<int>::iterator IntIter; vector<long long>::iterator LLIter; int main(int argc, char *argv[]) { int i, j; int a[3][3]; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) cin >> a[i][j]; int b[3][3] = {1}; b[0][0] = (a[0][0] + a[0][1] + a... |
#include <bits/stdc++.h> using namespace std; char arr[31][31]; int n, m, x; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL)); cin >> n >> m >> x; map<char, int> m1; vector<pair<float, float> > v; for (int i = 0; i < n; i++) { for (int j... |
#include <bits/stdc++.h> using namespace std; long long n, k; int32_t main() { cin >> n >> k; if ((n / k) & 1) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; cin >> s; long long ans = 0; for (long long i = 0; i < n; i++) { long long t = s[i] - 0 ; if (t % 2 == 0) { ans += i + 1; } } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; int n, m, k, dotx, doty; char t[502][502]; int vis[502][502]; int x[4] = {0, -1, 0, 1}; int y[4] = {1, 0, -1, 0}; void dfs(int r, int c) { if (r >= n || r < 0 || c >= m || c < 0 || t[r][c] == # || vis[r][c]) return; vis[r][c] = 1; for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, m, c; cin >> n >> m >> c; for (int i = 1; i <= m; i++) { int x, ans; cin >> x; if (x <= c / 2) { for (int j = 1; j <= n; j++) { if (x < a[j] || a[j] == 0) { a[j] = x; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, s, t, k, a, b, x, y, u; const int mod = 1e9 + 7; const int mxn = 2e5 + 5; long long mn = 1e18, mx = 0; long long arr[2000000], wan[2000000], finl[2000000]; string str, str2; vector<vector<long long> > v(200000), cm(200000); map<long long, l... |
#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 = 100; const int MAXLEN = 26; bool done[26]; bool have[26]; bool before[26][26]; char nxt[26]; int n; char s[MAXLEN + 1]; void run() { memset(done, false,... |
#include <bits/stdc++.h> using namespace std; long long a[120], b[120]; signed main() { ios::sync_with_stdio(0); cin.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i = 0; i < n; i++) cin ... |
#include <bits/stdc++.h> using namespace std; int n, a[1111][1111]; int main() { scanf( %d , &n); for (int i = 0; i < n - 1; i++) for (int j = 0; j < n - 1; j++) a[i][j] = 1 + (i + j) % (n - 1); for (int i = 0; i < n - 1; i++) a[n - 1][i] = a[i][n - 1] = a[i][i], a[i][i] = 0; for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { long long y, k, n; cin >> y >> k >> n; int flag = 0; int i = y / k + 1; while (i * k <= n) { cout << i * k - y << ; i++; flag++; } if (!flag) cout << -1 ; cout << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int n, a[N]; long long s[2][N]; double Ans; void Add(int tp, int x, long long sum) { while (x <= n) s[tp][x] += sum, x += (x & (-x)); } long long Query(int tp, int x) { long long ret = 0; while (x) ret += s[tp][x], x -= (... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 9; int n, a[MX], sum; void dp(int x, int y, int sum1, int sum2) { if ((x | y) == (1 << n) - 1) { if (!x || !y) return; if (sum1 != sum2) { cout << __builtin_popcount(x) << endl; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m, i; string s; int main() { char c; cin >> s; i = 0; while (s[i] < 80) { n *= 10; n += s[i] - 48; i++; } c = s[i]; if (n % 4 == 1) m = (n + 1) / 2; if (n % 4 == 2) m = (n + 2) / 2; if (n % 4 == 3) m... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<int, int> > H; vector<int> Ans[1000010]; int S[1000010]; int main() { scanf( %d%d , &n, &m), H.resize(m); int tot = 0; for (int i = 0; i < m; i++) scanf( %d , &H[i].first), tot += H[i].first, H[i].second = i + 1; if (t... |
#include <bits/stdc++.h> using namespace std; int N, K; vector<int> A; bool check(long long sum, long long temp, long long x) { long long t = (sum - K) / x; return t < temp; } int main() { cin >> N >> K; A.resize(N); int nn = N; long long sum = 0, x, j = 0; for (int i = 0; i < nn... |
#include <bits/stdc++.h> using namespace std; unsigned long long int gcd(unsigned long long int a, unsigned long long int b) { if (b == 0) return a; a %= b; return gcd(b, a); } unsigned long long int power(unsigned long long int x, unsigned long long int y, unsigned lo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.