func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int power(int a, int b, int m, int ans = 1) { for (; b; b >>= 1, a = 1LL * a *... |
#include <bits/stdc++.h> using namespace std; vector<int> graph[123490]; bool attacked[123490], visited[123490]; int n, m, parent[123490]; int dist, last; void dfs(int u, int depth) { if (attacked[u]) { if (dist < depth) { dist = depth; last = u; } else { if (dist == ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int a[N], b[N], par[N], val[N], sz[N], lst[N]; vector<int> his; pair<int, int> get(int v) { if (par[v] == v) return make_pair(v, val[v]); pair<int, int> g = get(par[v]); g.second ^= val[v]; return g; } bool merge(int u, i... |
#include <bits/stdc++.h> using namespace std; int n, a[100005]; vector<int> all, empty; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { (x *= 10) += ch - 0 ; ch = getchar... |
#include <bits/stdc++.h> using namespace std; vector<long long int> g[100005]; vector<pair<long long int, long long int> > ed; vector<long long int> w; vector<long long int> eff; long long int vis[100005]; long long int val[100005]; long long int rec(long long int i) { if (vis[i] != 1) { vis[i... |
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); const double EPS = 1e-9; const int MOD = 1000003; const int INF = 1000000000; const long long LINF = 1000000000000000000LL; vector<string> vs; bool row[500010], col[500010]; int main() { int n, m, ret = 1; cin >> ... |
#include <bits/stdc++.h> using namespace std; long long n, m, x, y, a, b, t; long long q[55][55]; long long g[55][55]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> q[i][j]; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { ... |
#include <bits/stdc++.h> using namespace std; int n, parent[2005] = {}; int ans = -1e9; int solve(int x, int byk) { byk += 1; if (parent[x] == -1) return byk; return solve(parent[x], byk); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = n - 1; i >= 0; i--) cout << arr[i] << ; cout << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long n, l[100005], r[100005]; signed main() { scanf( %lld , &n); long long ans = 0; for (register long long i = 1; i <= n; i++) { scanf( %lld%lld , &l[i], &r[i]); } sort(l + 1, l + n + 1); sort(r + 1, r + n + 1); for (register lo... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 9; int n, nxt[MAX], a[MAX]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; for (int l = 0; l < n; l++) { for (int i = n - 2, j = n - 1; i >= 0; i--) { while (i < j - a[j]) j--; ... |
#include <bits/stdc++.h> using namespace std; long long sqr(long long x) { return (long long)(x * x); } long long my_abs(long long x) { if (x < 0) return -x; return x; } const int MN = 1000 * 1000 * 10; int main() { long long ans = 0; long long n, m; cin >> n >> m; for (long long b =... |
#include <bits/stdc++.h> using namespace std; int MOD = 1e6 + 3; int main() { int n, m; scanf( %d%d , &n, &m); char s[n][m + 1]; for (int i = (0); i < (int)(n); i++) scanf( %s , s[i]); bool c[m][2]; bool r[n][2]; memset(c, 0, sizeof(c)), memset(r, 0, sizeof(r)); for (int i = (0); i... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 9; struct node { long long x, y, sum; } st[1200005]; int n, q, type, L, R, a[300005]; long long f[300005]; void build(int id, int l, int r) { if (l == r) { st[id].sum = a[l]; return; } int mid = l + r >> ... |
#include <bits/stdc++.h> using namespace std; string makeCentered(int len) { string output; for (int i = 0; i < 27; i++) { output.push_back( . ); } for (int i = 0; i < len; i++) { output[13 + i] = X ; output[13 - i] = X ; } return output; } string blank() { string... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int INF = 0x3f3f3f3f; int n, lm, rm; int q[N], fa[N], sz[N]; bool use[N]; vector<pair<int, int> > g[N]; int getc(int u) { int qn = 0; fa[q[qn++] = u] = u; for (int i = 0; i < qn; i++) { u = q[i]; sz[u] = 1;... |
#include <bits/stdc++.h> int main() { int n, m; double resn, resm; scanf( %d%d , &n, &m); resn = m / (double)n; resm = log(m) / log(n); if (resn > resm) { printf( > n ); } else if (resn < resm) { printf( < n ); } else printf( = n ); return 0; } |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { a[i] = a[i - 1] + arr[i - 1]; } int m; cin >> m; for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 700 + 7; const int MOD = 1e9 + 7; const int INF = 1e9 + 7; int a[maxn]; int g[maxn][maxn]; int n; struct as { int l, r, v; bool operator<(const as& b) const { if (l < b.l) return true; if (l > b.l) return false; if ... |
#include <bits/stdc++.h> using namespace std; int a[1000005], b[1000005]; int main() { int n, ans = 0; cin >> n; for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); a[x]++; } for (int i = 1000000; i >= 1; i--) { if (!a[i]) continue; b[i] = 1; for (int j =... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y, vx, vy; int refx, refy; long long exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1, y = 0; return a; } long long res = exgcd(b, a % b, y, x); y -= (a / b) * x; return res; } int main() ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 998244353; const int sz = 1e5 + 3, inf = 1e9 + 10; int a[sz], match[sz], c[sz]; int fr[sz]; bool vis[sz]; long long int x[sz]; void solve() { memset(vis, 1, sizeof vis); memset(match, 0, sizeof match); int n; cin >> ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 123; long long a[maxn], b[maxn], n, m; char s[maxn]; long long vis[20], t[20], sb[maxn]; void dfs(long long stp, long long sa) { if (sa > sb[stp + 1]) return; if (stp == 0) { cout << sa << endl; exit(0); } if (s... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, l[N], r[N], id[N]; bool cmp(int x, int y) { return r[x] == r[y] ? l[x] < l[y] : r[x] < r[y]; } int main() { cin >> n; for (int x, w, i = 1; i <= n; ++i) { cin >> x >> w; l[i] = x - w, r[i] = x + w, id[i] = i; }... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 110, VMAX = 1000100; int T, N; int number[NMAX], diff[NMAX * NMAX]; int b[NMAX]; bool val[VMAX]; int main() { int i, j, k, t; bool flag; scanf( %d , &T); for (t = 0; t < T; t += 1) { memset(val, 0, sizeof(val)); mem... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long bin_pow(long long a, long long b) { if (b == 0) { return 1; } long long res = bin_pow(a, b / 2); res *= res; res %= mod; if (b % 2) { res *= a; res %= mod; } return res; } ... |
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int n, i; scanf( %d , &n); getchar(); char row[n]; for (i = 0; i < n; ++i) { row[i] = getchar(); } if (n == 1 && row[0] == 0 ) { printf( No n ); return 0; } for (i = 1; i < n; ++i) { if (row[... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; template <typename T1, typename T2> inline void chkmin(T1& x, const T2& y) { if (y < x) x = y; } template <typename T1, typename T2> inline void chkmax(T1& x, const T2& y) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100 + 10; pair<int, int> d[MAX]; int main() { int i; set<int> first, second; for ((i) = (1); (i) <= (8); ++(i)) { scanf( %d%d , &d[i].first, &d[i].second); first.insert(d[i].first); second.insert(d[i].second); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const long long inf = 1e18 + 10; long long dis[N], sid[N], mark[N], h[N], dp[N], c[N]; pair<pair<long long, long long>, long long> E[N]; vector<pair<long long, long long> > adj[N], jda[N], g[N]; priority_queue<pair<long long, long long>... |
#include <bits/stdc++.h> using namespace std; int n, m; int p[2 * 100001], rnk[2 * 100001]; int cnt[2 * 100001]; long long pref[2 * 100001 + 5]; long long ans[2 * 100001 + 5]; vector<pair<int, int> > q; struct Edge { int a, b; int w; Edge(int a, int b, int w) : a(a), b(b), w(w) {} }; vec... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); } template <class T> inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); } template <class T> inline T BigMod(T Base, T power, T M = 1000000007) { ... |
#include <bits/stdc++.h> using namespace std; const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; template <typename T, typename TT> ostream& operator<<(ostream& s, pair<T, TT> t) { ... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int a[100010]; int main() { int i = 0, j = 0; int n, m; while (scanf( %d%d , &n, &m) != EOF) { mp.clear(); int f; for (i = 1; i <= n; ++i) { scanf( %d , &f); if (mp.find(f) != mp.end()) { mp[f... |
#include <bits/stdc++.h> using namespace std; int vis[1500000 + 5], a[1000006], marked[1500000], pt = 2; vector<int> v[1500000 + 5]; bool broken; bool hoyKina(int x) { for (int i = 0; i < v[x].size(); i++) { if (marked[v[x][i]]) return false; } for (int i = 0; i < v[x].size(); i++) { m... |
#include <bits/stdc++.h> using namespace std; const bool debug = true; const int MAXN = 100010; int dp[MAXN], t[MAXN]; const int inf = 2000000010; int n; int first_lower(int x) { if (x < 0) return 0; return upper_bound(t + 1, t + n + 1, x) - t - 1; } struct node { int mx; int lazy; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; if (n == 1 && k == 1) { cout << 0 << endl; return 0; } if (s[0] != 1 && k) { k--; s[0] = 1 ; } for (int i = 1; i < n && k; i++) { if (s[i] !=... |
#include <bits/stdc++.h> using namespace std; int getint() { unsigned int c; int x = 0; while (((c = getchar()) - 0 ) >= 10) { if (c == - ) return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - 0 ); } while (((c = getchar()) - 0 ) < 10); return x... |
#include <bits/stdc++.h> using namespace std; struct Edge { int x; int y; int w; }; const int N = 200 + 7; const int INF = (int)1e9; int n; int m; int d[N][N]; struct T { int f; int s; }; bool operator<(T a, T b) { return a.s - a.f < b.s - b.f; } int solve(int x, int y, int w... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; string a, b; int n; int x[MAXN], y[MAXN]; void pre() { int cnt = 0, len = b.size(); for (int i = 0; i < n; i++) { if (cnt == len) continue; if (b[cnt] == a[i]) { x[cnt] = i; cnt++; } } cn... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct segtree { int n; vector<pair<int, int>> st; segtree(int _n) { n = _n; st.assign(4 * n + 5, make_pair(0, 0)); } pair<int, int> merge(pair<int, int> a, pair<int, int> b) { pair<int, int> res = make_pa... |
#include <bits/stdc++.h> using namespace std; long long a[200005], dp1[200005], dp2[200005]; int main() { long long n, k, x; int xx; cin >> n >> k >> x; for (int i = 1; i <= n; i++) { scanf( %d , &xx); a[i] = xx; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int fun(int x, int y, int z) { return x * x + y * y + z * z + x * y + y * z + z * x; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { cin >> n; int a[n]; int f =... |
#include <bits/stdc++.h> using namespace std; int a[300010]; struct _ { int val, rpos; }; vector<_> min_, max_; int vmin[1200010], cmin[1200010], add[1200010]; void pushup(int rt) { if (vmin[rt << 1] == vmin[rt << 1 | 1]) { vmin[rt] = vmin[rt << 1]; cmin[rt] = cmin[rt << 1] + cmin[rt <... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int q; cin >> q; while (q--) { int n; cin >> n; string s, t; cin >> s >> t; string ss = s; string tt = t; sort(ss.begin(), ss.end()); sort(tt.beg... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long p, q, i, t, i1 = 0, i2 = 0, mx; char c; cin >> t; long long a[368], b[368]; for (i = 0; i < 368; i++) { a[i] = 0; b[i] = 0; } for (i = 0; i < t; i++) { cin >> c >>... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; string s, t; int mp[28], tempMap[28]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i, j, len1, len2, can = -1; cin >> s >> t; len1 = (int)s.size(), len2 = (int)t.size(); for (i = 0; i < len1; i... |
#include <bits/stdc++.h> int main() { int n, h, arr[1000], c = 0, i; scanf( %d %d , &n, &h); for (i = 0; i < n; i++) { scanf( %d , &arr[i]); if (arr[i] > h) c = c + 2; else c = c + 1; } printf( %d , c); return 0; } |
#include <bits/stdc++.h> const int M = 5004; int n, m, a[55], b[55]; double p[55], eps = 1e-9; double f[55][5005], cnt; double chk(double x) { for (int i = n; i >= 1; i--) { for (int j = m + 1; j <= M; j++) f[i + 1][j] = x; for (int j = 0; j <= m; j++) { f[i][j] = (f[i + 1][j + a[i]] +... |
#include <bits/stdc++.h> using namespace std; int main() { string a; vector<string> input; int n; cin >> n; bool flag = false; for (int i = 0; i < n; i++) { cin >> a; if (!flag && a[0] == a[1] && a[0] == O ) { a[0] = + ; a[1] = + ; flag = true; } ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lb = 1000; void vrikodara(long long n = 12) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(n) << fixed; } void solve() { string... |
#include <bits/stdc++.h> using namespace std; vector<long long> gaps(1e5 + 1); int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { long long a, b, c, n; cin >> a >> b >> c; n = (abs(b - a)) * 2; long lon... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print(vector<T> v) { for (T e : v) { cout << e << ; } cout << endl; } template <typename T> void print(vector<vector<T>> v) { int n = v.size(); for (int i = 0; i < n; i++) { cout << i << : ; f... |
#include <bits/stdc++.h> using namespace std; const unsigned long long maxn = 1000 + 10; const int INF = 0x3f3f3f3f; const double eps = 1e-10; const double pi = acos(-1.0); int g[maxn][maxn]; struct haha { int x, y, w; } p[maxn * 10], p0[maxn * 10]; struct Edge { int from, to, dist; }; str... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using int64 = long long int; template <typename T> void chmax(T &a, T b) { a = max(a, b); } template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chadd(T &a, T b) { a = a + b; ... |
#include <bits/stdc++.h> const int N = 100010; const int inf = 0x3f3f3f3f; using namespace std; map<string, int> A, B; string y; int solve(string x) { y = ; int sz = x.size(); int a = 0, b = 0; for (int i = 0; i < sz; i++) { if (x[i] == * ) a++; else if (x[i] == & ) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n + n / 2; return 0; } |
#include <bits/stdc++.h> using namespace std; inline void read(int &data) { data = 0; int e = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) e = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) data = data * 10 + ch - 48, ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 4e5 + 5; const long long M = 1e6 + 5; const long long inf = 1e18; const long long eps = 1e-5; inline long long read() { long long s = 0; register bool neg = 0; register char c = getchar(); for (; c < 0 || c > 9 ; c = getcha... |
#include <bits/stdc++.h> using namespace std; int x; void dfsUtil(int node, int count, bool visited[], int& maxCount, vector<vector<int> >& adj) { visited[node] = true; count++; for (auto& i : adj[node]) { if (!visited[i]) { if (count >= maxCount) { maxCount = co... |
#include <bits/stdc++.h> using namespace std; struct Nod { int mark, label; } nod[200010]; int val[200010]; bool cmp1(Nod n1, Nod n2) { if (n1.mark != n2.mark) return n1.mark > n2.mark; return n1.label < n2.label; } bool cmp2(Nod n1, Nod n2) { if (n1.mark != n2.mark) return n1.mark > n2.ma... |
#include <bits/stdc++.h> using namespace std; int main() { int s[100], t[100], n, p, i, j, solv, tim, c; scanf( %d%d , &n, &p); for (i = 0; i < n; i++) { scanf( %d%d , &s[i], &t[i]); } for (i = 1; i < n; i++) for (j = 0; j < n - i; j++) if (s[j] < s[j + 1] || (s[j] == s[j + 1... |
#include <bits/stdc++.h> using namespace std; bool valid(string s) { int start = 0, end = s.length() - 1; while (start < end) { if (s[start] == a && s[end] == a ) { start++; end--; } else if (s[start] == a && s[end] == z ) { return false; } else if (s[start] =... |
#include <bits/stdc++.h> using lli = long long int; int main() { std::string str; lli q, a, b, n, needSum; lli ost = 0; std::cin >> q; for (int i = 0; i < q; ++i) { std::cin >> a >> b >> n >> needSum; if (a * n == needSum || b == needSum) { std::cout << Yes << std::endl; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int num[5005], cnt[5005] = {}, id[5005]; int dp[5005][5005]; bool used[5005]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> num[i]; sort(num + 1, n... |
#include <bits/stdc++.h> using namespace std; long long int powerMod(long long int x, unsigned long long int y) { if (y == 0) return 1; long long int p = powerMod(x, y / 2) % 1000000007; p = (p * p) % 1000000007; return (y % 2 == 0) ? p : (x * p) % 1000000007; } long long int power(long long int... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, m, B, a[N], c[N], ans[N]; struct Node { int l, r, id; Node() {} Node(int _l, int _r, int _id) { l = _l, r = _r, id = _id; } bool operator<(const Node &p) const { return r < p.r; } } Q[N]; vector<int> V, q[400]; int... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const double eps = 1e-8; const int maxn = 1e6 + 5; const int maxm = 3e4 + 5; const long long mod = 1e9 + 7; const long long inf = 0x3f3f3f3f; const int _inf = -1e9 + 7; inline int scan() { int m = 0; char c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; void read(int &x) { register int c = getchar(); x = 0; for (; c < 48 || c > 57; c = getchar()) ; for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48; } queue<int> y[300005], v; int main() { int n, q, w = 0, x, z = 0, ... |
#include <bits/stdc++.h> using namespace std; struct P { int x; int a; }; P data[105]; bool cmp(P x, P y) { return x.x < y.x; } int main() { int n; int x, a; int po = 0, ne = 0; int res = 0; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d%d , &x, &a); dat... |
#include <bits/stdc++.h> using namespace std; int count = 0; bool YES = false; vector<string> record; int compare(vector<string> cards, int pile1, int pile2) { if (cards.at(pile1)[0] == cards.at(pile2)[0] || cards.at(pile1)[1] == cards.at(pile2)[1]) return 1; return 0; } void move(ve... |
/* in the name of Anton */ /* Compete against Yourself. Author - Aryan (@aryanc403) Atcoder library - https://atcoder.github.io/ac-library/production/document_en/ */ #include <algorithm> #include <cassert> #include <limits> #include <queue> #include <vector> #include <algorithm> ... |
#include <bits/stdc++.h> using namespace std; int n, a[3005], ans; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , a + i); for (int j = 0; j < i; j++) { if (a[j] > a[i]) ans++; } } if (ans % 2) printf( %.6lf , (ans - 1) * 2.0 + 1); else ... |
#include <bits/stdc++.h> using namespace std; int main() { int arr[100000 + 1]; int n, a; set<int> s; cin >> n; vector<bool> vst(n, false); for (int i = 0; i < n; ++i) { cin >> a; arr[i] = a; s.insert(a); } int k = 1; if (n != 1) for (int i = 0; i < n; ++i... |
#include <bits/stdc++.h> using namespace std; int perm[55]; int main() { int n; long long m; scanf( %d%lld , &n, &m); m--; int l = 1; int r = n; for (long long i = n - 2; i >= 0; i--) { if (m & (1LL << i)) { perm[r] = n - 2 - i + 1; r--; } else { per... |
#include <bits/stdc++.h> using namespace std; pair<long int, long int> p[500005]; bool cmp(pair<long int, long int> p1, pair<long int, long int> p2) { if (p1.second < p2.second) return true; else { if (p1.first < p2.first) return true; else return false; } } int m... |
#include <bits/stdc++.h> using namespace std; vector<int> alz(string a) { int n = a.size(); vector<int> res(n); int left = 0, right = 0; for (int k = 1; k < n; k++) { if (right < k) { right = left = k; while (right < n && a[right] == a[right - left]) right++; res[k] = r... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n]; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); int c = n / 2, ans = 0; for (int i = 0; i < n / 2 && c < n; i++, c++) if (x[i] * 2 <= x[c]) ans++; else i--; cout... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, x, m, z, u, v, f, a, b, l, r; cin >> t; while (t--) { cin >> n >> x >> m; a = x; b = x; for (int i = 0; i < m; i++) { cin >> l >> r; if (a >= l && a <= r && b >= l && b <= r) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; int a[x], i; for (i = 0; i < x; i++) { cin >> a[i]; } sort(a, a + x); int s = 0; int j = 0, m = 0; for (i = 0; i < x; i++) { while (j < x && a[j] - a[i] <= 5) { j++; s = max(s,... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<char, long long> > s1; vector<pair<char, long long> > s2; vector<pair<char, long long> > p; int sl, pl; int lps[1000009]; vector<int> ii; void calclps() { lps[0] = 0; int j = 0, i = 1; while (i < pl) { if (p[j] == p[... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; const long long INF64 = 1e18; const long double EPS = 1e-7; mt19937 myrand(time(NULL)); const int N = 100 * 1000 + 13; int n, ac, d; pair<int, int> a[N]; long double t[N]; bool read() { if (scanf( %d%d%... |
#include <bits/stdc++.h> using namespace std; int maxint = ~0U >> 1; int flow, cost; int pi[200001 + 1], v[200001 + 1]; int S, T; int INF = 1000000000; int tempAdd = 100000; struct etype { int t, c; etype* next; etype* pair; etype() { next = 0; } etype(int _t, int _c, etype* _n) { t ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool inside(T a, T b, T c) { return a <= b && b <= c; } long long modpower(long long x, long long n) { long long m = 1000000007; long long ans = 1; x = (x + m) % m; while (n > 0) { if (n & 1) { ans = (ans * x) %... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 222222; const int inf = 1e9 + 7; vector<int> adj[MAXN], radj[MAXN]; int vis[MAXN], q[MAXN], qn, C; int cost[MAXN], mn[MAXN], cnt[MAXN]; void dfs(int u) { vis[u] = 1; for (auto v : adj[u]) { if (vis[v] == 1) continue; dfs(v)... |
#include <bits/stdc++.h> using namespace std; const int MAX = (2e5) + 10; pair<int, int> ara[MAX]; int id[MAX]; vector<int> didi[MAX]; void solve() { int n; cin >> n; for (int i = 0; i <= n - 1; i++) { cin >> ara[i].first; } for (int i = 0; i <= n - 1; i++) { cin >> ara[i].se... |
#include <bits/stdc++.h> using namespace std; long long n, m, num[200001], sum[200001], ans; set<int> s; int main() { cin >> n >> m; for (int i = 0; i < m; i++) s.insert(i); for (int i = 0; i < n; i++) { int d, tmp; cin >> num[i]; d = num[i] % m; if (d > *s.rbegin()) ... |
#include <bits/stdc++.h> using namespace std; int m[100100]; vector<int> diff[100100]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> m[i]; diff[i - m[i]].push_back(i); } long long sum = 0; int d = 0, tot = 1; for (int i = 2; i <= n; i++) { auto... |
#include <bits/stdc++.h> int main() { int a, b; scanf( %d %d , &a, &b); printf( %d , a * b / 2); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; set<int> row; set<int> col; map<int, int> row_map; map<int, int> col_map; for (i = 1; i <= n; i++) { string s; cin >> s; for (j = 1; j <= n; j++) { if (s[j - 1] == . ) { ... |
#include <bits/stdc++.h> using namespace std; int n, a[200005], sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], sum ^= a[i]; if (n % 2 == 0) { if (sum) { puts( NO ); return 0; } n--; } puts( YES ); printf( %d n , n - 1); for (int ... |
#include bits/stdc++.h using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> ... |
#include <bits/stdc++.h> using namespace std; unsigned long long t1, t2, c1, c2, t0; unsigned long long yy1 = 0, y2 = 0; unsigned long long resyy1, resy2; inline bool besser(unsigned long long res1, unsigned long long res2, unsigned long long res3, unsigned long long res4) { return re... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); const int INFTY = 1e7; template <unsigned int N> class Field { inline unsigned int pow(unsigned int a, unsigned int p) { unsigned int r = 1, e = a; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; double r; int main() { scanf( %lf , &r); for (int a = 1; a <= 10; ++a) { for (int h = 1; h <= 10; ++h) { double area = (a / 2.0 * h); double bot = sqrt(a * a / 4.0 + h * h); double tmp = area / bot; ... |
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long p, long long mod) { long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p /= 2; } return ret; } long long power(long long a, long long p) { long long ret = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 501010; int n, k; int a[maxn], b[maxn]; long long s; int cnt; priority_queue<pair<int, int> > q; void Check(int d) { s = 0; cnt = 0; for (int i = 1; i <= n; ++i) { q.push(make_pair(d - a[i], 0)); int tmp = b[i] - q.to... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y / 2; x = (x * x) % p; } return res; } void solve() { long long ... |
#include <bits/stdc++.h> using namespace std; void read_file(bool outToFile = true) {} int n, m; bool vis[500 + 9][500 + 9]; string s; int l; int x, y; int ans[100000 + 1 + 9]; string alpha = *URDL ; int dij[5][2] = {{0, 0}, {-1, 0}, {0, +1}, {+1, 0}, {0, -1}}; bool valid(int i, int j) { return 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.