func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000 + 5; const int N = 2e5 + 5; const long long oo = 1e18 + 5; const long long mod = 998244353; int a[N], b[N]; int mul(int a, int b) { return 1ll * a * b % mod; } void solve() { int n, k; cin >> n >> k; vector<int> pos(n +... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { vector<string> s(9); for (long long int i = 0; i < 9; i++) { cin >> s[i]; } s[0][0] = s[0][1]; s[1][3] = s[1]... |
#include <bits/stdc++.h> using namespace std; struct Node { int l, r; pair<int, int> v; int mid() { return (l + r) >> 1; } }; struct HNode { int m, p; long long x, y, r, d; bool operator<(const HNode &cur) const { return d < cur.d; } }; Node tree[4 * 250005]; HNode hook[250005]; ... |
#include <bits/stdc++.h> #pragma GCC optimize( -O3 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; long long n, m, k, i, ost, x, y, ans, a[200010], f[200010], ost1, sum1; vector<pair<long long, long long>> v3, v1, v2; pair<long long, long long> sum; multiset<lon... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > ad; vector<int> cam(0); vector<bool> vis; bool k = false; void dfs(const int &m) { vis[m] = true; if (m == ad.size() - 1) { k = true; } else for (int i = 0; i < ad[m].size(); i++) { if (!vis[ad[m][i]]) dfs(ad[... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int a[N]; long long sum[N]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , a + i); sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; long long ans_sum = 0... |
#include <bits/stdc++.h> using namespace std; int main() { int N, p; scanf( %d%d , &N, &p); int i; p--; string S; cin >> S; int sz = S.size(), add = 0, flag = 0, first, last; for (i = 0; i < sz / 2; i++) { char c1 = S[i], c2 = S[sz - 1 - i]; if (c1 != c2) { if (fl... |
#include <bits/stdc++.h> int main() { int J, M; float QJ, QM; int i; scanf( %d , &J); scanf( %d , &M); i = 1; while (1) { J = J - i; if (J < 0) { printf( Vladik n ); break; } i++; M = M - i; if (M < 0) { printf( Valera n ); ... |
#include <bits/stdc++.h> using namespace std; int a[3001]; void swap(int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } int main() { int n; cin >> n; ; for (int i = 0; i < n; i++) { cin >> a[i]; } vector<pair<int, int> > x; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; const int INF = 1e7; struct info { pair<int, int> x = {-INF, -1}; }; struct segtree { int n; vector<info> t; segtree(int n) { this->n = n; t.resize(n * 4); } void Merge(info &node, info &l, info &r) { no... |
#include <bits/stdc++.h> using namespace std; int Distance(int x1, int y1, int x2, int y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } int main() { int n, m, x1, y1, x2, y2, x3, y3, x4, y4, flag, dis1, dis2; while (~scanf( %d%d , &n, &m)) { flag = 0; if (m > n) { sw... |
#include <bits/stdc++.h> using namespace std; int n, a[111], f[(1 << (23))], x[33]; int main() { while (cin >> n) { for (int i = 0, _a = (n); i < _a; i++) cin >> a[i]; if (n == 1) { cout << 1 << endl; continue; } int res = n + 1; for (int S = 0, _a = ((1 << (n)));... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long ans = 0; while (true) { if (!a || !b) { cout << ans; return 0; } if (a == b || (a % b == 0)) { cout << (a / b + ans); return 0; } if (a > ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmax(T& x, T y) { return x < y ? x = y, 1 : 0; } template <class T> bool ckmin(T& x, T y) { return x > y ? x = y, 1 : 0; } inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; int n, m, k, a[N]; bool mark[N]; int main() { cin >> n >> m >> k; for (int i = 1; i <= n; i++) cin >> a[i], mark[a[i]] = 1; deque<int> que; int ans = 0; for (int i = 1; i < N; i++) { while (que.size() && que.front... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; template <typename T> void read(T &x) { x = 0; char op = getchar(); int F = 1; while (!isdigit(op)) { if (op == - ) F *= -1; op = getchar(); } while (isdigit(op)) { x = (x << 1) + (x << 3) + op - 0 ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int maxn = 1e5 + 100; long long a[maxn]; map<long long, long long> p[maxn]; vector<int> G[maxn]; long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } long long ans = 0; void dfs(int v, int fa... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string str[n]; for (int i = 0; i < n; i++) cin >> str[i]; int brr[m]; for (int i = 0; i < m; i++) cin >> brr[i]; int count = 0; for (int i = 0; i < m; i++) { int arr[5] = {0}; for (int j =... |
#include <bits/stdc++.h> using namespace std; int main() { double n, a, d; cin >> n >> a >> d; vector<int> t; vector<int> v; double prev = 0; int bit = 1; for (int i = 0; i < n; i++) { double t1, v1; cin >> t1 >> v1; double t2 = 0, t3 = 0, tot = 0; double dis = 0;... |
#include <bits/stdc++.h> using namespace std; class Mod { public: int mod; Mod(int mod_ = 1e9 + 7) : mod(mod_) {} int add(int a, int b) { return (a + b) % mod; } int mul(long long a, int b) { return (a * b) % mod; } int pow(long long a, int x) { int ans = 1; while (x) { if... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; map<int, int> m[N]; set<pair<int, int> > s[N]; vector<int> g[N]; int n, c[N]; long long ans[N]; void dfs(int u, int p) { m[u][c[u]] = 1; s[u].insert(pair<int, int>(1, c[u])); ans[u] = c[u]; for (int v : g[u]) { if... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; long long INF = 1e18; int n, s; vector<int> ans; long long ansV = 0; long long dis[N]; int edge[N], val[N]; vector<pair<int, int> > adj[N]; void solve() { for (int i = 1; i <= n; i++) dis[i] = INF; priority_queue<pair<long ... |
#include <bits/stdc++.h> using namespace std; const long double PI = acosl(-1.0); const double EPS = 1e-12; void showBit(int no, int N) { for (int i = N - 1; i >= 0; i--) if ((no >> i) & 1) printf( 1 ); else printf( 0 ); printf( n ); } int binToDec(string s) { int ln... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > result; void move(pair<int, int> &from, pair<int, int> &to) { from.first -= to.first; to.first *= 2; result.push_back(make_pair(to.second, from.second)); } void removeone(pair<int, int> list[3]) { sort(list, list + 3); i... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) long long x, y, z, a, b, c, d, n, m, mod = 1000000007; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; string s; bool w = true; cin >> n >> m >> s; a = s.find( G ); b = s.find( T );... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); string a, b; int k; cin >> a >> b >> k; int n = a.length(), l = 0; long long gd = 0, bd = 0; int f = 0; if (a.length() != b.length()) { cout << 0; r... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void slove() { int n, m, k; cin >> n >> m >> k; int ls = 0; if (n % 2) { n--, ls += m / 2; } if (m % 2) m--; int flag = 1; if (ls > k) flag = 0; ... |
#include <bits/stdc++.h> template <class T, class F, class C> auto binary_search(T l, T r, F func, C cmp) -> T; auto division(int64_t n, int64_t d) -> int64_t { return n / d; } int main() { int64_t n, k, m, d; std::cin >> n >> k >> m >> d; int64_t answer = 0; for (int64_t q_k = 1; q_k <= d; ++q_... |
#include <algorithm> #include <cmath> #include <vector> #include <iostream> using namespace std; void solve() { int n, totalCost, prev, x, cost; totalCost = 0; cin >> n; if (n <= 1) { cout << 0 << n ; return; } cin >> prev; int m, M; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; char s[105]; int main() { int n, nr = 0; gets(s); n = strlen(s); int x = 0; for (int i = 0; i < n; i++) x = (x * 2 + s[i] - 0 ) % mod; for (int i = 1; i < n; i++) x = (x * 2) % mod; printf( %d n , x); retu... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, b, mod; cin >> n >> m >> b >> mod; int dp[502][502]; int bugs[n + 2]; for (int i = 0; i < n; i++) cin >> bugs[i]; memset(dp, 0, sizeof dp); dp[0][0] = 1; for (int k = 0; k < n; k++) { for (int j = 0; j <= b - ... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rang( chrono::high_resolution_clock::now().time_since_epoch().count()); int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); } const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; void solve() { int s... |
#include <bits/stdc++.h> using namespace std; const int N = (int)4e6 + 11; const long long inf = 1e9 + 7; int n, m, p[1 << 20], can[1 << 20]; int find_parent(int x) { if (x == p[x]) { return x; } return p[x] = find_parent(p[x]); } int main() { scanf( %d %d , &n, &m); for (int i =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 110, alpha = 26; int n, m; int dp[maxn][maxn][alpha]; bool mark[maxn]; vector<int> ts; vector<pair<int, int> > G[maxn]; void dfs(int a) { mark[a] = 1; for (pair<int, int> p : G[a]) { int b = p.first; if (!mark[b]) { ... |
#include <bits/stdc++.h> using namespace std; int a[105]; int main() { int n, i, f; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); f = 0; for (i = 1; i < n; i++) { if (a[i] != a[0]) { f = 1; break; } } if (f == 1) cout << a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 110; string s[maxn]; int cur[maxn], c[maxn]; int n, m, ans = 0; void dfs(int x) { if (x == n) { int flag = 1; for (int i = 1; i <= m; i++) if (cur[i] - c[i]) flag = 0; ans += flag; return; } for (char ... |
#include <bits/stdc++.h> using namespace std; struct Hint { int up, cnt; bool operator<(Hint o) const { return up < o.up; } }; int n, b, q; Hint h[10013]; int has[10013][5], take[10013]; int main() { scanf( %d%d%d , &n, &b, &q); for (int i = 1; i <= q; i++) { scanf( %d%d , &h[i].up, ... |
#include <bits/stdc++.h> using namespace std; const int N = 60; map<double, int> p; bitset<N * N> g[N * N + 5]; int n, m; double ya[N + 5], yb[N + 5]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %lf , &ya[i]); for (int i = 1; i <= m; i++) scanf( %lf , &yb[i]); i... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; int ans; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; int a[1111] = {}, cnt[1111] = {}; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, k; cin >> n; vector<long long> dp(n + 3, 0); vector<long long> v; long long sum = 0; for (int j = 0; j < n; j++) { cin >> k; if (j % 2 == 0) { ... |
#include <stdio.h> int main() { int t; scanf( %d , &t); while (t--) { int x, i; scanf( %d , &x); for (i = 1; i * (i + 1) / 2 < x; i++); if (i * (i + 1) / 2 - x != 1) { printf( %d n , i); } else { printf( %d n , i + 1); ... |
#include <bits/stdc++.h> template <typename Y> inline bool updmin(Y &a, Y b) { if (a > b) { a = b; return 1; } return 0; } template <typename Y> inline bool updmax(Y &a, Y b) { if (a < b) { a = b; return 1; } return 0; } template <typename Y> inline Y abs(... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); string r; int i = 0; while (i < n) { if (n - i >= 3) { if (s.substr(i, 3) == WUB ) { if (r.size() && r.back() != ) r += ; i += 3; } else ... |
#include <bits/stdc++.h> using namespace std; long long ara[12]; int main() { long long n, i, j, k; for (i = 0; i < 4; i++) { cin >> k; ara[i] = k; } if (ara[0] == 0 && ara[3] == 0 && ara[2] > 0) { printf( 0 n ); } else { if (ara[0] == ara[3]) printf( 1 n ); ... |
#include <bits/stdc++.h> using namespace std; bool isvowel(char c) { return c == a || c == e || c == i || c == o || c == u ; } int main() { char arr[110]; scanf( %s , arr); int len = strlen(arr); bool check = true; for (int i = 0; i < len; i++) { if (isvowel(arr[i])) { ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int x) { long long int res = 1; while (x > 0) { if (x & 1) { res *= a; } a *= a; x = x / 2; } return res; } int main() { long long int n; scanf( %lld , &n); lo... |
#include <bits/stdc++.h> using namespace std; const int A = 1e5 + 11; const int B = 1e6 + 11; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; inline int read() { char c = getchar(); int x = 0, f = 1; for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = g... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; vector<int> object, ans; map<int, int> counter; int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); } int main() { int n, num; scanf( %d , &n); for (int i = 0; i < n * n; i++) { scanf( %d , &num); object.push_back... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; vector<long long> g[100005]; long long vis[MAXN], s[MAXN], gc[MAXN]; long long n; void dfs(long long v) { vis[v] = 1; s[v] = 1; for (auto i : g[v]) { if (!vis[i]) { dfs(i); s[v] += s[i]; gc[v] = ... |
#include <bits/stdc++.h> using namespace std; int a[1000005]; queue<long long int> q; vector<long long int> v; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int i, j, k, n, m, mid; cin >> k; string s; cin >> s; n = s.size(); int co = 0; long long i... |
#include <bits/stdc++.h> using namespace std; inline int readint() { int x = 0; bool f = 0; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) { f = 1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; long long n, m; long long a[100000], b[100000]; long long val(long long p) { long long ret = 0; for (long long i = 0; i < n; ++i) ret += max((long long)0, p - a[i]); for (long long i = m - 1; i >= 0; --i) ret += max((long long)0, b[i] - p); return re... |
#include <cstdlib> #include <cstdarg> #include <cassert> #include <cctype> // tolower #include <ctime> #include <cmath> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <stdexcept> #include <map> #include <tuple> #include <unordered_map> #include <s... |
#include <bits/stdc++.h> using namespace std; int v[112345]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &v[i]); sort(v, v + n); int res = 1; for (int i = 0; i < n; i++) { if (v[i] >= res) { v[i] = res; res++; } } printf(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long a[maxn], b[maxn]; int main() { int m, n; long long sum1 = 0, sum2 = 0, max1 = 0, max2 = 0, t1, t2; scanf( %d%d , &m, &n); for (int i = 1; i <= m; i++) { scanf( %lld , &a[i]); sum1 += a[i]; if (a[... |
#include <bits/stdc++.h> using namespace std; int n; string st; int call() { int s = 0, r = -1, neg = 0; for (int i = 0; st[i]; i++) { if (st[i] == ( ) s++; else s--; if (s <= 1) r = i; if (s < 0) neg = 1; } int ans = 0; if (s == 2 && !neg) { s ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, m, far[MAXN], a[MAXN]; struct LCT { int fa[MAXN], ch[MAXN][2]; int s[MAXN], xs[MAXN]; long long xs2[MAXN], sum[MAXN], ans[MAXN], xans[MAXN]; bool isroot(int x) { return ch[fa[x]][0] != x && ch[fa[x]][1] != x; } int... |
#include <bits/stdc++.h> using namespace std; int a[200010], b[200010]; int n, m; inline bool isprime(int x) { for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0; return 1; } unsigned long long hashseed; unsigned long long h1[200010], h2[200010], t[200010]; inline void prehash() { ... |
#include <iostream> #include <algorithm> #include<cmath> #include<cstring> #include<cstdio> #include<cstdlib> #include<vector> #include<iomanip> #include<ctime> #include<set> #include<map> #include<queue> #include<stack> #include<bitset> #define sqr(x) ((x)*(x)) #define fz1(i,n) for ((i)=1... |
#include <bits/stdc++.h> using namespace std; long long int T, n; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> T; while (T--) { cin >> n; set<long long int> chk_div; vector<long long int> g; for (long long int i = 0, u; i < n; i++) cin >> ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 15 + 5; int deg[MAXN], s[MAXN]; queue<int> q; int main() { int n, sum = 0, u, v; cin >> n; while (!q.empty()) q.pop(); for (int i = 0; i < n; i++) { cin >> deg[i] >> s[i]; if (deg[i] == 1) q.push(i); sum += d... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { vector<long> vt; long i = 0, n, temp, count = 1; cin >> n; for (int i = 0; i < n; i++) { cin >> temp; vt.push_back(temp); } sort(vt.begin(), vt.end()); whil... |
#include <bits/stdc++.h> using namespace std; long long h[1000005]; long long dp[1000005][2]; const int mod = 1e9 + 7; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %I64d , &h[i]), h[i]--; for (int i = 1; i <= n; i++) { dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] *... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> p1, pair<int, int> p2) { return (p1.first < p2.first) || (p1.first == p2.first && p1.second > p2.second); } int main() { bool b[200000]; int t[200000]; int n; cin >> n; for (int i = 1; i <= n; ++i) { c... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; int scan() { return getchar(); } template <class T> void scan(T a) { cin >> a; } void scan(int &a) ... |
#include <bits/stdc++.h> using namespace std; FILE* stream; const long long P = 998244353; long long mpow(long long n, int deg) { if (deg == 0) { return 1; } if (deg % 2 == 0) { return mpow((n * n) % P, deg / 2) % P; } return (mpow(n, deg - 1) * n) % P; } signed main() { ... |
#include <bits/stdc++.h> using namespace std; int n; map<int, int> a; bool found; int b[5][5], sum, cols[5]; void backTrack(int x, int y, int sumRow, int sumDia1, int sumDia2) { if (x == n) { if (sumDia1 != sum || sumDia2 != sum) return; for (int i = 0; i < n; i++) if (cols[i] != sum... |
#include <bits/stdc++.h> using namespace std; double PI = 3.141592653589793; const double EPS = 1e-9; const int N = 1e6 + 5; const long long mod = 1e9 + 7; const int oo = 1e9 + 9; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int n, m; long long row[1005], col[1005]... |
#include <bits/stdc++.h> using namespace std; long long input() { long long x = 0, f = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) f |= ch == - , ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); return f ? -x : x; } const int N = 107; string s... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long sum = 0, f = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) ch = getchar(), f = -1; while (ch <= 9 && ch >= 0 ) sum = sum * 10 + ch - 0 , ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; string to_string(string s) { return + s + ; } string to_string(char s) { return string(1, s); } string to_string(const char* s) { return to_string((string)s); } string to_string(bool b) { return (b ? true : false ); } templat... |
#include <bits/stdc++.h> using namespace std; int find(int u[], int i) { if (u[i] == i) { return i; } return (u[i] = find(u, u[i])); } int main() { int n, m; cin >> n >> m; if (n != m + 1) { cout << no << endl; return 0; } int ufs[n]; for (int i = 0; i < n... |
#include <bits/stdc++.h> #include<cmath> using namespace std; int main(){ long long t; cin>>t; while(t--){ int a,b,n; long long ans=0; cin>>a>>b>>n; int ar[a+1],br[b+1],arr[2][n]; memset(ar,0,sizeof(ar)); memset(br,0,sizeof(br)); ... |
#include <bits/stdc++.h> using namespace std; int n, ex[3]; char st[210]; int main() { scanf( %d , &n); scanf( %s , st + 1); for (int i = 1; i <= (n); i++) { if (st[i] == R ) ex[0]++; if (st[i] == G ) ex[1]++; if (st[i] == B ) ex[2]++; } if ((ex[0] > 0) + (ex[1] > 0) + (... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100100 * 3; const int INF = 1E9; const int base = 1E9 + 7; void no() { cout << no n ; exit(0); } int a[maxn]; pair<int, int> b[maxn]; char ans[3030][3030]; int n, m; void validate() { vector<int> draws; n = m; for ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; const long long mod = 1e9 + 7; long long num[N]; long long a[N]; long long b[N]; long long ans[N]; signed main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long T = 1; cin >> T; while (T--) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c, d; scanf( %lld %lld %lld %lld , &a, &b, &c, &d); printf( %lld %lld %lld n , b, c, c); } int main() { int t; scanf( %d , &t); while (t--) solve(); } |
#include <bits/stdc++.h> using namespace std; long long a[300005], m[300005], t[300005], ans, sum, n, x, qwq; int main() { scanf( %lld , &n); for (long long i = 1; i <= n; i++) { scanf( %lld%lld , &a[i], &m[i]); x = m[i]; while (x) { x >>= 1ll; t[i]++; } sum +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 10; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long ans[maxn << 2]; int main() { long long n, k, m; scanf( %lld%lld , &n, &k); m = ... |
#include <bits/stdc++.h> using namespace std; bool isPrime(int x) { if (x == 1) return false; for (long long i = 2; i <= sqrt(x); i += 1) if (x % i == 0) return false; return true; } void print(int a[], int n) { for (long long i = 0; i < n; i += 1) cout << a[i] << ; } void iarr(int ... |
#include <bits/stdc++.h> using namespace std; unsigned long long int power(unsigned long long int a, unsigned long long int b, unsigned long long int p) { unsigned long long int res = 1; a = a % p; while (b > 0) { if (b & 1) { res = (res * a) % p; b--... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count(); std::mt19937_64 gen(gen_seed); const int A = 500; long long d[A + 1][A + 1]; long long fac[A + 1]; long long ifac[A + 1]; long lo... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 20, LMAX = 400000, INF = ~0u >> 1; int K, L = 1, f1[2 * LMAX], f2[LMAX], f3[LMAX]; long long A, B; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } int main() { int i, j; scanf( %I64d %I64d %d , &B, &A, &K); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, k, ans = 0, t; cin >> t; while (t--) { cin >> n >> k; ans = 0; while (n > 0) { if (n % k == 0) { n /= k; ans++; ... |
#include <bits/stdc++.h> long long p(long long n, long long k) { long long d = 1; while (n) { if (n & 1) d = (d * k) % 1000000007; k = (k * k) % 1000000007; n >>= 1; } return d; } int main() { long long n, l; scanf( %I64d , &n); l = p(n, 2); printf( %I64d , ((l + ... |
#include <bits/stdc++.h> using namespace std; template <class T> using VV = vector<vector<T>>; template <class T> inline bool SMIN(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> inline bool SMAX(T &l, const T &r) { return l > r ? l = r, 1 : 0; } const string yes = YES... |
#include <bits/stdc++.h> using namespace std; int n, k, i, j, mas[50077], fix[50077], dom, a[50077]; int main() { cin >> n; for (k = 1; k <= n; k++) cin >> a[k]; for (k = 1; k <= n; k++) { dom = a[k]; for (j = 1; j <= n; j++) mas[a[j]] = 0; for (i = k; i <= n; i++) { mas[a[i]... |
#include <bits/stdc++.h> const double pi = (double)(2.0 * acos(0.0)); const int inf = 1 << 30; const double eps = 1E-9; const double e = exp(1.0); const int sz = 100000 + 5; const int mod = 1000000000 + 7; using namespace std; int main() { double x, y, z, res, v; string st = ; scanf( %lf %... |
#include <bits/stdc++.h> using namespace std; int main() { int ans = 0; string s; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == 1 ) ans += 10; else if (s[i] == A ) ans += 1; else ans += s[i] - 0 ; } cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, a[100005], b[100005], difs, f, s; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); for (int i = 0; i < n; i++) if (a[i] != b[i]) difs++; if (difs > 2) { cout << NO ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) using namespace std; const int maxn = 3e5 + 5; const int maaxn = 1e7 + 2; const int minn = 22; const long long mod = 1e9 + 7; const long do... |
#include <bits/stdc++.h> using namespace std; const int p = 1e9 + 7; struct Matrix { int n, m; long long a[105][105]; Matrix(int x, int y) { n = x, m = y; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) a[i][j] = 0; } } void init() { for (int i = 1; ... |
#include <bits/stdc++.h> int main() { int n, a[5001]; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) if (a[a[a[i]]] == i) { printf( YES ); return 0; } printf( NO ); return 0; } |
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; void solve() { int n; cin >> n; int adad[n]; map<int, int> cnt; for (int i = 0; i < n; i++) { cin >> adad[i]; cnt[adad[i]]++; } int mini; mini =... |
#include <bits/stdc++.h> using namespace std; inline void writeln2() { cout << n ; } inline void writeln() { cout << n ; } inline void readln() {} template <typename T> inline void read(T&); template <typename T> inline void priws(T); template <typename T> inline void print(T); void err(vector... |
#include <bits/stdc++.h> using namespace std; set<int> marc[100010]; int input(void) { int x; scanf( %d , &x); return x; } int main() { int n = input(); for (int i = 0; i < (n); i++) { int x = input(), k = input(); if (x == 0) { marc[k].insert(0); } else { ... |
#include <bits/stdc++.h> using namespace std; struct Time { long long deno, num; inline long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } inline void simplify() { long long g = gcd(abs(deno), abs(num)); deno /= g; num /= g; if (deno < 0) { ... |
#include <bits/stdc++.h> using namespace std; int par1[10008]; int par2[10008]; vector<pair<int, int>> result; int find1(int r) { if (par1[r] == r) return r; else return par1[r] = find1(par1[r]); } int find2(int r) { if (par2[r] == r) return r; else return par2[r] =... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e17 + 10; const int N = 1e4 + 10; const long long mod = 998244353; map<string, int> ml; int c[N], vis[N], a[N], t, n, m, x, y, k, dp[N][105]; char s[N]; int ex, ey, cnt; long long dist[N]; vector<pair<int, int> > v; map<int, int>... |
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<pair<int, int> > a; vector<int> b; scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); if (t & 1) { int spd = 0; if (t != 5) scanf( %d , &spd); a.push_back({t, sp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.