func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n; char s1[51], s2[51], op[50][5]; int memo1[50][50][26], memo2[50][50][26], memo3[50][50]; int check1(int l, int r, char c) { if (l == r) return s1[l] == c; int &ret = memo1[l][r][c - a ]; if (ret == -1) { ret = 0; for (int i = l; i <... |
#include <bits/stdc++.h> using namespace std; struct Node { int a, b, c, d; } temp; queue<Node> q1, q2; string s1[305][305], s2[305][305]; int main() { int n, m; int ans = 0, m1 = 0, m2 = 0; int num1 = 0, num0 = 0; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j ... |
#include <bits/stdc++.h> using namespace std; const long long is_query = -(1LL << 62); struct Line { long long m, b; mutable function<const Line*()> succ; bool operator<(const Line& rhs) const { if (rhs.b != is_query) return m < rhs.m; const Line* s = succ(); if (!s) return 0; ... |
#include <bits/stdc++.h> using namespace std; struct mat { double a[3][3]; mat() { for (int i = (int)(0); i <= (int)(2); ++i) for (int j = (int)(0); j <= (int)(2); ++j) a[i][j] = 0; } mat operator*(const mat &b) const { mat c; for (int i = (int)(0); i <= (int)(2); ++i) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110, MOD = 1e9 + 7; long long dp[MAXN][2]; int main() { ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); int n, k, d; cin >> n >> k >> d; dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j ... |
#include <bits/stdc++.h> using namespace std; long long me[10000][1001]; long long n, m; long long d[10000]; long long g, r; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> m; for (long long i = 0; i < m; i++) cin >> d[i]; sort(d, d + m); cin >> g >> r; queue<p... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 1; int accept() { int b[N] = {0}; int d[N] = {0}; int n; cin >> n; int mx, check; for (int i = 0; i < n; i++) cin >> b[i]; sort(b, b + n); for (int i = 1; i < n; i++) { if (b[i] == b[i - 1]) { cout << ... |
#include <bits/stdc++.h> using namespace std; const int mx = 100010; int arr[mx]; int main() { string x; int n, c = -1, temp = 0; queue<int> stek; map<int, int> visit; cin >> n >> x; for (int i = 0; i < n - 1; i++) { if ((x[i] == o and x[i + 1] == g ) || (x[i] == g a... |
#include <bits/stdc++.h> const long long mod = 1e9 + 7; using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long n, m; vector<long long> a, b, v, pat; long long cal() { v.clear(); for (long long i = 1; i < m; i++) v.push_back(a[i]); v.push_bac... |
#include <bits/stdc++.h> using namespace std; int main() { int num, skill; cin >> num >> skill; int A[num]; for (int i = 0; i < num; i++) cin >> A[i]; int k = 0; while (A[k] <= skill && k < num) k++; int soluve; soluve = k; int stay; if (k == num) { cout << num << endl;... |
#include <bits/stdc++.h> #pragma GCC optimize( inline ) int rd() { register int k = 0; char c = getchar(); while (c > 9 || c < 0 ) c = getchar(); while (c >= 0 && c <= 9 ) k = k * 10 + c - 48, c = getchar(); return k; } const int N = 100001; struct Q { int o, t, l, r; } q[N]; ... |
#include <bits/stdc++.h> using namespace std; #pragma optimize( -Ofast ) const int mod = 998244353; struct num { int x; num(int x_ = 0) { x = x_; } } G, _1[2222222], X[2222222], rot[2222222], inv[2222222]; inline bool operator<(const num x, const num y) { return x.x > y.x; } inline num operator+(c... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100010; vector<int> a[MAX], ans; int x, y, n; bool v[MAX], d[MAX], f[MAX], l[MAX], odd[MAX], even[MAX]; void DFS(int start) { v[start] = true; if (d[start] && odd[start]) { f[start] = (1 - f[start]); } if (!d[start] && even[... |
#include <bits/stdc++.h> using namespace std; int a[3]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if (a[0] + a[1] > a[2]) { cout << 0 << endl; return 0; } cout << a[2] - a[1] - a[0] + 1; return 0; } |
#include <bits/stdc++.h> using namespace std; set<int> d; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t, n, a, k = 0; cin >> t >> n; int x[200] = {}; for (int i = 1; i <= t; ++i) { cin >> a; if (x[a] >= 1) continue; else {... |
#include <bits/stdc++.h> using namespace std; inline double sq(double a) { return a * a; } int a, b; int n; complex<double> p1[1024], p2[1024]; double d[1024][1024]; int vis[1024]; double distanceSP(const complex<double>& s0, const complex<double>& s1, const complex<double>& p) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pi = pair<int, int>; using pll = pair<ll, ll>; int n, k; vector<int> x; bool disjoint(int l1, int r1, int l2, int r2) { return r1 < l2 || r2 < l1; } int main() { ios_base::sync_with_stdio(false); cout << setprecision(12); ... |
#include <bits/stdc++.h> using namespace std; const int mx = 110, Mod = 1e6 + 3; int C, W, H; struct Matrix { int val[mx][mx]; int n; Matrix(int _n = mx, int _base = 0) { n = _n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) val[i][j] = (i == j ? _base : 0); } i... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 123; const int K = (int)500; const int maxn = (int)2e9; const int mod = (int)1e9 + 7; long long n; vector<long long> v; void solve() { cin >> n; long long cnt = 1; for (int i = 0; i <= 62; ++i) { if (i) { cnt *= ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void r1(T &x) { x = 0; char c(getchar()); int f(1); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); x *= f; } const int maxn = 100000... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0xFFFFFFFFFFFFFFFL; clock_t time_p = clock(); void time() { time_p = clock() - time_p; cerr << Time Taken : << (float)(time_p) / CLOCKS_PER_SEC << n ; } long long mul_mod(long long a, long long b, long long m) { long long y... |
#include <bits/stdc++.h> using namespace std; int main() { char a[1000]; int i = 0, lower = 0, upper = 0; cin >> a; int len = strlen(a); while (a[i] != 0) { if (a[i] >= a && a[i] <= z ) { lower++; i++; } else if (a[i] >= A && a[i] <= Z ) { upper++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } a.push_back((int)... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 10; const long long INF = 4e18 + 10; const int maxn = 1 * 1e5 + 5; const int maxe = maxn; int a[maxn]; int p[maxn]; int n, m; bool check(long long t) { for (int i = 1; i <= n; ++i) p[i] = a[i]; int j = n; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; char a[200][200]; long long check(long long x, long long y, long long n) { if (x >= 0 and x < n and y >= 0 and y < n and a[x][y] == . ) return 1; else return 0; } void solve() { long long n; cin >> n; map<long long, long long> m; ... |
#include <bits/stdc++.h> using namespace std; int v[361 * 2], acum[360 * 2]; int main() { int n, tmp; cin >> n; for (int i = 0; i < n; i++) { cin >> v[i]; v[i + n] = v[i]; } int ans = (1 << 20); for (int i = 0; i < n; i++) { for (int j = i; j < i + n; j++) { int a... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > g[300043]; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); for (int i = 0; i < m; i++) { int x, y, w; scanf( %d %d %d , &x, &y, &w); --x; --y; g[x].push_back(make_pair(y, make_pair(... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 41; const int mod = 1e9 + 7; const long long INF = 1e18; const int inf = 2e9; vector<int> g[N]; long long res; int cnt[2]; int a[N]; int sz[N]; bool used[N]; int cur_sz; long long cur; void pre(int v = 1, int p = -1) { sz[... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {0, 0, -1, 1}; const int dy[] = {1, -1, 0, 0}; const int N = 505; int n, m; char adj[N][N]; bool vis[N][N]; struct node { int type, x, y; node() {} node(int type, int x, int y) : type(type), x(x), y(y) {} void print() { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int arr[N]; int main() { int n; memset(arr, 0, sizeof arr); cin >> n; int maxx = n; int num; for (int i = 0; i < n; i++) { cin >> num; arr[num] = -1; while (arr[maxx] == -1) { cout << maxx << ... |
#include <bits/stdc++.h> using namespace std; int abs(int x) { return x > 0 ? x : -x; } int min(int x, int y) { return x < y ? x : y; } int max(int x, int y) { return x > y ? x : y; } int main() { int a1, a2, a3, a4; scanf( %d%d%d%d , &a1, &a2, &a3, &a4); if (abs(a3 - a4) > 1 || max(a3, a4) > min(... |
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; long long x, q = k - 1, flag, a[k], i, j; for (i = 0; i < n; i++) { cin >> x; if (!i) a[q--] = x; else { flag = 0; for (j = k - 1; j > q; j--) { if (a[j] == x) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000100100; int n, m; string s[105]; int team[105]; int dp[21][(1 << 21)]; int a[104]; int solve(int cur, int mask) { if (cur == m) return 0; int &ret = dp[cur][mask]; if (ret == inf) { if (s[cur] == p ) { int j = 0... |
#include <bits/stdc++.h> const double PI = 3.141592653589793238460; using namespace std; int main() { long long int t, n, k; cin >> t; while (t--) { cin >> n >> k; if ((n < k * k)) cout << NO << n ; else if ((k % 2) != (n % 2)) cout << NO << n ; else ... |
////JAI SHREE RAM//// #include <iostream> #include<bits/stdc++.h> using namespace std; const long long int INF = (long long)1e15; const long long int mod = 1e9+7; #define ll long long #define f(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define all(c) c.begin(),c.en... |
#include <bits/stdc++.h> using namespace std; int main() { int n; double x, cx; cin >> n >> x; cx = x; double a[n + 1], b[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == 1) { cout << -1; return 0; } } for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; vector<int> gr[N]; bool access = true; int p[N], h[N], a[N], g[N]; void dfs(int v, int ancestor = -1) { a[v] = p[v]; int sum_g = 0; for (int to : gr[v]) { if (to == ancestor) continue; dfs(to, v); sum_g += g[t... |
#include <bits/stdc++.h> using namespace std; int n, A[6], B[(1 << 6)], C[100001], P[(1 << 6)], Q[(1 << 6)]; char s[100001]; void TakeInputs() { string s; cin >> s; for (auto c : s) { int i = c - a ; ++A[i]; } n = s.size(); for (int i = 0; i < n; ++i) { C[i] = (1 << 6)... |
#include <bits/stdc++.h> using namespace std; int n, m; int team[101]; char c[101]; int dp[21][(1 << 20) + 5]; int a[1001]; int solve(int pos, int mask) { if (pos == n) return 0; if (dp[pos][mask] != -1) return dp[pos][mask]; int ans; if (team[pos] == 1) { ans = -(1 << 30); for... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; scanf( %lld , &n); long long a, b, c; scanf( %lld , &a); scanf( %lld , &b); scanf( %lld , &c); if (a <= (b - c)) { printf( %lld n , n / a); } else { n -= b; long long x = 0; if (n >= 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, kk, a[200]; scanf( %d%d , &n, &kk); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int sum, tp, mx = a[0]; for (int i = 0; i < n; i++) for (int j = i; j < n; j++) { priority_queue<int> la, sm; sum = 0; ... |
#include <bits/stdc++.h> using namespace std; string s, p; long long l, r, dp[32][3][3][3][3]; string ts(long long x) { string ans; while (x) { ans.push_back( 0 + x % 2); x /= 2; } while (ans.size() != 31) ans.push_back( 0 ); reverse(ans.begin(), ans.end()); return ans; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return !b ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } template <typename T> T sqr(T a) { return a * a; } template <typename T> T cube(T a) { retu... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = 3.14159265359; const int mod = 1000 * 1000 * 1000 + 7; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; string s; int dp[100005]; int solve(int idx) { if ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[100005]; vector<int> v1[100005]; int visited[100005]; stack<int> s; int n, m; set<int> se[100005]; void dfs(int node) { int i; visited[node] = 1; int n = v1[node].size(); for (i = 0; i < n; i++) { if (visited[v1[node]... |
#include <bits/stdc++.h> const int Maxn = 1000; const int Inf = 0x3f3f3f3f; int n, m; int a[Maxn + 5], b[Maxn + 5]; std::vector<int> edge[Maxn + 5]; int pre[Maxn + 5]; long long dis[Maxn + 5]; bool vis[Maxn + 5]; bool check(int x) { for (int i = 1; i <= n; i++) { vis[i] = 0; } vis[1]... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); cout << 3 nL 2 nR 2 nR << n + n - 1; } |
#include <bits/stdc++.h> using namespace std; const int Maxn = 102; int n, K; double dp[2][Maxn][Maxn]; int a[Maxn]; inline int c2(int x) { return x * (x - 1) / 2; } inline int max(int x, int y) { return x > y ? x : y; } inline int min(int x, int y) { return x < y ? x : y; } int main() { scanf( %d... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, x, y = 0; cin >> n >> x; for (int i = 1; i <= n; i++) { char a; long long d; cin >> a >> d; if (a == + ) x += d; else if (x >= d) ... |
#include <bits/stdc++.h> using namespace std; struct segtree2 { int seg[512 * 1024 * 2]; int mum; void init(int n) { mum = 1; while (mum < n) mum <<= 1; for (int i = 0; i < mum * 2; i++) seg[i] = -1; } void add(int k, int x) { k += mum - 1; seg[k] = x; while (... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; int a, c; int arrA[2000]; int arrC[2000]; void sol() { cin >> c >> a; for (int i = 0; i < c; i++) { cin >> arrC[i]; } for (int i = 0; i < a; i++) { cin >> arrA[i]; } int result = 0; int j = 0; ... |
#include <bits/stdc++.h> void __check(const char* expr, const char* file, unsigned int line) { printf( %s:%u: failed check `%s n , file, line, expr); abort(); } using namespace std; template <typename T> bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; ... |
#include <bits/stdc++.h> using namespace std; struct Player { string name; long int points; map<int, int> places; }; Player compSecond(Player a, Player b) { if (a.points > b.points) { return a; } else if (a.points < b.points) { return b; } for (int i = 1; i < 70; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a; b = 1; while ((b * b + 1) / 2 < a) b += 2; cout << (a == 3 ? 5 : b); return 0; } |
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> a[111]; int m; long long p[111]; long long an; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].second, &a[i].first); sort(a + 1, a + 1 + n); scanf( %d , &m); for (int i = 1; i <= m; ++i) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 5; struct Edge { int v, nxt; Edge() {} Edge(int _v, int _nxt) : v(_v), nxt(_nxt) {} }; Edge E[MAXN * 2]; int head[MAXN], ans[MAXN], sub[MAXN], mxsub[MAXN]; int tot = 0, fuc, n, x, y; void addedge(int u, int v) { E[tot] ... |
#include <bits/stdc++.h> using namespace std; const double EPS = 0.0000001; const double PI = acos(-1); const long long INFLL = 0x7FFFFFFFFFFFFFFF; const int INF = 0x7FFFFFFF; template <typename T> inline void next(T &num) { char c; num = 0; do { c = getchar_unlocked(); } while (c !=... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int INF = 1e9; const int N = 150010; int n, m, s, k; int a[110][110]; int main() { scanf( %d%d%d , &n, &m, &k); int s0 = 0, s1 = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf( %d ,... |
#include <bits/stdc++.h> using namespace std; long long modulo = 1000000007; int choose(int n, int r) { if (n < r) { return 0; } if (n == r || r == 0) { return 1; } return choose(n - 1, r - 1) + choose(n - 1, r); } int get_factors(int n) { int numFactors = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; int N, K; long long B; long long A[100005], Ac[100005]; int main() { cin >> N >> K >> B; map<long long, int> ct; for (int i = 0; i < N; i++) { cin >> A[i]; ct[A[i]]++; } ct[A[N - 1]]--; for (int i = 0; i < N - 1; i++) Ac[i] = A[... |
#include <bits/stdc++.h> using namespace std; const int nax = 2e5; int par[nax], dp[nax]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; map<int, int> prev; int ma = -1, mai; for (int i = 0; i < n; i++) { int a; cin >> a; dp[i] = 1; par[i] ... |
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; while (a--) { int b, c; cin >> b >> c; int n = abs(b - c); n = n / 5 + (n % 5) / 2 + (n % 5) % 2; cout << n << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; multiset<long long> buckets[30]; long long bsum[30]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int q, tot = 0; cin >> q; while (q--) { char c; long long x; cin >> c >> x; int p = 31 - __builtin_clz(x), ans = 0... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int n; int cnt[1 << 20]; int cnt2[1 << 20]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; ll res = 0; ++cnt2[0]; for (int pref = 0, a, i = 1; i <= n; +... |
#include <bits/stdc++.h> using namespace std; unordered_set<int> si; int fff = 0; int fj = 2; void mmin(int &t) { for (int j = fj; 1;) { int fflag = 0; vector<int> pr; for (int i = 2; i < sqrt(j) + 1; i++) { if (j % i == 0) { if (si.find(i) == si.end() && si.find(j / i)... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 2000005; const int INF = 0x3f3f3f3f; struct Num { int a, b; Num() {} Num(int x, int y) : a(x), b(y) {} bool operator<(const Num &y) const { return a == y.a ? b < y.b : a < y.a; } bool operator>(const Num &y) const { return a == y... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 2; long long gcd(long long a, long long b) { if (b > a) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); } long long expo(long long a, long long b, long long mod) { long long res = 1; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:100000000000000 ) using namespace std; const long long int INF = 2e18; char mode[5002 / 2][5002]; short int cup[4][5002 / 2][5002]; short int up[4][5002 / 2][5002]; int best = 0, cnt = 0; inline int geti(int type, int x, int y) { if (up[type][... |
#include <bits/stdc++.h> using namespace std; long long totalSum; long long check(long long a, long long b, long long c, long long r) { if (b + c > a) { return 0; } long long d = min(r, a - b - c); return (d + 2) * (d + 1) / 2; } int main() { long long a, b, c, l, total; cin >> a... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const double alpha = 0.9; struct Node { int size, key, nodeCount; bool isExist; Node *lc, *rc; unordered_map<int, int> mp; bool isBad() { return lc->nodeCount > alpha * nodeCount + 5 || rc->nodeCount > al... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> A[55]; double pos[55][55]; bool comp(pair<long long, long long> a, pair<long long, long long> b) { if (a.first > b.first) return 1; else if (a.first < b.first) return 0; else { return a.second <= b.second; ... |
#include <bits/stdc++.h> using namespace std; int main() { long n, m, i, j, mn, mx; scanf( %ld %ld , &n, &m); long a[n][m]; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf( %ld , &a[i][j]); } } mx = 0; for (i = 0; i < n; i++) { mn = LONG_MAX; for... |
#include <bits/stdc++.h> using namespace std; long long pwr(long long a, long long b, long long mod) { a %= mod; if (a < 0) a += mod; long long ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; a = (a * a) % mod; b /= 2; } return ans; } long long pwr(long long a, l... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using lpair = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = 8e18; void print() {} template <class H, class... T> void print(H&& h, T&&... t) { cout << h << n [sizeof...(t) == 0]; print(forward<T>(t)...); } int main... |
#include <bits/stdc++.h> using namespace std; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const int INF = 1000000000; const long long LINF = 1000000000000000000; const long long MOD = 1000000007; const double PI = acos(-1.0); const double EPS = 1e-10; ... |
#include <bits/stdc++.h> using namespace std; inline int setBit(int N, int pos) { return N = N | (1 << pos); } inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); } inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); } int main() { long long n, k, x, sum = 0; scanf( %ll... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long power(long long a, long long b, long long m = mod) { long long x = 1; while (b) { if (b & 1) { x = 1ll * x * a % m; } a = 1ll * a * a % m; b /= 2; } return x; } const int N = ... |
#include <bits/stdc++.h> using namespace std; void in() {} int main() { in(); int n; cin >> n; int arr[n + 10], ps[n + 10]; for (int i = 0; i < n; ++i) { scanf( %d , arr + i); ps[arr[i]] = i + 1; } ps[0] = ps[n + 1] = -1; int a = 0, pre = 1; for (int i = 1; i <= n +... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; string a, b; cin >> a >> b; vector<int> ans; int l = 0, r = n - 1, x = 0; for (int i = n - 1;... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int N = 3e5 + 100; const double PI = acos(-1.0); void fre() { freopen( /Users/luras/Desktop/in.txt , r , stdin); freopen( /Users/luras/Desktop/out.txt , w , stdout); } int n, m, i, j, ans, p... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3 * 100002; int a[N], pr[N]; ll cnt[N]; map<int, int> s[N]; int main() { int q; cin >> q; while (q--) { ll ans = 0; int n; cin >> n; for (int i = 0; i <= n; i++) { pr[i] = -1; ... |
#include <bits/stdc++.h> using namespace std ; using LL = long long ; short int mark[500005] ; class cmp{ public: bool operator () (const pair<int, int> &p1, const pair<int, int> &p2){ return ((p1.first < p2.first) || (p1.first == p2.first && p1.second > p2.second)) ; } } ;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; int k; cin >> n >> k; int ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar, ar + n); long long lista[n]; int cantidad[n]; int index = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n, k; cin >> n >> k; vector<vector<long long>> a(n, vector<long long>(3)); vector<long long> b(k); vector<int> ... |
#include <bits/stdc++.h> using namespace std; void bfs(long long root, list<long long> adj[], vector<long long> &level) { level[root] = 0; queue<long long> qu; qu.push(root); while (!qu.empty()) { long long cur = qu.front(); qu.pop(); for (auto it : adj[cur]) { if (level[it... |
#include <bits/stdc++.h> using namespace std; void fast() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { int n, c = 0; char x; vector<pair<int, int> > v; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> x; if (... |
#include <bits/stdc++.h> const int kM = 4e4 + 5; const int kN = 55; int M, n, m, k; long long T[kM << 3], tag[kM << 3], a[kN][kM], pre[kM], s[kM], f[kN][kM]; void Update(int cur) { T[cur] = std::max(T[cur << 1], T[cur << 1 | 1]); } void PushTag(int cur) { T[cur << 1] += tag[cur]; T[cur << 1 | 1] += ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, mxn = 2e5 + 5; int n; int a[200005]; int mp1[200005], mp2[200005]; map<int, int> mp; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> ... |
#include <bits/stdc++.h> using namespace std; int read() { char c = getchar(); while (!isdigit(c)) c = getchar(); int num = 0; while (isdigit(c)) num = num * 10 + c - 0 , c = getchar(); return num; } void write(int num) { if (num >= 10) write(num / 10); putchar(num % 10 + 0 ); } ... |
#include <bits/stdc++.h> char str[4005] = {0}; long T[4005] = {0}; long f[4005][4005] = {0}; long s[4005][4005] = {0}; int main() { long i, j, k; long tot = 1; long sum = 0; scanf( %s , str + 1); for (i = 1; str[i]; i++) { if ((str[i] == * || str[i] == / ) && (str[i - 1]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, dist[110][110]; scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf( %d , &dist[i][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; cout << 2 * n - 1 << << 2 << n ; cout << 1 << << 2 << n ; } |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, x, y, z, ans2, ans; int ans1[101]; int main() { cin >> n >> m; for (i = 1; i <= m; i++) { y = -1; for (j = 1; j <= n; j++) { cin >> x; if (x > y) { y = x; z = j; } } ans1[z]+... |
#include <bits/stdc++.h> using namespace std; struct edge { int u, v, w, id; } e[500001]; int f[500001], last[500001]; int Left[500001]; struct que { int x, y, next; } q[1000001]; int head[500001]; int cnt; void init() { cnt = 0; memset(head, -1, sizeof(head)); } void add_edge(in... |
#include <bits/stdc++.h> using namespace std; const int N = 55; int read() { int w = 0, f = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) f = 1, c = getchar(); while (c >= 0 && c <= 9 ) w = w * 10 + c - 0 , c = getchar(); return f ? -w : w... |
#include <bits/stdc++.h> inline int read() { int x; char c; while ((c = getchar()) < 0 || c > 9 ) ; for (x = c - 0 ; (c = getchar()) >= 0 && c <= 9 ;) x = x * 10 + c - 0 ; return x; } int a[100000 + 5]; void solve(int n) { for (int i = 20, x; i; --i) if (n & (1 << i))... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5004; const int MAXNN = MAXN * 2 + 10; const int INF = 0x3f3f3f3f; struct Edge { int u, v, f, cap; Edge() { f = 0; } Edge(int uu, int vv, int cc) : u(uu), v(vv), f(0), cap(cc) {} inline int other(int w) { return w == u ? v : u; } ... |
#include <bits/stdc++.h> using namespace std; double cp(const complex<double> &a, const complex<double> &b) { return a.real() * b.imag() - b.real() * a.imag(); } inline complex<double> line_inter(const complex<double> &a, const complex<double> &b, ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline int read(T& x) { x = 0; char c = getchar(), f = 1; while (c > 9 || c < 0 ) { if (c == - ) f = -1; if (c == -1) return -1; c = getchar(); } while (c <= 9 && c >= 0 ) x = (x << 1) + (x << 3)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.