func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; vector<int> a[1000001]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { int g; scanf( %d , &g); while (g--) { int p; scanf( %d , &p); a[p].push_back(i); } ... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; const double PI = acos(-1); template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } int n, m, a, b; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); cin.ignore(); while (t--) { int n, arr[1030]; map<int, int> maps; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); maps[arr[i]]++; } int ans = -1... |
#include <bits/stdc++.h> using namespace std; vector<int> fibonacci; void createFibbo(int num); int main() { int num; cin >> num; if (num == 0) cout << 0 0 0 n ; else if (num == 1) cout << 0 0 1 n ; else if (num == 2) cout << 0 1 1 n ; else if (num == 3) cout <... |
#include <bits/stdc++.h> using namespace std; bool debug = 1; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; int dp[1 << 20], s[105], t[105]; string ac[105]; int main() { scanf( %d , &n); for (int(i) = 0; (i) < (int)(n); (i)++) scanf( %d , s + i); sort(s... |
#include <bits/stdc++.h> using namespace std; int main() { long n, m; cin >> n >> m; map<string, long> ma; vector<string> v; for (long i = 0; i < n; i++) { string a; cin >> a; v.push_back(a); ma[a] = 1; } long k = 0; long count = 0; for (long i = 0; i < n ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INF = 1e9; const long long LINF = INF * INF; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1 << 19; int n, k; vector<pair<long long, long long>> g[N]; long long dp[N][2]; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; bool f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == - , ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return f ? -x : x; } inline void write(int x) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3fffffff; const int maxn = 100010; int n, k; int main() { cin >> n >> k; if (k > (n - 1) / 2) puts( -1 ); else { printf( %d n , n * k); for (int i = 0; i < n; ++i) for (int j = 1; j <= k; ++j) printf( %d %d n... |
#include <bits/stdc++.h> using namespace std; long long C[5001][5001], fak[5000], a, b, c, ans1, ans2, ans3; const long long MOD = 998244353; void generate() { C[0][0] = 1; for (long long i = 1; i <= 5000; i++) { C[i][0] = 1; for (long long j = 1; j <= i; j++) { C[i][j] = (C[i - 1][j... |
#include <bits/stdc++.h> using namespace std; int long long a[200005], b[200005]; vector<int> v; int main() { int n, t; scanf( %d , &t); while (t--) { scanf( %d , &n); int long long neg = 0, ans = 0; for (int i = 0; i < n; i++) { scanf( %lld , &a[i]); } for (int... |
#include <bits/stdc++.h> int main(int argc, char *argv[]) { std::string s; int n; std::cin >> n >> s; int con = 0; int ans = 0; for (int i = 0; i < s.length();) { while (s[i] == x ) { con++; i++; } if (s[i] != x ) { if (con >= 3) { ans += c... |
#include <bits/stdc++.h> using namespace std; struct FenwickTree { vector<int> tree; FenwickTree(int n = 0) { tree.resize(n); } void update(int i, int delta) { for (; i < (int)tree.size(); i |= i + 1) tree[i] += delta; } int sum(int ind) { int sum = 0; while (ind >= 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { char c = a + i % k; cout << c; } cout <... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(const array<long long int, 2> &a, const array<long long int, 2> &b) { return (a[0] > b[0]); } long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } bool inline isPrime(long... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vecto... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000; const int MAXN = 1 << 20; const long long MOD = 1e9 + 7; template <typename T> void chmin(T &a, T b) { if (a > b) a = b; } template <typename T> void chmax(T &a, T b) { if (a < b) a = b; } template <typename T>... |
#include <bits/stdc++.h> using namespace std; long long a[2000010] = {0}, b[2000010] = {0}; int main() { long long n, tmp, k, sign = 1, mx; cin >> n >> k; mx = -1; for (long long i = 0; i < n + 1; ++i) { cin >> b[i]; } for (long long i = 0; i < n + 1000; ++i) { a[i] += b[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int r, c; cin >> r >> c; char a[r + 1][c + 1]; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cin >> a[i][j]; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { if (a[i][j] ... |
#include <bits/stdc++.h> using namespace std; int n, a[105], c, x, k; int main() { cin >> n; for (int i = 0; i < 2; i++) { cin >> x; while (x--) cin >> k, c += 1 - a[k], a[k] = 1; } cout << (c == n ? I become the guy. : Oh, my keyboard! ); } |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, x, y, c, t, n, m, X, Y, bada, chota; cin >> n; long long a[n]; for (i = (0); i < (n); i++) cin >> a[i]; c = 0; for (i = (1); i < (n); i++) { if (a[i] < a[i - 1]) { c += a[i - 1] - a[i]; } } ... |
#include <bits/stdc++.h> using namespace std; int x[110]; int y[110]; int d[110][2100]; int c[2010][2010]; int modd = 1000000007; int sum[10010]; int main() { int n, ans = 0, schet = 0; cin >> n; for (int i = 0; i < 1001; i++) { c[i][i] = 1; c[i][0] = 1; } for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void cmn(T &a, const T &b) { if (b < a) a = b; } template <class T> inline void cmx(T &a, const T &b) { if (b > a) a = b; } const double eps = 1e-9; const long double leps = 1e-14; string inp; const int MN = 1000 + 100... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; int memo[2002][10][10][10][10]; int n; int in[2002], out[2002]; int calc(int i, int b1, int b2, int b3, int b4, int floor) { if (i == n && (b1 + b2 + b3 + b4) == 0) return 0; int a[4], load = 0; memset(a, 0, sizeof a); if... |
#include <bits/stdc++.h> using namespace std; bool check(int n, int k, int diff, int a[]) { vector<bool> dp(n); int last = -1; for (int i = k - 1; i < n; i++) { int low = 0, high = i - k + 1; while (low < high) { int pivot = (low + high) / 2; if (a[i] - a[pivot] > diff) ... |
#include <bits/stdc++.h> using namespace std; class opr { public: int q; int w; opr *pNext; opr *pLost; }; opr *pHead = 0; opr *pTail = 0; opr *pN = 0; void addvalue(int e, int r) { opr *p = new opr; if (pHead == 0) { p->q = e; p->w = r; p->pNext = 0; p->... |
#include <bits/stdc++.h> using namespace std; int n, t, i, nn, p[2000010], tmp, x; long long ans; int main() { scanf( %d , &n); nn = n; while (n >= 0) { for (t = 0; n >> t; t++) ; t--; x = (1 << t + 1) - 1; for (i = 1 << t; i <= n; i++) p[i] = x - i, p[x - i] = i; ... |
#include <bits/stdc++.h> using namespace std; struct IO { IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } } _; long long n, m, len, k, t, a, b; long long c[101]; long long p[101][101]; long long dp[101][101][101]; long long rec(long long idx, long long col, long... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool f = 1; for (int i = 0; i < s.length(); ++i) if (s[i] == H || s[i] == Q || s[i] == 9 ) { cout << YES << endl; f = 0; break; } if (f) cout << NO << endl; } |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; void qread(int &x) { int neg = 1; x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = 10 * x + c - 0 , c = getchar(); x *= ne... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int n, h, w, g[N], p[N], t[N], ansx[N], ansy[N]; vector<int> v[3 * N]; int main() { scanf( %d%d%d , &n, &w, &h); for (int i = 0; i < n; i++) { scanf( %d%d%d , g + i, p + i, t + i); v[p[i] - t[i] + N].push_back(i); } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) { int n, k; cin >> n >> k; string s; cin >> s; sort(s.begin(), s.end()); if (s[k - 1] != s[0]) { cout << s... |
#include <bits/stdc++.h> clock_t __t = clock(); namespace my_std { using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T rnd(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } template <typename T> inline bool chkmax(T &x... |
#include <bits/stdc++.h> using namespace std; long long n, ch, maxx, minn = 10000, k, x, m; long long mass[65][65], temp[8][8]; long long d1[124], d2[124]; long long st1, en1, st2, en2; long long p1[124], p2[124]; long long a[10000]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin... |
#include <bits/stdc++.h> using namespace std; int main() { int c[3][3]; int MAX = -1; int pos = -1; int area = 0; for (int i = 0; i < 3; i++) { int a, b; cin >> a >> b; c[i][0] = min(a, b); c[i][1] = max(a, b); if (a > MAX) { MAX = a; pos = i; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 30; typedef struct { long long x, y; } point; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; vector<pair<pair<int, int>, int> > vpp; vector<pair<int, int> > vp; con... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 200005; long long n, has; long long num[maxn], rk[maxn]; long long a[maxn]; signed main() { long long k, j, i; scanf( %lld , &n); for (k = 1; k <= n; k++) scanf( %lld , &a[k]); rk[0] = 1; num[1] = 0; has = 1; fo... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 4010; const long long mod = 1e9 + 9; long long f[maxn * 2][maxn], n, w, b; long long num[maxn * 2], inv[maxn * 2]; long long pp(long long a, long long b) { if (!b) return 1; long long cnt = pp(a, b / 2); cnt = 1ll * cnt * cnt %... |
#include <bits/stdc++.h> using namespace std; const int N = 123456; int s[N]; int main() { int n, k, ans = 0; scanf( %d%d , &n, &k); for (int i = 0; i < n; ++i) { scanf( %d , s + i); } for (int i = 0; i < n - k; ++i) { ans = max(ans, s[i] + s[(n - k) * 2 - i - 1]); } prin... |
#include <bits/stdc++.h> using namespace std; struct Edge { int from, to; long long capacity, cost; Edge(int from, int to, long long capacity, long long cost) { this->from = from; this->to = to; this->capacity = capacity; this->cost = cost; } }; vector<vector<int>> adj; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using std::cerr; using std::cin; using std::cos; using std::cout; using std::endl; using std::make_pair; using std::max; using std::min; using std::next_permutation; using std::pair; using std::priority_queue; using std::queue... |
#include <bits/stdc++.h> const int maxN = 1000005, p = 998244353; int n, ans, fac[maxN], inv[maxN]; inline int power(int x, long long y) { int res = 1; for (; y; y >>= 1, x = (long long)x * x % p) { if (y & 1) { res = (long long)res * x % p; } } return res; } inline int bin... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s; cin >> t; int i = 0, j = 0; while (j < t.size()) { if (s[i] == t[j]) i++; j++; } cout << i + 1 << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; multimap<int, string> MM; long long int BinSearch(long long int a[], vector<long long int>& tVec, long long int x, long long int y, long long int v) { while (y > x + 1) { long long int m = x + (y - x) / 2; if (a[tVec[m]] >= v)... |
#include <bits/stdc++.h> using namespace std; string convertTostr(int x) { stringstream ss; ss << x; string st; st = ss.str(); return st; } unsigned long long convertToint(string y) { unsigned long long num; stringstream ss(y); ss >> num; return num; } unsigned long long ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; const int N = 5e4 + 10; int y[N]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , y + i); } int low = 1, high = 1e9; while (low != high) { int mid = (low + high) / 2; ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k = 0, l = 0, n; int a[1001], b[10001]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { cin >> b[i]; } for (i = 0; i < n; i++) { k = k | a[i]; } for (i = 0; i <... |
#include <bits/stdc++.h> using namespace std; void debug(int a[], int n) { cout << Array: [ ; for (auto i = 0; i != n; i++) cout << a[i] << ; cout << ] n ; } void debugv(vector<int>& v) { cout << Vector: [ ; for (auto i = 0; i != v.size(); i++) cout << v[i] << ; cout << ] n ;... |
#include <bits/stdc++.h> using namespace std; const unsigned long long inf = 0x3f3f3f3f3f3f3f3f; const unsigned long long MAXN = 1e5 + 5; unsigned long long cnt[MAXN]; vector<unsigned long long> adj[MAXN]; vector<unsigned long long> vis(MAXN, 0); void dfs(unsigned long long v) { vis[v] = 1; if (ad... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MOD = 1000 * 1000 * 1000 + 7; const int MAX = 1000 * 1000 + 47; long long getN(long long a) { long long res = a; while (a) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; int n, u, v, dp[maxn], d[2]; long long f[maxn], ans, sum; vector<int> a[maxn]; void dfs(int nod, int pa, int x) { d[x]++; for (int i : a[nod]) { if (i != pa) { dfs(i, nod, x ^ 1); dp[nod] += dp[i]; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int a[n]; int b[n]; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == a ) { a[i] = 1; b[i] = 0; } else { a[i] = 0; b[i] = 1; } if (i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; deque<int> D; for (int i = 1; i <= N; ++i) D.push_back(i); for (int k = 2; k <= N; ++k) { int x = D.front(); D.pop_front(); for (int i = k - 1; i < N - 1; i ... |
#include <bits/stdc++.h> int main() { int i, cnt1 = 0, l, diff, a, c, fck; scanf( %d%d , &a, &c); l = a; diff = 0; while (l > 0) { if (l % 3) diff += (3 - (l % 3)) * pow(3, cnt1); l /= 3; cnt1++; } cnt1 = 0; l = 0; while (c || diff) { fck = c + diff; l... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; pair<int, int> intersect(pair<int, int> a, pair<int, int> b) { vector<pair<int, int>> v; v.push_back(a); v.push_back(b); sort(v.begin(), v.end()); a = v[0]; b = v[1]; if(a.first >= b.first && a... |
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <cstring> #include <list> #include <casser... |
#include <bits/stdc++.h> const int N = 200100; using namespace std; vector<long long int> v[N]; long long int n, down[N], up[N], k, s[N], a[N]; long long int ans; void f(long long int x, long long int p) { s[x] = a[x]; for (int i = 0; i < v[x].size(); i++) { long long int y = v[x][i]; if... |
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll t; cin >> t; while(t--){ ll n; cin >> n; ll x[n]; for(ll i=0; i<n; i++){ cin >> x[i]; } ... |
#include<bits/stdc++.h> #define fo(i,a,b) for(int i=a;i<=b;i++) #define gc (p1==p2&&(p2=(p1=fr)+fread(fr,1,1<<20,stdin))==p1?EOF:*p1++) #define fl fwrite(fw,1,p3-fw,stdout),p3=fw char ch,fr[1<<21],*p1=fr,*p2=fr,fw[1<<21],*p3=fw; void rd(int&x) { while(!isdigit(ch=gc));x=ch-48; while( isdigit(ch=gc)) x... |
#include <bits/stdc++.h> const int Max_N = 100005, Mod = 1000000007; int Fact[Max_N], Inv_Fact[Max_N]; long long Inv(const int x) { return x == 1 ? 1 : (Mod - Mod / x) * Inv(Mod % x) % Mod; } long long Binomial(const int x1, const int x2) { return x1 == -1 && x2 == -1 ? 1 ... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[300007]; bool vis[300007]; int Time[300007], timeMin[300007], cnt = 0, res = 0; int dfs(int u, int p) { vis[u] = true; Time[u] = timeMin[u] = cnt++; int ret = 0; vector<int> childList; for (auto child : adj[u]) { if (child... |
#include <bits/stdc++.h> const int M = 100010; int n, k; int l[M], r[M], a[M]; long long dp[M], ans = 1e18; template <typename T> inline void read(T &x) { x = 0; char ch = getchar(); int f = 1; for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) f = -1; for (; ch >= 0 && ... |
#include <bits/stdc++.h> using namespace std; const int N = 10000; const long double pi = acos(-1.0); int n, sum[2020]; long long bin[2020], f[2020][2020]; char s[2020]; int read() { int x = 0, f = 1; char ch = getchar(); while ((ch < 0 ) || (ch > 9 )) { if (ch == - ) f = -1; ch... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t, s, q; cin >> t >> s >> q; int ans = 0; int tot = s; while (tot < t) { tot *= q; ++ans; } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<set<int> > v(26); for (int i = 0; i < s.size(); i++) v[s[i] - a ].insert(i); int q = 0, op = 0; cin >> q; while (q--) { cin >> op; if (op == 1) { int pos = 0; char x; ... |
#include <bits/stdc++.h> using namespace std; inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return (n >> b) & 1; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } int dist[... |
#include<bits/stdc++.h> #define llong long long #define mkpr make_pair #define x first #define y second #define iter iterator #define riter reverse_iterator #define y1 Lorem_ipsum_ #define tm dolor_sit_amet_ using namespace std; inline int read() { int x = 0,f = 1; char ch = getchar(); fo... |
#include <bits/stdc++.h> using namespace std; long long a[10], nd[10], dad[10], root, ans; int nopd(long long n) { long long now = 2, ans = 0; for (; now * now <= n; now++) while (n && n % now == 0) { n /= now; ans++; } if (n > 1) ans++; return ans; } bool prime(lon... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, n, b, x, y, s; int q; cin >> q; while (q--) { cin >> a >> b >> n >> s; long long ts = a * n + b; if (ts < s) { cout << NO n ; continue; } if (s % n > b) { cout << NO n ; ... |
#include <bits/stdc++.h> using namespace std; int uf[55]; int buc[55]; bool chk[55]; int ans[5000][2]; int fh(int idx) { if (uf[idx] != idx) uf[idx] = fh(uf[idx]); return uf[idx]; } vector<int> edge[55]; void dfs(int idx) { if (chk[idx]) return; chk[idx] = true; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int fst[N], v[2 * N], w[2 * N], nxt[2 * N], cnt = 1; bool vis[2 * N]; int c[N], ans[N], n; queue<int> q; void add(int x, int y, int z) { v[++cnt] = y, w[cnt] = z; c[y] += z; nxt[cnt] = fst[x], fst[x] = cnt; } void bfs() ... |
#include <bits/stdc++.h> using namespace std; string s, t; double ans; double solve(string s) { int a = 0, b = 0, c = 0, p = 0; for (int i = 0; i < s.size(); i++) { char e = (b % 2) ? R : L ; if (s[i] == X ) b++; else if (s[i] == e) a++, b++, p = 0; else ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int N; int arr[300005]; int segf[4 * 300005]; int segb[4 * 300005]; int pow29[300005]; void inv(long long a, long long b, long long &x, long long &y) { if (a == 0) { x = 0; y = 1; return; } inv((b % a), ... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int test_case = 0; test_case < T; test_case++) { int num, round = 1; vector<int> result; cin >> num; while (num > 0) { if (num % 10 != 0) { result.push_back((num % 10) * round); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 314000000; int n, m, id[111111], dis[111111], dp[111111]; int val[111111], sum[111111], deg[111111]; int vis[111111]; vector<int> str[111111]; vector<int> to[111111]; vector<int> fr[111111]; int add(int x, int y) { int s = x + y; re... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, t; cin >> n; while (n--) { cin >> t; if (t <= 2) { cout << 0 << endl; continue; } if (t % 2 != 0) { cout << t / 2 << endl; } else { cout << t / 2 - 1 << endl; } ... |
#include <bits/stdc++.h> using namespace ::std; const long long maxn = 400; const long long mod = 1e9 + 7; const long long inf = 1e17 + 500; string s[maxn]; long long a[maxn]; string t; long long n; long long ger[maxn][maxn]; long long tvi[maxn][maxn]; long long sav[maxn][maxn]; long long tyu[ma... |
#include <bits/stdc++.h> using namespace std; const int MN = 1000 * 100 + 1000; const int INF = (1u << 31) - 1; int l1[MN]; int l2[MN]; int b[MN]; int p[MN]; int n, m, _; int main() { ios::sync_with_stdio(false); cin >> n >> m >> _ >> _; for (int i = 0; i < n; i++) cin >> l1[i]; for (i... |
#include <bits/stdc++.h> using namespace std; int dp1[100010]; int dp2[100010]; int a[100010]; int main(int argc, char const *argv[]) { int n; cin >> n; for (int i = 1; i <= n; i++) { std::cin >> a[i]; } dp1[0] = 0; int sum = 0; for (int i = 1; i <= n; i++) { sum += a[i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; const double PI = acos(-1.0); const int EPS = (1e-10); const int N = 1e5 * 2 + 10; const int inf = 1e9 * 2 + 10; const ll INF = 1e18 * 2 + 10; const int MOD = 1e9 + 7; int nx... |
#include<bits/stdc++.h> using namespace std; #define ll long long int const ll mod = 1e9+7; void solve(){ int a; cin>>a; float arr[a]; float sum=0; for(int i=0;i<a;i++){ cin>>arr[i]; sum+=arr[i]; } float avg = sum/(float)a; sort(arr,arr+a); int ans=0; ... |
#include<iostream> #include <math.h> using namespace std; bool issquare(long int num) { long int sqrtnum=sqrt(num); if(num==(sqrtnum*sqrtnum)) { return true; } else{ return false; } } int main() { int t; cin>>t; for(int i=0;i<t;i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; const long long oo = 1LL << 60; const long long kNumMoves = 4; const long long kMoves[kNumMoves][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; long long GetMinMoves(long long x, long long y, long long m) { if (max(x, y)... |
#include <bits/stdc++.h> int main() { char a[21]; char b[21]; int s1[21]; int s2[21]; int lena; int lenb; while (scanf( %s%s , &a, &b) != EOF) { lena = strlen(a); for (int i = 0; i < lena; i += 2) { if (a[i] == [ && a[i + 1] == ] ) s1[i / 2] = 2; el... |
#include <bits/stdc++.h> const int maxn = 2 * 100000; const int inf = 99999999; class array { public: int num; int left; int right; array() { left = right = inf; } } a[maxn + 1]; int queue[maxn + 1]; int head = 1, tail = 1; int main() { int n; scanf( %d , &n); int nowzero = ... |
#include <bits/stdc++.h> using namespace std; int main() { string q1, q2, ans; cin >> q1 >> q2; int n, k = 0, c(0), p; n = q1.length(); for (int i = 0; i < n; i++) { if (q1[i] != q2[i]) { c++; if (c % 2 == 1) { ans += q1[i]; } else { ans += q2[i]... |
#include <bits/stdc++.h> int main() { int a[4], i, test, flag = 1, flag2 = 1; double test2, testn; for (i = 0; i < 4; i++) scanf( %d , &a[i]); test = a[1] - a[0]; if (a[2] - a[1] == test && a[3] - a[2] == test) { printf( %d , a[3] + test); flag = 0; flag2 = 0; } if (flag)... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; const ll MOD = 998244353; const ll INF = 1e15 + 373; template <typename T> using vector2 = vector<vector<T>>; template <typename T> vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) { return vector2<T>(n0, vector<T>(n1, e... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 500; int n; long long a[maxn], ans; long long dfs(int l, int r, int now) { if (l == r) { return 1; } long long fenge = r + 1; for (int i = l; i <= r; i++) { if (a[i] & (1 << now)) { fenge = i; brea... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int test; cin >> test; while (test--) { int n, m; cin >> n >> m; int array[n]; for (int i = 0; i < n; i++) cin >> array[i]; int sum = 0; for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { int r; while (b) { r = a % b; a = b; b = r; } return a; } int GCD(int a, int b) { if (a == 0) return b; else return GCD(b % a, a); } long long int power(long long int a, long long int ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; ; cin >> t; while (t--) { int s; vector<int> v; cin >> s; for (int i = 0; i < s; i++) { int x; cin >> x; v.push_back(x); } int f = 0; for (int i = 0; i < s - 1; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 200000; const int MAX_L = MAX_N * 2; vector<int> nbrs[MAX_N]; int ps[MAX_N], cis[MAX_N], vs[MAX_L]; bool used[MAX_N]; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); for (int i = 0; i < m; i++) { int u, v; scanf... |
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf( %d , &n); if (n % 5 == 0) { cout << n / 5; } else cout << n / 5 + 1; return 0; } |
#include <bits/stdc++.h> const int INF = (int)1e9; const int long minINF = (int)-1e9; const int mod = (int)1e9 + 7; const int MAXN = (int)2e6 + 5; using namespace std; long long arr[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, tmpsum = 0; cin >> n; int v[2][n]; for (int i = 0; i < n; i++) cin >> v[0][i] >> v[1][i]; for (int i = 0; i < n; i++) { sum += v[1][i]; sum -= v[0][i]; if (sum >= tmpsum) tmpsum = sum; } cout << ... |
#include <bits/stdc++.h> using namespace std; int an = 0; int ht; char a[20][20][20]; int h[20][20][20]; int fill(int x, int y, int k) { if (k <= 0 || k > ht || a[k][x][y] == # || h[k][x][y]) return 1; an++; h[k][x][y] = 1; fill(x - 1, y, k); fill(x, y - 1, k); fill(x, y + 1, k); ... |
#include <bits/stdc++.h> using namespace std; int n, m, c; vector<int> l; vector<int> r; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> c; while (l.size() + r.size() < n) { int val; cin >> val; if (val <= c / 2) { bool temp = 0; for (int i ... |
#include <bits/stdc++.h> using namespace std; const int N = 102; char a[N][N][N]; int main() { int n, m, p; int i, j, k, l; scanf( %d%d%d , &n, &m, &p); for (i = 0; i < n; i++) { for (j = 0; j < m; j++) scanf( n%s , &a[i][j][0]); for (j = 0; j < m; j++) for (k = 0; k < p; k+... |
#include <bits/stdc++.h> using namespace std; const double eps = 1E-9; const double Exp = 2.718281828459045; const double Pi = 3.1415926535897932; const int Max_Bit = 63; const int INF = 2000000000; const long long LINF = 1000000000000000007ll; const int MOD = 1000000007; const int NMAX = 100005; co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.