func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() {} Point(double a, double b) { x = a; y = b; } Point operator+(Point who) { return {x + who.x, y + who.y}; } Point operator-(Point who) { return {x - who.x, y - who.y}; } Point operator/(double ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (((n + 1) % 4) > 1) cout << 1 << endl; else cout << 0 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long nInf = -1000000000; const long long pInf = 1000000000; const long long mod = 1000000007; const int MAXN = 3010; void getdata(); void preproc(); void solve(); vector<int> g[MAXN]; bool gr[MAXN][MAXN]; int n, m; int main() { int t =... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T mod_v(T num) { if (num >= 0) return num % 1000000007; else return (num % 1000000007 + 1000000007) % 1000000007; } template <class T> inline T gcd(T a, T b) { a = abs(a); b = abs(b); while (b) b ^= a ^= ... |
#include <bits/stdc++.h> using namespace std; int n, m; char matr[1010][1010]; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; bool Field(int x, int y) { if (x < 1 || x > n) return false; if (y < 1 || y > m) return false; return true; } int color[1010][1010]; int ans[1010][1010]; int... |
#include <bits/stdc++.h> using namespace std; const int N = 100, mod = 1e9 + 7; long long a[N], k, n; struct mat { int d[N][N]; mat() { memset(d, 0, sizeof d); } mat operator*(const mat& o) { mat p; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k ... |
#include <bits/stdc++.h> using namespace std; int op(int y) { if (y < 0) y = -y; return y; } int n, pos, l, r; int main() { cin >> n >> pos >> l >> r; if (l == 1 && r == n) { cout << 0; } if (l == 1 && r != n) { cout << op(r - pos) + 1; } if (l != 1 && r == n) { ... |
#include <bits/stdc++.h> using namespace std; int mn[1111]; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); for (int i = 0; i < m; i++) { mn[i] = 1e9; } for (int i = 0; i < n; i++) { int x, y; scanf( %d%d , &x, &y); --x; mn[x] = min(mn[x], y); } int... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long int MOD = 1e9 + 7; const int N = 1e6 + 6; int sum[N][3], prv[N][3]; int main() { int n; string s; cin >> n >> s; s = * + s; prv[0][0] = prv[0][1] = -1; for (int i = 1; i <= n; i++) { sum[i][0] ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > anom; long long int fact[200005]; long long int invfact[200005]; long long int MOD = 1000000007; long long int dp[2005][25]; long long int invmod(long long int i) { long long int ans = 1; long long int mult = i; long long in... |
#include <bits/stdc++.h> using namespace std; const int N = 150; const int M = 6e4 + 5; int n, m; struct Node { int a, b; } s[N]; bool cmp(Node a, Node b) { if (a.b > 0 && b.b < 0) return 1; if (a.b < 0 && b.b > 0) return 0; if (a.b > 0 && b.b > 0) return a.a < b.a; return a.a + a.b > ... |
#include <bits/stdc++.h> using namespace std; long long n, ans, k, cnt1[200010], cnt2[200010][10]; vector<long long> adj[200010]; long long sub(long long a, long long b) { return (a - b + k) % k; } void dfs(long long st, long long par, long long depth) { cnt2[st][depth % k] = 1; cnt1[st] = 1; for ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 233; struct item { int ini, num; } t[MAXN]; int vis1[MAXN] = {0}, vis2[MAXN] = {0}; int cg[MAXN] = {0}; int n; bool cmp1(const item &a, const item &b) { return a.num < b.num; } bool cmp2(const item &a, const item &b) { return a.i... |
#include <bits/stdc++.h> using namespace std; int n, arr[3], ans, a, b, c, ma, t; multiset<int> s; int main() { scanf( %d , &n); for (int i = 0; i < 3; i++) scanf( %d , arr + i); for (int i = 0; i < n; i++) { scanf( %d , &t); s.insert(t); ma = max(t, ma); } sort(arr, arr + ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; set<char> res; vector<char> ans; for (int i = 0; i < s.length(); i++) { if (s[i] == s[i + 1]) { i++; } else { char c = s[i]; ... |
#include <bits/stdc++.h> using namespace std; int x[1010], y[1010], cnt, _cnt; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) scanf( %d %d , &x[i], &y[i]); while (true) { int cnt = 0; for (int i = 1; i <= n; i++) if ((x[i] + y[i]) & 1 == 1) cnt++; if (cnt >= 1... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 123; const long double EPS = 1e-9; const int MX = 1e9 + 1; const int inf = 1e9 + 123; const int MOD = 1e9 + 7; const int N = 1e5 + 123; const int dx[] = {0, 0, 1, -1}; const int dy[] = {1, -1, 0, 0}; int n, m; long long dp[... |
#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; const int N = 1001; int i, j, n, ans; int a[N], f[N][300], d[20], sum[N][10]; void init() { d[1] = 1; for (i = 2; i <= 9; i++) d[i] = d[i - 1] * 2; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); for (i = 1; i <= n; i++) { f... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int a[MAXN], op[MAXN], op1[MAXN], op2[MAXN]; int n, m; vector<long long> sum[MAXN * 4]; set<int> col[MAXN]; vector<int> e[MAXN * 4]; void get(int o, int l, int r, int x, int y) { if (x <= l && r <= y) { e[o].push_back(x);... |
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 5; vector<int> adj[N]; int n, m, eu[N], ev[N], ew[N], a[N], b[N], g[N]; bool dfs1(int u, int t, int w, int p = -1) { if (u == t) { return 1; } for (int e : adj[u]) { int v = eu[e] ^ ev[e] ^ u; if (v == p) { ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000 * 1000 * 1000 + 7; long long mod(long long n) { n %= MOD; if (n < 0) return n + MOD; else return n; } long long fp(long long a, long long p) { long long ans = 1, c = a; for (long long i = 0; (1ll << i) <= ... |
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long arr[n][n]; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) cin >> arr[i][j]; } long long ans[n]; ans[2] = sqrt(arr[1][2] * arr[2][0] / arr[1][0]); ans[1] = arr[1][2... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, p, q, l, b = 0, i, d, m, n, k, sum = 0, t = 1, x = 0, z = 0, y = 0; vector<long long int> v; cin >> a; for (int i = 0; i < a; i++) { cin >> x; if (x > 0) { sum = sum + (x - 1... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, oo = 1e9 + 10, MOD = 1e9 + 7; void solve() { long long a, b; cin >> a >> b; if (a > b) { long long ans = 0; while (b != a) { b *= 2; ans++; if (b > a) { cout << -1 n ; return;... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; vector<long long> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } long long count = 0; for (int i = 0; i < m - 1; i++) { if (a[i] > a[i + 1]) { count++; } } cout... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000000007; const int maxn = 300010; int vis[maxn], cnt[maxn]; long long sum[maxn]; int mod(int x, int u) { int ret = 0; for (int i = 2; i <= u; ++i) if (vis[i]) { ret += x % i; } return ret; } long long ... |
/*-- ILSH --*/ #include bits/stdc++.h using namespace std; typedef long long ll; typedef double ld; #define pb push_back #define pop pop_back #define mp make_pair #define vii vector < ll > #define dt cout<< HERE n ; #define pii pair < ll , ll > #define vpi vector < pii > #define fi first #... |
#include <bits/stdc++.h> using namespace std; const int N = 2222; const long long INF = 1e9 + 19; const int ALF = 26; int n; string s[N]; vector<vector<int>> nextS[N]; int m; int id[N]; string t; pair<int, int> dp[N][N]; vector<vector<int>> nextT; pair<int, int> nextG[N][ALF]; void read() { ... |
#include <bits/stdc++.h> using namespace std; const long long int Maxn3 = 1e3 + 10; const long long int Maxn4 = 1e4 + 10; const long long int Maxn5 = 1e5 + 10; const long long int Maxn6 = 1e6 + 10; const long long int Maxn7 = 1e7 + 10; const long long int Maxn8 = 1e8 + 10; const long long int Maxn9 = 1e... |
#include <bits/stdc++.h> int main() { int n, a, sum; scanf( %d , &n); int k = 0; int arr[100]; for (int i = n - 9 * (log10(n) + 1 + 1); i <= n; i++) { sum = a = i; while (a != 0) { sum += a % 10; a /= 10; } if (sum == n) { arr[k++] = i; } }... |
#include <bits/stdc++.h> using namespace std; const int maxn = ((int)5e2) + 5; vector<string> str; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { string s; cin >> s; str.push_back(s); } ... |
#include <bits/stdc++.h> using namespace ::std; const long double PI = acos(-1); const long long MOD = 1000000000 + 7; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long add(long long a, long long b, long long m = MOD) { if (a >= m) a %= m; if (b >= m) b %= m; ... |
#include <bits/stdc++.h> using namespace std; void file() {} const int N = 1e5 + 5, MAX = 3e7, MOD = 1e9 + 7; int a[N]; int n, k; long long dp[N][12]; long long seg[4 * N][12]; void update(int indx, int l, int r, int pos, int who, long long val) { if (l == r) { seg[indx][who] = val; retu... |
#include <bits/stdc++.h> using namespace std; const long long LLmn = LLONG_MIN; const long long LLmx = LLONG_MAX; const long long MOD = 1e6 + 3; const long long N = 1e9 + 7; const long double PI = 3.14159265358979323846; long long gcd(long long a, long long b) { if (a == 0) { return b; } ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 5; const long long P = (479 << 21) + 1; const long long G = 3; long long wn[21]; inline long long fpw(long long x, long long y, long long m) { long long rtn = 1; for (x = (x >= m ? x % m : x); y; y >>= 1) { if (y & 1) rtn = ... |
#include <bits/stdc++.h> using namespace std; int mark[2000010 * 2]; int tree[2000010 * 4]; bool emerged[2000010 * 2]; void insert(int l, int r, int i, int ind, int num) { tree[ind] += num; if (l == r) return; int mid = (l + r) / 2; if (i <= mid) insert(l, mid, i, ind * 2, num); if (i > mi... |
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, y, n, sol = 0, energy = 0; cin >> n; for (int i = 1; i <= n; ++i) { cin >> y; energy += x - y; if (energy < 0) { sol = sol - energy; energy = 0; } x = y; } cout << sol; } |
#include <bits/stdc++.h> using namespace std; mt19937 rng(time(0)); uniform_int_distribution<int> uid(-1e9, 1e9); long double f[51]; vector<vector<vector<long double>>> dp; pair<long double, long double> solve(vector<int> v, int l, int r) { dp.assign(v.size() + 1, vector<vector<long double>>( ... |
#include <bits/stdc++.h> using namespace std; long long int fast_exp(long long int a, long long int b) { if (a == 0) return 0; if (b == 0) return 1; if (b == 1) return a; if (b % 2 == 0) { return fast_exp(((a % 1000000007) * (a % 1000000007)) % 1000000007, b / 2) % 1000000007; ... |
#include <bits/stdc++.h> using namespace std; long long A[10][10] = {}; void rec(long long x, long long y, long long n) { if ((n % 2) == 0) { A[x][y] = n + 1; } if (n == 0) return; else { long long arrx[] = {-2, 2}; long long arry[] = {-1, 1}; for (auto i : arrx) { ... |
#include <bits/stdc++.h> using namespace std; long long K = 1; int main() { vector<int> ma, v; int n, b, i, ans, x; cin >> n >> b; ans = b; v.resize(n); for (i = 0; i < n; i++) cin >> v[i]; ma.resize(n); ma[n - 1] = v[n - 1]; for (i = n - 2; i >= 0; i--) ma[i] = max(v[i], ma[i ... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; int n, m, vis[100005], in[100005], d[100005]; vector<int> e[100005]; int dfs(int i) { vis[i] = 1; int ans = 0; for (auto first : e[i]) { if (vis[first]) { ans = max(ans, d[first]); continue; } ... |
#include <bits/stdc++.h> using namespace std; bool is_opening(char c) { switch (c) { case ( : case [ : case { : case < : return true; break; case ) : case ] : case } : case > : return false; break; } } bool is_match_... |
#include <bits/stdc++.h> using namespace std; int num[5]; char board[5][10][55]; int p[] = {1, 2, 3, 0}; int main() { for (int i = 0; i < 4; i++) cin >> num[i], num[i]--; int cnt, ii, k; for (int i = 0; i < 4; i++) { for (int j = 0; j < 8; j++) for (k = 0; k < 50; k++) board[i][j][k]... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 250 + 10; const int INF = 0x7f7f7f7f; const int mod = 1000000007; const double eps = 1e-10; const double pi = acos(-1.0); inline int realcmp(double a, double b) { return (a > b + eps) ? 1 : ((a + eps < b) ? -1 : 0); } string s[1111]; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; char c = getchar(); bool f = 0; for (; !isdigit(c); c = getchar()) f ^= c == - ; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); x = f ? -x : x; } inline void readChar(char &c) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 2e18; const double PI = acos(-1.0); const double E = exp(1); const double EPS = 1e-8; const long long mod = 1e4 + 7; const int maxn = 3e5 + 5; void pre() { freopen( in.txt , r , stdin); freopen( o... |
#include <bits/stdc++.h> using namespace std; set<pair<int, int> > S; set<pair<int, int> >::iterator itr; int n, l, r, ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; while (n--) { cin >> l >> r; itr = S.lower_bound(make_pair(l, 0)); ++ans; ... |
#include <bits/stdc++.h> using namespace std; long long int dp[20][1 << 20]; long long int len[1 << 21] = {0}; std::vector<int> v[1000000]; int n; int r[21][21]; long long int solve(int last, int mask, int pa) { long long int sol = 0; if (r[last][pa] == 1 && len[mask] >= 3) { sol += 1; }... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 * 1000 + 7, MAX_LOG = 20; int n, m; vector<int> adj[MAXN]; bool isPassed[MAXN]; int par[MAXN][MAX_LOG], cycleCnt[MAXN], h[MAXN]; void pre(int root) { isPassed[root] = true; for (auto nei : adj[root]) { if (!isPassed[nei]) { ... |
#include <bits/stdc++.h> int n = 0, m = 0, a[100002], b[1000002], c[1000002]; int main() { while (scanf( %d , &n) != EOF) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); if (n == 0) continue; int max = 0; int p = 0, q = 0, k = 0; for (int i = 0; i < n; i++) { scan... |
#include <bits/stdc++.h> using namespace std; long long l, r, k; void go(long long x) { int i, j; long long y, z; for (i = 62; i >= 0; i--) { if (x & (1LL << i)) break; } if ((1LL << i) == x) { x++; } long long xx = x; xx &= ((1LL << i) - 1); y = (1LL << (i + 1)) | ... |
#include <bits/stdc++.h> using namespace std; int main() { int m; int count[200005][2]; cin >> m; while (m--) { int n, a, b; long long T; cin >> n >> T >> a >> b; vector<pair<int, int> > problems(n + 1); for (int i = 1; i <= n; i++) { cin >> problems[i].second; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long int> v; for (int i = 1; i <= n; i++) { long long int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end()); long long int total = 0; int cnt = 0; for (int i = 0; i < v... |
#include<bits/stdc++.h> #define ll long long #define MAX 1000006 #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a)*((b)/gcd(a,b))) using namespace std; //******************* my code starts here ********************************** int main() { int t; cin>>t; get... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 50; inline int rd(register int x = 0, register char ch = getchar(), register int f = 0) { for (; ch < 0 || ch > 9 ; ch = getchar()) f = ch == - ; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = (x << 1) + (x << ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, k; cin >> n >> k; int answer = 1; while (k % 2 == 0) { k /= 2; answer++; } cout << answer; return 0; } |
#include <bits/stdc++.h> using namespace std; struct STree { vector<int> st; int n; STree(int n) : st(4 * n + 5, 0), n(n) {} void upd(int k, int s, int e, int p, int v) { if (s + 1 == e) { st[k] = v; return; } int m = (s + e) / 2; if (p < m) upd(2 * k,... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[3001]; long long visited[3001][3001]; long long poss[3001]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m, k; cin >> n >> m >> k; pair<long long, long long> parent[n + 1][n + 1]; for (l... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 6; const long long MOD = 1e9 + 7; int a[56]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, cnt = 0, mn = 50; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; mn = min(mn, a[i... |
#include <bits/stdc++.h> using namespace std; using namespace std; struct sch { long long int s, e, t; }; bool sortinrev(const struct sch &a, const struct sch &b) { return (a.s < b.s); } vector<long long int> graph[200010]; vector<long long int> graphr[200010]; long long int vis[200010], visf[200010... |
#include <bits/stdc++.h> using namespace std; template <typename U, typename V> inline void smax(U &a, const V &b) { if (a < b) a = b; } const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; const int NN = 1010; int hd[NN]; int nx[NN << 1]; int to[NN << 1]; int ... |
#include <bits/stdc++.h> int N, M, K, MOD; int dp[200][200][200]; int C[200][200]; int fac[200]; __attribute__((optimize( -O3 ))) __attribute__((optimize( -O3 ))) __inline __attribute__((__gnu_inline__, __always_inline__, __artificial__)) int calc(int n, int m, int k) { if (n == 0) { if ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, b; cin >> n >> a >> b; long long int m = 0; for (long long int i = 1; i < n; i++) { long long int q = i; long long int w = n - i; long long int ca = a / q, cb = b / w; if (min(ca, cb) > m) m = min(... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int L, v, l, r, d; cin >> L >> v >> l >> r; if (r == l && r % v == 0) d = 1; else d = r / v - (l - 1) / v; cout << L / v - d << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? : ); return os; } template <class T> istream& operator>>(istream& is, vector<T>& v) { for (... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 100010; int n, k, m; int a[N]; int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; int cnt = 0; while (k > 0) { cnt += 1... |
#include <bits/stdc++.h> using namespace std; int vis[200005]; pair<int, int> seg[200005]; vector<pair<int, pair<int, int> > > v; int main() { ios::sync_with_stdio(0); cin.tie(0); long long m, n, i, j, t, x, y, w, k, l, r; cin >> n >> k; for (i = 0; i < n; i++) { cin >> l >> r; ... |
#include <bits/stdc++.h> using namespace std; long long niz[1000000]; long long kum[1000000]; int main() { ios_base::sync_with_stdio(false); cout.precision(10); cout << fixed; int n, s, f; cin >> n; for (int i = 1; i <= n; i++) { cin >> niz[i]; } cin >> s >> f; long lon... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 5; const long long int inf64 = 1e18 + 5; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, i; pair<long long int, long long int> fr; cin >> n; vector<pair<long long int, long long int> > v; cin >> fr.first... |
#include <bits/stdc++.h> using namespace std; void print(int x) { cerr << x; } void print(long x) { cerr << x; } void print(long long x) { cerr << x; } void print(unsigned x) { cerr << x; } void print(unsigned long x) { cerr << x; } void print(unsigned long long x) { cerr << x; } void print(float x) { c... |
#include <bits/stdc++.h> using namespace std; int main() { char str1[10], str2[10], str3[10]; int flag1, flag2, flag3; flag1 = 0; flag2 = 0; flag3 = 0; cin >> str1 >> str2 >> str3; if (strcmp(str1, str2) == 0) { flag1 = 1; } else if (strcmp(str2, str3) == 0) { flag2 = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[3010], x, y, c[100], d[100], n, l, r, time, count = 0, p, q, i, j; scanf( %d%d%d%d , &p, &q, &l, &r); memset(a, 0, sizeof(a)); while (p--) { scanf( %d%d , &x, &y); for (i = x; i <= y; i++) a[i]++; } for (i = 0; i < ... |
#include <bits/stdc++.h> std::priority_queue<std::pair<long long, int> > que; long long dis[2005]; int w[2005][2005]; int main() { int n, mn = 1e9; scanf( %d , &n); for (int i = 0; i < n - 1; i++) { for (int j = 1; j < n - i; j++) { int x; scanf( %d , &x); w[i][i + j] =... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; } long long ar[3]; void solve() { long long x, y, ans = 0; cin >> x >> y; ar[0] = ar[1] = ar[2] = y; while (ar[0] < x || ar[1] < x || ar[2] < ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; typedef class Point { public: double x, y; Point(double x = 0.0, double y = 0.0) : x(x), y(y) {} } Point, Vector; Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); } double cross(Vector u, Vector v) { ret... |
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define lli long long int #define llu unsigned long long int #define pb push_back #define rt return 0 #define endln n #define all(x) x.b... |
#include <bits/stdc++.h> using namespace std; long long make(long long n) { if (n % 4 == 3) return 0; if (n % 4 == 0) return n; if (n % 4 == 1) return 1; if (n % 4 == 2) return (n ^ 1); } int main() { long long n; cin >> n; long long i, nim = 0; for (i = 0; i < n; i++) { lo... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int p = 0; p < t; ++p) { int n; cin >> n; int d[2][n]; for (int i = 0; i <= 1; ++i) { for (int j = 0; j < n; ++j) cin >> d[i][j]; } if (n == 1) cout << 0 << endl; el... |
#include <bits/stdc++.h> using namespace std; const long long p = 1e9 + 7; struct aaa { long long x, y; } a[200010]; long long n, ans = 1, sz[500010], fa[500010], v[500010], fac[500010], aa[500010], bb[500010], cnt0, cnt1; map<long long, long long> mp0, mp1; long long find(long long x) ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, s; cin >> a >> b >> s; if (a < 0) a *= (-1); if (b < 0) b *= (-1); (s >= (a + b) && (s - a - b) % 2 == 0) ? cout << YES : cout << NO ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long n, x; cin >> n >> x; long long ans = 0; for (long long i = 1; i <= n; i++) { if (i * n >= x) { if (x % i == 0) ans += 1; } } cout << ans; return 0; } |
#include <bits/stdc++.h> int t, n, per[200001], where[200001]; int groupcnt; int main() { scanf( %d , &t); for (int test = 0; test < t; test++) { scanf( %d , &n); groupcnt = 0; for (int i = 1; i <= n; i++) { scanf( %d , &per[i]); where[per[i]] = i; } for (int ... |
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; int main() { int n, m, k; map<int, int> f1; cin >> n >> m >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; } bool f = false; sort(a, a + n); sort... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int n, a, b; while (scanf( %d , &n) != EOF) { v.assign(n, 0); for (int i = 0; i < n; i++) { scanf( %d , &v[i]); } sort(v.begin(), v.end()); a = 1; b = n - 1; while (a < n && v[a] =... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using str = string; using srt = short; const int INF = (int)1e9 + 4; const int MOD = (int)1e9 + 7; const int N = 1005; const ll inf = (ll)4e18; const ll mod = 998244353; bool us[N][N]; set<pair<in... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long n; scanf( %I64d , &n); printf( %I64d , n - n / 2 - n / 3 - n / 5 - n / 7 + n / (2 * 3) + n / (2 * 5) + n / (2 * 7) + n / (3 * 5) + n / (3 * 7) + n / (7 * ... |
#include <bits/stdc++.h> using namespace std; int row[300000]; int verts[300000]; int main() { long long int v, p = 0, h, input, answer = 0, tanswer = 1000000000; cin >> v >> h; row[0] = 0; verts[0] = 0; for (int i = 1; i <= v; i++) { cin >> verts[i]; } verts[v + 1] = 100000000... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; map<string, int> m; for (__typeof((n)) i = (0); i < (n); i++) { cin >> s; if (m[s]) cout << YES << endl; else cout << NO << endl; m[s]++; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; long long powr(long long exp) { if (exp == 1) return 2; if (exp % 2 == 0) { long long ret = (powr(exp / 2)) % 1000000007; ret = (ret * ret) % 1000000007; return ret; } long long ret = powr(exp / 2) % 1000000007; ret = (ret * ret * 2... |
#include <bits/stdc++.h> using namespace std; const int N = 101; const int BITS = 60; struct node { int son[2]; bool all; bool have; } f[N * 200 * 4]; int na, nb; int tot; vector<pair<int, int> > d[BITS + 1]; void ins(long long l, int bits, int s, long long ll, long long rr) { if (l + ... |
#include <bits/stdc++.h> using namespace std; bool isv(char x) { if (x == a || x == e || x == i || x == o || x == u ) return true; return false; } int main() { ios::sync_with_stdio(0); long long c, a, b, act; cin >> c; cin >> a >> b; act = max(a, b); --c; while (c--)... |
#include <bits/stdc++.h> using namespace std; const int MAXn = 2e5 + 3; const long long INF = 1e15 + 1; long long t[4 * MAXn], sum[MAXn], lazy[4 * MAXn]; int id[MAXn]; void Build(int v, int l, int r) { lazy[v] = 0; if (l == r) { t[v] = sum[l]; return; } int mid = (r + l) / 2; ... |
#include <bits/stdc++.h> using namespace std; long long n, tmp1, tmp2, q; string s, t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> q; for (int rr = 0; rr < q; rr++) { cin >> n >> s; tmp1 = 0, t = ; while (s[tmp1] == 0 && tmp1 < n) { ... |
#include <bits/stdc++.h> using namespace std; using Int = long long; int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0); vector<int> state; void makemove(vector<int>& A) { if (A.empty()) { cout << 0 << endl; exit(0); } else { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { int k; cin >> k; bool ok = true; int pa = 0, pb = 0; for (int j = 0; j < k; ++j) { int a, b; cin >> a >> b; if (a < pa || b < pb) ok = false; ... |
#include <bits/stdc++.h> const int int_reme = 2147483647; const int log21e9_reme = 30; const int maxn = 2e5 + 10; const long long mod = 1e9 + 7; const int INF = 0x3f3f3f3f; using namespace std; char DATA[maxn], duizhao[maxn]; int main() { int t; scanf( %d , &t); while (t--) { int n; ... |
#include <bits/stdc++.h> using namespace std; const unsigned long long mod1 = 1000000007; const unsigned long long mod2 = 1073676287; const unsigned long long base1 = 1000000033; const unsigned long long base2 = 1190494759; vector<unsigned long long> base_pow(1000009); int main() { ios_base::sync_with... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.