func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int inf = 0x3f3f3f3f; const int Minf = 0x7f7f7f7f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const long long MINF = 0x7f7f7f7f7f7f7f7fll; const int N = 2e5 + 50; vector<int> t[N]; int dfn[N], rig[N]; int fa[N][20], dep[N]... |
#include <bits/stdc++.h> using namespace std; int main() { double r, x1, y1, x2, y2; cin >> r >> x1 >> y1 >> x2 >> y2; long long x = (long long)sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / 2 / r; if (x * 2.0 * r < sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))) cout << x ... |
#include <bits/stdc++.h> using namespace std; int n, i, j, x; long long m, k, x1, u1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6; bool t = 0; int main() { cin >> x1 >> u1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> x5 >> y5 >> x6 >> y6; m = (x2 - x1) * (y2 - u1); if (x3 < x2 && y3 < y2 && x4 > x1 && y4 > u... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; unsigned seed = chrono::system_clock::now().time_since_epoch().count(); mt19937 eng(seed); long long random2() { return (1ll << 31ll) * eng() + eng(); } struct FT { vector<long long> s; FT(int n) : s(n) {} void update(int p... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > v; vector<long long> p; int main() { long long n, i, j, x; long long m; cin >> n; cin >> m; for (i = 0; i < n; i++) { cin >> x; p.push_back(x); } long long z = *max_element(p.begin(), p.end(... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, d, i, j = 1, k, l = 0, n, m, t, s = 0, p, r, ans, w = 0, y, x, lcm, gcd, q, count; string str; vector<string> vc; vector<string> vc2; map<long long int, long long int> mp; set<s... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; int n; vector<pair<int, int> > v[maxn]; int size[maxn]; long long mi, mx; void dfs(int first, int fa) { size[first] = 1; for (pair<int, int> i : v[first]) { if (i.first == fa) continue; dfs(i.first, first); ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; const int MOD = 1e9 + 7; const int LEN = 8, MAGIC = 1e8; int a[N], b[N]; int n; char bignum[N]; long long m[N]; int tot; int f[N], g[N]; int add(int a, int b) { a += b; if (a < 0) a += MOD; if (a >= MOD) a -= MOD; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; bool black[MAX]; vector<int> vec[MAX]; bool old_black[MAX]; const int MAX_BLOCK_SIZE = 600; int t[MAX], v[MAX]; bool used[MAX]; vector<pair<pair<int, int>, int>> v2[MAX]; int push[MAX]; bool clear[MAX]; void dfs_1(int pos, int... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const double eps = 1e-6; int x[8], y[8]; bool check(int a, int b) { return a >= min({x[0], x[1], x[2], x[3]}) && a <= max({x[0], x[1], x[2], x[3]}) && b >= min({y[0], y[1], y[2], y[3]... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0), eps = 1e-4; const int inf = ~0U >> 2; int mod = 1e9 + 7; int Pow(int x, long long t) { int r = 1; for (; t; t >>= 1, x = (long long)x * x % mod) if (t & 1) r = (long long)r * x % mod; return r; } const long long ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int a[1005]; int main() { int x, y, n; cin >> x >> y; int a[10] = {-x, -y, x - y, x, y, y - x}; cin >> n; int ans = (n + 2) % 6; a[ans] %= mod; if (a[ans] < 0) a[ans] += mod; cout << a[ans] << endl; ret... |
#include <bits/stdc++.h> using namespace std; long long int M = 1e9 + 7; long long int cdiv(long long int a, long long int b) { return (a % b == 0) ? a / b : a / b + 1; } long long int myMod(long long int a, long long int b) { long long int r = a % b; return r < 0 ? r + b : r; } long long int ... |
#include <bits/stdc++.h> const int MAX = 111; using namespace std; int A[MAX]; int main() { int N, a, b; scanf( %d%d%d , &N, &a, &b); for (int i = 0; i < (a); ++i) { int(x); scanf( %d , &x); A[x] = 1; } for (int i = 0; i < (b); ++i) { int(x); scanf( %d , &x); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, T; cin >> t; for (T = 0; T < t; T++) { long long l, i; string s, s1, s2; cin >> s; l = s.size(); for (i = 0; i < l / 2; i++) { s1.push_back(s[i]); } for (i = l / 2; s[i] != 0 ; i++... |
#include <bits/stdc++.h> using namespace std; int a[150], b[150]; void put(int x, int y[]) { if (x == 1) y[1] = 1; else if (x == 2) { y[1] = 3; y[2] = 4; } else { for (int i = 1; i <= x - 1; i++) y[i] = 2; y[x] = x - 2; } } int main() { int n, m; scanf( %d... |
#include <bits/stdc++.h> using namespace std; template <typename T> vector<T>& operator--(vector<T>& v) { for (auto& i : v) --i; return v; } template <typename T> vector<T>& operator++(vector<T>& v) { for (auto& i : v) ++i; return v; } template <typename T> istream& operator>>(istream&... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; vector<vector<int>> adj; vector<bool> vis; vector<int> dep; vector<int> sz; vector<int> dif; void dfsd(int v, int c) { vis[v] = true; c++; for (auto it = adj[v].begin(); it != adj[v].end(); ++it) { if (vis[*it]... |
#include <bits/stdc++.h> using namespace std; long long n, sd, i, j, top, s, ans[100005], pos[100005], a[100005]; bitset<100005> f[62], g[62]; void read(long long &p) { p = 0; char x = getchar(); while (x < 0 || x > 9 ) x = getchar(); while (x >= 0 && x <= 9 ) { p = p * 10 + x - 0 ;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } void solve() { long long p, q; cin >> p >> q; long long g = p; long long t = q; map<long long, long long> f, l; for (long long i = 2; i * i <= t; i++) { if (t % i =... |
#include <bits/stdc++.h> using namespace std; template <typename Kausi> void debug(vector<Kausi> v) { cerr << v = [ ; long long n = v.size(); for (int i = 0; i < n; i++) { cerr << v[i]; if (i < n - 1) cerr << , ; } cerr << ] length = << v.size() << n ; } long long str... |
#include <bits/stdc++.h> using namespace std; long long d, k, a, b, t; void solve() { cin >> d >> k >> a >> b >> t; if (d <= k) { cout << d * a; return; } long long ans = k * a + d * b - k * b; long long mult = t + k * a - k * b; if (mult >= 0) { cerr << 1 << n ; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class t, class u> void chmax(t& first, u second) { if (first < second) first = second; } template <class t, class u> void chmin(t& first, u second) { if (second < first) first = second; } template <class t> using v... |
#include <bits/stdc++.h> #pragma GCC optimize( -Ofast , -funroll-all-loops ) using namespace std; const int N = 5e3 + 10; int n, m, k, deg[N], dp[N][N], res, pre[N][N]; int head[N], nex[N], to[N], w[N], tot; inline void add(int a, int b, int c) { to[++tot] = b; nex[tot] = head[a]; w[tot] = c; ... |
#include <bits/stdc++.h> using namespace std; string s1[10], s2[10], name[10], score[10]; map<string, int> mp; int a[10][10]; bool better(int x, int y) { int i; int px = 0, py = 0, mx = 0, sx = 0, sy = 0, my = 0; for (i = 0; i < 4; i++) { if (i != x) { if (a[x][i] > a[i][x]) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, w, x, c; cin >> a >> b >> w >> x >> c; long long ans = 0; if (a < c) ans = ceil((double(a - c) * w + b) / (x - w)); cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; uint64_t getSeed() { auto ptr = new char; delete ptr; return (uint64_t)ptr + chrono::high_resolution_clock::now().time_since_epoch().count(); } mt19937 rnd(getSeed()); ll rndVal(uint64_t a, uint64_t b) { return un... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = 1 << 30; const int mod = 100000... |
#include <bits/stdc++.h> using namespace std; int main() { long long int r, x1, y1, x2, y2; cin >> r >> x1 >> y1 >> x2 >> y2; long long int xd = x2 - x1, yd = y2 - y1; double dist = sqrt(xd * xd + yd * yd); long long int int_part = (int)dist; double frac_part = dist - int_part; long long... |
#include <bits/stdc++.h> using namespace std; int toInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; } long long toInt64(string s) { long long r = 0; istringstream sin(s); sin >> r; return r; } double toDouble(string s) { double r = 0; istringstrea... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, x, count = 0, sum = 0; cin >> n >> x; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; sum = sum + a[i]; } sort(a, a + n); in... |
#include <bits/stdc++.h> const int N = 100005; long long a[N], s[N]; long long max; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %I64d , &a[i]); } std::sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { s[i] = s[i - 1] + a[i]; max += s[... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, i; cin >> n; vector<long long int> a(n), mini(n); for (i = 0; i < (n); i++) cin >> a[i]; mini[n - 1] = a[n - 1]; for (i = n - 2; i >= 0; i--) { mini[i] = min(mini[i + 1], a[i]); } for (i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int n, d; int a[105]; int main() { ios_base::sync_with_stdio(false); cin >> n >> d; for (int i = 0; i < n; i++) cin >> a[i]; int dp[n][n]; sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) dp[i][j] = a[j] - a[i];... |
#include <bits/stdc++.h> using namespace std; int maps[1010][1010]; int n; int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}}; int pre[8][1010][1010]; double sums[8][1010][1010]; void partial() { for (int i = 0; i < 8; i++) { for (int j = 0... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, ll>; int n, m; vector<pii> coupons; bool comp(pii a, pii b) { return a.second > b.second; } ll getlen(ll x) { if (x % 2 == 1) return x * (x - 1) / 2 + 1; return x * (x - 1) / 2 + x / 2; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int MOD = 1e9 + 7; string ans = What are you doing at the end of the world? Are you busy? Will you save us? ; string a = What are you doing while sending ; string b = ? Are you busy? Will you send ; string c ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m; cin >> n >> m; if (m > n) cout << -1; else if (m == n) cout << n; else { long long int x, y; for (y = (n / 2); y >= 0; y--) { if... |
#include <bits/stdc++.h> using namespace std; const int N = 55; int n, m; int sz, inp; long long ans[N]; long long sum[N]; long long suf[N]; long long pre[N]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; ++i) { scanf( %d , &sz); ans[i] = pre[i] = -1e9; while (... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double eps = 1e-8; const int mod = 1e9 + 7; const int P = 1e9 + 7; const int N = 2e7; const int maxn = 1e6 + 5; long long t, a, b, x, y, n, minn; int main() { ios::sync_with_stdio(false); cin >> t; while (t--) ... |
#include <bits/stdc++.h> using namespace std; unsigned long long f(unsigned long long x, int b) { for (int i = 0; i < 64; i++) if (__builtin_popcountll(x) < b) x |= 1ULL << i; return x; } unsigned long long brute(unsigned long long l, unsigned long long r) { unsigned long long ret = l; for... |
#include <bits/stdc++.h> using namespace std; int up[200005]; void init() { memset(up, -1, sizeof(up)); } int Find(int x) { if (up[x] < 0) return x; int root = Find(up[x]); up[x] = root; return root; } void Union(int x, int y) { x = Find(x); y = Find(y); if (x == y) return; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); map<long long, vector<pair<int, int>>> d; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { long long sum = 0; for (int j = i; j < n; j++) { sum += a[j]; ... |
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << ; cout << endl; } template <class T> void chmin(T &t, T f) { if (t > f) t = f; } template <class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() ... |
#include <bits/stdc++.h> using namespace std; const long long int mxN = 1e5 + 5; const long long int MOD = 1e9 + 7; long long int one = 0; long long int ceil1(long long int a, long long int b) { if (a % b == 0) return (a / b); else return ((a / b) + 1); } void solve() { long long i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, o; string st; long long a[maxn], all; int cc[100], where[100], zhu[100], g[maxn], wc[maxn]; int f[66][maxn]; int main() { cin >> n; all = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; all ^= a[i]; ... |
#include <bits/stdc++.h> using namespace std; int N, Q; vector<vector<int>> V; map<pair<int, int>, int> M; int ret[101010]; template <int um> class UF { public: vector<int> par, rank; vector<vector<int>> hist; UF() { par = rank = vector<int>(um, 0); for (int i = 0; i < um; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, ss; getline(cin, s); getline(cin, ss); int ara[500]; memset(ara, 0, sizeof ara); for (auto x : s) if (isalpha(x)) ara[x]++; bool ok = true; for (auto x : ss) { if (isalpha(x)) { if (!ara[x]) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 1e5 + 100; const int maxn = 1e6; const int MAXL = sqrt(1e7) + 1; int n, a[220], f[220][410]; void solve() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); f... |
#include <bits/stdc++.h> using namespace std; int cal(vector<int> q, int n, int m) { int sum = 0; for (int i = (int)0; i < (int)n; ++i) { for (int j = (int)i; j < (int)n; ++j) { int mn = INT_MAX; for (int k = (int)i; k < (int)j + 1; ++k) mn = ((mn) < (q[k]) ? (mn) : (q[k])); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100100; struct node { long long l, r; long long color; long long sum; long long change; } tree[maxn << 2]; long long n, m; int a[maxn]; void pushup(long long cur) { if (tree[cur * 2].color == tree[cur * 2 + 1].color) ... |
#include <bits/stdc++.h> using namespace std; int n = 5000001; void okms() { vector<int> kk(n); kk[0] = 0, kk[1] = 0; for (int(i) = 2; i < n; ++i) kk[i] = 1; vector<bool> ch(n); for (int(i) = 0; i < n; ++i) ch[i] = true; ch[0] = 0, ch[1] = 0; vector<int> trr(n); for (int i = 2; i *... |
#include <bits/stdc++.h> using namespace std; long long n, m, q; long long siz[100005]; long long par[100005]; string s; unordered_map<string, long long> idx; vector<pair<long long, long long> > e[100005]; long long ans[100005]; long long dis[100005]; pair<long long, pair<long long, long long> > edg... |
#include <bits/stdc++.h> using namespace std; int n, now, p[20000], p_, g[10], ans; int xx[10]; int tmp[10000]; int yoo[2][10000][10], f[1000][1000]; void dfs(int k) { int tmp = 0; for (int i = 1; i < k; ++i) tmp = tmp * 10 + xx[i] / g[k + 1] % 10; if (k == n) { ans += ::tmp[tmp]; re... |
#include <bits/stdc++.h> using namespace std; int main() { int tc, n, i, j, p, k; scanf( %d , &tc); while (tc--) { scanf( %d , &n); vector<int> v[n + 5]; for (i = 0; i < n; i++) { scanf( %d , &p); v[p].push_back(i); } k = 0; for (i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int a[200005]; int main() { int n; scanf( %d , &n); int sum = 0; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); sum += a[i]; } vector<int> ans; for (int i = 1; i <= n; ++i) { if ((sum - a[i]) % (n - 1) == 0 && (sum - a... |
#include <bits/stdc++.h> using namespace std; int get(string str) { int cnt = 0; for (int i = 0; i < str.size() - 1; i++) { if (str[i] == V && str[i + 1] == K ) cnt++; } return cnt; } int main() { string str; cin >> str; int res = get(str); for (int i = 0; i < str.size()... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool fs(T &x) { int c = getchar(); int sgn = 1; while (~c && c < 0 || c > 9 ) { if (c == - ) sgn = -1; c = getchar(); } for (x = 0; ~c && 0 <= c && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; x *= ... |
#include <bits/stdc++.h> using namespace std; int main() { int c1, c2, c3, c4; int n, m, x; int b = 0, t = 0, tot = 0; scanf( %d %d %d %d , &c1, &c2, &c3, &c4); scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %d , &x); if (x * c1 > c2) b += c2; else ... |
#include <bits/stdc++.h> using namespace std; int q[111], qr[111], s[111]; int d[222][111]; int dp[111][222]; bool ss[222]; int n, k; bool rec(int kk, int i) { if (dp[kk][k + i] != -1) return dp[kk][k + i]; if (kk == 0) return ss[k + i]; bool r; if (ss[k + i]) r = false; else { ... |
#include <bits/stdc++.h> using namespace std; long long t, a, b; int main() { scanf( %I64d%I64d%I64d , &t, &a, &b); if (t > a && a != b || b < a) printf( 0 n ); else if (t == 1) { if (a == b) { if (a == 1) printf( inf n ); else printf( 1 n ); } els... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007LL; long long large = 2000000000000000000LL; vector<int> dp; vector<vector<int> > adj; int f(int u) { if (dp[u] != -1) return dp[u]; vector<int> ch; for (int j = 0; j < (int)adj[u].size(); j++) { int v = adj[u][j]; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using ll = long long; using ld = long double; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vpi = vector<pi>; using si = set<int>; using sl = set<ll>; using qi = qu... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const double PI = acos(-1); long long mod = 1e9 + 7; struct segment { long long l, r; bool operator<(const segment& s) const { if (r != s.r) return r > s.r; return l < s.l; } }; const long long MAXN = 2e5 + 7... |
#include <bits/stdc++.h> using namespace std; int cum[200000]; int main() { int n, x, k; cin >> n >> x >> k; int arr[n + 10]; set<int> st; map<int, int> pos; int now = 0; for (int i = 1; i <= n; i++) { scanf( %d , &arr[i]); st.insert(arr[i]); } for (set<int>::iterat... |
#include <bits/stdc++.h> using namespace std; int a, b, mn = 1000000009, mx; char c[59][59]; int ist, ien; bool w; int main() { cin >> a >> b; for (int i = 1; i <= a; i++) for (int j = 1; j <= b; j++) { cin >> c[i][j]; if (c[i][j] == * ) mn = min(j, mn), mx = max(j, ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) cout << i << ; cout << endl; } } |
#include <bits/stdc++.h> using namespace std; int main() { long long int q; cin >> q; while (q--) { long long int b, w; cin >> b >> w; if (b >= w) { if (b > 3 * w + 1) { std::cout << NO << std::endl; continue; } else { std::cout << YES ... |
#include <bits/stdc++.h> using namespace std; int n; int a[100010]; int s[100010]; int solve() { int ret = 0, top = 0; for (int i = 0; i < n; i++) { while (top && a[s[top]] < a[i]) --top; if (top) ret = max(ret, a[s[top]] ^ a[i]); s[++top] = i; } return ret; } int main() ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long pw(long long a, long long b, long long p) { if (b == 0) return 1; long long t = pw(a, b / 2, p); if (b % 2) return ((a * t * t) % p); else... |
#include <bits/stdc++.h> using namespace std; const int mod = int(1e9) + 7; const int MX = 200500; long long f[MX]; long long f1[MX]; int pow_mod(long long a, int st) { a %= mod; long long res = 1; while (st) { if (st & 1) { res *= a; res %= mod; } a *= a; ... |
#include <bits/stdc++.h> using namespace std; template <typename TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << = << h << n ; } template <typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) { while (*sdbg != , ) cerr << *sdbg++; cerr << = << h << , ; _dbg... |
#include <bits/stdc++.h> using namespace std; int dp[1 << 25]; int n, m; int a[30][30]; int qi[30][30]; int st[30][30]; char c[30][30]; int lowbit(int x) { return (x & (-x)); } int main() { scanf( %d , &n); scanf( %d , &m); for (int i = 1; i <= n; i++) scanf( %s , c[i] + 1); for (int i... |
#include <bits/stdc++.h> long long n, i, j, h, k, t, d, m, a, b, c; using namespace std; char s; string ss; int main() { cin >> t; for (h = 1; h <= t; h++) { cin >> n; ss = . ; while (n > ss.length()) ss = ss + . ; cin >> a >> b >> c; d = 0; for (i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; queue<int> v1; deque<int> v2; for (int i = 0; i < s.size(); i++) { if (s[i] == ( ) v1.push(i); else { v2.push_front(i); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long a[maxn]; int main() { int n; scanf( %d , &n); priority_queue<long long, vector<long long>, greater<long long>> que; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); que.push(a[i]); } if (n == 1... |
#include <bits/stdc++.h> using namespace std; int main() { int a[3], b[3]; for (int i = 0; i < 3; i++) cin >> a[i] >> b[i]; bool flag = false; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int p = 0; p < 2; p++) { if (max(a[1], a[2]) <= a[0] && b[1] + b[2] ... |
#include <bits/stdc++.h> using namespace std; int N, K; void rip() { puts( -1 ); exit(0); } int main() { scanf( %d %d , &N, &K); if (K == 1) { rip(); } else if (K == 2) { if (N <= 4) rip(); else { printf( %d n , N - 1); for (int i = (1); i < (N); i... |
#include <bits/stdc++.h> using namespace std; int main() { int k, l, i = 0, mod = 0; cin >> k; cin >> l; while (l > 1) { mod += l % k; l = l / k; i++; } if (mod > 0) cout << NO ; else cout << YES << endl << i - 1; return 0; } |
#include <bits/stdc++.h> using std::abs; using std::bitset; using std::cerr; using std::cin; using std::cout; using std::deque; using std::map; using std::max; using std::min; using std::pair; using std::queue; using std::set; using std::sort; using std::string; using std::swap; using st... |
#include <bits/stdc++.h> using namespace std; void imprimirVector(vector<long long> v) { if (!v.empty()) { int p = v.size(); cout << [ ; for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << , ; cout << v[p - 1] << ] << endl; } else cout << [] << endl; } long long to... |
#include <bits/stdc++.h> using namespace std; map<string, long long> mp; int main() { int n; cin >> n; mp.clear(); for (int i = 1; i <= n; ++i) { string tmp; cin >> tmp; mp[tmp]++; } cout << (mp[ UL ] + mp[ DR ] + mp[ ULDR ] + 1) * (mp[ UR ] + mp[ DL ] + m... |
#include <bits/stdc++.h> using namespace std; bool isprime(int n) { if (n == 1) return false; if (n == 2) return true; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } void answer(int f) { if (f) { cout << YES ; } else... |
#include <bits/stdc++.h> using namespace std; int n, m, ans[1010], foo[1010]; int t, l, r; pair<pair<int, int>, int> ranges[1010]; int main() { memset(foo, -1, sizeof(foo)); scanf( %d%d , &n, &m); for (int i = 0; i < m; ++i) { scanf( %d%d%d , &t, &l, &r); ranges[i] = make_pair(pair<int... |
#include <bits/stdc++.h> using namespace std; char s[110000]; char res[110000]; int main() { scanf( %s , s); int resLen = 0; int last = 0; int index = 0; for (int i = 0; i < 110000; i++) res[i] = 0; for (char c = z ; c >= a ; c--) for (int i = index; s[i]; i++) if (s[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { int a[110][110]; int n, i, j; long long s = 0; cin >> n; if (n == 1) { cin >> i; cout << i; return 0; } for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) { cin >> a[i][j]; if (i == j) s += a[... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<pair<long double, long double>> v; for (long long int i = 0; i < n; i++) { long double x, y; cin >> x >> y; v.push_back(make_pair(x, y)); } long double sum = 0; for (lon... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; const int MAXN = 1e3 + 3; int n; bool dp[MAXN][10]; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> s; n = (int)s.length(); s... |
//begin #include <Core> /* * Package: StandardCodeLibrary.Core * */ #include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <utility> #include <vector> #include <list> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #inc... |
#include <bits/stdc++.h> using namespace std; long long get() { long long x = 0; char s = getchar(); while (s < 0 || s > 9 ) s = getchar(); while (s >= 0 && s <= 9 ) x = (x << 3) + (x << 1) + (s ^ 48), s = getchar(); return x; } long long Max(const long long x, const long long y)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 100; long long n, x, y; int a[maxn]; vector<long long> v[maxn]; int vis[maxn]; int flag; void dfs(int u) { int i, j; vis[u] = 1; if (u == y) { flag = 1; return; } for (i = 0; i < v[u].size(); i++) { ... |
#include <bits/stdc++.h> const int N = 100002; int n, k, l[N], r[N]; char s[N]; bool check1() { if (n == k || l[n] == 1 || r[1] == n || l[n - k] == 1 || r[k + 1] == n) return 1; for (int i = 2; i <= n - k; i++) if (s[i - 1] == s[i + k] && l[i - 1] == 1 && r[i + k] == n) return 1; return ... |
#include <bits/stdc++.h> using namespace std; const int N = 35050; const int inf = 1e9; int t[2 * N], lz[N], n, h, k; int dp[55][N], val[N]; pair<int, int> up[N]; int pv[N]; inline void carrot() { for (int i = int(0); i < int(n + 1); ++i) pv[i] = n; for (int i = int(n - 1); i >= int(0); i--) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 300005; int n; int ans = 300005, pos = 1; long long tnow, wnow; struct node { long long t, w; } a[N]; priority_queue<long long, vector<long long>, greater<long long> > q; bool cmp(node a, node b) { return a.t > b.t; } int main() { s... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int inf = 2e9; int ans[208][208]; int n, m; namespace MaxFlow { struct Edge { int to, capacity, revid; Edge() : to(-1), capacity(0), revid(-1){}; Edge(int t, int c, int r) : to(t), capacit... |
#include <bits/stdc++.h> using namespace std; struct s { long long x; long long y; }; vector<s> v; bool cmp(s a, s b) { if (a.x == b.x) return a.y < b.y; return a.x > b.x; } int main() { long long a, b, c, d, e, i, j, k, xx, yy; s aa, bb; scanf( %lld %lld , &a, &b); for (i ... |
#include <bits/stdc++.h> using namespace std; int c1, c2, c3, c4, n, m; const int maxn = 1050; int a[maxn], b[maxn]; int p, q, r, s; int x, y; int main() { cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; x += min(c1 * a[i], c2); } for ... |
#include <bits/stdc++.h> using namespace std; set<pair<int, int> > s; int t[200000]; int n, k, q; int main() { cin >> n >> k >> q; for (int i = 1; i <= n; ++i) scanf( %d , t + i); for (int i = 0; i < q; ++i) { int type, id; pair<int, int> p; scanf( %d %d , &type, &id); p = ... |
#include <bits/stdc++.h> using namespace std; const int dd = (int)1e5 + 7; int A[dd], k[dd], j[dd], G[dd]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < n; ++i) { int l, r; scanf( %d %d , &l, &r); G[l - 1]++, G[r]--; } int F = 0; for (int i = 0; i <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.