func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long int con = 0; vector<pair<long long int, long long int> > v; long long int t[5000][5001]; vector<vector<pair<long long int, long long int> > > ans(5001); bool istrue[5001]; vector<long long int> a[5001]; long long int dis[5001]; int n; int ppp =... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int k; cin >> k; if (k % 2 != (i + j) % 2) k++; cout << k << ; } cout << endl; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int MXN = 5e4 + 5; const int INF = 1e9; const long long P = 29; const long long MOD = 1e9 + 7; int t; int main() { srand(time(0)); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); cin >> t;... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, flag = 1; char c = getchar(); while ((c > 9 || c < 0 ) && c != - ) c = getchar(); if (c == - ) flag = 0, c = getchar(); while (c <= 9 && c >= 0 ) { x = (x << 3) + (x << 1) + c - 0 ; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p) { out << ( << p.first << , << p.second << ) ; return out; } template <typename T> ostream& operator<<(ostream& out, vector<T> const& v) { long long l = v.s... |
#include <bits/stdc++.h> using namespace std; const long long N = 200000 + 10; const long long INF = 2e9 + 10; long long dic[N], idx[N]; int main() { long long n, k, ii; scanf( %lld%lld , &n, &k); for (long long i = 0; i <= n; ++i) scanf( %lld , idx + i), dic[i] = idx[i]; for (long long i = 1;... |
#include <bits/stdc++.h> using namespace std; bool sortmahstyle(const pair<int, int> &a, const pair<int, int> &b) { if (a.first < b.first) return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m; cin >> n >> m; long long int hash[... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<long long int> a(n), b(n); set<long long int> s; for (int i = 0; i < n; i++) { cin >> a[i]; s.insert(a[i]); } for (int i =... |
#include <bits/stdc++.h> using namespace std; long long a[100010]; int main() { long long n, pos; while (cin >> n >> pos) { for (long long i = 0; i < n; i++) scanf( %I64d , &a[i]); sort(a, a + n); long long res1 = 0, res2, res; if (pos < a[0]) res1 = a[n - 2] - pos; e... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int M = 310; int n, m, s, e0, E; pair<int, int> dp[N][M]; int a[N]; vector<int> elAtB[N]; inline int findj(int j0, int val) { if (j0 >= m) return -1; vector<int> &v = elAtB[val]; if (v.size() == 0) return -1; vecto... |
#include <bits/stdc++.h> int main() { int i, j, k, n; scanf( %d , &n); k = sqrt(n); for (i = k; i >= 1; i--) { if (n % i == 0) { j = i; break; } } printf( %d %d , j, (n / j)); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long maxn = 100005; long long n, d, b; long long a[maxn]; bool f(long long x) { long long l = 1 + x; long long r = n - x; deque<pair<long long, long long>> dq; for (long long i = 1; i <= n; i++) if (a[i] != 0) dq.push_front({i, a[i... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3 ) #pragma GCC target( avx ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) const int MOD = 1000000007; const int INF = 1000000009; co... |
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 10; const long long inf = 1ll << 60; const long long mod = 1e9 + 7; void GG() { cout << 0 n ; exit(0); } long long mpow(long long a, long long n, long long mo = mod) { long long re = 1; while (n > 0) { if (n & 1) r... |
#include <bits/stdc++.h> using namespace std; struct lem { long long m; long long v; int id; bool operator<(const lem& other) const { if (m > other.m) return true; if (m < other.m) return false; if (v > other.v) return true; if (v < other.v) return false; return id > ot... |
#include <bits/stdc++.h> using namespace std; const int maxn = 20; const int inf = 1e9; int dp[maxn][maxn][maxn]; int vis[maxn][maxn][maxn]; int path[maxn][maxn][maxn]; int n, a, b; int h[maxn]; int dfs(int i, int cur, int pre) { cur = cur < 0 ? 0 : cur; pre = pre < 0 ? 0 : pre; if (i == n... |
#include <bits/stdc++.h> using namespace std; string s, s1, s2, s3; int sa[300010][20], lcp[300010], rnk[300010], root[300010], cnt[300010][4], col[300010], n; pair<pair<int, int>, int> q[300010]; pair<int, pair<int, int> > lcp_pair[300010]; vector<long long> ansvec; long long ans, mod = 1e9 + 7; ... |
#include <bits/stdc++.h> using namespace std; vector<string> v; string s; const int N = 1000001; int n; long long d, arr[N]; unsigned long long gcd(long long x, long long y) { if (y == 0) { return x; } return gcd(y, x % y); } void gen(long long ind, string t) { if (ind == s.size(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1 + 9e6; const int inf = 0x3f3f3f; vector<bool> dp[24]; int n; int a[23]; vector<pair<int, int> > pre[23]; int ans; int main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> n; for (int i = 0; i < n; ++i)... |
#include <bits/stdc++.h> using namespace std; string onezero(int n) { string s = 1 ; for (int i = 1; i < n; ++i) { s += 0 ; } return s; } string findSum(string str1, string str2) { if (str1.length() > str2.length()) swap(str1, str2); string str = ; int n1 = str1.length(), n... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e5 + 1; long long int n, m, i, j, l, k, x, y, a, b, cnt[3], sum[3]; void solve() { string s; cin >> s; long long int n = s.length(); long long int lst = 0, maxi = -1; long long int val = 0; for (long long int i = 0; i... |
#include <bits/stdc++.h> using namespace std; int a[1010], d[1010]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; d[a[i]]++; } int mx = 0, mxi = 0; for (int i = 1; i <= n; i++) { if (d[a[i]] > mx) mx = d[a[i]]; if (d[a[i]] != 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long answer = 0; for (int i = s.length() - 1; i > 0; i--) { string temp = s.substr(i - 1, 2); if (stoi(temp) % 4 == 0) { answer += i; } } for (int i = 0; i < s.length(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int c[1005]; int a[12] = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292}; int main() { long long n; while (cin >> n) { if (n <= 11) { cout << a[n] << endl; } else { long long m; m = a[11] + (n - 11) * 49; cout ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int ret = 0, flag = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) flag = -1; c = getchar(); } while (c >= 0 && c <= 9 ) ret = ret * 10 + (c ^ 0 ), c = getchar(); return flag * ret; } str... |
#include <bits/stdc++.h> using namespace std; double ans, m; int n; double binpow(double a, int b) { if (b == 0) return 1; else if (b == 1) return a; else if (b % 2 == 0) { double t = binpow(a, b / 2); return t * t; } else return a * binpow(a, b - 1); } int main... |
#include <bits/stdc++.h> int main() { int i; for (i = 0; i < 10; i++) { printf( ??%d>>%d?? n , i, i); } printf( ??>>? n ); for (i = 0; i < 9; i++) { printf( %d?<>%d n , i, i + 1); } printf( 9?>>?0 n?<>1 n>>?? n ); } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; long long t = n; vector<pair<int, int> > laptop; for (int i = 0; i < n; i++) { long long temp1, temp2; cin >> temp1 >> temp2; la... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 7, M = 1e9 + 7; vector<int> primes; bool isp[N]; void sieve() { fill(isp, isp + N, 1); isp[0] = isp[1] = 0; for (int i = 2; i * i < N; i++) if (isp[i]) for (int j = i * i; j < N; j += i) isp[j] = 0; for (int i = 2;... |
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, b1, b2, b[200007], ans, dl, dll[200007], an[200007]; map<unsigned long long, unsigned long long> a[11]; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for (unsigned long long i = 1; i <= n; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = int(1e6) + 100; const long long inf = 1e6; int n, m; int a[maxn], cnt[maxn], b[maxn]; void read() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); for (int i = 1; i <= n; ++i) b[i] = a[i]; } long long POW... |
#include <bits/stdc++.h> using namespace std; const int MX = 300000; int n, arr[MX], bit[MX], ans = 0, lis; void update(int x, int V) { while (x <= n) { bit[x] = max(bit[x], V); x += x & -x; } } int get(int x) { int ret = 0; while (x > 0) { ret = max(ret, bit[x]); x -... |
#include <bits/stdc++.h> using namespace std; priority_queue<long long, std::vector<long long>, std::greater<long long> > pqs; queue<long long> q; stack<long long> sta; set<long long> st; set<long long>::iterator P; long long i, j, n, m, t, k, a, b, c, x, mx, mn; string s, s1; char z; vector<pair<lo... |
#include <bits/stdc++.h> using namespace std; struct Node { Node *arr[26]; int state; bool isEnd = false; Node() { for (int i = 0; i < 26; i++) arr[i] = nullptr; isEnd = true; } }; void insert(const string &s, Node *root) { Node *curr = root; for (char c : s) { if (... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n; while (cin >> n) { int ans = 0; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; ans += a[x] + a[y]; a[x]++, a[y]++; } cout << ans << endl; } return 0; }... |
#include <bits/stdc++.h> using namespace std; const long long MOD = pow(10, 9) + 7; const long long MAX = LONG_LONG_MAX; void solve() { int n; cin >> n; vector<string> a(n, ); for (int i = 0; i < n; i += 1) cin >> a[i]; for (int i = 0; i < n; i += 1) { for (int j = 0; j < n; j += 1) ... |
#include <bits/stdc++.h> using namespace std; int8_t sign(int a, int b, int &c, int x, int y) { return a * 1LL * x + b * 1LL * y + c < 0LL ? -1 : 1; } void solve() { int x, y, x1, y1; cin >> x >> y >> x1 >> y1; int16_t ans = 0; int16_t n; cin >> n; for (int i = 0, u, v, c; i < n; i++... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64777216 ) using namespace std; template <class T> inline T sqr(T x) { return x * x; } const double pi = acos(-1.0), eps = 1e-9; const int INF = 1000 * 1000 * 1000, MAXN = 1000005, MOD = 1000000007; const long long INFL = 1000000000000000000; ... |
#include <bits/stdc++.h> using namespace std; char s[2004], temp[2004], e[2004], c, cnt; int n; int q[27]; void f(int x) { cnt++; if (cnt != n * 3) printf( %d , x); else printf( %d n , x); int i; for (i = n - x + 1; i <= n; i++) temp[n - i + 1] = s[i]; for (i = 1; i < n - ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 10, MAX = 7e5 + 1e4, MOD = 1e9 + 7, MAXL = 25; void OUT(long double o, int x) { cout << fixed << setprecision(x) << o; return; } long long sth[MAX], mah[MAX], reg[MAX], ti[MAX], en[MAX], he[MAX], hh[MAX], pa[MAX]; long l... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int res = 1; if (k == 1) { cout << n; } else { while (res <= n) res = (long long)(res * 2); cout << res - 1; } return 0; } |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const int inf = 99999999; int n; char c[20]; int r[20]; int b[20]; int dp[1 << 16][123]; int main() { int n; cin >> n; int maxi = 0; int ans1 = 0; int ans2 = 0; for (int i = 0; i < n; i++) { cin >> ... |
#include <bits/stdc++.h> void output1(int n) { for (int i = 0; i < n; ++i) { printf( 10 ); } printf( n ); } void output2(int m) { --m; for (int i = 0; i < m; ++i) { printf( 01 ); } printf( 0 n ); } void output3(int n, int m) { if (n == m + 1) { --n; for... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) const char nl = n ; using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using str = string; str to_string(char c) { return st... |
#include <bits/stdc++.h> using namespace std; const long long N = 5100; const long long M = 15; const long long mod = 1e9 + 7; const long long MOD = 998244353; const long long P = 1336; const long double eps = 0.000000001; const long long inf = 1e9; mt19937 gen(chrono::high_resolution_clock::now().tim... |
#include <bits/stdc++.h> using namespace std; const int MAX = 500000 + 24; int a[MAX]; int main() { int n, m, ans, tmp, u, v, fc; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } m = a[0]; ans = 0; for (int i = 0; i < n; i++) { while (i < n && a[i] == ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int n, a[maxn], cnt[maxn], mx = 0, last[maxn * 2], ans = 0; void solve1(int x) { for (int i = 1; i <= n; i++) last[n - i] = last[n + i] = -1; last[n] = 0; int cur = 0; for (int i = 1; i <= n; i++) { if (a[i] == x) ... |
#include <bits/stdc++.h> using namespace std; int main() { int arr[6]; for (int i = 0; i < 6; i++) { cin >> arr[i]; } sort(arr, arr + 6); int tracker[10]; for (int i = 0; i < 10; i++) { tracker[i] = 0; } for (int i = 0; i < 6; i++) { tracker[arr[i]]++; } int... |
#include <bits/stdc++.h> using namespace std; string s; int n, a, b, ans, nr1, nr0, minD; int main() { cin >> n >> a >> b; cin >> s; a--; b--; minD = (int)1e8; nr1 = (int)1e8; nr0 = (int)1e8; for (int i = 0; i < s.size(); i++) { if (s[i] == s[a]) { nr1 = i; ... |
#include <bits/stdc++.h> using namespace std; template <class T> void minn(T& a, T b) { if (a > b) a = b; } template <class T> void maxx(T& a, T b) { if (a < b) a = b; } void debug() { return; } template <class H, class... T> void debug(H a, T... b) { cerr << a; debug(b...); } vo... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; int n, m, a[N], t[N], r[N], second[N]; pair<int, int> T[2][N * 4]; pair<int, int> get_max(int l, int r, int v = 1, int tl = 1, int tr = n) { if (tl > r || tr < l) return make_pair(-mod, 0); if (l <= tl && t... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e6 + 3; const int INFI = 1e9 * 2; const long long LINFI = 1e17; const double pi = acos(-1.0); const int N = 111; const int M = 222222; const int move[8][2] = {1, 0, -1, 0, 0, 1, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int a[N][N]; int main()... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long inff = 0x3f3f3f3f3f3f3f3f; const int N = 5e2 + 8; int n, kk, a[N], dp[2][N][N]; int main() { cin.tie(0); cout.tie(0); cin >> n >> kk; int qw = 0; dp[qw ^ 1][0][0] = 1; for (int i(1); i <= (n); ++i) ... |
#include <bits/stdc++.h> using namespace std; string s1, s2, s3; int win(string s1, string s2) { if (s1 == rock ) { if (s2 == rock ) return 0; if (s2 == scissors ) return 1; if (s2 == paper ) return 2; } if (s1 == paper ) { if (s2 == rock ) return 1; if (s2 == scis... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[101]; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); int i = 1; while (a[i] == a[i - 1] && i < n) i++; if (i == n) printf( NO n ); else printf( %d n , a[i]); return 0... |
#include <bits/stdc++.h> using namespace std; using namespace placeholders; template <class T> void mini(T &l, T r) { l = min(l, r); } template <class T> void maxi(T &l, T r) { l = max(l, r); } template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << = << h << n ; } ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long up = 2e5 + 5; pair<int, int> pt[2005]; inline bool cmp(const pair<int, int>& a, const pair<int, int>& b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } long long fac[up],... |
#include <bits/stdc++.h> using namespace std; const int big = ((long long int)1 << 30); const long long int mod = 1000000007; int main(void) { int n, m, ans = 0, i, q, w, gen = 0; vector<int> kaz; vector<bool> uma; scanf( %d %d , &n, &m); m--; kaz.resize(n); uma.resize(n + 1); fo... |
#include <bits/stdc++.h> const int INF_INT = 0x3f3f3f3f; const long long INF_LL = 0x7f7f7f7f; const int MOD = 1e9 + 7; const double eps = 1e-10; const double pi = acos(-1); using namespace std; const int N = 200200; int n, m, q; int u[N], v[N]; struct Query { int l, r, s, t, id; Query(int l,... |
#include <bits/stdc++.h> using namespace std; bool deb = false; int n; vector<int> p, b; void init() { if (!deb) return; p.resize(n); for (auto& x : p) cin >> x; b.resize(n); for (int i = 0; i < n; ++i) b[p[i]] = i; } int get(int i, int j) { if (deb) return p[i] ^ b[j]; cout <<... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, k; while (cin >> n >> k) { int r = n, l = 1; cout << l; l++; for (int i = 1; i < k; i++) if (i % 2) { cout << << r; r--; } else { ... |
#include <bits/stdc++.h> using namespace std; long long m[1000005], n[1000005], w[1000005]; int main() { long long a, b, c; char ch[10]; while ((scanf( %lld%lld%lld , &a, &b, &c)) != EOF) { long long t; scanf( %lld , &t); long long p = 0, q = 0, r, sum1 = 0, sum2 = 0, f; for (i... |
#include <bits/stdc++.h> using namespace std; int n, m; char s[25][25]; int c[25][25]; int chs[1 << 21]; int dp[1 << 21]; vector<int> hv; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %s , s[i]); } for (int i = 0; i < n; ++i) { for (int j = 0; j < m... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long mod = 998244353; const long long maxn = 3e5 + 10; long long p[2] = {1000000007, 998244353}; long long seed[2] = {500000004, 500000004}; int main() { int x, a[6]; scanf( %d , &x); for (int i = 0; i < 6; i++) ... |
#include <bits/stdc++.h> using namespace std; long long int n; long long int u; string s; int q; int count(long long int number) { if (!number) return 0; int result = 0; while (number % 2 == 0) { result++; number >>= 1; } return result; } long long int solve(long long int... |
#include <bits/stdc++.h> using namespace std; const int boss = 2e5; map<int, int> used; queue<int> q; int n, k, c[2], a[boss + 10]; int main() { int i, answer = 0; cin >> n >> k; for (i = 1; i <= n; i++) { scanf( %d , &a[i]); if (used[a[i]] || c[a[i] % 2] == n / 2) q.push(i);... |
#include <bits/stdc++.h> using namespace std; const int mx = 2e5 + 10; int main() { int n, arr[mx], temp, z = 0; queue<int> visit; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); if (arr[i] == 0) visit.push(i); } temp = visit.front(); visit.pop(); f... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline int len(const T &a) { return a.size(); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tc; cin >> tc; while (tc--) { int n, m; cin >> n >> m; vector<int> k(n); vector<int> c(m); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 610001; const long long inf = (long long)5e16; struct node { long long val, id; }; node a[N], b[N]; bool cmp(node x, node y) { if (x.val == y.val) return x.id < y.id; return x.val < y.val; } long long n, m, ans[N], pos[N]; ... |
#include <bits/stdc++.h> using namespace std; int k, n, a; int d[1001]; bool vis[1001], flag; int main() { scanf( %d%d , &n, &k); int cut = 0; for (int i = 2; i <= k; i++) { if (k % i) continue; int crt = 1; while (k % i == 0) { crt *= i; k /= i; } d[c... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 1, -1, 0, 0}; const int dy[] = {0, 0, 0, 1, -1}; struct MinCostMaxFlow { int head[20010], total; int next[1000010], aim[1000010], flow[1000010], cost[1000010]; int f[20010], from[20010], p[20010]; bool v[20010]; MinCostMaxFlo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 51; struct BIT { int x[MAXN]; inline void add(int pos, int val); inline int query(int pos); }; BIT bit; int n, tp, res, totd, r; int x[MAXN], d[MAXN], st[MAXN], f[MAXN], g[MAXN]; long long int dsc[MAXN]; inline int read()... |
#include <bits/stdc++.h> using namespace std; int T, N, M; int A[300][300]; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main() { scanf( %d , &T); for (; T--;) { scanf( %d%d , &N, &M); bool ok = true; for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int r, g, b, w; cin >> r >> g >> b >> w; int count = 0; if (r % 2) count++; if (g % 2) count++; if (b % 2) count++; int m = min(r, min(g, b)); bool flag; if (co... |
#include <bits/stdc++.h> using namespace std; const int N = 55; int n, k, dp[N][N]; long long a[N], sum[N], dq; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; for (int i = 60; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<vector<int>> a(5, vector<int>(n)); for (int i = 0; i < n; i++) { string s; cin >> s; vector<int> aa(5); for (int j = 0; j < s.size(); j++) { aa[s[j] - a ]++; } for (int j... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, n2 = 1, a[5010], dat[20010], ans = 0; vector<long long> v, vv[5010]; map<long long, long long> mp; void build(long long k, long long lb, long long ub) { if (lb == ub) return; build(k * 2 + 1, lb, (lb + ub) / 2)... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define FOR(i, n) for(int (i)=0; (i)<(n); (i)++) #define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++) #define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--) template<class T, class U> void umin(T& x, const U& y){... |
#include <bits/stdc++.h> using namespace std; long long f[110][2][2]; int ans[110]; int n; long long k; long long calc(long long x, long long a, long long b) { if (f[x][a][b] != -1) return f[x][a][b]; f[x][a][b] = 0; int y = n - x + 1; if (x > y) return f[x][a][b] = 1; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; inline int init() { int now = 0, ju = 1; char c; bool flag = false; while (1) { c = getchar(); if (c == - ) ju = -1; else if (c >= 0 && c <= 9 ) { now = now * 10 + c - 0 ; flag = true; } else if (flag)... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = +100500; const long long INF = 1e9; bool ans[MAXN]; long long get(long long x) { long long l = 0, r = INF; while (l + 1 < r) { long long m = (l + r) / 2; if (m * (m + 1) / 2 <= x) { l = m; } else { r... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5; int arr[MAX]; int main() { int T; cin >> T; while (T--) { int n; cin >> n; for (int i = 0; i < n; i++) { int c; cin >> c; arr[c - 1] = i; } int l = arr[0], r = arr[0]; for (... |
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<string.h> #include<map> #include<vector> #include<string> using namespace std; const int maxN = 3e5+ 10; typedef long long int ll; #define mod 998244353 ll dp[maxN]; ll f[maxN]; string c[maxN]; int main() {... |
#include <bits/stdc++.h> using namespace std; int mp[28]; bool fl[28]; int main() { int n, k; cin >> n >> k; string s; cin >> s; memset(mp, 0, sizeof(mp)); for (int i = 0; i < s.size(); i++) { mp[s[i] - a + 1]++; } int cnt = 0; int ans = 0; for (int i = 1; i <= 26... |
#include <bits/stdc++.h> using namespace std; void upd(long long &x, long long y) { x += y; } struct node { int nxt; long long sta, v[10]; node() { nxt = 0; memset(v, 0, sizeof(v)); } }; struct state { vector<node> nodes; int head[100007]; state() { memset(head, -1, siz... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; vector<long long> v(100004); vector<long long> t(100004, 0); int n; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int bsearch(int r, int key) { int l = -1; while (r - l > 1) { int m = (r + l) / 2... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> dd; map<long long, long long> tong; int main() { long long n; cin >> n; string s; cin >> s; long long sum = 0; for (long long i = 0; i < s.size(); i++) { sum += (s[i] - 0 ); } for (long long i = 2; i <... |
#include<iostream> #include<cstdio> #include<unordered_map> using namespace std; const int N=105; const int MOD=1000000007; int n,q; int c[N]; int b[N]; int sb[N],sc[N]; int l,r; int solve(int x) { static int f[N][N*N],g[N][N*N]; f[0][0]=g[0][0]=1; for(int i=1;i<=n;i++) {... |
#include <bits/stdc++.h> using namespace std; int m = 1e9 + 7; int p = 31; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; long long t = 1; cin >> t; while (t--) { long long w, h; cin >> w >> h; long long k1, k2, k3, k4; cin >> k1; ... |
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &x) { int f = 0; x = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f |= (ch == - ); for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; if (f) x = -x; } const int N = 200005; int a[N],... |
#include <bits/stdc++.h> using namespace std; int arr[1001][1001]; int main() { int n, m, f1 = 0; cin >> n >> m; int cnt = m; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j && arr[i][j] == 0) { arr[i][j] = 1; arr[j][i] = -1; cnt--... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print1d(vector<T> &a) { for (long long int i = 0; i < a.size(); i++) { cout << a[i] << ; } cout << endl; } vector<long long int> divisor(long long int n) { vector<long long int> a; for (long long int i = 1; i... |
#include <bits/stdc++.h> using namespace std; #define l1 long long int #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define test l1 t;cin>>t;while(t--) // Function to check // if parentheses are balanced bool isBalanced(string exp) { // Initialising Variabl... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.size(); int a[2]; int b[2]; a[0] = a[1] = 0; b[0] = b[1] = 0; long long ans_odd = 0LL; long long ans_even = 0LL; for (int i = 0; i < l; i++) { ans_odd++; if (s[i] == a ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin >> n; vector<long long> q(1000100, 0); for (long long i = 0; i < n; i++) { long long t; cin >> t; q[t]++; } long long ans = 0; fo... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool chmax(T& a, const T& b) { return a < b ? (a = b, true) : false; } template <typename T> bool chmin(T& a, const T& b) { return b < a ? (a = b, true) : false; } int N, Q; const int MAX_N = 100000; const int BUCKET = 100, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> v(n); for (auto &it : v) cin >> it; int ans = 0; sort(v.begin(), v.end... |
#include <bits/stdc++.h> using namespace std; int main() { int n, arr[1000], arr2[1000], i = 0; cin >> n; while (i < n) { cin >> arr[i]; arr2[arr[i]] = i + 1; i++; } sort(arr, arr + n); for (i = 0; i < n; i++) { cout << arr2[arr[i]] << ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 105; int zy[N][N * N / 2]; bool dp[N][N * N / 2]; deque<int> ans; void dfs(int n, int k) { if (n == 1) { ans.push_back(1); return; } else { if (zy[n][k] > 0) { dfs(n - zy[n][k] + 1, k - zy[n][k]); int sz = ... |
#include <bits/stdc++.h> using namespace std; int n; char ara[55][55]; bool ok(int i, int j) { if (i >= n || j < 0 || j >= n) return false; if (ara[i][j] == # ) return false; return true; } int main() { while (cin >> n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j+... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.