func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct data { int info; int l, r; data() { info = 0; l = 0; r = 0; } }; data tr[100000 * 40]; int avail = 0; int update(int no, int s, int e, int in, int val) { int idx = no; if (!no) { idx = ++avail; tr[idx]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a; map<int, int> mp; for (int i = 0; i < n; i++) { int val; cin >> val; if (mp.find(val) == mp.end()) { mp[val]++; a.push_back(val); } } sort(a.begin(),... |
#include <bits/stdc++.h> using namespace std; long long int xpow(long long int a, long long int b) { if (b == 0) return 1; if (b % 2 == 0) { long long int k = xpow(a, b / 2); return k * k; } if (b % 2 != 0) return a * xpow(a, b - 1); } int main() { ios_base::sync_with_stdio(false... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; double a; int ans = 0; vector<int> v; int n, m; cin >> n; int ara1[n]; for (int i = 0; i < n; i++) cin >> ara1[i]; cin >> m; int ara2[m]; for (i... |
#include <bits/stdc++.h> using namespace std; const double pi(3.14159265358979); int a[100010], d[100010]; int main() { int x, i, j, n; scanf( %d , &n); scanf( %d , &x); for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n; i++) d[i] = abs(a[i] - x); int ans = 0; ... |
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { long long int n, i, j, k, f = 0; scanf( %lld , &n); long long int a[n]; for (i = 0; i < n; i++) scanf( %lld , &a[i]); for (i = 2; i < n; i++) { if (a[i] >= a[0] + a[1]) { f = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int v = 0; int ans = 0, ans1 = 0; for (int i = 0; i < n; i++) { int a; cin >> a; if (i < k - 1 && a != 0) ans1++... |
#include <bits/stdc++.h> using namespace std; template <class T> void pv(vector<T> &vec) { for (int i = 0; i < (int)(vec).size(); i++) cout << vec[i] << (i == (int)(vec).size() - 1 ? n : ); } bool ok(int x) { return (x % 10 == 7); } int main() { ios_base::sync_with_stdio(false); cin.... |
#include <bits/stdc++.h> using namespace std; const int sN = 1 << 19; long long v[sN], d[sN], l[sN], r[sN], s[sN], w[sN]; int n, m; int t, Left, Right; long long x; void down(int a, int c1, int c2) { d[c1] += d[a]; d[c2] += d[a]; s[c1] += d[a] * w[c1]; s[c2] += d[a] * w[c2]; d[a] = 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int inf = 0x3f3f3f3f; const int mod = 998244353; int a[N], n, L; bool check(double x, int id) { double s1 = 0, s2 = 0; double t = x; int s = 1; for (int i = 1; i <= n + 1; i++) { double cur = 1.0 * (a[i] - a[i ... |
#include <bits/stdc++.h> using namespace std; int n, i, j, v[1005]; char s[1005]; int main() { scanf( %d n , &n); scanf( %s , s + 1); s[0] = L ; s[n] = R ; for (i = 1; i <= n; ++i) { j = i - 1; while (s[j] != L ) { if (s[j] == R ) ++v[i]; --j; } in... |
#include <bits/stdc++.h> using namespace std; long long int max(long long int a, long long int b) { if (a < b) swap(a, b); return a; } long long int min(long long int a, long long int b) { if (a >= b) swap(a, b); return a; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ... |
#include <bits/stdc++.h> #pragma GCC optimize( -O3 ) using namespace std; void solve() { long long int n, k; cin >> n >> k; vector<long long int> a(n); for (long long int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); long long int ones = 0; vector<long long int> b; for ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, vector<T> V) { os << [ ; for (auto v : V) os << v << ; os << ] ; return os; } template <class T> ostream& operator<<(ostream& os, set<T> second) { os << { ; for (auto s : second)... |
#include <bits/stdc++.h> using namespace std; struct node { int a[2][2]; node() { a[0][0] = a[0][1] = a[1][0] = a[1][1] = 0; } int *operator[](const size_t &s) { return a[s]; } }; node segTree[400008], L[400008]; node id, M, zero; int a[100002]; int lazy[400008]; inline node operator+(node &... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long s = 1; for (long long i = 1; i <= n; i++) { s += (i - 1) * 4; } cout << s; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int a[N]; int main() { ios_base::sync_with_stdio(false); int n, U; cin >> n >> U; for (int i = 1; i <= n; ++i) cin >> a[i]; double ans = -1; for (int i = 1, j = 1; i + 1 <= n; ++i) { while (j + 1 <= n and a[j + ... |
#include <bits/stdc++.h> int main() { int q; std::cin >> q; while (q--) { int n, ans(0); std::cin >> n; std::set<std::string> check, p; std::string s; std::vector<std::string> res, a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; check.insert(a[i]);... |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; inline void smax(int &x, int y) { x = max(x, y); } inline void smin(int &x, int y) { x = min(x, y); } ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a % b)); } ll n, m, a, b; vector<vector<int... |
#include <bits/stdc++.h> using namespace std; vector<int> SEC; int main() { long long n, x, y; cin >> n >> x >> y; long long tedX = 0, tedY = 0; while (tedX + tedY < x + y) { if ((tedX + 1) * y > (tedY + 1) * x) { SEC.push_back(2); tedY++; } else if ((tedX + 1) * y < (t... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; struct Event { int x, type, ind; Event() {} Event(int x, int type, int ind) : x(x), type(type), ind(ind) {} bool operator<(const Event &other) const { return make_pair(x, type) < make_pair(other.x, other.type); } }; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pair<int, int>>; using vvi = vector<vi>; int Bit(int mask, int b) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; const int MAXN = -1; const int MOD = 1; const int INF = (int)(1e9); int sign(long long x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } vector<int> getB(vector<int> a, int n, int &s) { vec... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long T = 0; int f = 0; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) f |= c == - ; for (; c >= 0 && c <= 9 ; c = getchar()) T = T * 10 + c - 0 ; return f ? -T : T; } const double eps = 1e-7;... |
#include <bits/stdc++.h> using namespace std; struct child { long long v, p, d; }; child c[4123]; bool gone[4123]; int main() { int n; scanf( %d , &n); for (int i = 0; i < (int)(n); i++) { scanf( %lld%lld%lld , &c[i].v, &c[i].d, &c[i].p); } int ans = 0; vector<int> all; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, q, i; cin >> q; for (i = 0; i < q; i++) { cin >> n; if (n == 2) { cout << 2 << endl; } else if (n % 2 == 1) { cout << 1 << endl; } else if (n != 2 && n % 2 == 0) { cout << 0 << endl; ... |
#include <bits/stdc++.h> using namespace std; int n, mnPre[(100005)], mxPre[(100005)], mnSuf[(100005)], mxSuf[(100005)]; pair<int, int> a[2][(100005)]; long long solve(int ax) { sort(a[ax] + 1, a[ax] + 1 + n); for (int i = 1; i <= n; ++i) { mnPre[i] = min(mnPre[i - 1], a[ax][i].second); mxPr... |
#include <bits/stdc++.h> using namespace std; long long int M = 1000000007; long long int min(long long int a, long long int b, long long int c, long long int d) { long long int arr[4] = {a, b, c, d}; sort(arr, arr + 4); return arr[0]; } long long int max(long long int a, long ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int solver(string s) { if (s.length() == 1) { if (s == 0 ) return 1; if (s == _ ) return 1; else return 0; } if (s[0] == 0 ) { return 0; } if (s.back() == _ ) { int ans = ... |
#include <bits/stdc++.h> using namespace std; const int N = 500010; int ans[N], arr[N], MAX[N]; long long power_mod(long long x, long long y) { x %= 1000000007; long long res = 1; while (y) { if (y & 1) { res = (res * x) % 1000000007; } y /= 2; x = (x * x) % 100000000... |
#include <bits/stdc++.h> using namespace std; int n, p[11111], c[11111]; vector<pair<int, int> > ve; int main() { int a; cin >> n; for (int i = 2; i <= n; i++) { cin >> a; c[i] = a; } int s = 1; cin >> p[1]; for (int i = 2; i <= n; i++) { cin >> p[i]; if (p[i]... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int INF = 2147483647; const int p[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67}; long long a[100][32], b[100][32]; int main() { int n; scanf( %d , &n); a[0][0] = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { set<long long> s; for (long long a = 1; a <= 2 * 1e9; a *= 2) { for (long long b = 1; b <= 2 * 1e9; b *= 3) { s.insert(a * b); } } int l, r, ans = 0; cin >> l >> r; for (set<long long>::iterator it = s.begin(); it... |
#include <bits/stdc++.h> using namespace std; const bool debug = 0; int main() { if (!debug) { cin.tie(0); cin.sync_with_stdio(0); cout.tie(0); cout.sync_with_stdio(0); } int n, m; cin >> n >> m; vector<vector<int>> d(m, vector<int>(n)); for (int i = 0; i < m; i++) ... |
#include <bits/stdc++.h> using namespace std; namespace IO { inline char gc() { static char buf[1000000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> inline void read(T &x) {... |
#include <bits/stdc++.h> using namespace std; int main() { long int t; cin >> t; while (t--) { long long n; cin >> n; unordered_map<int, long long> mmap; while (n % 3 == 0) { mmap[3]++; n /= 3; } while (n % 2 == 0) { mmap[2]++; n /= 2; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 58; vector<int> adj[maxn], V; bitset<maxn> mark; void dfs(int v) { mark[v] = 1; V.push_back(v); for (auto u : adj[v]) { if (!mark[u]) { dfs(u); V.push_back(v); } } } int main() { ios::sync_... |
#include <bits/stdc++.h> const int N = 123456; int arr[N], i, j; using namespace std; int main() { long long n, k, a, b, ans1 = 0, ans2 = 0, ans = 0; scanf( %lld %lld , &n, &k); scanf( %lld %lld , &a, &b); ans1 = (n - 1) * a; if (k == 1) return cout << ans1 << endl, 0; while (n != 0 && n... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const int maxk = 17; struct TNode { int L, R; int lc, rc; int sum; bool sw; TNode(int L = 0, int R = 0) : L(L), R(R), lc(-1), rc(-1), sum(0), sw(false) {} }; TNode t[3 * maxn]; int tc = 0; int build(int L, int R) ... |
#include <bits/stdc++.h> using namespace std; int A[200005]; int lazy[600005], ma[600005], mi[600005]; long long sum[600005]; void push_up(int cur) { sum[cur] = sum[cur * 2] + sum[cur * 2 + 1]; ma[cur] = max(ma[cur * 2], ma[cur * 2 + 1]); mi[cur] = min(mi[cur * 2], mi[cur * 2 + 1]); } void pus... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while ( 0 <= c && c <= 9 ) { x = x * 10 + c - 0 ; c = getchar(); } return x * f; } int n, m,... |
#include <bits/stdc++.h> using namespace std; const int N = 100; double pr[10][N][N], p[N][N], dp[10][N][N]; int n; int main() { double ans = 0; cin >> n; for (int i = 0; i < (1 << n); i++) for (int j = 0; j < (1 << n); j++) cin >> p[i][j], p[i][j] /= 100; for (int i = 0; i < (1 << n); i... |
#include <bits/stdc++.h> inline void in(int &MAGNUS) { scanf( %d , &MAGNUS); } inline void out(int MAGNUS) { printf( %d n , MAGNUS); } inline void in(int &MAGNUS, int &CLAR) { scanf( %d%d , &MAGNUS, &CLAR); } inline void out(int MAGNUS, int CLAR) { printf( %d %d n , MAGNUS, CLAR); } inline void inl(long long ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e7 + 7; const int Mx = (int)1e7; int n, m; int A[N], B[N]; int lp[N]; map<int, vector<int> > a, b; void precalc() { for (int i = 2; i <= Mx; i++) { if (!lp[i]) { lp[i] = i; if (i * 1ll * i <= Mx) { for ... |
#include <bits/stdc++.h> int f[100001]; int a[100001]; using namespace std; int main() { bool isAm = false; long long int n, m, x; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; if (f[x] == 0) f[x] = i + 1; else f[x] = -1; } for (int i = 0; i < m... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; long long binpow(long long base, long long exp, int mod) { long long res = 1; while (exp... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; struct abc { int left, right, capacity, cost; } edge[12345]; int n, k, x, e = 0, cost[50], p[50]; void addEdge(int a, int b, int c, int d) { edge[e].left = a; edge[e].right = b; edge[e].capacity = c; edge[e].cost = d;... |
#include <bits/stdc++.h> using namespace std; int Month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int A[1000 + 1]; int B[126]; void omae_wa_mou_shindeiru() { int n, k; cin >> n >> k; string s; cin >> s; for (int i = 0; i < n; ++i) { int c = 1; while (s[i] == s[... |
#include <bits/stdc++.h> using namespace std; long long w, j, i, m, n, a[2005][2005], k; vector<int> v[2010]; int main() { scanf( %d %d , &m, &n); for (i = 1; i <= m; i++) { a[i][1] = 1; } for (i = 1; i <= m; i++) { for (j = 1; j * j <= i; j++) { if (i % j != 0) continue; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i; while (cin >> i) { if (i % 2) cout << 1 << endl; else cout << 2 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxN = 1e5 + 10; int n, m, s, f; int t[maxN], l[maxN], r[maxN]; bool inside(int l, int m, int r) { return l <= m && m <= r; } void slv() { int d = f > s ? 1 : -1; m++; t[m] = inf, l[m] = inf, r[m] = -inf; i... |
#include <bits/stdc++.h> using namespace std; int n, m; string s[55]; vector<int> getRow(int x) { vector<int> R; for (int i = 1; i <= m; i++) if (s[x][i] == # ) R.push_back(i); return R; } vector<int> getCol(int x) { vector<int> C; for (int i = 1; i <= n; i++) if (s[i][x] ==... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int const nmax = 200000; struct Person { int cost; int number; bool operator<(Person const &a) const { return number < a.number; } }; Person v[1 + nmax]; void solve() { int n; cin >> n; for (int i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; int times[50] = {0}; int graph[50][50] = {0}; void findMissing(int n, int &temp1, int &temp2) { bool condition = false; for (int i = 0; i < n; i++) { if (times[i] != (n - 1)) { if (condition) temp2 = i; else { temp1 ... |
#include <bits/stdc++.h> using namespace std; int n, m; int mp[500][500]; int rSum[500][500], cSum[500][500]; int dSumF[500][500], dSumB[500][500]; int blacks(int r1, int c1, int r2, int c2) { int ans = 1; if (r1 == r2 && c1 == c2) { ans = 1; } else if (r1 == r2) { if (c2 > c1) { ... |
#include <bits/stdc++.h> using namespace std; const string FILENAME = input ; vector<pair<int, int> > best; vector<int> a; int main() { int n, m; cin >> n >> m; vector<int> has(2 * n, 0); vector<int> pr(2 * n, -1); vector<pair<int, int> > next(2 * n, {0, 0}); for (int i = 0; i < 2 * n... |
#include <bits/stdc++.h> using namespace std; int main() { int t, k, i, j; bool flag, flag1, final_flag; string p, q; cin >> t; for (i = 0; i < t; i++) { map<char, int> m; final_flag = false; cin >> p >> q; for (j = 0; j < p.size(); j++) { if (m.find(p[j]) == m.en... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long oo = 1e18; const long long mod = 1e9 + 7; const int INF = 1 << 30; vector<pair<pair<int, long long>, int>> adj[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0); int n, m, ... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1E-9; const int INF = (int)1E9; const long long INF64 = (long long)1E18; const long double PI = 2 * acos(.0); int n, k; string number; int repla2[11]; string construct(int ind) { string resp = ; bool used[10005]; memse... |
#include <bits/stdc++.h> const int MOD = 998244353; int n, c, a[3005], cnt[3005], pw[3005], ipw1[3005], ans[3005]; inline int mval(int x) { return x >= MOD ? x - MOD : x; } inline void inc(int &x, int a) { (x += a) >= MOD && (x -= MOD); } inline void dec(int &x, int a) { x = mval(MOD + x - a); } inline int ... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } const int N = 1e5 + 7; const int xinc[] = {0, ... |
#include <bits/stdc++.h> using namespace std; int n; int num[100008]; int cnt1[100008]; int cnt2[100008]; int cnt; struct node { int s, t; } ans[100008]; bool cmp(node a, node b) { if (a.s == b.s) return a.t < b.t; return a.s < b.s; } int main() { scanf( %d , &n); for (int i = ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; bool ans = false; for (int i = 1; i <= n; ++i) for (int start = 0; start < n; ++start) { int jump = 0; int cur = start; while (cur < n && s[cur] == * ) { ... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const double eps = 1e-10; const long long inf = 0x3f3f3f3f3f3f3f3fLL; const long long N = 2e5 + 5; const long long MOD = 1e9 + 7; long long pw(long long b, long long p) { long long res = 1; while (p > 0) { if (p & 1) res = r... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; long long n, m, a, d; long long t[N]; int main() { cin >> n >> m >> a >> d; for (int j = 1; j <= m; j++) { scanf( %lld , &t[j]); } t[m + 1] = 8e18; long long i = 1, ans = 0, last = -1; for (int j = 1; j <= m + 1;... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double esp = 1e-8; const int msz = 10000; const int mod = 1e9 + 7; struct Tr { char s[26]; int len, l; }; Tr s[111]; bool vis[26]; int main() { char str[1111]; int n, ans; scanf( %d , &n); for (in... |
#include <bits/stdc++.h> using namespace std; const int N = 1e1 + 5; int a[N][N], pos[N][N], last[N * N]; double ev[N * N], reg[N * N]; int main() { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { scanf( %d , &a[i][j]); if (i % 2 == 0) { pos[i][j] = 10 * i + j... |
#include <bits/stdc++.h> using namespace std; long long int n, m, cnt = 0, k, cntt = 0, cnts = 0; long long int v[100001]; bool vis[100001], ans[100001]; long long int cnte[100001]; int main() { cin >> n >> m; memset(vis, false, sizeof(vis)); memset(cnte, 0, sizeof(cnte)); for (int i = 1; i ... |
#include <bits/stdc++.h> int a, b, c, d, h; int main() { scanf( %d %d %d %d , &a, &b, &c, &d); h = a + 8 * c; if (h >= b) { printf( 0 ); return 0; } if (c <= d) { printf( -1 ); return 0; } printf( %d , (b - h) / (12 * (c - d)) + (((b - h) % (12 * (c - d... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; void solve() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } if (count(v.begin(), v.end(), 1) == 1) { cout << 0 << endl; return; } int s... |
#include <bits/stdc++.h> using namespace std; int cnt[1 << 14]; signed main() { ios_base ::sync_with_stdio(false); cin.tie(0); int n, k, maxn = 0; cin >> n >> k; for (int i = 0; i < n; ++i) { int a; cin >> a; maxn = max(maxn, a); ++cnt[a]; } long long ans = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { char s[1000]; gets(s); int a[1000] = {0}; for (int i = 0; i < strlen(s); i++) { if (s[i] <= z && s[i] >= a ) a[s[i]]++; } int m = 0; for (int i = 0; i < 1000; i++) if (a[i]) m++; cout << m; } |
#include <bits/stdc++.h> using namespace std; struct Lem { int m, v, id; bool operator<(Lem b) const { return m < b.m || (m == b.m && v < b.v); } }; int n, k, h; Lem a[(100000 + 10)]; bool can(long double t) { int j = k; for (int i(n - 1), _l(0); i >= _l; --i) { if (j > 0 && (long doub... |
#include <bits/stdc++.h> using namespace std; long long a[200000]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; long long prev = 0; long long last = 1e18; for (int i = 0; i < n / 2; ++i) { long long x; cin >> x; prev = max(prev, x ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; char a[N][N]; void fileIO() {} int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; fileIO(); int h, w; int tot = 0; cin >> h >> w; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++)... |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <cstdio> #include <utility> #include <queue> #include <math.h> #include <set> #include <bitset> #include <cmath> #include <bitset> #include <stack> #include <cstring> #include <deque> us... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; long long mod = 1e9 + 7; vector<long long> g[27]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s1, s2; cin >> s1 >> s2; long long n1 = s1.size(), n2 = s2.size(), i, j; for (i =... |
#include <bits/stdc++.h> using namespace std; int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; int n, m, k; bool isValid(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; int freex = -1, f... |
#include <bits/stdc++.h> using namespace std; int ar[30]; int br[30]; unordered_map<long, long> nm; int main() { std::ios::sync_with_stdio(false); ; int n; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> ar[i]; br[i] = ar[i]; nm[ar[i]] = i; } sort(ar, ar ... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } long long power(long long a, long l... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( -ffloat-store ) #pragma GCC optimize( -fno-defer-pop ) long long int power(long long int a, long long int b, long long int m) { if (b == 0) return 1; if (b == 1) ret... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 250 + 7; int a[MAXN][MAXN], ans[MAXN][MAXN]; bool rmax[MAXN * MAXN], cmax[MAXN * MAXN], vis[MAXN * MAXN]; bool canr[MAXN], canc[MAXN]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, d = 0; cin >> n >> a >> b; n = n - a; if (n <= b) { cout << n; } else { cout << b + 1; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long i, j, k, n, t, x, l, r, m; cin >> t; while (t--) { cin >> n; k = n / 2; long long sum = 0, y, cnt = 1; x = 3; y = 1; while... |
#include <bits/stdc++.h> using namespace std; using ll = long long; ll MOD = 1000000007; ll mod = 998244353; int inf = 1000001000; ll INF = 1e18 + 5; int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int t; cin >> t; for (int(_) = 0; (_) < (t); (_)++) { int n;... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int FFTMOD = 119 << 23 | 1; const int INF = (int)1e9 + 23111992; const long long LINF = (long long)1e18 + 23111992; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long sign = 1; long long x = 0; char ch; while (!isdigit(ch = getchar())) if (ch == - ) sign = -1; while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * sign; } inline void wonl() { putcha... |
#include <bits/stdc++.h> using namespace std; const int MX = 300000; const long long mod = 1e9 + 7; const long long inf = 1e18; long long a[MX + 5]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long tc, cs = 1, i, j, k, x, y, z, n, m; cin >> n; for (i = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int a[n], i, max = 0, f; for (i = 0; i < n; i++) scanf( %d , &a[i]); stack<int> s; for (i = 0; i < n; i++) { while (!s.empty()) { if (s.top() < a[i]) { f = s.top() ^ a[i]; s.p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n; cin >> n; while (n--) { long long int m; cin >> m; if (m % 3 == 0 || m % 7 == 0) cout << YES << endl; else { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; const int mod = 998244353; map<pair<int, int>, int> mp; pair<int, int> a[maxn], b[maxn]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].first, &a[i].second); for (int i = 1; i <= n; +... |
#include <bits/stdc++.h> int GCD(int u, int v) { while (v != 0) { int r = u % v; u = v; v = r; } return u; } int main() { int amtV; int amtE; std::vector<std::pair<int, int>> graph; std::cin >> amtV >> amtE; int connected = 0; int remaining = amtE; if (amt... |
#include <bits/stdc++.h> using namespace std; int dist(int x, int y) { if (y > x) return (y - x); else return (12 - x + y); } int main() { int i, j, q, r, t; string a, b, c; cin >> a >> b >> c; map<string, int> m; m[ C ] = 1; m[ C# ] = 2; m[ D ] = 3; m[ D# ] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long x, y, n, m, t, q, a, b, count = 0; cin >> n; long long arr[n]; for (x = 0; x < n; x++) cin >> arr[x]; long long cop[n]; for (x = 0; x < n; x++) cop[x] = arr[x]; s... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; using pii = pair<int, int>; using pll = pair<long long, long long>; using vb = vector<bool>; using vi = vector<int>; using vl = vector<long long>; using vvb = vector<vector<bool>>; using vvi = vector<vector<int>>; using vvl = v... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << fixed << setprecision(0) << powl(2, n + 1) - 2; } |
#include <bits/stdc++.h> 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); } inline int ones(int n) { int... |
#include <bits/stdc++.h> using namespace std; double eps = 1e-7; int main() { int t; double a, b, ans; scanf( %d , &t); while (t--) { scanf( %lf%lf , &a, &b); ans = 0.50000000; if (b < eps) { printf( %lf n , 1.0); continue; } if (a < eps) { pri... |
#include <bits/stdc++.h> #define ll long long #define II pair<int,int> #define fi first #define se second #define task test using namespace std; void Init(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); } int n; int a[200001]; int res; int d(II &a,II &b){ return ... |
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 128; int type[MAXN][MAXN]; constexpr char* pat[6] = { #//. , #. , .# , .//# , .... , #### }; int main() { int n, m, a, b, c, k, x, y; scanf( %d%d , &n, &m); scanf( %d%d%d , &a, &b, &c); k = 0; for (int i = 0; i <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.