func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> int main() { int a, b; scanf( %d %d , &a, &b); int fc, uc, df, sum = 0; fc = a; uc = 0; df = b; while (1) { sum += fc; if (fc == 0 && uc < df) break; uc += fc; fc = uc / df; uc = uc % df; } printf( %d n , sum); return 0; ... |
#include <bits/stdc++.h> using namespace std; long long N; bool ask(long long n) { cout << ? << n << endl; bool res; cin >> res; return res; } void solve() { cin >> N; long long l = 1; long long r = N - 1; long long delta = 0; long long start = N; bool t = false; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; int in; cin >> n >> m; vector<int> v(n + 1, 0); for (int i = 1; i <= n; ++i) { cin >> in; v[i] = in; } int a, b; double c = 0; double ret = 0; for (int i = 0; i < m; ++i) { cin >> a >> b >>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c = 0, ans = 0; scanf( %d%d%d , &n, &a, &b); for (int i = 0; i < n; i++) { int x; scanf( %d , &x); if (x == 1) { if (a > 0) a--; else if (b > 0) { b--; c++; } e... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 405; int n, ans = -1; int c[MAXN]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &c[i]); for (int i = 2; i <= n; i++) { for (int j = i; j <= n; j++) { int p = c[i - 1... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100 + 13; int N, M; int s[maxN][maxN]; void enlarge(int x, int y, int l) { int col = s[x][y]; for (int i = x; i <= x + l; i++) for (int j = y; j <= y + l; j++) s[i][j] = col; return; } void paint(int x, int y) { int col =... |
#include <bits/stdc++.h> using namespace std; class TaskA { public: void solve(istream& in, ostream& out) { int n, m; in >> n >> m; int cell = m - 1; for (int i = 0; i < n; ++i) { if (i & 1) { for (int j = 0; j < m; ++j) out << (j == cell ? # : . ); cell... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; vector<int> ps[200000]; int sum[200000]; int main() { int T; cin >> T; for (int t = 0; t < T; t++) { int n; cin >> n; for (int i = 0; i < n; i++) ps[i].clear(); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; pair<long long int, pair<int, bool> > p[200005 << 1]; long long int a[200005], tree[200005 << 2][2]; long long int get(int n, int b, int e, int i, int j, bool c) { if (i > j || j < b || e < i) return 0; if (i <= b && j >= e) return tree[n][c]; int l, r, ... |
#include <bits/stdc++.h> using namespace std; long long i, j, k, n, m, res, c1, c0; long long a[200009]; string s; set<long long> st; queue<long long> q; int main() { int nt; cin >> nt; while (nt--) { cin >> s; s = R + s; s += R ; long long last = 0, res = 0; f... |
#include <bits/stdc++.h> using namespace std; struct BIT { int a[400010], size, n, dl, dr, dir, len; inline void set(int x, int v) { int k = v - query(x, x); for (; x <= size; x += ((x) & (-(x)))) a[x] += k; } inline void add(int x, int v) { for (; x <= size; x += ((x) & (-(x)))) a... |
#include <bits/stdc++.h> using namespace std; int n, m, nrE; struct Dish { int p, s, b; } d[100002]; struct Person { int inc, pref; } v[100002]; struct Event { int x, y, z, t; bool operator<(const Event &ot) const { if (x == ot.x) return z > ot.z; return x < ot.x; } } E[1... |
#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; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18; const long double PI = 3.141592653589793116, EPS =... |
#include <bits/stdc++.h> using namespace std; const long long int maxn = 1e3 + 2; const long long int mod = 1e3 + 2; vector<long long int> d; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, x, ans = INT_MAX; cin >> n >> x; long long int mi... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int a, n2 = 0, n1 = 0; for (int i = 0; i < n; i++) cin >> a, a - 1 ? n2++ : n1++; if (n2) cout << 2 << ; if (n1) cout << 1 << ; for (int i = 0; i < n2 - 1; ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> res, res2, res3; int x[10005], y[10005], id[35], b[35], vis[10005], r[10005]; bitset<35> c[35], d[35], tmp; int insert(int x, int y, bitset<35> now) { for (int i = 0; i <= 30; i++) if (x & (1 << i)) { if (!b[i]) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } using ll = long long; using ld = long double; const int maxn = 1e6 + 5; int n, r; ll c[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int n, m, row, column; int a[5005]; int cnt[1005]; int main() { int i, j, k, l; int x, y; int tc, t; int res = 0; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); cnt[a[i]]++; } j = *(max_element(cnt, cnt ... |
#include <bits/stdc++.h> using namespace std; const int N = 5010, Q = 100010; int n, q, ac; int a[N][N * 2]; int ans[Q]; vector<pair<pair<int, int>, pair<int, int>>> seq; void ch(int j, int k, int x) { for (; j <= n; j += j & -j) for (int l = k; l <= n * 2; l += l & -l) a[j][l] += x; } int q... |
#include <bits/stdc++.h> int main() { int p[105]; int n, m, i, j, t; memset(p, 0, sizeof(p)); scanf( %d%d , &n, &m); for (i = 0; i < m; i++) { scanf( %d , &t); for (j = t; p[j] == 0; j++) p[j] = t; } for (i = 1; i < n; i++) printf( %d , p[i]); printf( %d n , p[n]); ret... |
#include <bits/stdc++.h> using namespace std; vector<long long int> odds; int main() { int n; scanf( %d , &n); long long int sum = 0; int length_odds = 0; for (int x = 0; x < n; x++) { long long int num; scanf( %lld , &num); if (num % 2 == 0) { sum += num; } els... |
#include <bits/stdc++.h> using namespace std; typedef struct _Box { int pos, weight; } Box; Box arr[200010]; long long int bit1[200010], bit2[200010]; const int mod = 1e9 + 7; int num; int getLowbit(int n) { return n & (-n); } void add(long long int* bitArr, int pos, long long int val, bool should... |
#include <bits/stdc++.h> using namespace std; const int N = 10, M = 1e6 + 7, K = 200, p = 1e9 + 7; int n, e[N], s[M], wf[K], q[N][K], f[N][N], ans[N][M]; bitset<40> op, wq[N][M]; unordered_map<bitset<40>, int> rt[N]; inline int read() { int num = 0; char g = getchar(); while (g < 48 || 57 < g) g... |
#include <bits/stdc++.h> using namespace std; int main() { long long int r, x, y, x1, y1, t, u; double ans = 0; cin >> r >> x >> y >> x1 >> y1; t = abs(x - x1); u = abs(y - y1); ans = t * t + u * u; ans = sqrt(ans); ans = ans / (2 * r); ans = ceil(ans); cout << ans; retur... |
#include <bits/stdc++.h> using namespace std; int32_t seed; mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count()); inline int32_t rnd(int32_t l = 0, int32_t r = INT_MAX) { return uniform_int_distribution<int32_t>(l, r)(rng); } template <typename T, typename G> ostream& operator<<(... |
#include <bits/stdc++.h> using namespace std; const int N = 400; const int MOD = (int)1e9 + 7; int n, x; long long fac[N], c[N][N]; map<int, int> h; vector<int> d; int fix(int x) { for (int i = 2; i * i <= x; i++) { while (x % (i * i) == 0) { x /= i * i; } } return x; }... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; int a[N], f[N][21], la[21]; int main() { int n, q; scanf( %d%d , &n, &q); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); for (int j = 0; j <= 18; j++) if (!(a[i] & (1 << j))) for (int k = 0; k <= 18... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; const int MOD = 1000000007; int a[300005]; int main() { int n, p; cin >> n >> p; for (int i = 1; i <= n; i++) cin >> a[i]; while (p--) { int l, r, x; cin >> l >> r >> x; int lar = r - x; int num = a[... |
#include <bits/stdc++.h> using namespace std; struct edge { int a, b, cost; }; vector<edge> e; const int INF = 1e8; char alphabet[26] = { a , b , c , d , e , f , g , h , i , j , k , l , m , n , o , p , q , r , s , t , u , v , w , x , ... |
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #include <iostream> #include <algorithm> #include <queue> #include <vector> #include <set> #include <map> #include <cassert> #include <function... |
/* Karmanye vadhikaraste Ma Phaleshu Kadachana | Ma Karmaphalaheturbhurma Te Sangostvakarmani ||*/ //----------------------------------------------------------------------------------------------------------------// /* this is begining have to survive more and go through long journey*/ ////////////////////... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, k; char s[N]; int chk(char s[]) { for (int i = 1; i <= n; i += k) { for (int j = 1; j <= k; j++) { if (i + j - 1 > n || i + j - 1 + k > n) break; if (s[i + j - 1] != s[i + j - 1 + k]) { if (s[i + j... |
#include <bits/stdc++.h> using namespace std; long long ans = 0, ar[100001], n, ll, ars[100001]; string s; int main() { cin >> n; for (int i = 1; i <= n; i++) { scanf( %d , &ars[i]); ar[i] = ar[i - 1] + ars[i]; } cin >> s; for (int i = n - 1; i >= 0; i--) { if (s[i] == 1 )... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<pair<int, int> > a; long long sum, ans; int e, deg; int get_e(int num, int deg) { if (num == 1) return 0; if (num == 2) return 1; int res = num * (num - 1) / 2; if (deg & 1) { int bad = num - 2; res += bad / 2; } ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(1919810); int T, n, K, zr; inline char qry(int la, int ra, int lb, int rb) { cout << ? << ra - la + 1 << << rb - lb + 1 << endl; for (int i = la; i <= ra; i++) cout << i << (i == ra ? n : ); for (int i = lb; i <= rb; i++) cout <<... |
#include <bits/stdc++.h> using namespace std; template <typename float_t> struct _complex_ { float_t x, y; _complex_<float_t>(float_t _x = 0, float_t _y = 0) : x(_x), y(_y) {} float_t real() const { return x; } void real(float_t _x) { x = _x; } float_t imag() const { return y; } void imag(... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:268435456 ) using namespace std; const int maxn = 4050; const int maxsec = 86400; vector<pair<int, int> > input; int dp[maxn][maxn]; int main() { int k, n; scanf( %d , &n); ; scanf( %d , &k); ; int i, j; int x, y; for... |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(0); int n, m, k, a, ans = 0; std::cin >> n >> m >> k; for (int i = 0; i < n; i++) { std::cin >> a; if (a == 1) { m--; if (m == -1) { m++; ans++; } } if (a == 2) { ... |
#include <bits/stdc++.h> using namespace std; int row[5001] = {0}; int rowt[5001] = {0}; int col[5001] = {0}; int colt[5001] = {0}; int main() { int n, m, k; cin >> n >> m >> k; int q, t, a; for (int i = 1; i < k + 1; i++) { cin >> q >> t >> a; t--; if (q == 1) { ro... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int Array[n]; for (int i = (int)0; i < (int)n; ++i) cin >> Array[i]; stable_sort(Array, Array + n); int Sum = accumulate(Array, Array + n, 0, plus<int>()); int Middle = Sum / n; vector<int> a(n, Middle); ... |
#include <bits/stdc++.h> const double pi = 3.1415926535897; using namespace std; int main() { string s; cin >> s; int counter = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == a ) counter++; } if (s.length() / 2 < counter) cout << s.length(); else cout << (coun... |
/*#pragma GCC optimize( O3 ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimize( unroll-loops )*/ #include<bits/stdc++.h> using namespace std; #define CIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ll long long int #define pb push_back #de... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; array<int, N> a; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; long long ans = 0; long long power = 1; while (abs(power) < 1e15) { ... |
#include <bits/stdc++.h> using namespace std; void solve(int n, int k) { int i; for (i = 1; i <= 2 * k; ++i) if (i & 1) printf( %d %d , 2 * i - 1, 2 * i); else printf( %d %d , 2 * i, 2 * i - 1); for (i = 4 * k + 1; i <= 2 * n; ++i) printf( %d , i); putchar( n ); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 8; const int dxs[] = {2, 1, -1, -2, -2, -1, 1, 2}; const int dys[] = {-1, -2, -2, -1, 1, 2, 2, 1}; char s0[8], s1[8]; bool flds[N][N]; inline void readpos(char s[], int &x, int &y) { x = s[0] - a ; y = s[1] - 1 ; } inline void setkn... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; if ((x == n / 2 || x == n / 2 + 1) && (y == n / 2 || y == n / 2 + 1)) cout << NO << endl; else cout << YES << endl; } |
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1000000; const double pi = 3.1415926535897932384626433832795; using namespace std; double s, v1, v2; long long n, kol; long long check(double xx) { long long sum = 0; dou... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans; scanf( %lld , &n); if (n % 2 == 0) { ans = n / 2; } if (n % 2 == 1) { ans = (n - 1) / 2 - n; } printf( %lld n , ans); return 0; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, d, a[1000]; int main() { cin >> n >> d; for (int i = 0; i < n; i++) { int s; cin >> s; a[s]++; } int maxn = 0; for (int i = 1; i <= 100; i++) { int l = 0; for (int j = i; j <= i + d; j++) { l += a[j]; ... |
#include <bits/stdc++.h> using namespace std; int s1[105], s2[105]; int a[105], b[105]; int tt[305]; int main() { int n, T; scanf( %d%d , &n, &T); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } sort(b + 1, b + 1 + n); for (int i = 1; i <= n; i++) tt[b[i]]... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 8; int a[N], b[N]; int n, m; long long x, k, y; bool chk(int l, int r, long long &res) { if (l > r) return true; bool canDel = false; int mx = *max_element(a + l, a + r + 1); int len = r - l + 1; if (l - 1 >= 0 && a[l - 1]... |
#include <bits/stdc++.h> int x, k; int NumsBetween(int a, int b) { return (b / x - (a - 1) / x); } int main() { int n; std::cin >> n >> x >> k; std::vector<int> array(n, 0); for (int i = 0; i < n; ++i) { std::cin >> array[i]; } std::sort(array.begin(), array.end()); long long ans... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(const T &x) { return x * x; } inline long long sqr(int x) { return sqr<long long>(x); } template <class T> T binpow(const T &a, long long n) { return n == 0 ? 1 : sqr(binpow(a, n / 2)) * (n % 2 ? a : 1); } long long ... |
#include <bits/stdc++.h> using namespace std; const int MX = 100000; vector<int> divisors[MX + 10]; int n, last[MX + 10], pos, X; int main() { for (int j = 1; j <= MX; j++) for (int i = j; i <= MX; i += j) divisors[i].push_back(j); cin >> n; for (int j = 1; j <= n; j++) { cin >> X >> p... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const long long SZ = 1010, SSZ = 100010, APB = 26, one = 93, INF = 0x3f3f3f3f3f3f3f3f, mod = 1000000007; long long n, m, bg, fn, cnt; long long to[SSZ], wt[SSZ], head[SZ]; long long nex[SSZ], mk[SSZ]; long long dfn[SZ... |
#include <bits/stdc++.h> struct node { int h, typ; bool operator<(node b) const { if (typ == b.typ) return h > b.h; return typ < b.typ; } } a[10010]; int n, x, y, sum, L, R, ans, dp[10010]; int main() { scanf( %d%d%d , &n, &x, &y); for (int i = 1; i <= n; i++) scanf( %d , &a[i].h... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long data[n + 1]; long long mx = LLONG_MIN; for (int i = 1; i <= n; i++) { cin >> data[i]; mx = max(mx, data[i]); } vector<int> graph[n + 1]; for (int i = 0; i < n - 1; i++) { int s, t;... |
#include <bits/stdc++.h> using namespace std; long long tree[3 * 100005]; bool lazy[3 * 100005]; void update(long long node, long long b, long long e, long long i, long long j, long long v) { if (i > e || j < b) { return; } if (b >= i && e <= j) { lazy[node] = true; {... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const long long mod = 1e9 + 7; long long sod(long long n) { long long sum = 0; while (n > 0) { sum += n % 10; ... |
#include <bits/stdc++.h> using namespace std; long long int nodes_size; long long int edge_size; class edge { public: long long int node; long long int cost; edge(long long int i, long long int j) { node = i; cost = j; } }; class graph { public: long long int node; ... |
#include <bits/stdc++.h> using namespace std; int main() { int e, f; cin >> e >> f; cout << e + f << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int n; pair<long long, long long> h2md_logl[100000][19]; pair<long long, long long> h2md_logr[100000][19]; long long dist_log[100000][19]; long long h[100000]; int max_2h_minus_d(int from, int to, int dir, long long& dist, long long& alldi... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; int main(void) { ios_base::sync_with_stdio(false); int N; cin >> N; long long minx = inf, maxx = -inf, miny = inf, maxy = -inf; vector<pair<long long, long long>> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]... |
#include <bits/stdc++.h> using namespace std; const long long int INF = LONG_LONG_MAX; const long long int NINF = LONG_LONG_MIN; const long long int mmod = 998244353; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); long long int t; cin >> t; while (t-- > 0) { long long int ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; long long mod = 1000000007; vector<long long> gr[200001]; vector<long long> grev[200001]; long long a[200005]; void solve() { long long n, d, a, b; cin >> n >> d >> a >> b; vector<pair<long long, long long> > ans; for ... |
#include <bits/stdc++.h> using namespace std; int n, d[55], f[2][55][55][55][55]; int main() { register int i, p1, p2, c1, c2, cur = 0, val; scanf( %d , &n); for (i = 1; i <= n; ++i) scanf( %d , &d[i]); f[cur][d[1] == 2][d[1] == 3][d[2] == 2][d[2] == 3] = 1; for (i = 3; i <= n; ++i) { cu... |
#include <bits/stdc++.h> using namespace std; const int N = int(2e5) + 9; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int n = s.size(); int m1 = 0, m2 = 0; bool on = false; int n1 = 0, n0 = 0, N1 = 0, N0 = 0; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e4 + 50; const int INF = 1e8 + 100; int val[MAXN], vec[MAXN]; int dp[MAXN][100]; int n, t; bool check(int x) { return x == ((1 << 3) - 1); } int solve(int id, int suco) { if (check(suco)) return 0; if (id >= n) return (INF); if ... |
#include <bits/stdc++.h> using namespace std; string s1 = What are you doing at the end of the world? Are you busy? Will you save us? ; string s2 = What are you doing while sending ; string s3 = ? Are you busy? Will you send ; string s4 = ? ; long long M[100005]; char f(long long ... |
#include <bits/stdc++.h> using namespace std; int d[1503][1503][26], e[1503][26], z[1503][26]; int main() { ios::sync_with_stdio(false); int n, q, m; char c; string s; cin >> n >> s >> q; for (int i = 0; i < 26; i++) for (int j = 1; j <= n; j++) e[j][i] = e[j - 1][i] + (s[j - 1] == ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } int n, arr[109]; vector<int> odd, even; int main() { scanf( %d , &n); for (int i = 0; i < (int)(n); i++... |
#include <bits/stdc++.h> using namespace std; struct node { int data; long int sum; struct node *left, *right; struct node* next; }; struct node* newNode(int data) { struct node* Node = new (struct node); Node->data = data; Node->left = Node->right = Node->next = NULL; return (No... |
#include <bits/stdc++.h> using namespace std; int n, m; long long a[100001]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); scanf( %d , &m); int Left = 1; for (; m--;) { int x, y; scanf( %d%d , &x, &y); while (Left < x) { a[Left + ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; c ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, m, lim, p = 1, a[N], nex[N * 2], spot[N * 2], head[N], fa[N], f[N], g[N]; int maxcolor[N][2], c[N]; bool color[N], v[N]; void add(int x, int y) { nex[++p] = head[x], head[x] = p, spot[p] = y; nex[++p] = head[y], head[y] = p, ... |
#include <bits/stdc++.h> using namespace std; int n, m, b[101][101]; bool isHorrizontal() { int i, j; for (i = 0; i < n / 3; i++) { for (j = 0; j < m; j++) { if (b[i][j] != 1) return false; } } for (i = n / 3; i < (n - n / 3) / 2 + (n / 3); i++) { for (j = 0; j < m; j++) ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { ll a, b, c; cin >> a >> b >> c; ll x, y; if (a == c and b == 1) { cout << -1 -1 << n ;... |
#include <bits/stdc++.h> using namespace std; int grid[101][101]; int canDoRowOperation(int r, int c) { int m = 1000; for (int j = 0; j < c; j++) m = min(m, grid[r][j]); return m; } int canDoClmOperation(int r, int c) { int m = 1000; for (int i = 0; i < r; i++) m = min(m, grid[i][c]); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 100010; inline long long read() { long long p = 0; long long f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { p = p * 10 +... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s; scanf( %d%d , &n, &s); int a, max, sum = 0; scanf( %d , &a); max = a; sum += a; for (int i = 1; i < n; i++) { scanf( %d , &a); if (a > max) max = a; sum += a; } sum -= max; if (sum <= s) ... |
#include <bits/stdc++.h> using namespace std; int n; int pos[100005]; pair<int, long long> ai[4 * 100005]; void update_ai(int node, int l, int r, int pos, pair<int, long long> val) { if (l == r) { ai[node] = val; return; } int mid = (l + r) >> 1; if (pos <= mid) update_ai(2 *... |
#include <bits/stdc++.h> using namespace std; long long nx2(long long n) { long long p = 1; if (n && !(n & (n - 1))) return n; while (p < n) p <<= 1; return p; } namespace Debug { void dout() { cerr << n ; } template <typename Head, typename... Tail> void dout(Head H, Tail... T) { ce... |
#include <bits/stdc++.h> using namespace std; long long x, y, u = 0, v = 0; vector<pair<long long, long long> > visited; void move(char c) { if (c == U ) v++; else if (c == D ) v--; else if (c == L ) u--; else u++; } int main() { ios_base::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)5e5 + 123, inf = 1e9, mod = 1e9 + 7, M = 511; const long long INF = (long long)1e18; int n, m, k, x, y, d, t, e; long long A[M][M], a[2][M][M]; vector<pair<int, int> > ex[M][M], ey[M][M]; int main() { cin.tie(0); cout.tie(0); ios... |
#include <bits/stdc++.h> using namespace std; struct pt { double x, y; pt(const double &_x = 0.0, const double &_y = 0.0) : x(_x), y(_y) {} }; pt operator+(const pt &a, const pt &b) { return pt(a.x + b.x, a.y + b.y); } int n, m, id[102][5]; pt verts[500], radius, pent[2][5], centre; const double P... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<int, int>; using pll = pair<ll, ll>; vector<ll> primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; vector<int> v[30]; for (int i = 0; i < n; i++) { v[s[i] - 96].push_back(i); } int m; cin >> m; while (m--) { string a; cin >> a; int h[30] = {0}; for ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { string s, t; cin >> s >> t; int count = 0; int i = s.length() - 1; int j = t.length() - 1; while (s[i] == t[j] && i >= 0 && j >= 0) { i -= 1; j -= 1; count += 1; } cout << (s.leng... |
#include <bits/stdc++.h> using namespace std; int a[1010]; int main() { int n, i; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int ans = 0; int x; for (int i = 0; i < n; i++) { x = 1; if (a[i] >= 0) { ans++; for (int j = i + 1; j < n; j++) ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long tmp[1000005]; long long n; void get_tmp() { tmp[1] = -1; for (int i = 1; i <= n; i++) tmp[i + 1] = (tmp[i] + 1) * i % mod; } long long a[1000005]; int main() { cin >> n; get_tmp(); a[1] = 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; const int max_n = 100011, inf = 1000111222; const int mod = 1000000007; int n, m, fenv[333][333]; map<int, vector<pair<int, int>>> mp; pair<int, int> a[max_n]; int sum(int tt[], int r) { int result = 0; f... |
#include <bits/stdc++.h> using namespace std; const int64_t inf = (int64_t)1e18; vector<int64_t> a[2], g[2]; void dfs(int obj, int idx, int64_t cur) { if (idx == a[obj].size()) { g[obj].push_back(cur); return; } dfs(obj, idx + 1, cur); while (a[obj][idx] <= inf / cur) cur *= a[obj][i... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > ans; pair<int, int> ar1[2100]; int ar2[2100]; int n, x; long long anss = 0; void findPlace(int i); int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; ar1[i].first = x; } for (int i = 1; i <= n;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); char a[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = * ; int begin, end; begin = end = n / 2; for (int i = 0; i <= n / 2; i++) { for (int j = begin; j <= end; j++) a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c = 0, x; int max, min; cin >> n >> m >> min >> max; for (int i = 0; i < m; i++) { cin >> x; if (x > min && x < max) c++; if (x < min || x > max) return cout << Incorrect , 0; } if (c + 2 <= n) cout... |
#include <bits/stdc++.h> using namespace std; int ans, ansIndex, n, s, x, val, res = 2000000006; int main() { scanf( %d%d%d , &n, &s, &x); int nxt = s, m = min(800, n); for (int i = 0; i < m; i++) { printf( ? %d n , (rand() * 107 + rand()) % n + 1); fflush(stdout); scanf( %d %d , &va... |
#include <bits/stdc++.h> using namespace std; bool life[100005]; int num[100005]; int pre[100005]; int main() { int now = 0, temp = 0; int n; long long ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &num[i]); pre[i] = now; now = i; while (num[i... |
#include <bits/stdc++.h> using namespace std; bool func(char a, char b) { if (a + 1 == b - 1) return true; if (a + 1 == b + 1) return true; if (a - 1 == b - 1) return true; if (a - 1 == b + 1) return true; return false; } int main() { int t; cin >> t; while (t--) { int n; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; template <class T> typename T::value_type arr_sum(const T& v, int n) { typename T::value_type sum = 0; for (int i = (0); i < (n); ++i) sum += v[i]; return sum; } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.