func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long n, cnt[21][21], pos[21][400001], dp[1 << 20]; vector<long long> v[21]; signed main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin >> n; for (long long i = 1; i <= n; i++) { long long a; cin >> a; a-... |
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } int N, M, K; signed long long mo = 1000000007; int L, R; string LL, RR; vector<string> S; int V[201]; vector<vector<int> > TR; vector<int> AC; signed lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, ans = 0; cin >> n; vector<int> v; int dat[101] = {}; for (int i = 0; i < n; ++i) { cin >> a; if (a == 1) break; v.push_back(a); } if (a != 1) { sort(v.begin(), v.end()); for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const long long p = 998244353; long long po(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a; if (b % 2 == 0) { long long u = po(a, b / 2); return (u * u) % p; } else { long long u = po(a, b - 1); return (a... |
#include <bits/stdc++.h> using namespace std; bool solve(vector<int> ps, vector<int> v) { if (ps.empty()) return v[0] == 0; int n = v.size(); vector<int> nps(ps.begin() + 1, ps.end()); vector<vector<int> > g(ps[0], vector<int>(n / ps[0])); bool ans = true; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 77; int n; char s[N]; vector<int> v, k, x; int dp[N][N][N][2]; int count(vector<int> &list, int from, int w) { int cnt = 0; for (int i = from; i < list.size(); i++) { if (list[i] < w) cnt++; } retu... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, flag = 0; int a[5005]; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; } for (i = 1; i <= n; i++) { if (a[a[a[i]]] == i) { cout << YES ; return 0; } } cout << NO ; } |
#include <bits/stdc++.h> const double PI = 3.1415926535897932384626433; const int KL = 1e4 + 10; const long long MOD = 1e9 + 7; using namespace std; int n; struct point { long double x, y, z; }; long double dis(point a, point b) { long double dx = a.x - b.x; long double dy = a.y - b.y; l... |
#include <bits/stdc++.h> using namespace std; struct Node { vector<Node*> next; Node() : next(26, nullptr) {} }; Node* root = new Node; void insert(string& s, int i, Node* c) { if (i >= s.length()) return; if (c->next[s[i] - a ] == nullptr) { c->next[s[i] - a ] = new Node; } in... |
#include <bits/stdc++.h> using namespace std; int a1, a2, b1, b2, c1, c2; int main() { cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2; if (a1 == 0 && b1 == 0 && c1 != 0 || a2 == 0 && b2 == 0 && c2 != 0) { cout << 0 n ; return 0; } int m1 = b1 * a2, m2 = b2 * a1; if (m1 == m2) if (c... |
#include <bits/stdc++.h> using namespace std; long long ax, ay, bx, by, cx, cy; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> ax >> ay >> bx >> by >> cx >> cy; if ((by - ay) * (cx - bx) == (cy - by) * (bx - ax)) cout << NO n ; else if ((by - ay) * (by - ay) + (bx - ax) * (bx ... |
#include <bits/stdc++.h> int main() { int n(0); scanf( %d , &n); char first = x , last = y ; int count(0); if (n % 2 == 0) { for (int k = 0; k < n / 2; k++) { printf( %c%c , (count) % 2 + a , (count) % 2 + a ); ++count; }; puts( ); for (int k = 0; k < n... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:102400000,102400000 ) using namespace std; const double PI = acos(-1.0); int f_max(int a, int b) { return a > b ? a : b; } int f_min(int a, int b) { return a < b ? a : b; } int f_abs(int a) { return a > 0 ? a : -a; } int gcd(int a, int b) { return b... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; long long mod = 1e9 + 7; long long fmod(long long b, long long exp) { long long res = 1; while (exp) { if (exp & 1ll) res = (res * b) % mod; b = (b * b) % mod; exp /= 2ll; } return res; } long long buc[101]... |
#include <bits/stdc++.h> using namespace std; void fastInOut(); unsigned long long power(unsigned long long b, unsigned long long pow) { if (b == 0) return 0; else if (pow == 1) return b; else if (pow % 2 == 0) return power(b * b, pow / 2); else return b * power(b * b, pow ... |
#include <bits/stdc++.h> const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const double eps = 1e-8; const int MAXN = 1e3 + 10; const long long MOD = 1e9 + 7; int cases = 0; using std::string; const int dir[][2] = {{-1, 0}, {-1, -1}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1... |
#include <bits/stdc++.h> using namespace std; using namespace std; const int maxn = 3e5 + 5; int level[maxn * 2], num[maxn * 2], par[maxn * 2]; char s[maxn * 2]; stack<int> stk; int main() { int n, cnt = 0; scanf( %d , &n); scanf( %s , s + 1); for (int i = 1; i <= n; i++) { if (stk.e... |
#include <bits/stdc++.h> using namespace std; const int N = 300005; int n, k, i, a, b, da, db, u, v, head[N], Next[N * 2], adj[N * 2], j, dp[N], ans, dd, t; void Push(int u, int v) { Next[++k] = head[u]; head[u] = k; adj[k] = v; } void dfs(int i, int fa) { int j, mxx = 0; dp[i] = 0... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cerr.tie(0); int n, tmp; vector<pair<int, int> > a; cin >> n; for (int i = 0; i < n; i++) cin >> tmp, a.push_back(make_pair(tmp, i + 1)); sort(a.begin(), a.end()); int c1 = 0, c2 =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; int c[maxn], A[maxn], B[maxn]; int n, k, a, b, q, cmd; void add(int *c, int p, int val) { for (; p <= n; p += p & -p) c[p] += val; } int sum(int *c, int p) { int ret = 0; for (; p; p -= p & -p) ret += c[p]; return ret; ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 2 * 1e6 + 10; long long a[maxn], b[maxn], q[maxn], sz[maxn], n; 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 ... |
#include <bits/stdc++.h> using namespace std; const int Max = 50; int row[Max][Max] = {0}, dp[Max][Max][Max][Max] = {0}, a[Max][Max]; int main() { int n, m, q; cin >> n >> m >> q; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %1d , &a[i][j]); row[i][j] = ... |
#include <bits/stdc++.h> using namespace std; int t; int n, k; int siz[100086]; int c, x; int id[100086]; int mx; char s[100086]; inline int get(int l, int r) { printf( ? %d , r - l + 1), fflush(stdout); for (int i = l; i <= r; i++) printf( %d , i), fflush(stdout); puts( ); fflush(st... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 3e5 + 5; const long long INF = 1e14; vector<long long> adj[33]; int dirx[] = {-1, 1, 0, 0}; int diry[] = {0, 0, -1, 1}; long long ans[33][2]; void dfs(int u, int p, int dir, long long dist) { int d = 0... |
#include <bits/stdc++.h> using namespace std; inline int Max(int a, int b) { return (a > b ? a : b); } inline int Min(int a, int b) { return (a > b ? b : a); } int dp[45][65][65]; int cnt[65], K; void Init() { for (int i = 0; i < 65; i++) { int n = i; int x = 0; while (n) { x++... |
#include <bits/stdc++.h> using namespace std; struct ms { string s; int id; }; bool operator<(const ms &a, const ms &b) { return a.s < b.s; } vector<ms> sv, msv[11]; string s; int n, lenmin = 11, lenmax = 0; bool used[10000] = {false}; int main(void) { int i; cin >> n; sv.reserve(n... |
#include <bits/stdc++.h> using namespace std; int Szukaj(vector<int>& moje, vector<bool>& jest, int x) { int nr = -1; for (int i = 0; i < moje.size(); ++i) { if (moje[i] >= x && jest[i]) { if (nr == -1) nr = i; else { if (moje[i] < moje[nr]) nr = i; } ... |
#include <bits/stdc++.h> using namespace std; struct node { int d, s; int id; }; node a[100009], b[100009]; map<int, int> Map; vector<int> e[100009], vec; int match[100009]; int vis[100009]; int n, m; bool cmp(node x, node y) { return x.d > y.d; } bool find(int x) { for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = (1 << 18) + 5; const int MAXM = 1005; bitset<MAXM> STree[MAXN], Prime, mask; int Lazy[MAXN], a[MAXN], in[MAXN], out[MAXN], time_tag, n, m, H[MAXN]; vector<int> G[MAXN]; void dfs(int i, int fa) { in[i] = ++time... |
#include <bits/stdc++.h> using namespace std; const int N = 600 + 5; const int M = 2e5 + 5; template <class T> inline void getin(T& num) { char c; bool flag = 0; num = 0; while ((c = getchar()) < 0 || c > 9 ) if (c == - ) flag = 1; while (c >= 0 && c <= 9 ) { num = num *... |
#include <bits/stdc++.h> using namespace std; bool is_right(complex<long long> p1, complex<long long> p2, complex<long long> p3) { return (conj(p2 - p1) * (p3 - p1)).imag() < 0; } const int N = 1e5 + 5; vector<complex<long long> > U; complex<long long> a[N]; int n; void read_input() ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T& x, T y) { return x > y ? x = y, true : false; } template <class T> inline bool chkmax(T& x, T y) { return x < y ? x = y, true : false; } inline int read(void) { int x, f = 1; char ch = getchar(); f... |
#include <bits/stdc++.h> int valid(char prev, char next) { char s[] = aeioun ; for (int i = 0; i < 6; i++) if (prev == s[i]) return 1; for (int i = 0; i < 5; i++) if (next == s[i]) return 1; return 0; } int main() { char s[300]; scanf( %s , s); int v = 1; for (int i = ... |
#include <bits/stdc++.h> using namespace std; map<pair<long long, long long>, pair<long long, long long> > mp; long long n; pair<long long, long long> solve(pair<long long, long long> a) { if (a.second < 10) return make_pair(a.first || a.second, a.second - max(a.first, a.second)); if (mp[a].first)... |
#include <bits/stdc++.h> using namespace std; int k; int n1, n2, n3; int t1, t2, t3; int v1[3000]; int v2[3030]; int v3[3030]; int main() { ios::sync_with_stdio(false); cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3; int time = t1 + t2 + t3 - 1; int pos = 0; int res = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; #define int int64_t #define MOD 998244353 #define inf 9e18 #define tikoo (int) (1e9 + 7) template<typename T, typename T1> T max(T a, T1 b) { if (b > a) a = b; return a; } template<typename T, typename T1> T min(T a, T1 b) { if (b < a) a = b; return a; }... |
#include <bits/stdc++.h> using namespace std; void cppio() { ios_base::sync_with_stdio(0); cin.tie(0); } const int maxn = int(2e5) + 10; int n; int a[maxn]; int p, q; long long first, second; int gcd(int a, int b) { if (!b) { first = 1, second = 0; return a; } int q = a... |
#include <bits/stdc++.h> using namespace std; long long a[100005], dist[100005], sad[100005], subt[100005], ans = 0LL; vector<pair<long long, long long> > adj[100005]; void dfs(long long node, long long par, long long min_vertex) { if (par != -1) sad[node] = (a[node] < dist[node] - dist[min_vertex]); mi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 10; const int M = 128; const int inf = 0x7fffffff; const long long INF = 9E18; const int mod = 1e9 + 7; int n, m; int pos[M][maxn], len[M]; int dp[M][maxn]; char s[M][maxn]; int main() { scanf( %d%d , &n, &m); for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { string x; deque<char> vec; int c; bool flag; int max = 0; for (int i = 0; i < 8; i++) { cin >> x; for (int j = 0; j < x.length(); j++) vec.push_back(x[j]); if (i % 2 == 0) { c = 0; while (true) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 3, i, j, a, b; vector<pair<int, int> > v, v2; for (i = 0; i < 3; i++) { scanf( %d%d , &a, &b); v.push_back(make_pair(a, b)); v2.push_back(make_pair(b, a)); } int cnt, c2, c3; sort(v.begin(), v.end()); so... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ans = 0; bool flag = false; if (n == 2) { cout << 1 << n ; return 0; } for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { flag = true; break; } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 56; int n, a[N]; int cnt(int x) { int ans = 0; for (int i = 1; i <= n; ++i) ans += (a[i] == x); return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n; for (int i =... |
#include <bits/stdc++.h> using namespace std; long long num[30], pre[100010], cnt; int main() { int n, l, lr, ll; char s[100010]; cin >> n; for (int i = 0; i < n; i++) { cin >> s + 1; l = strlen(s + 1); for (int j = 0; j < 26; j++) if (num[j] && j + a != s[1] && j + a ... |
#include <bits/stdc++.h> using namespace std; long long sub(long long a, long long b) { return (a - b + 1000000007) % 1000000007; } long long add(long long a, long long b) { return (a + b) % 1000000007; } long long mul(long long a, long long b) { return (a * b) % 1000000007; } vector<long long> adj[1000... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v, v1; int a, b, c, d, e, f, g, h, i, j, k, l; cin >> a; for (i = 0; i < a; i++) { v.clear(); v1.clear(); cin >> c >> d >> b; map<int, int> m; for (j = 0; j < b; j++) { cin >> e; m[e]... |
#include <bits/stdc++.h> using namespace std; int t, n; string s; int main() { ios_base::sync_with_stdio(false); cin >> t; while (t--) { cin >> s; int mask = 0; n = s.size(); int ok100001 = (s[0] == 1 ); for (int i = 1; i + 1 < n; ++i) ok100001 &= (s[i] == 0 ); ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long a[30], b[30], dp[30][30][30]; struct node { long long dis[30][30]; node operator*(const node &t) const { node rep; memset(rep.dis, 0x3f, sizeof rep.dis); for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p = 0, q = 0; cin >> n; string str; cin >> str; for (int i = 0; i < n; i++) { if (str[i] == F && str[i + 1] == S ) p = p + 1; if (str[i] == S && str[i + 1] == F ) q = q + 1; } if (q > p) cout << YE... |
#include <bits/stdc++.h> const int nMax = 200001; struct Segment { int left; int right; long long sum; long long forced; Segment* lChild; Segment* rChild; }; Segment* initTree(int left, int right, long long forced) { Segment* segment = new Segment; segment->left = left; segme... |
#include <bits/stdc++.h> using namespace std; const int N = 502; pair<int, pair<int, int> > dp[N][N]; int a[N]; int b[N]; map<int, int> a_val_to_pos; int main() { int n, m; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; cin >> m; for (int i = 0; i < m; ++i) cin >> b[i]; for (in... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<long long, long long>; using pcc = pair<char, char>; using pdd = pair<double, double>; using vi = vector<int>; using vs = vector<string>; using vll = vector<ll>; using vpii = vector<pii>;... |
#include <bits/stdc++.h> int v[1000001]; using namespace std; int main() { int a, b, c, d; scanf( %d%d%d%d , &a, &b, &c, &d); while (b <= 1000000) { v[b] = 1; b += a; } while (d <= 1000000) { if (v[d] == 1) { printf( %d , d); return 0; } d += c; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double t = 0; cin >> n; int i, a[n], b[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n; i++) { b[i] = a[n - 1 - i]; } for (i = n - 1; i >= 0; i--) { if (i % 2 == 0) t ... |
#include <bits/stdc++.h> using namespace std; const long long N = 5 * 1e5 + 1; long long n, a[N], sum[N], s, f, ans; int32_t main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; if (i) sum[i] = sum... |
#include <bits/stdc++.h> using namespace std; void run() { long long n; cin >> n; long long p[n]; for (long long i = 0; i < n; i++) cin >> p[i]; for (long long i = 0; i < n; i++) { if (p[i] == 0) p[i] = -1; if (p[i] != -1) p[i] %= 2; } long long ones = 0, zeros = 0; for (... |
#include <bits/stdc++.h> using namespace std; template <typename T> void _do(T x) { cerr << x << n ; } template <typename T, typename... U> void _do(T x, U... y) { cerr << x << , ; _do(y...); } const int MOD1 = 1e9 + 7; const int MOD2 = 998244353; const long long INF = 2e18; const ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; const long long MX = 2e5 + 5; const long long MOD = 1e9 + 7; const long long INF = 1e18; const long double PI = acos((long double)-1); const long long xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1}; mt199... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); double fRand(double fMin, double fMax) { double f = (double)rand() / RAND_MAX; return fMin + f * (fMax - fMin); } template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, ... |
#include <bits/stdc++.h> void _print(int *a, int n) {} using namespace std; const int N = 300; int n, m; int a[N][N], h[N], v[N]; int ans[N][N]; signed main() { scanf( %d , &n), scanf( %d , &m); for (int i = (0); i < (n); ++i) for (int j = (0); j < (m); ++j) { scanf( %d , &a[i][j]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, l = -99999999, r = 99999999; scanf( %d , &n); for (int i = 0; i < n; ++i) { int rat, div; scanf( %d , &rat), scanf( %d , &div); if (div == 1) l = max(l, 1900 - sum); else r = min(r, 1899 - ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int r[105]; int i; double pi = acos(-1.0); for (i = 0; i < n; i++) { cin >> r[i]; } sort(r, r + n); int s = 0; for (i = 0; i < n; i++) { s = r[i] * r[i] - s; } printf( %.6lf n , s ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e5 + 5; bool dn = false; int n; bool check(int res[]) { for (int i = 1; i < n; i++) { if (abs(res[i] - res[i - 1]) != 1) { return false; } } cout << YES n ; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { int64_t t; cin >> t; vector<int64_t> ans; map<int64_t, int64_t> m; for (int64_t i = 0; i < t; i++) { m[0] = 0; m[1] = 0; m[2] = 0; int64_t n; cin >> n; for (int64_t j = 0; j < n; j++) { int... |
#include <bits/stdc++.h> using namespace std; const int mxN = 2e5; const int MOD = 1e9 + 7; template <typename ForwardIterator, typename T> ForwardIterator first_less_than(ForwardIterator first, ForwardIterator last, T value) { auto it = std::lower_bound(first, last, valu... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mn = 1e5 + 1; ll n, d, a[mn], b[mn], ans = 1, cnt = 1, pos = 1, ansid[mn]; struct pairs { int val, id; pairs operator+(pairs A) { return (pairs){val + A.val, id + A.id}; } } tree[mn * 4], f[mn]; pairs maxp(pairs A, pairs... |
#include <bits/stdc++.h> using namespace std; void incr(long long &st, long long &en, long long &k, long long val) { en++; if (val <= k) { k++; } } void decr(long long &st, long long &en, long long &k, long long val) { long long sz = en - st + 1; if (val < k) { k -= val; sz... |
#include <bits/stdc++.h> using namespace std; using i128 = __int128_t; using u128 = __uint128_t; const long long MOD = 998244353; const long double PI = 3.141592653589793238; const long long pi = 31415926; const long long inf = 1000000000000000000; const long long small_inf = INT_MAX; long long int mo... |
#include <bits/stdc++.h> using namespace std; struct Medianer { priority_queue<int> low; priority_queue<int, vector<int>, greater<int> > high; Medianer() {} int getMedian() { return low.top(); } void insert(int a) { if (low.empty()) low.push(a); else if (a > low.top()) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> class fenwick_tree { private: int n; vector<T> fenw; public: fenwick_tree(int _n) : n(_n) { fenw.resize(n); } size_t size() { return n; } void update(int x, T val) { while (x < n) { fenw[x] += val; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, x, y, n; cin >> t; for (int i = 0; i < t; ++i) { cin >> x >> y >> n; if (n % x > y) { n = n - (n % x - y); } else if (n % x != y) { n = n + (y - n % x) - x; } cout << n << endl; } retu... |
#include <bits/stdc++.h> using namespace std; int st(int x, int pos) { return x = x | (1 << pos); } int Reset(int x, int pos) { return x = x & ~(1 << pos); } int main() { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2) { cout << 4 + 2 * (abs(y1 - y2) + 1) << endl; } el... |
#include <bits/stdc++.h> using namespace std; int cnt[11], l[11]; int main() { for (int i = 0; i < 6; i++) { scanf( %d , &l[i]); cnt[l[i]]++; } int ok = 0; for (int i = 1; i < 10; i++) if (cnt[i] >= 4) { ok = 1; cnt[i] -= 4; } if (ok) { int a = -1,... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007LL; int n; int fn[300005]; int sons[300005]; vector<int> edges[300005]; void dfs(int u) { if (edges[u].empty()) sons[u] = 1; else { for (int i = 0; i < edges[u].size(); ++i) { int v = edges[u][i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, r; cin >> n; if (n == 0) { cout << 1 << endl; return 0; } r = n % 4; if (r == 1) { cout << 8 << endl; } else if (r == 2) { cout << 4 << endl; } else if (r == 3) { cout << 2 <... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e6 + 10; const long long mod = 998244353; double eps = 1e-10; void in(long long &x) { x = 0; char c = getchar(); long long y = 1; while (c < 0 || c > 9 ) { if (c == - ) y = -1; c = getchar(); } while (c ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 7; const long long mod = 1e9 + 7; int a[N]; int main() { int n; cin >> n; for (int i = (1); i < (n + 1); ++i) scanf( %d , a + i); sort(a + 1, a + 1 + n); if (n == 0) { cout << YES n1 n1 n3 n3 n ; } else if (n == 1... |
#include <bits/stdc++.h> using namespace std; int n, x, y, a, b; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; if (x < 0) a++; else b++; } cout << (a < 2 || b < 2 ? Yes : No ); } |
#include <bits/stdc++.h> using namespace std; int main() { int n, t = 0; cin >> n; string s; cin >> s; t = s.length(); cout << t + 1 << endl; } |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 300500; int main() { cin... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000050; bool arr[N]; int main() { int n, x; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } sort(v.begin(), v.end()); if (v.size() == 1) cout << 0 << n ; else { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; char grid[n][m]; int x1 = 1e9, y1 = 1e9, x2 = 0, y2 = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cin >> grid[... |
#include <bits/stdc++.h> using namespace std; long long int dp[1000005]; int a[30]; int main() { int t, k, i, j, n, m, x, y, q, c, d; dp[0] = 0; dp[1] = 0; for (i = 2; i < 1000005; i++) dp[i] = dp[i / 2] + dp[i - i / 2] + i / 2 * 1LL * (i - i / 2); cin >> k; if (k == 0) { cou... |
#include <bits/stdc++.h> using namespace std; int vis[7], sum[7]; string a[7], t[7]; vector<string> ans(10, { ), now; void solve() { now.clear(); for (int i = 1; i <= 6; i++) sum[i] = (int)t[i].size(); if (sum[2] <= sum[1] || sum[2] <= sum[3] || sum[5] <= sum[4] || sum[5] <= sum[6]) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n][m]; int b[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cin >> a[i][j]; } for (int i = 0; i < n; i++) { b[i] = a[i][0]; for (int j = 1; j < m; j++) b[i] = min(a[... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; int used[100005]; int color[100005]; int odd_cycle; vector<pair<int, int> > v; int odd; int even; void DFS(int node, int cor, int par = -1) { if (cor == 0) { even++; } else { odd++; } color[node] = cor; ... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 1000000000000000000; long long mod = 1000000000; long double pi = 3.141592653589793238; void pls() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } long long n, k, d; vector<vector<int>> res; void backtrack(vecto... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; inline int mod(int n) { return (n % 1000000007); } int gcd(int a, int b) { if (a == 0 || b == 0) return 0; if (b == 1) return b; else return gcd(b, a % b); } int fpow(int x... |
#include <bits/stdc++.h> using namespace std; long long n; long long a[100005][4]; set<long long> se; map<long long, long long> mp; pair<long long, long long> ve[400005][5]; pair<long long, long long> pe[400005][5]; long long prim(long long i) { for (long long j = 2; j * j <= i; j++) { if (i %... |
#include <bits/stdc++.h> using namespace std; using pii = pair<long long, long long>; using pil = pair<long long, long long>; using pli = pair<long long, long long>; using pll = pair<long long, long long>; using pdd = pair<long double, long double>; using vint = vector<long long>; using vll = vector<lon... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-10; template <typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; } template <typename T> void operator>>(vector<T>& a, int b) { while (b--) if (!a.empty()) a.pop_back(); ... |
#include <bits/stdc++.h> using namespace std; char a[2000005]; int n, k, kmp[2000005], z[2000005]; int ch[2000005]; inline void GetKMP() { int j = 0; for (int i = 2; i <= n; i++) { while (j && a[j + 1] != a[i]) j = kmp[j]; if (a[j + 1] == a[i]) j++; kmp[i] = j; } return; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, a[55], b[55], i, amin, bmin; long long int sum; scanf( %d , &t); while (t--) { scanf( %d , &n); amin = 0x3f3f3f3f; for (i = 0; i < n; i++) { scanf( %d , &a[i]); if (amin > a[i]) amin = a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int MN = 200010; int N, Q; struct BIT { vector<int> tree; vector<pair<int, int> > lazy; void init() { tree = vector<int>(4 * N, 0); lazy = vector<pair<int, int> >(4 * N, {1, 0}); } void prop(int l, i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:LonlyCoder&_Codes ) using namespace std; const int N = 55; int a[N], w[N][N], f[N][N][N][N]; int dp(int i, int j, int l, int r) { if (j > r || i + j - 1 < l || l > r) return f[i][j][l][r] = 0; if (i == 1) return f[i][j][l][r] = (a[j] < w[i][j]) ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m; b /= 2; a = (... |
#include <bits/stdc++.h> using namespace std; int a[10]; bool cmp(int a, int b) { if (a > b) return true; else false; } int main(void) { int i, n = 6, h; for (i = 0; i < n; i++) { scanf( %d , &h); a[h]++; } sort(a, a + 10, greater<int>()); int x = a[0]; ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long fact[51], invfact[51]; int n50 = 0, n100 = 0, k = 0; struct node { int l[2], r[2], b; }; long long nways[51][51][51][51][2], shortest[51][51][51][51][2]; queue<node> q; long long pmod(long long base, long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << white n1 2 << endl; } else { cout << black << endl; } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.