func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int tag[10]; int main() { string a, b; while (cin >> a >> b) { memset(tag, 0, sizeof(tag)); ; int len = a.size(); int len1 = b.size(); for (int i = 0; i < len1; i++) { int num = b[i] - 0 ; tag[num]++; } ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int n, k; bool d[1001]; long long dp[1001][2][1001]; int cnt[10001]; long long DP(int i, bool f, int j) { if (i == n) return cnt[j] == k; if (dp[i][f][j] != -1) return dp[i][f][j]; long long ret = 0; if (d[i] =... |
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18, N = 2e6 + 3, BASE = 130; int main() { long long int n, k; cin >> n >> k; vector<int> arr(n), up(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = n - 2; i >= 0; i--) { if (arr[i + 1] == ... |
#include <bits/stdc++.h> using namespace std; void PLAY() { cout << fixed << setprecision(10); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; vector<string> x(n), y(m), ans;... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:64000000 ) using namespace std; const double PI = 2 * acos(0.0); const double eps = 1e-9; template <class T> T jog(T a, T b) { return a + b; } template <class T> T bog(T a, T b) { return a - b; } template <class T> T gon(T a, T b) ... |
#include <bits/stdc++.h> using namespace std; int n; int changed; int answer1, answer2 = 1023; int main() { cin >> n; int i; for (i = 0; i < n; i++) { char tp; cin >> tp; if (tp == | ) { int number; cin >> number; answer1 |= number; answer2 |= num... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; string s, t; char c[N]; int cs[2][N], ct[2][N], q; int main() { scanf( %s , c); s = c; scanf( %s , c); t = c; int at = 0; for (auto &i : s) { at++; if (i == C || i == B ) { i = B ; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T maxi(T a, T b) { return a > b ? a : b; } template <typename T> inline T mini(T a, T b) { return a < b ? a : b; } template <typename T> inline T absl(T a) { return a > 0 ? a : -a; } template <typename T> inli... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; struct node { int l, r, sum; } hjt[maxn * 40]; int a[maxn], root[maxn], cnt; int last[maxn]; void insert(int l, int r, int pre, int &now, int p, int v) { hjt[++cnt] = hjt[pre]; now = cnt; hjt[now].sum = hjt[pre].sum + ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int num = 0; int e[21][21]; int flag[21]; int dfs(int x, int sum, int mid) { if (x > n) { num = num + 1; } else { mid = dfs(x + 1, sum, mid); for (int y = 1; y <= n; y++) { if (num >= k) { break; }... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 50005; const int MAXD = 55; const int MOD = 1e9 + 7; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } wh... |
#include <bits/stdc++.h> using namespace std; long long mdin(long long a, long long m) { long long r1 = m, r2 = a, t1 = 0, t2 = 1; while (r2 > 0) { long long q = r1 / r2; long long r = r1 % r2; r1 = r2; r2 = r; long long t = (t1 - q * t2) % m; t1 = t2; t2 = t; }... |
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define pb push_back #define mp make_pair #define rep(n) for(int i=0;i<n;i++) #define repit(x) for(auto it : x) #define ll long long #define vi vector<int> #define vc vector<char> ... |
#include <bits/stdc++.h> using namespace std; int n, m; int table[1000][1000]; int main() { int k = 0; scanf( %d %d %d , &n, &m, &k); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { scanf( %d , &table[i][j]); } } while (k) { char command; int x, y;... |
#include <bits/stdc++.h> using namespace std; ifstream Cin( input.txt ); ofstream Cout( output.txt ); int main() { long long i, n4 = 0, n7 = 0, n; string a, b; cin >> a >> b; for (i = 0; i < a.length(); i++) if (a[i] != b[i]) { if (a[i] == 4 ) n4++; else ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; ll min(ll a, ll b) { if (a < b) return a; return b; } void solve() { ll testCases; cin >> testCases; while (testCases--) { ll n; cin >> n; vector<ll> arr(n); vector<ll> res(n, 1); for (int i =... |
#include <bits/stdc++.h> using namespace std; const int maxN = 3000 + 1; pair<int, int> a[maxN]; pair<int, int> b[maxN]; int nx[maxN], pr[maxN], v[maxN]; int r, c, n; inline int gg(int i) { pair<int, int> x = {a[i].second, a[i].first}; return lower_bound(b, b + n + 2, x) - b; } inline int ff(i... |
#include <bits/stdc++.h> using namespace std; int arr[500005], brr[500005]; pair<int, int> tree[500005 * 4]; vector<int> vv[500005]; vector<pair<int, int> > qr[500005]; int ans[500005]; void build(int node, int b, int e) { if (b == e) { tree[node] = make_pair(500000000, 500000000); return;... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int MAXN = 200000; int n, tot; bool bz[N]; vector<int> g[N], edge[N]; int e[N * 2][2], gg[N]; int sz; long long ans[N]; void add(int x, int y) { e[++tot][0] = y; e[tot][1] = gg[x]; gg[x] = tot; } void dfs(int... |
#include <bits/stdc++.h> using namespace std; int main() { int k, n; scanf( %d%d , &n, &k); vector<int> a(n), b(n), distributed(n), p(n); vector<vector<int> > cart(k); for (int i = 0; i < n; ++i) { scanf( %d%d , &a[i], &b[i]); distributed[i] = 0; p[i] = i; } for (int i ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const int mod = (int)1e9 + 7; const double pi = acos(-1.0); const double eps = 1e-9; const int maxn = (int)2e6 + 11; long long n; long long a[maxn]; long long sum[maxn]; int main() { cin >> n; a[1] = 2; sum[1] = 2; ... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> mp[12]; long long a[200005], dig[200005]; long long state[200005][12]; int main() { long long n, k; scanf( %lld %lld , &n, &k); for (int i = 0; i < n; i++) scanf( %lld , &a[i]); for (int i = 0; i < n; i++) { dig[i] =... |
#include <bits/stdc++.h> using namespace std; const long long LINF = ~0ULL >> 1; const int N = 1e3 + 7; const int INF = 2e8 + 7; const int MOD = 1e9 + 7; const double PI = acos(-1.0); const double EPS = 1e-8; int n; long long calc(long long A, long long B, long long C) { return (A + 1) * (B + 2) *... |
#include <bits/stdc++.h> using namespace std; int n, x, r[100000], pos[100000], flag = 1, flag2; pair<int, int> a[100000]; vector<int> ans, ans2; int l(int n) { if (!n) return 1; if (n % 10 == 4 || n % 10 == 7) return l(n / 10); return 0; } int main() { scanf( %d , &n); for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10; const int MOD = 998244353; const int INF = 10; int fact[MAXN], invfact[MAXN]; int add(int a, int b) { int sum = a + b; return (sum >= MOD ? sum -= MOD : (sum < 0 ? sum += MOD : sum)); } int mul(int a, int b) { return 1LL * ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int* m = new int[n]; int* r = new int[n]; for (int i = 0; i < n; i++) { cin >> m[i]; } for (int i = 0; i < n; i++) { cin >> r[i]; } double total = 0; for (int i = 0; i < 1000000; i++) { ... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 1, -1, -1}; int dy[] = {1, -1, -1, 1}; long long int n, k, d1, d2, rem; bool _solve(long long int w1, long long int w2, long long int w3) { long long int tar = n / 3; if (w1 < 0 || w2 < 0 || w3 < 0) return false; if (tar >= w1 && tar >= ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1.01e9; const double eps = 1e-9; const int N = 1010; char s[N][N]; char res[N * N]; int resc = 0; char ch[4] = { D , L , R , U }; int dx[4] = {1, 0, 0, -1}; int dy[4] = {0, -1, 1, 0}; pair<int, int> q[N * N]; int st = 0, en = 0; ... |
#include <bits/stdc++.h> using namespace std; char s[100010], a[110], b[110]; int pa[110], pb[110]; int main() { scanf( %s%s%s , s, a, b); int i, j; j = -1; pa[0] = -1; int lena = strlen(a); for (i = 1; i < lena; i++) { while (j > -1 && a[j + 1] != a[i]) j = pa[j]; if (a[j + ... |
#include <bits/stdc++.h> using namespace std; long long N, a[100010], s[100100], cnt[100010]; void update(long long *t, long long pos, long long val) { for (; pos <= N; pos += pos & (-pos)) t[pos] += val; } long long query(long long *t, long long r) { long long res = 0; for (; r > 0; r -= r & (-r)... |
#include <bits/stdc++.h> using namespace std; int res[111]; int a[111][111]; bool used[111]; ; bool used_j[111]; int v[111]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 10; const long long INF = 1e18; const long double EPS = 1e-12; int a[300005]; map<int, int> mi; int l_, r_; long long pre[300005]; int b[300005]; int main() { int n; scanf( %d , &n); for (int i =... |
#include <bits/stdc++.h> using namespace std; inline int Read() { int x = 0, f = 1, c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 300005; int n, m, a[MAXN], f[MAXN], g[MAXN]... |
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { int m; int n; cin >> m >> n; vector<int> a[500]; vector<int> b[500]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; auto solve = []() { int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].first--; }... |
#include <bits/stdc++.h> using namespace std; long long int res(long long int x) { long long int ans = 0; if (x > 0) ans = (x * (x - 1)) / 2; return ans; } int main() { long int n; long long int d; cin >> n >> d; vector<long long int> vect; long long int x; for (long int i = ... |
#include <bits/stdc++.h> using namespace std; bool Check(int N, int pos) { return (bool)(N & (1 << pos)); } int Set(int N, int pos) { return (N | (1 << pos)); } long long BigMod(long long B, long long P, long long M) { long long R = 1; while (P > 0) { if (P % 2 == 1) { R = (R * B) % M; ... |
#include <bits/stdc++.h> using namespace std; char bd[1100][1100]; int n, m; int rt[1100][1100]; int down[1100][1100]; int cnt[1100][1100]; int check(int width, int height, int x, int y) { int filled = 0; bool first = true; while (true) { int godown = down[x][y] - height; if (godow... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const int N = 100100; char a[N], b[N]; int n, m, k, p[27]; int Par(int i) { return p[i] = (i == p[i]) ? i : Par(p[i]); } bool same(int i, int j) { return Par(i) == Par(j); } int comp[27]; void mrg(int i, int j) { if (same(i, j)... |
#include <bits/stdc++.h> using namespace std; double pi = acos(-1); struct point { int x, y; } p[2005]; vector<double> v; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d%d , &p[i].x, &p[i].y); long long ans = 0; for (int i = 1; i <= n; i++) { v.clear... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6, MAX = 2e5 + 5, OO = 1000000009; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } long long lcm(long long x, long long y) { return (x * y / gcd(x, y)); } long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000 * 1000 * 1000 + 7; const int INF = 2000 * 1000 * 1000; const double EPS = 1e-9; const double pi = acos(-1.0); const int maxn = 100010; inline long long sqr(int n) { return n * 1ll * n; } struct Point { int x, y; Point() {} in... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, m; cin >> n >> m; vector<long long> col(m); for (long long i = 0; i < m; i++) { cin >> col[i]; } vector<long long> suf(m, 0); suf[m - 1] = 0; for (long long ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int iinf = 1 << 29; const long long llinf = 1ll << 60; const double PI = 3.14159265; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long mrand(long long B) { return (unsigned long long)rng() % ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, x, sum = 0; long long int c[100009]; scanf( %lld %lld , &n, &x); for (i = 0; i < n; i++) { scanf( %lld , &c[i]); } sort(c, c + n); for (i = 0; i < n; i++) { sum = sum + c[i] * x; x--; i... |
#include <bits/stdc++.h> using namespace std; const long long inf = 2147383647; const double pi = 2 * acos(0.0); const double eps = 1e-9; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; inline long long gcd(long lon... |
#include <bits/stdc++.h> using namespace std; int f[4040][4040], n, k, ans; struct info { int be, ti; } e[4040]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d%d , &e[i].be, &e[i].ti); e[n + 1].be = 86401; if (n == k) { printf( 86400 ); return 0; ... |
#include <bits/stdc++.h> using namespace std; inline long long fmm(long long a, long long b, long long m = 1000000007) { long long r = 0; a %= m; b %= m; while (b > 0) { if (b & 1) { r += a; r %= m; } a += a; a %= m; b >>= 1; } return r % m; } ... |
#include <bits/stdc++.h> using namespace std; long long t = 1; void solve() { long long n, x, y, cnt = 0, p = 1; cin >> n; vector<long long> arr(n + 1), vis(n + 1, 0); vector<vector<long long> > v(n + 1); for (long long i = 0; i < n - 1; i += 1) { cin >> x >> y; v[x].push_back(y); ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> point[100]; double ang[100]; double dp[10000000]; int i, j, k, N, M, K, l, r; void clear() {} void init() { scanf( %d%d%d , &N, &l, &r); for (i = 0; i <= N - 1; i++) { int first; scanf( %d%d%d , &point[i].first, &point[i].sec... |
#include <bits/stdc++.h> using namespace std; int vis[100005], n, m, x, y, mi, eg, re; char t; vector<vector<pair<int, int> > > adj; vector<vector<int> > re1; vector<int> t0, t1; void dfs(int u, int ty) { if (vis[u] == -1) { vis[u] = ty; if (ty == 0) t0.push_back(u); else ... |
#include <bits/stdc++.h> using namespace std; int hashCh = 31; struct HashCh { string code; int number; }; long long getHash(string text) { long long hash = 0; int size = text.size(); for (int i = 0; i < size; i++) { int ch = static_cast<int>(text[i]); hash += pow(hashCh, i) * ... |
#include <bits/stdc++.h> using namespace std; struct fastIO { fastIO() { ios_base::sync_with_stdio(0); } }; const int MAXN = 1e6 * 2; long long n, a[MAXN], x, ans = MAXN, b; int main() { fastIO(); cin >> n; for (long long i = 0; i < n; i++) cin >> a[i]; for (x = 0; x < n; x++) { b ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k, x; cin >> n >> k; char s; string str; int p = n / k, q = n % k; for (int i = 0; i < k; ++i) { x = i + 97; s = x; if (i == k - 1) p = p + q; ... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=405; const int P=998244353; ll dp[2][maxn][maxn][3][3],sum[maxn][maxn]; int cur,las,n,c[26]; void add(ll &dpp,ll add) { add%=P; while(add<0) add+=P; dpp+=add; while(dpp>=P) dpp-=P; } int main() { scanf( %d... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { a = abs(a), b = abs(b); if (a < b) swap(a, b); return b ? gcd(b, a % b) : a; } vector<vector<int> > adj; set<int> st; const int dx[] = {0, 0, -1, 1}; const int dy[] = {-1, 1, 0, 0}; long long n, ary[30000... |
#include <bits/stdc++.h> using namespace std; vector<int> v[100001]; int n, cost[100001]; int gr, nod, gr2; void DFS(int x, int t, int val) { for (int i = 1; i <= v[x][0]; i++) { if (v[x][i] != t) { if (val == 0) { DFS(v[x][i], x, cost[v[x][i]]); } else { if (val ... |
#include <bits/stdc++.h> using namespace std; int Ans[1001], A[1001], B[1001], C[1001], D[1001], E[1001]; int value(int Arr[], int i, int j, int k) { return (Arr[j] - Arr[i]) * (Arr[k] - Arr[i]); } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> A[i] >> B[i] >> C[i] >>... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int T; cin >> T; while (T--) { int N; cin >> N; vector<int> a(N); ; for (int& x : a) cin >> x; int ans = (a[0] == 1); fo... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using Vi = vector<int>; using Pii = pair<int, int>; int uplg(int n) { return 32 - __builtin_clz(n); } int uplg(ll n) { return 64 - __builtin_clzll(n); } void run(); int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fi... |
#include <bits/stdc++.h> using namespace std; int main() { string q[41]; long long n, p, i, count = 1, check = 1; cin >> n >> p; for (i = 0; i < n; i++) cin >> q[i]; for (i = n - 2; i >= 0; i--) { if (q[i] == halfplus ) { count = count * 2 + 1; check++; } else ... |
#include <bits/stdc++.h> using namespace std; void solve(); const int N = 10000005; long long i, j, n, s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { solve(); cout << n ; } return 0; } void solve() { cin >> n; for (i ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; int main() { long long dp[3001][100][2] = {0}; long long n, l; cin >> n >> l; vector<long long> a(n), b(n); for (long long i = 0; i < n; ++i) { cin >> a[i] >> b[i]; dp[a[i]][i][0] = 1; dp[b[i]][i][1] = ... |
#include <bits/stdc++.h> using namespace std; int par[100005], val[100005]; int lefm[100005], rim[100005]; int root = 0; vector<vector<int> > adjl; int n; void pre(int node) { if (adjl[node].size() == 0) { lefm[node] = val[node]; rim[node] = val[node]; return; } for (int i = ... |
#include <bits/stdc++.h> using namespace std; long double judge1(long long k, long long d, long long t) { long double ans; long double unit = k + (d - k) * 1.0 / 2; ans = floor(t / unit) * d; long double res = t * 1.0 - floor(t / unit) * unit; if (res <= k) { ans += res; return ans; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<bool> pref(1 << n); for (int i = 0; i < k; i++) { int x; cin >> x; pref[x - 1] = true; } const int oo = -1; vect... |
#include <bits/stdc++.h> using namespace std; int n; int l[2005], r[2005]; long long k, w[2005]; long long s[2005][2005]; long long f[2005]; long long h[2005]; long long up(long long x) { return (x / k + (x % k > 0)); } int main() { cin >> n >> k; for (int i = (1); i <= (n); i++) cin >> l[i] >... |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int n, a[maxn]; int main() { scanf( %d , &n); for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]); for (int i = (1); i <= (n - 1); ++i) { for (int j = (1); j <= (a[i]); ++j) printf( PRL ); printf( R ); } for (int... |
#include <bits/stdc++.h> using namespace std; long long n, h, ok; long long cal(long long dep, long long pos, int tag) { if (ok) return 0; if (dep == 0) { ok = 1; return 0; } long long tmp; if (!tag) { if (pos > (1LL << (dep - 1))) tmp = (1LL << dep) + cal(dep - 1, po... |
#include <bits/stdc++.h> long long a[100][100]; using namespace std; struct DynamicDisjointSetDS { std::unordered_map<int, int> parent, degree; int N; DynamicDisjointSetDS(int n) { N = n; } int getParent(int vertex) { if (parent.find(vertex) != parent.end()) { if (parent[vertex] != v... |
#include <bits/stdc++.h> using namespace std; int read() { int f = 1, x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -f; c = getchar(); } while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return f * x; } inline int lowbit(int x) { re... |
#include <bits/stdc++.h> using namespace std; struct grp { long long to, wt, edgeCode; char type; }; struct Node { long long x, dis; }; struct comp { inline bool operator()(const Node& n1, const Node& n2) const { if (n1.dis != n2.dis) return n1.dis < n2.dis; return n1.x < n2.x; ... |
#include <bits/stdc++.h> long long int power(long long int x, long long int b) { long long int p = 1; while (b > 0) { if (b & 1) { p = p * x; p %= 1000000007; } b >>= 1; x *= x; x %= 1000000007; } return p % 1000000007; } using namespace std; struct ... |
#include <bits/stdc++.h> using namespace std; vector<int> di[100003]; struct trie { trie *zero, *one; int val; trie() { zero = one = NULL; val = 100003; } } * root[100003]; void add(trie *cur, int a) { int i, ck; for (i = 20; i >= 0; i--) { ck = (1 << i & a); if... |
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n <= 1) return false; for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; } int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; vector<long long... |
#include <bits/stdc++.h> using namespace std; char bb[111][111]; int in[111][111]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) scanf( %s , bb[i]); vector<pair<pair<int, int>, int>> stars; for (int i = 1; i < n - 1; i++) { for (int j = 1; j < m - 1; j++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 500; const int LN = 21; const long long mod = 1e9 + 7; const long long INF = 1LL << 57; long long n, m, u, v, k, t, q, a, x, d; int tree[4 * N]; int sum[4 * N]; int lim = 1e6 + 2; int arr[N], brr[N]; bool print = false; void modif... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k, d; cin >> n >> k >> d; long long a[101], b[101]; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); a[0] = 1; long long sum = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &a) { T x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = ... |
#include <bits/stdc++.h> using namespace std; long long n, l, v1, v2, k; long double dn, dl, dv1, dv2, dk; long long times; long double x; double T; int main() { scanf( %lld%lld%lld%lld%lld , &n, &l, &v1, &v2, &k); dn = n; dl = l; dv1 = v1; dv2 = v2; dk = k; times = (n - 1) / k... |
#include <bits/stdc++.h> using namespace std; int const N = 3e5; int n, p1[N], p2[N], p3[N], num1[N], num2[N], F[N][2], T[N * 4]; void buildT(int v, int tl, int tr) { if (tl == tr) { T[v] = 1; } else { int tm = (tl + tr) / 2; buildT(v * 2, tl, tm); buildT(v * 2 + 1, tm + 1, tr); ... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; long long x, y, z, a, b, c, sum, ans, total, t, cnt, n, m, k, p, kase; string s1, s2; map<long long, long long> mp; set<long long> s; map<long long, long long>::iterator itr1, ptr1; set<long long>::iterator itr, ptr; int main() { i... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; long long n, sum, n1, pick, ans, t, a[N], b[N], f[N], f1[N], m, t1; int main() { scanf( %lld , &n); for (int i = 1; i <= 8; i++) { scanf( %lld , &a[i]); sum = sum + a[i] * i; } if (sum <= n) return printf( %lld n ,... |
#include <bits/stdc++.h> using namespace std; string st[5050]; int fr[27]; int main() { memset(fr, 0, sizeof(fr)); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> k >> n; for (int i = 0; i < k; i++) { cin >> st[i]; } string res = st[0]; memset(fr,... |
#include <bits/stdc++.h> using namespace std; int a[5]; int main() { scanf( %d%d%d%d , &a[0], &a[1], &a[2], &a[3]); while (a[0] != 1 || a[1] != 1 || a[2] != 1 || a[3] != 1) { bool f = 1; for (int i = 0; i < 4; i++) if (a[i] % 2 == 0 && a[(i + 1) % 4] % 2 == 0) { printf( /%d n... |
#include <bits/stdc++.h> using namespace std; string multiply(string num1, string num2) { int len1 = num1.size(); int len2 = num2.size(); if (len1 == 0 || len2 == 0) return 0 ; vector<int> result(len1 + len2, 0); int i_n1 = 0; int i_n2 = 0; for (int i = len1 - 1; i >= 0; i--) { in... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, x[N], y[N], xs[N], ys[N], cnt[2][2]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &x[i], &y[i]); xs[i] = x[i], ys[i] = y[i]; } sort(xs + 1, xs + n + 1); sort(ys + 1, ys + n + ... |
#include <bits/stdc++.h> using namespace std; int main() { cout << fixed; double d, L, v1, v2; cin >> d >> L >> v1 >> v2; cout << setprecision(8) << (L - d) / (v1 + v2) << endl; } |
#include <bits/stdc++.h> using namespace std; long long scan_d() { char t = getchar(); long long you = 0; while (t > 9 || t < 0 ) t = getchar(); while (t <= 9 && t >= 0 ) { you *= 10; you += t - 0 ; t = getchar(); } return you; } long long dp[1050][1050]; long ... |
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &x) { int f = 0; x = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f |= (ch == - ); for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; if (f) x = -x; } const int N = 20, mod = 998244353... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long mod = 1e9 + 7; const long long N = 1e5 + 10; inline long long add(long long x, long long y) { x += y; if (x >= mod) x -= mod; return x; } inline long long mul(long long x, long long y) { x = (1LL * x ... |
#include <bits/stdc++.h> using namespace std; vector<int> c; vector<bool> used; void dfs(int u, vector<vector<int>>& v) { used[u] = 1; for (int i = 0; i < v[u].size(); i++) { if (c[u] == c[v[u][i]] && !used[v[u][i]]) { dfs(v[u][i], v); } } } int main() { int n; cin >>... |
#include <bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } long long power(long long a, long long b) { if (b == 0) { return 1; } else { if (b % 2 == 0) { return (a * power((a * a) % 1000000007, b / 2)) % 1000000007; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; struct node { double x, y; } po[1010]; double dis(node a, node b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } node mark; double cha(node a, node b, node c) { return (b.x - a.x) * (c.y - a.y)... |
#include <bits/stdc++.h> using namespace std; long long n, x, c, cnt; vector<long long> v1, v2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; while (n--) { cin >> x; if (x > 0) v1.push_back(x), c += x; else v2.push_back(abs(x)... |
#include <bits/stdc++.h> long long n, t, ans; short i, j, k; char cnt, l; long long C[43][43]; int main() { scanf( %I64d %I64d , &n, &t); for (i = 0; (1ll << i) < t; ++i) ; if ((1ll << i) ^ t) { puts( 0 ); return 0; } k = i + 1; for (i = 0; i < 43; ++i) C[0][i] = 1ll;... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1001; int dp2[MAX_N][MAX_N], dp5[MAX_N][MAX_N]; int n; string findPath(int (*p)[MAX_N]) { int i = n - 1, j = n - 1; string path = ; while (i != 0 && j != 0) { if (p[i - 1][j] > p[i][j - 1]) { path.insert(0, R ); ... |
#include <bits/stdc++.h> using namespace std; int B, n, m; int li[500008], ri[500008], mx[500008], tag[500008]; short g[480][100008]; int bel[500008], de[500008], ai[500008], pa[500008]; short size[500008]; int find(int x) { if (pa[x] == x) return x; return pa[x] = find(pa[x]); } void link(int... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; long long a[N]; int n; bool check(long long x) { long long sum = 0; for (int i = 2; i <= n; ++i) { if (x - a[i] < 0) return false; sum += x - a[i]; } return (sum >= a[1]); } int main() { scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; bool isPowerOfTwo(int n) { if (n == 0) return false; return (ceil(log2(n)) == floor(log2(n))); } void asquare() { long long n, c = 0, ans = LONG_LONG_MAX; cin >> n; string sn; if (isPowerOfTwo(n) == true) cout << 0 n ; else { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.