func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i++) o << << v[i]; return o << endl; } template <typename U, typename V> ostream &operator<<(ostream &o, pair<U, ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, case1, case2, case3, case4; cin >> a >> b >> c >> d; case1 = abs(pow(a, 2) + pow(b, 2) - pow(c, 2)) - 2 * a * b; case2 = abs(pow(a, 2) + pow(b, 2) - pow(d, 2)) - 2 * b * a; case3 = abs(pow(a, 2) + pow(c, 2) - pow(d, 2)) -... |
#include <bits/stdc++.h> using namespace std; int n; int cnt[10000001] = {}; int par[10000001], ra[10000001]; void dsuInit() { for (int i = 0; i < (int)(10000001); ++i) par[i] = i, ra[i] = cnt[i]; } int dsuParent(int v) { if (v == par[v]) return v; return par[v] = dsuParent(par[v]); } void... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; map<long long, long long> pos, icon; void read() { cin >> n >> m >> k; for (long long i = 1; i <= n; i++) { long long temp; cin >> temp; pos[temp] = i; icon[i] = temp; } } void solve() { long long ans = ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char g[s.length()]; int j = 0; for (int i = 2; i < s.length(); i++) { if (s[i] == s[i - 1] && s[i - 1] == s[i - 2] && s[i] != 0 ) { s[i - 2] = 0 ; char cc = s[i]; while (i + 1 < s.lengt... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; if (n == 1) { cout << 0 << endl; return 0; } if (n == 2) { cout << 1 n1 2 n ; return 0; } cout << (n / 2) * (n / 2 + n % 2) << endl; for (i = 1; i <= n / 2; i++) for (j = ... |
#include <bits/stdc++.h> using namespace std; vector<long long> translate; long long get(long long x) { return lower_bound(translate.begin(), translate.end(), x) - translate.begin(); } int main() { ios_base::sync_with_stdio(0); long long n; cin >> n; if (n == 1) { cout << 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int k = 4 * n; for (int i = 0; i < n; i++) { cout << k << ; k -= 2; } cout << endl; } } |
#include <bits/stdc++.h> using namespace std; const string st = AHIMOTUVWXY ; string s; int main() { ios::sync_with_stdio(0); cin >> s; int n = s.size(); for (int i = 0; i <= n - 1; ++i) if (st.find(s[i], 0) == -1) { cout << NO ; return 0; } string s1 = s; r... |
#include <bits/stdc++.h> const int md = 1e9 + 7; const long long hs = 199; const long double eps = 1e-9, pi = acos(-1); using namespace std; struct node { int val, x, y; node(int _v = -1, int _x = -1, int _y = -1) { val = _v, x = _x, y = _y; } }; struct query { int t, x, y; query(int _t = ... |
#include <bits/stdc++.h> int main() { char s[10000]; int a, b, i; scanf( %d n , &b); for (i = 0; i < b; i++) { gets(s); a = strlen(s); if (a > 10) printf( %c%d%c n , s[0], a - 2, s[a - 1]); else printf( %s n , s); } return 0; } |
#include <bits/stdc++.h> using namespace std; bool forms(long long a, long long b, long long c) { if ((a * a) + (b * b) == (c * c)) return true; return false; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t, n; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int inf = 0x3f3f3f3f; inline long long read() { register long long x = 0, f = 1; register char c = g... |
#include <bits/stdc++.h> using namespace std; template <class T> int chkmax(T& a, T b) { if (b > a) { a = b; return 1; } return 0; } template <class T> int chkmin(T& a, T b) { if (b < a) { a = b; return 1; } return 0; } template <class iterator> void out... |
#include <bits/stdc++.h> using namespace std; void ans(int n, int p) { if (n == 5) { assert(p == 0); for (int i = int(1); i <= int(n); i++) { printf( %d %d n , i, i + 1 > n ? i + 1 - n : i + 1); printf( %d %d n , i, i + 2 > n ? i + 2 - n : i + 2); } return; } int ... |
#include <bits/stdc++.h> using namespace std; int n, f[1000005]; long long ans, las; int gets() { int v = 0; char ch; bool f = 0; while (!isdigit(ch = getchar())) if (ch == - ) f = 1; v = ch - 48; while (isdigit(ch = getchar())) v = (v << 1) + (v << 3) + ch - 48; return f ? -v... |
#include <bits/stdc++.h> using namespace std; int n, c, d; const int maxn = 3456789; const long double PI = acos((long double)(-1.0)); const long double eps = 1e-18; long double ang[maxn]; int main() { while (cin >> n >> c >> d) { for (int i = 0; i < (n); i++) { int r, w; scanf( ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long linf = (long long)1e18; const double eps = (double)1e-8; const int mod = (int)1e9 + 7; const int maxn = (int)3e5 + 5; int n, m; vector<int> a[maxn]; int fl; int c[maxn]; vector<int> ta, tb; set<pair<int, int>... |
#include <bits/stdc++.h> const int MAXN = 1000 + 10; int n; std::set<int> g[MAXN]; std::vector<std::pair<int, int> > process(bool ty) { std::vector<std::pair<int, int> > ans; for (int i = 2; i < n; i++) { while (!g[1].count(i + 1)) { int k = *std::next(g[1].find(i)); assert(g[i].co... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ax, ay, bx, by, cx, cy; cin >> n >> ax >> ay >> bx >> by >> cx >> cy; if (bx > ax) { if ((by > ay) && ((cx > ax) && (cy > ay)) || (by < ay) && ((cx > ax) && (cy < ay))) { cout << YES ; return 0; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ori[300][300], mat[300][300], mr[300], mc[300], vis[100000], l[100000], r[100000]; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %d , &ori[i][j]); for (int i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; int n, k; int a[12000], dp[1100][1100], f[1100]; int ans; void work() { int i, j, l, o, last; scanf( %d%d , &n, &k); dp[0][0] = 1; f[0] = 1; for (i = 1; i <= n; i++) { scanf( %d , &a[i]); for (j = k; j >= a[i]; j--) { if (f[... |
#include <bits/stdc++.h> using namespace std; char S[77777]; char T[77777]; char CET[77777]; int fv[77777]; inline int back(int point, int lenT, int lenS) { if (point == lenT + 1) { return 1; } int start; if (point == lenS) { start = T[point] - a + 2; } else { start =... |
#include <bits/stdc++.h> using namespace std; string s; int len; int ans, tmp; void input() { cin >> s; } void solve() { len = s.length(); for (int i = 0; i < len; i++) { for (int j = i + 1; j < len; j++) { tmp = 0; while (s[i + tmp] == s[j + tmp]) tmp++; if (tmp > ans)... |
#include <bits/stdc++.h> using namespace std; long long int dp[(1ll << 19)][19]; long long int n, T; long long int t[19], g[19]; long long int ans = 0; long long int solve(long long int mask, long long int cnt, long long int last) { if (cnt > T) return 0; if (cnt == T) return 1; if (dp[mask][las... |
#include <bits/stdc++.h> using namespace std; template <class T> __inline__ __attribute__((always_inline)) T read() { T x = 0, w = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) w = -w; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * w; } t... |
#include <bits/stdc++.h> using namespace std; const long long N = 998244353; const long long mod = 1e9 + 7; long long binpow(long long b, long long p) { long long ans = 1; while (p > 0) { if (p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1; } return ans; } long lon... |
#include <bits/stdc++.h> int main(int argc, char *argv[]) { int a1, a2, a3, x; scanf( %d%d%d , &a1, &a2, &a3); x = a2; --a3; while (a3--) { x = a1 + a2; a1 = a2; a2 = x; } printf( %d n , x); return 0; } |
#include <bits/stdc++.h> int power_ten(int n) { int digits = 0; while (n >= 10) { n = n / 10; digits = digits + 1; } n = 1; while (digits > 0) { n = n * 10; digits = digits - 1; } return n; } int next_number(int sum, int count) { if (count == 1) { retu... |
#include <bits/stdc++.h> using namespace std; long long KK = 998244353; int main() { long long n; cin >> n; string a; long long cont = 1; cin >> a; if (a[0] != a[n - 1]) { cont += 2; for (int i = 1; i < n; i++) { if (a[i] == a[i - 1]) { cont++; } else ... |
#include <bits/stdc++.h> using namespace std; int main() { string p; cin >> p; int n; cin >> n; bool a = false, b = false; while (n--) { string s; cin >> s; if (s == p) { a = true; b = true; } if (s[0] == p[1]) a = true; if (s[1] == p[0]) b... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) positive = 0; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - 0 ; return positive ? x : -x;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int can[maxn][maxn]; int p[maxn]; int main() { ios ::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> p[i]; char k; for (int i = 1; i <= n; i++) for (int j = 1; j <= n;... |
#include <bits/stdc++.h> using namespace std; void solve() { long n, ans = 0; long count = 0; cin >> n; string s; cin >> s; while (s.size() && s[0] == s.back()) { count++; s.pop_back(); } if (s.empty()) { if (count <= 2) { cout << 0 << endl; return... |
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } using ll = long long; using R = long double; const R EPS = 1e-9L; inline i... |
#include <bits/stdc++.h> using namespace std; inline void minimize(int &x, int y) { x = min(x, y); } inline void maximize(int &x, int y) { x = max(x, y); } const int N = 200000 + 1067; int n, m; int val[N], pos[N], it[N], res[N]; vector<int> to[N]; struct Node { int id, a; } node[N]; bool comp(N... |
#include <bits/stdc++.h> using namespace std; const int maxn = 30; int n, k; long long s, ans, a[maxn], fac[maxn]; map<long long, long long> mp[maxn]; void dfs1(int x, int usd, long long now) { if (x == n / 2 + 1) { if (mp[usd].find(now) == mp[usd].end()) mp[usd].insert(make_pair(now, 1));... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : (-x); } template <class T> T sqr(T x) { return x * x; } const int maxn = 57; char ty[maxn][maxn]; bool allow[300]; int d[maxn][maxn]; int f[maxn][maxn]; int n, m, k; int sx, sy, fx, fy; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> inline string toStr(T x) { stringstream st; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int ar[5][5]; for (int i = 1; i <= 4; i++) for (int j = 1; j <= 4; j++) cin >> ar[i][j]; int f = 0; if (ar[1][4] && (ar[3][2] || ar[2][1] || ar[1][3] || ar[1][2] || ar[1][1] || ar[4]... |
#include <bits/stdc++.h> using namespace std; long long read() { long long t = 0, f = 1; char c = getchar(); while (!isdigit(c)) f = c ^ 45, c = getchar(); while (isdigit(c)) t = (t << 1) + (t << 3) + (c ^ 48), c = getchar(); return f ? t : -t; } const long long N = 5021, inf = 1e18; long ... |
#include <bits/stdc++.h> using namespace std; vector<int> isbandyk(int a, vector<int> prad) { vector<int> rez; vector<int> ats(prad.size(), -1); int pas = 0; for (int i = 0; i < prad.size(); i++) { if (prad[i] <= a - 1) { rez.push_back(prad[i]); pas = i; ats[i] = 1; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long arr[n]; vector<long long> prime... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); string str; cin >> str; bool flag = false; for (int i = 0; i < str.size(); i++) { if (str[i] == H || str[i] == Q || str[i] == 9 ) { flag = true; break; } } if (flag) ... |
#include <bits/stdc++.h> using namespace std; const int MX = (1 << 20); priority_queue<pair<int, int> > Q[MX]; string str; int n, K; int main() { cin >> str >> K; n = str.size(); int cur = 0; for (int j = 0; j < n; j++) Q[0].push(make_pair( z - str[j], j)); while (1) { while (cur ... |
#include <bits/stdc++.h> const int MAXN = 100005; using namespace std; int n, m, q, v, u, a; vector<int> E[MAXN], c[MAXN]; int L[MAXN], P[MAXN][17], M[MAXN][17][10], res[20], aux[20], cc[10]; void dfs(int cur, int prev) { P[cur][0] = prev; L[cur] = L[prev] + 1; for (auto to : E[cur]) if (t... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { long long d; cin >> d; long long dis = d * d - 4 * d; if (dis < 0) { cout << N n ; continue; } else { double sq = sqrt(dis); double b = (d + sq)... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; long double PI = 3.14159265358979323846; using ll = long long; const ll modo = 1000000000; const ll inf = LONG_LONG_MAX; const ll ms = (2e6) + 5; ll peil(ll a, ll b) { if (a % b) return a / b + 1; return a / b; } long... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k, t; long long a[200045]; long long b[200045]; long long c[100001]; long long d[100001]; long long e[1000001]; pair<long long, long long> aa[1000... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > mas[2]; int a[(int)1e5 + 10], b[(int)1e5 + 10]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; int a = abs((x + y) % 2); mas[a].push_back({(x + y - a) / 2, (x - y - a) ... |
#include <bits/stdc++.h> using namespace std; bool compare(const pair<int, int>& i, const pair<int, int>& j) { return i.first < j.first; } int main() { string r, s; cin >> r >> s; vector<int> v; if (r.length() != s.length()) { cout << NO << n ; return 0; } ... |
#include <bits/stdc++.h> int main() { char n[100]; scanf( %s , n); int l = strlen(n); int t = 0; for (int i = 0; i < l; i++) { if (n[i] == 4 || n[i] == 7 ) { t += 1; } } if (t == 4 || t == 7) { printf( YES ); } else { printf( NO ); } } |
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> m1, m2, m3; int n, m; cin >> n >> m; int a, b, c; for (int i = 0; i < m; i++) { cin >> a >> b >> c; if (m1[a] == 0 && m1[b] == 0 && m1[c] == 0) { m1[a] = 1; m1[b] = 2; m1[c] = 3; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x = 0; cin >> n; char ch[n]; for (int i = 0; i < n; i++) { cin >> ch[i]; } cout << n + 1 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int const sqN = 320; int add(int a, int b); int sub(int a, int b); int arr[100005]; struct query { int index; int l; int r; int ans; }; bool comp(query &a, query &b) { if (a.l / sqN != b.l / sqN) { return a.l / sqN < b.l / sqN; ... |
#include <bits/stdc++.h> using namespace std; int n, i, j, k, t; string s, m; int main() { cin >> s >> n; for (i = 0; i <= s.length(); i++) { if (s[i] != _ && isupper(s[i])) s[i] = tolower(s[i]); if (s[i] == o ) s[i] = 0 ; else if (s[i] == l || s[i] == i ) s[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { vector<stack<int> > vs; int maxi = -1, maximum = 0, nbVertices, n, type[100009], destination[100009], source[100009]; cin >> n; vs = vector<stack<int> >(n); for (int i = 0; i < n; ++i) { source[i] = 0; } for (int i ... |
#include<bits/stdc++.h> using namespace std; typedef long long int lli; const lli N = 1000009, K = z - a + 1; string s, t; lli n, k, a[K], b[K]; void Solve() { for(int i = 0; i < K - 1; i++) { while(a[i] > b[i] && a[i] >= k) { a[i] -= k; a[i + 1] += k; ... |
#include <bits/stdc++.h> const int N = (int)1e5 + 7; const int MOD = (int)1e9 + 7; const long long INF = (long long)1e18; using namespace std; bool solve(vector<int> &A, int n) { for (int i = 1; i < n; i++) { if (A[i] > A[i - 1]) { return true; } } for (int i = 1; i < n; i++) {... |
#include <bits/stdc++.h> using namespace std; int main() { string s, val = ><+-.,[] ; cin >> s; long long int size = 0; for (int i = 0; i < s.size(); i++) { size = (size * 16 + val.find(s[i]) + 8) % 1000003; } cout << size; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010; int n, m, l, r, k, a[MAXN], b[MAXN]; int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (a[i] <= m) { b[a[i]]++; } } r = n / m; l = 1; for (... |
#include <bits/stdc++.h> using namespace std; void JaiMataDi() { int n; cin >> n; string a, b; cin >> a >> b; int cnt = 0; for (int i = 0; i < n; i++) { if ((a[i] == 0 ) and (b[i] == 1 )) cnt += 2; else if ((a[i] == 1 ) and (b[i] == 0 )) cnt += 2; else i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:500000000 ) using namespace std; int main() { int n, i, s; scanf( %d %d , &n, &s); vector<int> a(n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } sort(a.begin(), a.end()); long long res = 0; int pos = n / 2; if (... |
#include <bits/stdc++.h> using namespace std; void sc(char& c) { char temp[4]; scanf( %s , temp); c = temp[0]; } struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; int testnum; int a, b; int lens[11]; v... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int mod = 1e9 + 7; const int M = 2010; pair<int, int> p[M]; int n, m, k, s, x, y, cnt; int fac[2 * N], inv[2 * N], K[30], f[M][30]; bool pd1, pd2; int Pow(int a, int b) { if (b == 0) return 1; int ret = Pow(a, b / 2); ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2200, MAX_K = 2200, INDEX = 1; int n, k, a[MAX_N + INDEX], books[MAX_K + INDEX]; int ans = 0; bool isBook(int x) { for (int i = 1; i <= k; i++) { if (books[i] == x) { return true; } } return false; } int dist(i... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); set<pair<string, int> > name, s; int n; cin >> n; string a; for (int i = 0; i < n; i++) { cin >> a; name.insert(make_pair(a, i + 1)); cin >> a; name.insert(make_pair(a, i + 1)... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int arr[n * n + 1], cnt[1001] = {0}, a[n + 1][n + 1]; vector<int> q4, q2, q1; for (int i = 1; i <= n * n; i++) { cin >> arr[i]; cnt[arr[i]]++; } for (int i = 1; i <= n * n; i++) { int d = cnt[... |
#include <bits/stdc++.h> using namespace std; bool compare(string &s1, string &s2) { return s1.size() < s2.size(); } bool sortmahstyle(const pair<int, int> &a, const pair<int, int> &b) { if (a.first < b.first) return true; return false; } long long int const maxm = 1e6; long long int const minm = -1... |
#include <bits/stdc++.h> using namespace std; int a[111][111]; int main() { int N, K, i, k; cin >> N >> K; if (K > N * N) puts( -1 ); else { for (i = 0; i < N && K; i++) for (k = i; k < N && K; k++) { if (K == 1) { if (i == k) a[i][k] = 1; ... |
#include <bits/stdc++.h> using namespace std; signed main() { std ::ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; string s; cin >> s; long long a[2] = {0}; for (long long i = 0; i < n; i++) a[s[i] - 48]++; if (a[0] == a[1]) { cout ... |
#include <bits/stdc++.h> using namespace std; int const INF = 100 + (int)1e9; long long const INFL = 100 + (long long)1e18; long double const PI = 3.141592653589793238462643L; mt19937 tw(960172); bool is_prime(long long x) { for (long long y = 2; y * y <= x; ++y) if (x % y == 0) return 0; retu... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; char s[N], t[N], S[N]; int n, ch[N][26], fa[N]; int len[N], anc[N], dif[N], nd, la; int ans[N], _ans[N], from[N]; void extend(int n) { int c = S[n], p = la; for (; S[n - len[p] - 1] != c; p = fa[p]) ; if (!ch[p][c - a ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, i, j, n, m, po1, po2, w1, w2, z1, z2, lr, pr, li, pi, tw, ti; cin >> n; if ((n / 2) % 2 == 1) { cout << ! -1 ; return 0; } po1 = 1; po2 = n / 2 + 1; cout << ? << po1 << endl; cin >> w1; cout << ... |
#include <bits/stdc++.h> const long long oo = 0x7f7f7f7f7f7f7f7f; using namespace std; const long long maxn = 1e6 + 999; long long n, m, k, visa[maxn], visb[maxn], b[maxn], tota, totb, totc, totd; struct goods { long long val, id; friend bool operator<(goods x, goods y) { return x.val < y.val; } } a... |
#include <bits/stdc++.h> using namespace std; int b1[] = {0, 0, 1, -1}; int b2[] = {1, -1, 0, 0}; int d1[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int d2[] = {-1, 0, 1, -1, 1, -1, 0, 1}; string st; const int mxn = 1e6; struct tp { int tt, cl, op; } tree[4 * mxn]; void build_tree(int s, int e, int index) ... |
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); const long long inf = 1e18, M = 1e9 + 7; const long long int N = 1; bool left_turn(pair<long long int, long long int> a, pair<long long int, long long int> b, pair<long long int, long long int> c) ... |
#include <bits/stdc++.h> using namespace std; inline long long min(long long x, long long y) { return x < y ? x : y; } inline long long max(long long x, long long y) { return x > y ? x : y; } const int Maxn = 1e4 + 5; int n, k, m, ans = -1; int a[Maxn], b[105], c[30], dis[30][Maxn], f[2000005], pw[30]; bo... |
#include <bits/stdc++.h> using namespace std; long long cnt, prime[100], pcnt; long long flg; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long search(long long a, long long b) { if (!b) return 0; long long d = gcd(a, b); a /= d; b /= d; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int INF = 1e9; int a[N], maxv[N << 2], addv[N << 2]; int dmax[N][21]; int n, ans; void maintain(int rt, int l, int r) { maxv[rt] = 0; if (l < r) maxv[rt] = max(maxv[rt << 1], maxv[rt << 1 | 1]); maxv[rt] += addv[rt]; ... |
#include <bits/stdc++.h> using std::max; using std::min; const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x3f3f3f3f3f3f3f3f; __inline__ __attribute__((always_inline)) unsigned int rnd() { static unsigned int seed = 416; return seed += 0x71dad4bfu, seed ^= seed >> 5, seed += 0xc6f74... |
#include <bits/stdc++.h> using namespace std; const int N = 2e7 + 7; long long mn = (long long)(1e18 + 7), mx = -(long long)(1e18 + 7); long long n, m, k, s, q, t; long long a, b, c, d, e; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> a >> b >> c >... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230; template <class T> int getbit(T s, int i) { return (s >> 1) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300010; int h[MAXN], v[MAXN]; int main() { int n; scanf( %d , &n); for (int i = 0; i < (n); ++i) { scanf( %d , &h[i]); } v[0] = 1; v[n - 1] = 1; for (int i = (1); i < (n - 1); ++i) { v[i] = min(h[i], v[i - 1... |
#include <bits/stdc++.h> const int nmax = 500000; int ans[nmax + 5]; int main() { int n, i, j, x1, y1, x2, y2; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d%d%d%d , &x1, &y1, &x2, &y2); ans[i] = (((x2 % 2) + 2) % 2) * 2 + ((y2 % 2) + 2) % 2 + 1; } printf( YES n ); for (... |
#include <bits/stdc++.h> int main() { long long n; while (~scanf( %I64d , &n)) { long long m = sqrt(n); long long m1 = sqrt(m); long long i; long long sum; int flag = 0; for (i = m + 1; i >= m + 1 - 100; i--) { sum = 0; long long b = i; while (b) { ... |
#include <bits/stdc++.h> using namespace std; int bit[200005]; void update(long long int x) { while (x < 200005) { bit[x] += 1; if (x == 0) break; x += x & (-x); } } long long int query(long long int x) { long long int ans = 0; while (x >= 0) { ans += bit[x]; if (... |
#include <bits/stdc++.h> using namespace std; int get(int a) { int maxx = 0; for (int i = 0; i < 21; i++) if (a & (1 << i)) maxx = i; int ans = (1 << (maxx + 1)) - 1; return (ans ^ a); } int main() { int n; cin >> n; vector<int> a(n + 1); for (int i = n; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 4e5 + 10; const int M = 1e6 + 10; const long long mod = 1e9 + 7; const double PI = acos(-1); long long w[N]; int fa[N][21]; long long wi[N][21]; long long mx[N][21]; int Find(int x, int y) { for (int ... |
#include <bits/stdc++.h> using namespace std; const int prime = 999983; const int INF = 0x7FFFFFFF; const long long INFF = 0x7FFFFFFFFFFFFFFF; const double pi = acos(-1.0); const double inf = 1e18; const double eps = 1e-6; const long long mod = 1e9 + 7; long long qpow(long long a, long long b) { l... |
#include <bits/stdc++.h> using namespace std; int k, i; int main() { cin >> k; for (i = 1; i <= k; i <<= 1) { } cout << 2 3 << endl; cout << i * 2 - 1 << << k << 0 << endl; cout << i << << i * 2 - 1 << << k << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; long long int ma = -1, mi = 1000000000000000; inline long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; } inline long long int lcm(long long int a, long long int b, long long int MOD) { return a / gcd(a, b) * b % MOD; } ... |
#include <bits/stdc++.h> using namespace std; int AA[100010]; int BB[100010]; long long dp[100010]; int N; vector<long long> M; vector<long long> B; bool bad(long long l1, long long l2, long long l3) { long double XX1 = 1.00000 * (M[l1] - M[l2]) / (M[l1] - M[l3]); long double XX2 = 1.00000 * (B[... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int n, m; int a[200000]; char tmp[200000]; int b[200000]; int bi; int c[200000]; int ci; int d[200000]; vector<int> dab; void calc() { int i, j; int cnt = 0; d[0] = -((1 << 30) - 1); ci = 0; for (i ... |
#include <bits/stdc++.h> using namespace std; const int delta = (int)1e9 + 7; int n, a[(int)3e5 + 20], b[(int)3e5 + 20], x, y, z, ans, h[(int)3e5 + 20]; vector<int> G[(int)3e5 + 20]; bool cmp(int u, int v) { if (a[u] == a[v]) return u < v; return a[u] > a[v]; } bool ac1() { for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <bits/stdc++.h> using namespace std; long long int f[100010], n, a[100010]; const long long int inf = 2000000000000; int main() { long long int i, j, k; scanf( %I64d , &n); for (i = 1; i <= n; i++) { scanf( %I64d , &a[i]); } f[0] = 0; sort(a + 1, a + 1 + n); for (i = 1... |
#include <bits/stdc++.h> 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 = getchar(); } return x * f; } using namespace std;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3E5 + 5; int n, m, sz, val, x, y, color[MAXN]; vector<int> v[MAXN], G[MAXN]; template <class T> void read(T& x, T f = 1, char ch = getchar()) { x = 0; while (ch < 0 || ch > 9 ) f = (ch == - ? -1 : 1), ch = getchar(); while (ch >... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( -O2 ) using namespace std; const long long N = 500000 + 10; const long long MOD = 1000000000 + 7; const long long INF = 100000000000000010; const long long LOG = 25; long long dp[N], n, a[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.