func_code_string stringlengths 59 71.4k |
|---|
/*████████████████████████████████████████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████████████████████████ ███████████████████████████▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓███████████████████████ ███████████████████████████▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int MOD = 1e9 + 7; int dx[8] = {0, 0, 1, -1, -1, 1, -1, 1}, dy[8] = {1, -1, 0, 0, -1, -1, 1, 1}; void INPUT() {} void OUTPUT() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { IN... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; } void solve() { long long a, b; cin >> a >> b; long long ct = 0; while (a > 0 && b > 0) { if (a > b) { ... |
#include <bits/stdc++.h> using namespace std; struct query { long long l, r, x; }; int n, a[109]; long long m; int main() { cin >> n >> m; vector<query> v; vector<long long> cp = {1LL << 60}; for (int i = 0; i < n; i++) { cin >> a[i]; int pr = sqrt(a[i]); for (int j = 1... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; const long long int inf = 0x3f3f3f3f3f3f3f3fLL; const double eps = 1e-9; const double PI = acos(-1); long long int i, j, k; void solve(void); inline bool equal(double a, double b) { return fabs(a - b) < eps; } int main... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; cin >> t; while (t-- > 0) { int n; cin >> n; string srr[n]; for (int i = 0; i < n; i++) { cin >> srr[i]; } vector... |
#include <bits/stdc++.h> using namespace std; inline long long rd() { long long x = 0; char o, f = 1; while (o = getchar(), o < 48) if (o == 45) f = -f; do x = (x << 3) + (x << 1) + (o ^ 48); while (o = getchar(), o > 47); return x * f; } const int maxn = 1e2 + 5; const long long... |
#include <bits/stdc++.h> using namespace std; int m, n, a[7][7] = {{0, 1, 2}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}, {0, 2, 1}, {0, 1, 2}}; int main() { cin >> n >> m; n %= 6; cout << a[n][m]; return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline void chkmin(T1& a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chkmax(T1& a, T2 b) { if (a < b) a = b; } using ll = long long; using ld = long double; const string FILENAM... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; long long sum[N][N]; int spt[11][N][N], mn[N][N], arr[N][N]; bool visit[N][N]; int n, m, a, b, x; void buildSparse() { int LN = log2(n) + 1, LM = log2(m) + 1; for (int lg = 1; lg <= LM; lg++) for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; struct Edge { int from, to, w; } edges[maxn]; int val[maxn]; long long ans; int size[maxn], fa[maxn]; bool cmp(Edge a, Edge b) { return a.w > b.w; } int Getfa(int x) { if (fa[x] == x) return x; else ret... |
#include <bits/stdc++.h> using namespace std; int main() { int N, M; char eat; cin >> N >> M; scanf( %c , &eat); char temp[5000]; vector<vector<bool>> grid(N, vector<bool>(M)); for (int r = 0; r < N; r++) { scanf( %s , temp); for (int c = 0; c < M; c++) grid[r][c] = (temp[c] ... |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define MP make_pair #define ll long long #define lb lower_bound #define ub upper_bound #define bs binary_search #define fo(i,a,b) for(int i=a;i<b;i++) #define rfo(i,b,a) for(int i=b;i>=a;i--) typedef vector<ll> vi; ty... |
#include <bits/stdc++.h> using namespace std; struct t { char c; int a, b; t(char c, int a, int b) : c(c), a(a), b(b) {} t() {} }; int n; vector<t> e; double temp; double t0 = 1000; double gen_rand() { int x = rand() + 1, y = rand() + 1; x %= y; return x / (double)y; } in... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); } template <typename T> T lcm(T a, T b) { return (a * (b / gcd(a, b))); } template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << [ ; for (auto v : V) ... |
#include <bits/stdc++.h> using namespace std; string getbiner(long long n) { string ret = ; while (n) { if (n % 2) ret += 1 ; else ret += 0 ; n /= 2; } return ret; } long long getnum(string s) { long long ret = 0; long long now = 1; cout << t ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int arr[n + 1]; int dp[n + 1][3]; for (int i = 1; i <= n; i++) cin >> arr[i]; dp[0][0... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 100 * 1000 + 10; bool f1[maxn], f2[maxn]; int n, dis[maxn], dis2[maxn], barg[maxn], mxdis, mxdis2, jj1, j2, h1, h2; vector<int> e[maxn], e2[maxn]; vector<pair<int, int> > v1, v2; void barg2(int v, int p, int t) { f2[v] = true; dis2... |
#include <bits/stdc++.h> using namespace std; int n; int a[200005]; string ans = ; int main() { ios_base::sync_with_stdio(0); ; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int l = 0, r = n - 1; int mini = 0; while (l <= r) { if (l == r) { if (a[... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int n, a[100100], m, x, rs = 1e9; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= m; i++) cin >> x, a[x]++; for (int i = 1; i <= n; i++) rs = min(rs, a[i]); ... |
#include <bits/stdc++.h> using namespace std; vector<int> a, b; int x[50]; int main() { int n, l; scanf( %d%d , &n, &l); for (int i = 0; i < (int)n; ++i) scanf( %d , x + i); for (int i = 1; i < (int)n; ++i) a.push_back(x[i] - x[i - 1]); a.push_back(x[0] + l - x[n - 1]); for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; complex<double> r() { double a, b; cin >> a >> b; return {a, b}; } double cross(complex<double> a, complex<double> b) { return (conj(a) * b).imag(); } double orient(complex<double> a, complex<double> b, complex<double> c) { return cross(b - a... |
#include <bits/stdc++.h> using namespace std; void USACO(string s) { ios_base::sync_with_stdio(0); cin.tie(0); freopen((s + .in ).c_str(), r , stdin); freopen((s + .out ).c_str(), w , stdout); } const long long MAXN = 5010; void solve() { long long n; string s; cin >> n; ci... |
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; int n, m, ret; char G[maxn][maxn]; bool ok(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; } void dfs(int x, int y) { if (G[x][y] == . ) return; G[x][... |
#include <bits/stdc++.h> const int MOD = int(1E9) + 7; const int MAXN = 100000; int pw[MAXN + 5], cnt[MAXN + 5]; void init() { pw[0] = 1; for (int i = 1; i <= MAXN; i++) pw[i] = 2LL * pw[i - 1] % MOD; } int main() { init(); int n, x; scanf( %d , &n); for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000003; const int maxn = 500010; int n, m; char str[maxn]; struct node { int lr, ud; } ma[maxn]; inline char s(int i, int j) { return str[(i - 1) * m + (j - 1)]; } int tran(int i, int j) { return (i - 1) * m + (j - 1); } int solve() ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; long long k, x; cin >> t; while (t--) { cin >> k >> x; cout << x + ((k - 1) * 9) << endl; } } |
#include <bits/stdc++.h> using namespace std; long long n, t, i, j, a[300006], q; int main() { scanf( %lld , &t); while (t--) { long long ans = 0; memset(a, 0, sizeof a); scanf( %lld%lld , &n, &q); for (i = 1; i <= n; i++) { scanf( %lld , &a[i]); } long long fla... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k1, k2; cin >> n >> k1 >> k2; bool ya = 0; while (k1--) { int a; cin >> a; if (a == n) { ya = 1; } } while (k2--) { int a... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010; vector<int> edges[MAXN]; queue<int> q; int visited[MAXN]; int main() { int n, m, a, b; char x; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> x; if (x == # ) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int n, q; int a[maxn], b[maxn], f[maxn], g[maxn][30]; int c(int l, int r) { int k = (int)log2(r - l + 1); return max(g[l][k], g[r - (1 << k) + 1][k]); } void solve() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]... |
#include <bits/stdc++.h> using namespace std; string itos(int a) { if (!a) return 0 ; string res; while (a) { res += (char)( 0 + (a % 10)); a /= 10; } reverse((res).begin(), (res).end()); return res; } int main() { int n; int a[10], can = 0; ; cin >> n; ... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; long long fn(long long x, long long rn[]) { if (x == rn[x]) return x; else return rn[x] = fn(rn[x], rn); } bool un(long long x, long long y, ... |
#include <bits/stdc++.h> using namespace std; int n, s; int c[3]; void init() { int score; scanf( %d%d , &n, &s); for (int i = 0; i < n; i++) { scanf( %d , &score); c[score - 3]++; } } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void extended_gcd(int a, int b, int c... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e9 + 7; long long a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a, b, x, y, z; cin >> a >> b >> x >> y >> z; cout << max(0ll, y - (a - 2 * x)) + max(0ll, ... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << : << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include<bits/stdc++.h> using namespace std; #define INF 1234567890 #define ll long long int T; int N, M, P; vector<int> g[400401], h[400401]; bool vis[400401], reach[400401], loop[400401]; vector<int> st; int myscc[400401], sz[400401], dp[400401]; void DFS(int n) { vis[n] = true; f... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t; cin >> t; vector<int> a(7); while (t--) { long long k; cin >> k; int sum = 0; for (int i = 0; i < 7; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; struct node { int go[2], sum; node(int x0, int x1, int _sum) { go[0] = x0, go[1] = x1, sum = _sum; } }; node root(-1, -1, 0); vector<node> t = {root}; int get_sum(int v) { return v == -1 ? 0 : t[v].sum; } int go(int v, int id) { if (t[v].go[id] == ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000009; long long A[200000]; long long root(long long a) { long long i = a; if (A[i] != i) { A[i] = root(A[i]); } return A[a]; } void unio(long long a, long long b) { long long ra = root(a); long long rb = root(b... |
#include <bits/stdc++.h> const int maxn = 200005, K = 37, mod = 1e9 + 7; int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; } int dec(int a, int b) { return a - b < 0 ? a - b + mod : a - b; } int mul(int a, int b) { return 1ll * a * b % mod; } int ksm(int a, int b = mod - 2) { int ret = 1;... |
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) - 1; const long long lINF = (1LL << 62) - 1; const double dINF = 1e40; const int MAXT = 1 << 22, MAXN = 1001000; struct seg_tree { int sum[MAXT], len; void build(int n) { for (len = 1; len < n; len <<= 1) ; } ... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)-1e18; const int N = 200 * 1000 + 100; vector<int> g[N]; vector<int> w[N]; vector<pair<long long, long long> > cur; long long add[N]; long long ans[N]; int a[N]; long long dfs2(int v) { ans[v] = add[v]; for (int i... |
#include <bits/stdc++.h> using namespace std; std::mt19937 rnd( (int)std::chrono::steady_clock::now().time_since_epoch().count()); long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int NDIG = 6; const int MAXQ = 100000; const int MAXSUM = 999999; int nvals; int g... |
#include <bits/stdc++.h> using namespace std; bool isprime(int a) { for (int i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } bool v[10010]; int gcd(int a, int b) { if (a % b == 0) return b; return gcd(b, a % b); } int main() { int T; cin >> T; ... |
#include <bits/stdc++.h> const long long mod = 1000000007; const long long Inf = 2 * 1e9; using namespace std; long long toint(string s) { long long anss = 0; for (int(i) = 0; (i) < s.length(); (i)++) anss = anss * 10 + (s[i] - 0 ); return anss; } long long gcd(long long a, long long b) { i... |
#include <bits/stdc++.h> using namespace std; void input() {} int main() { input(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; if (n % 2 == 0) cout << -1 << n ; else { for (int i = 0; i < n; i++) cout << i << ; cout << n ; ... |
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, l; const int N = 1e5 + 8; int vis[N]; vector<int> adj[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >> n; for (i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].push_... |
#include <bits/stdc++.h> using namespace std; double r[1000]; double p = atan(1.) * 4.; int main() { double rez = 0; int n; cin >> n; for (int i = 0; i < n; i++) cin >> r[i]; sort(r, r + n); bool t = true; for (int i = n - 1; i >= 0; i--) { if (t) rez += r[i] * r[i] * p... |
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int i = s.size() - 1; while (s[i] == ? ) { i--; } while (s[i] == 32) { i--; } if (s[i] == y || s[i] == u || s[i] == o || s[i] == i || s[i] == e || s[i] == a ) { ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-6; const int INF = 0x3f3f3f3f; const int MAXN = 1e5 + 10; int cnt, head[MAXN], tot; int n, tim, a[MAXN], root[MAXN]; struct Poi { int w, dfn, dep, col; } poi[MAXN]; bool cmp(int a, int b) { return p... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int row = -n; row <= n; row++) { int top = n - abs(row); for (int i = 0; i < abs(row); i++) { cout << ; } for (int i = 0; i < top; ++i) { cout << i << ; } for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n, d = 0; n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == o ) d++; } if (d == 0) { cout << YES ; return 0; } if ((n - d) % d == 0) { cout << YES ; return 0;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 10002; const int maxm = 15000002; int f[maxm], p[maxn]; bool v[maxn]; int a[maxn]; int n, m, s; int main() { int i, j; for (i = 2; i < 12; i++) { if (!v[i]) p[s++] = i; for (j = 0; j < s && i * p[j] < 12; j++) { v... |
#include <bits/stdc++.h> int minx, miny, minz, maxx, maxy, maxz, n, m, Q, x, y, z, mx1, mn1, mx2, mn2, mx3, mn3, D, cnt; using namespace std; struct node { int l, r, maxx, maxy, maxz, minx, miny, minz, d[3]; } t[2000005]; inline bool cmp(node aa, node bb) { if (aa.d[D] == bb.d[D]) { if (aa... |
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; int gg(int x, int y) { int z = y; while (x % y != 0) { z = x % y; x = y; y = z; } return z; } map<int, vector<int>> X[2... |
#include <bits/stdc++.h> using namespace std; const int MN = 200010; int a[MN], b[MN], p[MN], q[MN]; char ans[MN]; int main() { int t, m, k; for (scanf( %d , &t); t--;) { scanf( %d%d , &m, &k); int pos = 0, pos1; for (int i = 1; i <= k; i++) { scanf( %d , &a[i]); } ... |
#include <bits/stdc++.h> using namespace std; int main() { char a[10][10]; char b[10][10]; vector<char> v, l; long long int i, count = 0, j; for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { cin >> a[i][j]; } } v.push_back(a[0][0]); v.push_back(a[0][1]); v.p... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); int sum = 0, maxi = -1; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; maxi = max(a[i], maxi); } if (maxi > (sum / 2)) cout << T << n ; else... |
#include <bits/stdc++.h> int main() { int k, d, i, n, x; scanf( %d%d , &k, &d); n = k; x = d; if ((k > 1) && (d == 0)) { printf( No solution ); } else { for (i = 1; ((i < n) && (x > 0)); i++) { printf( 1 ); x--; } while (i < n) { printf( 0 ); ... |
#include <bits/stdc++.h> int main() { int n, o, i, k, m; scanf( %d%d , &n, &o); scanf( %d%d , &k, &m); int a[n], b[o]; for (i = 0; i < n; i++) scanf( %d , &a[i]); for (i = 0; i < o; i++) scanf( %d , &b[i]); if (a[k - 1] < b[o - m]) printf( YES ); else printf( NO ); retu... |
#include <bits/stdc++.h> using namespace std; const long long N = 5e5 + 9; vector<long long> adj[N], vec[N]; long long h[N], up[N], ans[N]; pair<long long, long long> edge[N]; vector<pair<long long, long long> > a[N]; void DFS1(long long u, long long par) { h[u] = 1; for (long long v : adj[u]) ... |
#include <bits/stdc++.h> using namespace std; bool dp[10005][3]; int main() { int n, i; string s; set<string> ans; cin >> s; n = s.length(); for (i = n - 1; i >= 5; i--) { if (i + 2 <= n) { if (i + 2 == n || dp[i + 2][1] || (dp[i + 2][0] && s.substr(i + 2, 2) != s... |
#include <bits/stdc++.h> using namespace std; const int maxn = 345; int ai[maxn]; int bi[maxn]; bool used[maxn]; int m, r, t; void init() { for (int i = 1; i <= m; i++) { scanf( %d , &ai[i]); ai[i]++; } } vector<int> V; void play() { memset(bi, 0, sizeof(bi)); memset(used... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, N = 1e5 + 5; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; long long a[n + 5], ans = 0, maxx = 0, sum = 0; vector<long long> e, o; for (int i = 0; i < n; i+... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, x, y; scanf( %d%d%d , &n, &m, &k); bool f = false; while (k--) { scanf( %d%d , &x, &y); int mn = (1 << 20); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (i == 1 || j == 1 || i ... |
#include<bits/stdc++.h> using namespace std; #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define int long long #define rep(i,a,b) for(int i=a;i<b;i++) #define repn(i,a,b) for(int i=a;i>=b;i--) #define ff first #define ss second #define lb lower_bound #define ub upper_... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int ans = 0; int inp; for (int i = 0; i < n; i++) { cin >> inp; int temp = (inp + k - 1) / k; ans += temp; } cout << (ans + 1) / 2 << endl; } |
#include <bits/stdc++.h> using namespace std; map<char, int> m; char letters[30]; int numbers[30]; int mystring[30]; int ceiling(int top, int bottom) { return (top + bottom - 1) / bottom; } int main() { string s; int n; cin >> s >> n; for (int i = 0; i < (int)s.length(); i++) m[s[i]]++; ... |
#include <bits/stdc++.h> using namespace std; const long long Size = 501; const long long mod = 1e9 + 7; long long a[Size], num[Size]; bool vis[Size]; long long f[Size], d[Size]; long long dp[Size][Size]; inline long long min(long long a, long long b) { return a < b ? a : b; } inline long long max(lon... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500010; const int MAXM = 500010; const int INF = 1e9 + 7; const double pi = acos(0.0) * 2.0; const double eps = 1e-12; inline int read(int &x) { scanf( %d , &x); return x; } inline long long read(long long &x) { scanf( %I64d , ... |
#include <bits/stdc++.h> using namespace std; template <class T> using v2d = vector<vector<T> >; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } mt19937 rng(chrono::system_clock:... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { unsigned int n; cin >> n; unsigned long k; cin >> k; if (n & 1) { for (int i = 2; i <= (n); i++) { if (n % i ... |
#include <bits/stdc++.h> using namespace std; void solve(priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > &P, priority_queue<pair<long long, int> > &N, vector<long long> &ans, int k, int x) { while (k > 0) ... |
#include <bits/stdc++.h> using namespace std; char ch[200000]; int main() { scanf( %s , ch + 1); int n = strlen(ch + 1); int flag = 0; for (int i = 1; i <= n; i++) { if (ch[i] != ch[n - i + 1]) flag++; } if (flag == 2 || n % 2 == 1 && flag == 0) printf( YES ); else pr... |
#include <bits/stdc++.h> using namespace std; map<string, int> globmap; int optwin[32000]; int optptsc[32000]; int optptso[32000]; int pts[32000]; map<string, int> hashid; string hashinv[32000]; void findit(int s) { if (optwin[s] != -1) { return; } string S = hashinv[s]; string a... |
#include <bits/stdc++.h> using namespace std; int longestIncreasingSubsequenceDP(int a[], int n) { int dp[n], ans = 0; for (int k = 0; k < n; k++) { dp[k] = 1; for (int i = 0; i < k; i++) { if (a[i] <= a[k]) { dp[k] = max(dp[k], dp[i] + 1); ans = max(dp[k], ans); ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, a[4]; char s[N]; int main() { cin >> n >> s; for (int i = 0; i < n; ++i) { if (s[i] == A ) a[0]++; else if (s[i] == C ) a[1]++; else if (s[i] == G ) a[2]++; else if (s[i] == T... |
#include <bits/stdc++.h> using std::abs; using std::bitset; using std::cerr; using std::cin; using std::copy; using std::cout; using std::deque; using std::endl; using std::fill; using std::fixed; using std::greater; using std::iota; using std::istream; using std::lower_bound; using std::m... |
#include <bits/stdc++.h> using namespace std; const int N = 100 * 1000 + 5; int xs, ys, xt, yt, n, a[N], b[N], r[N]; map<pair<int, int>, int> mark; map<pair<int, int>, int> dist; int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, 1, -1}; void bfs(int x, int y) { queue<pair<int, ... |
#include<bits/stdc++.h> #define ll long long using namespace std; ll T,n,k; void work(){ scanf( %lld%lld ,&n,&k); if(n<=k){printf( %lld n ,(long long)ceil((double)k*1.0/(double)n));return;} else{ if(n%k==0){ printf( %lld n ,1LL); return; } else printf( %lld n ,2LL); } return... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 3000 + 47; vector<int> g[MAX]; vector<int> S; int L[MAX]; int U[MAX]; queue<int> q; int D[MAX]; int n; void dfs(int v... |
#include <bits/stdc++.h> using namespace std; int n, m, l, r, cnt; int a[105]; int main() { cin >> n >> m; for (int i = 0; i < n; ++i) { cin >> l >> r; for (int i = l; i <= r; ++i) { a[i] = 1; } } for (int i = 1; i <= m; ++i) { if (!a[i]) cnt++; } cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, ser = 0, dim = 0; vector<int> v; cin >> n; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } for (int i = 0; i < n; i++) { if (i % 2 == 0) { ser += max(v.front(), v.back()); if (v.f... |
#include <bits/stdc++.h> using namespace std; int n, b, t[32], c[32], s[1 << 11], cnt[1 << 11]; bool dp[12][25][1 << 11]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , t + i); if (t[i] > 1) c[++b] = t[i]; } if (n == 1) { puts( YES ); return 0; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long MOD = 1e9 + 7; long long dp[4000][4000]; long long mn[4000][4000]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(); int n; cin >> n; int t; int speed = 0; int ans = 0; int c = 0; int bs; stack<int> s; cin >> t >> speed; for (int i = 1; i < n; i++) { cin >> t; if (t ==... |
#include <bits/stdc++.h> using namespace std; const double eps(1e-8); const long long inf = -99999999999999999; long long row, col, k, p; long long sumr[1001]; long long sumc[1001]; long long answerR[1000001]; long long answerC[1000001]; priority_queue<long long> Rtmp, Ctmp; int main() { scanf( ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000000 + 7; const long long int N = 10000000 + 6; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; char matrix[4][n]; for (int i = 0; i < 4; i++) for (int j = ... |
#include <bits/stdc++.h> template <typename T> void read(T& val) { std::string tmp = typeid(val).name(); if (strcmp(tmp.c_str(), i ) == 0) scanf( %d , &val); else if (strcmp(tmp.c_str(), x ) == 0) scanf( %I64d , &val); else if (strcmp(tmp.c_str(), d ) == 0) scanf( %lf , &val); ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18; const long double Pi = 3.141592653589793116, EPS = 1e-9, Gold = ((1 + sqrt(5)) / 2); long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 10000... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; using pii = pair<int, int>; struct Node { vector<ll> con; ll h1, h2; } g[100010]; ll dfs(ll n, ll p) { g[n].h1 = g[n].h2 = 0; for (auto &i : g[n].con) { if (i == p) continue; ll k = df... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n, m; cin >> n; vector<int> v(2 * n), v2; for (int i = 0; i < 2 * n; i++) { cin >> v[i]; } for (int i = 0; i < 2 * n; i++) { int d = 1; ... |
#include <bits/stdc++.h> using namespace std; int c[1100000], v[1100000], w[1100000], n, K, s1[1100000], s2[1100000], len1, len2, pre1, pre2; void insert(int k) { while (len1 >= pre1 && v[s1[len1]] <= v[k]) len1--; s1[++len1] = k; while (len2 >= pre2 && c[s2[len2]] >= c[k]) len2--; s2[++len2... |
#include <bits/stdc++.h> using namespace std; string s; int a[305], ans[305], b[305][305], n, mx = 0; bool visit[305]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { cin >> s; for (int j = 0; j < n; j++) { b[i][j + ... |
#include <bits/stdc++.h> using namespace std; long long int isp[100005]; void pp() { for (long long int i = 2; i <= 100000; i++) { if (!isp[i]) { for (long long int j = i * i; j <= 100000; j += i) { isp[j] = 1; } } } } int32_t main() { ios_base::sync_with_stdi... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> p; vector<pair<long long, long long>> adj[101]; long long visited[101]; long long parent[101]; long long maxi = 0; set<long long, greater<long long>> set1; vector<long long> arr; long long ans[101]; void dfs(long long v, long l... |
#include <bits/stdc++.h> using namespace std; using namespace std; vector<int> x[1003]; int a[1003], v[1003]; int n; void pp() { for (int i = 1; i <= n; i++) { for (int j = 0; j < x[i].size(); j++) cout << i << << x[i][j] << n ; } } int main() { int m, k; cin >> n >> m >> k; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; long long n, l, r; pair<long long, long long> dfs(long long x) { if (x == 0) return make_pair(1, 0); else if (x == 1) return make_pair(1, 1); long long tmp = x & 1; pair<long long, long... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.