func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n; int init[110]; string lst[110]; vector<int> fin; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = (int)0; i < (int)n; ++i) cin >> lst[i]; for (int i = (int)0; i < (int)n; ++i) cin >> init[i]; bool flag = 1; whi... |
#include <bits/stdc++.h> using namespace std; int mm[110][110]; int tmp[110][110]; void draw(int a, int b, int v) { for (int lx = 0; lx < a; lx++) for (int ly = 0; ly < b; ly++) tmp[lx][ly] += v; return; } void prt(int a, int b) { for (int lx = 0; lx < a; lx++) { for (int ly = 0; ly ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { return (!b) ? a : gcd(b, a % b); } int n, k; void solve() { cin >> n >> k; string s; cin >> s; vector<vector<int>> mvs; int mxs = 0; int cnt = 0; while (cnt <= n) { vector<... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a == 0) return b; return gcd(b % a, a); } vector<string> results(100001); vector<pair<int, string> > wishes; vector<pair<int, string> > S_M, M_L, L_XL, XL_XXL, XXL_XXXL; bool compare(pair<int, string> a, pa... |
#include <bits/stdc++.h> struct TSubStr { TSubStr(const std::string& text, size_t begin, size_t end) : Text(text), Begin(begin), End(end) {} const std::string& Text; size_t Begin; size_t End; static inline size_t getId(const std::string& text, size_t begin, s... |
#include <bits/stdc++.h> using namespace std; char s1[1000], s2[1000], v[1000], s[1000]; int d[200][200][200]; int p[200][200][200][3]; int pp[1000]; int main() { int i, j, k, l1, l2, l, tmp, ans, bk, ti, tj, tk, m; scanf( %s%s%s , s1, s2, v); l1 = strlen(s1); l2 = strlen(s2); l = strlen... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int mex = 1e9; for (int i = 0; i < m; i++) { int l, r; cin >> l >> r; mex = min(mex, r - l + 1); } cout << mex << n ; for (int i = 0; i < n; i++) { cout << i % mex << ; } ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e4 + 5; class Matrix { public: long long a[3][3]; int n; void Init(int key) { memset(a, 0, sizeof a); if (key) for (int i = 0; i < n; i++) a[i][i] = 1; } Matrix operator*(const Mat... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool smin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const long long N = 1e5 + 10, mod = (long long)1e9 + 7; long long n,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const double eps = 1e-8; map<int, int> ma; int n, x, num; int getId(int x) { if (ma.count(x) == 0) { ma[x] = num++; } return ma[x]; } int cnt[maxn]; vector<int> v; int main() { ... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( fast-math ) using namespace std; mt19937 rnd(time(0) + 228 + k + e + k + e + r + o + f + e + y ); vect... |
#include <bits/stdc++.h> const int N = 1e5 + 10; const int LOGN = 20; long long ans; int n; int pre[N << 1], to[N << 1], head[N], wcnt; long long dis[N]; int val[N], fa[N]; int dep[N]; int table[LOGN][N << 1]; int LOG2[N << 1]; int idcnt; int st[N]; inline int minp(int x, int y) { return (dep[... |
#include <bits/stdc++.h> using namespace std; ifstream fin( input.txt ); ofstream fout( output.txt ); bool isPrime(int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3; for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; } inline ... |
#include <bits/stdc++.h> inline int read() { int data = 0, w = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) w = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) data = data * 10 + (ch ^ 48), ch = getchar(); return data * w; } const in... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5006; const int mod = 1000000009; double x[maxn], y[maxn], z[maxn]; double d[maxn][maxn]; int n; double dis(double x1, double y1, double z1, double x2, double y2, double z2) { double dx = x1 - x2; double dy = y1 - y2; double dz = z... |
#include <bits/stdc++.h> template <typename Y> inline bool updmin(Y &a, Y b) { if (a > b) { a = b; return 1; } return 0; } template <typename Y> inline bool updmax(Y &a, Y b) { if (a < b) { a = b; return 1; } return 0; } template <typename Y> inline Y abs(... |
#include <bits/stdc++.h> using namespace std; string s; int main() { long long k, d, t; scanf( %lld %lld %lld , &k, &d, &t); if (k % d == 0) { printf( %.10lf n , (double)t); return 0; } t *= 2; long long period = (k / d + 1) * d; long long periodPoints = 2 * k + period - k;... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > 9 || c < 0 ) && c != - ) ; for ((c == - ? sg = 1, c = getchar() : 0), first = 0; c >= 0 && c <= 9 ; c = getchar()) first = (first << 1) +... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2500 + 5; int cnt = 0; int rec[MAXN], mp[MAXN][MAXN], dp[MAXN][MAXN]; bool prime[MAXN]; void init(int n) { memset(prime, true, sizeof(prime)); prime[0] = prime[1] = false; for (int i = 2; i <= n; i++) { if (prime[i]) rec[cnt++]... |
#include <bits/stdc++.h> using namespace std; vector<int> prefix_function(string t, string s, int k) { int m = (int)s.size(); s = t + ? + s; int n = (int)s.length(); vector<int> pi(n); for (int i = 1; i < n; ++i) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j]) j = pi[j - 1]; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m; int fw[N][N], fb[N][N]; int dx[8] = {-2, -2, 2, 2, 1, 1, -1, -1}; int dy[8] = {1, -1, 1, -1, 2, -2, 2, -2}; queue<pair<int, int> > q; void bfs(int x, int y, int f[][N]) { for (int i = 1; i <= n; ++i) for (int j = 1; j ... |
#include <bits/stdc++.h> int main() { int N; std::cin >> N; std::set<std::pair<int, int>> doubled; std::set<std::pair<int, int>> pend; int to_double = 0; int f_doubled = 0; int64_t total_damage = 0; int t; int d; for (int i = 0; i < N; i++) { std::cin >> t; std::cin... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5005, MAXC = 1000005; int a[MAXN], b[MAXC], c[MAXC]; int n, k, _max; int main() { if (0) { freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); }; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) sca... |
#include <bits/stdc++.h> using namespace std; const int maxnum = 2005; char str[maxnum][maxnum]; int state[maxnum]; int main() { int m, n; while (~scanf( %d%d , &n, &m)) { memset(state, 0, sizeof(state)); for (int i = 0; i < n; ++i) { scanf( %s , str[i]); for (int j = 0; j ... |
#include <bits/stdc++.h> using namespace std; struct edge { int to, next, w; edge(int _to = 0, int _next = 0, int _w = 0) : to(_to), next(_next), w(_w) {} } e[300010 << 1]; int n, m; int g[300010], nume = 0; int d[300010]; int f[300010][2]; vector<int> ans; namespace LCT { int f[300010]; v... |
#include <bits/stdc++.h> using namespace std; long long int dp[360361]; long long int k; bool reach(long long int from, long long int to) { if (from <= to) return false; long long int d = from - to; if (d == 1) return true; for (long long int i = (long long int)(from - to + 1); i < ((lo... |
#include <bits/stdc++.h> using namespace std; const long long INF = 10000000000; const int maxn = 5010; long long a[maxn]; long long last[maxn]; int dp[maxn]; long long s[maxn]; int n; int main(int argc, char *argv[]) { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); f... |
#include <bits/stdc++.h> using namespace std; int abso(int a, int b) { if (a < b) return b - a; else return a - b; } long long power(long long x, long long e) { long long temp; if (e == 0) return 1; if (e % 2 == 0) { temp = power(x, e / 2); return temp * temp; } e... |
#include <bits/stdc++.h> int n, m, q; std::vector<int> dp; std::vector<std::pair<int, int> > edges; struct bip { std::vector<int> pers; std::stack<std::pair<int, int> > updates; std::stack<int> change; void update(int i, int j) { updates.push({i, pers[i]}); pers[i] = j; } int... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, s = 0, k2 = 0, k1 = 0, z; cin >> n >> m >> k; z = k % 2; while (true) { if (s + 2 * m >= k) { goto v; } else { s = s + 2 * m; k2++; } } v:; cout << k2 + 1 << ; while (tr... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, r; char str[] = { R , O , Y , B , G , I , V }; cin >> n; r = n % 7; n -= r; for (i = 0; i < n; i++) cout << str[i % 7]; for (i = 0; i < r; i++) cout << str[3 + i % 4]; } |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, +1, -1}; int dy[] = {+1, -1, 0, 0}; int dxx[] = {+1, 0, -1, 0, +1, +1, -1, -1}; int dyy[] = {0, +1, 0, -1, +1, -1, +1, -1}; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } vector<pair<long long, long long> > ans; int main(... |
#include <bits/stdc++.h> using namespace std; const long long MAX = 4e6; vector<long long> vec[1000000]; long long N, T, ok, cur = 2, arr[MAX], res[MAX], cnt[MAX], prime[MAX]; void cal() { prime[0] = 1; prime[1] = 1; for (long long A = 2; A < MAX; A++) if (!prime[A]) { if (A < 100000... |
#include <bits/stdc++.h> using namespace std; bool r[1010], c[1010]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; a--; b--; r[a] = 1; c[b] = 1; } int ans = 0; for (int i = 1; i < n - 1; i++) { if (!c[... |
#include <bits/stdc++.h> using namespace std; long long int modinverse(long long int x, long long int y) { if (y == 0) { return 1; } long long int p = modinverse(x, y / 2) % 1000000007; p = (p * p) % 1000000007; return (y % 2 == 0) ? p : (x * p) % 1000000007; } long long int modexp(lon... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int tmp = 0; tmp < t; tmp++) { unsigned long long int n, k; cin >> n >> k; if (k >= n) { cout << 1 << n ; continue; } bool fl = false; for (int i = 2; i * i <= n; i++) {... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; double prob[maxn]; int main() { ios::sync_with_stdio(false); int n, p; while (cin >> n >> p) { int l, r; for (int i = 0; i < n; ++i) { cin >> l >> r; prob[i] = (double)(r / p - (l - 1) / p) / (r + 1 -... |
#include <bits/stdc++.h> using namespace std; const long long int MAX = -1000000000000000000; const long long int MIN = 1000000000000000000; const long long int inf = 1000000000000000000; const long long int KOK = 100000; const long long int LOG = 30; const long long int li = 105; const long long int mo... |
#include <bits/stdc++.h> using namespace std; string a; int main() { cin >> a; cout << a; for (int i = a.size() - 1; i >= 0; i--) cout << a[i]; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1061109567; const int MAXN = 510005; int dp[MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(20); int n, d; cin >> n >> d; memset(dp, 0, sizeof dp); dp[0] = 1; int items[n]; ... |
#include <bits/stdc++.h> using namespace std; const int logN = 18; const int maxN = 200005; char pch[maxN]; int n, m, q, sz; vector<pair<int, char> > g[maxN]; pair<int, int> orange[maxN][logN]; pair<int, int> rrange[maxN][logN]; vector<array<int, 4> > queries[maxN]; int par[maxN][logN], pos[maxN], o... |
#include <bits/stdc++.h> using namespace std; int a[1005][1005], i, m, ans, k, l, j, q, x, n, ma, mi; string s; int main() { cin >> n >> k; if (k >= (n + 1) / 2) { cout << -1; return 0; } cout << n * k << endl; for (int i = 1; i <= n; i++) { int w = k; for (int j = 1;... |
#include <bits/stdc++.h> using namespace std; struct Node { string oper; bool val; int left = -1; int right = -1; bool will_left_change = false; bool will_right_change = false; }; vector<Node> tree; bool f(bool l_val, bool r_val, string oper) { if (oper == AND ) { return (l_... |
#include <bits/stdc++.h> using namespace std; priority_queue<long long> q; int n, k; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < k; i++) q.push(0); for (int i = 0; i < n; i++) { long long s, m; scanf( %I64d%I64d , &s, &m); long long num = q.top(); q.pop(); n... |
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, c, r; cin >> t; while (t--) { cin >> a >> b >> c >> r; int min = a < b ? a : b; int max = min == a ? b : a; int res = max - min + 1; if (c - r >= min && c + r <= max) { res = res - 2 * r - 1; ... |
#include <bits/stdc++.h> using namespace std; int n, a[2006]; int one, g, mn = 1e9; int gcd(int _a, int _b) { return _b == 0 ? _a : gcd(_b, _a % _b); } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); g = gcd(g, a[i]); if (a[i] == 1) one++; } i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 405; const int maxm = 5005; const int INF = 1000000000; const int mod = 1000000; struct EDGE { int cap, cost, v, next; } edge[mod]; int head[maxn], E, q[mod]; bool used[maxn]; int pre[maxn], cur[maxn], dis[maxn]; void add_edge(int ... |
#include <bits/stdc++.h> using namespace std; const int maxk = 11; long long p[maxk]; void init() { p[0] = 1; for (int i = 1; i <= maxk; ++i) p[i] = p[i - 1] * 10; } long long f(long long x) { if (x == 0) return 0; long long ret = 0; int pc = maxk - 1; while (p[pc] > x) --pc; ret... |
#include <bits/stdc++.h> const long long inf = 1e16; using namespace std; long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f * x; }... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int c1, c2; int d1, d2; int diff1, diff2; for (int i = 0; i < 3; i++) { if ((n - i) % 3 == 0) { c2 = (n - i) / 3; c1 = n - 2 * c2; ... |
#include <bits/stdc++.h> using namespace std; long long int n = 0, m, l = 0, k, a, b, c, sum = 0, i, r = 0, j, second, h, first = 0, sc, ans = 0, x, t, y; double aa, pp; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> k >> b >> n >> t; if (k ==... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const long double pi = acos(-1.0); const long double eps = 1e-5; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3f; struct poi { double x, y; } p[200010]; int main() { ios::sync_with_stdio(0), ci... |
#include <bits/stdc++.h> using namespace std; template <class T> void debug(T a, T b) { for (; a != b; ++a) cerr << *a << ; cerr << endl; } template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; int n, m, h, t, maxv; int e[maxn][2]; set<int> mp[maxn]; vector<int> g[maxn]; vector<int> xv, yv; set<int> comm; bool check(int x, int y, vector<int> &xv, vector<int> &yv, set<int> &comm) { int lx = max(0, (int)(h - xv.size()))... |
#include <bits/stdc++.h> using namespace std; int n, m, G, R, d[100127], w[100127], rt, tot = 0, mi[100127 * 20], c[100127 * 20][2]; long long f[100127], s[100127], ans; void change(int &p, int l, int r, int x, int v) { if (!p) p = ++tot; mi[p] = v; if (l ... |
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { while (b ^= a ^= b ^= a %= b) ; return a; } template <class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } template <class T> inline int countbit(T n) { return (n == 0) ? 0 : (1 + countbit(n... |
#include <bits/stdc++.h> using namespace std; int n, m, t, tbl[510][510], star[510][510], sum[510]; int main() { scanf( %d%d%d , &n, &m, &t); if (t == 0) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) ans += i * j; cout << ans << endl; return... |
#include <bits/stdc++.h> using namespace std; int main() { int k, d; cin >> k >> d; if (k > 1 && d == 0) cout << No solution ; else { cout << d; for (int i = 0; i < k - 1; i++) cout << 0 ; } return 0; } |
#include <bits/stdc++.h> using namespace std; map<string, int> a; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; while (n--) { int temp_val; string temp_s; cin >> temp_val >> temp_s; sort(temp_s.begin(), temp_s.end()); if (a[te... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2020 + 1; int vis[MAXN], par[MAXN], orig[MAXN], match[MAXN], aux[MAXN], t, N; vector<int> conn[MAXN]; queue<int> Q; void addEdge(int u, int v) { conn[u].push_back(v); conn[v].push_back(u); } void init(int n) { N = n; t = 0; ... |
#include <bits/stdc++.h> long long i, j, r, c, fre[1000], ans; char na, name1[1000][1000]; using namespace std; int main() { scanf( %lld %lld %c , &r, &c, &na); for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { scanf( %c , &name1[i][j]); } } for (i = 0; i < r; i++) { ... |
#include <iostream> #include <iomanip> #include<iterator> // for iterators #include<vector> // for vectors #include <utility> #include <algorithm> #include <set> #include <map> #include <stack> #include <unordered_map> using namespace std; int main() { int t, n, temp; scanf( %d , &t); ... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long res = 1; a %= 998244353; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % 998244353 % 998244353; a = a * a % 998244353; } return res; } long long gcd(long long a... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int MAX = 2e5 + 5; const long long MAX2 = 11; const long long MOD = 998244353; const long long MOD2 = 1000005329; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, 0, -1, 1... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double eps = 1e-10; const double pi = acos(-1.0); const int maxn = 1e6 + 10; const long long inf = 0x3f3f3f3f; const int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}... |
#include <bits/stdc++.h> using namespace std; int a[1000011]; int find(long long v) { int i, ret = -1; for (i = 1; i <= 2 * sqrt(v) + 1; ++i) { if (1ll * i * (i - 1) / 2 >= v) { ret = i; break; } } if (ret == -1 || 1ll * ret * (ret - 1) / 2 != v) return -1; return r... |
//Code By CXY07 #include<bits/stdc++.h> using namespace std; //#define FILE //#define int long long #define debug(x) cout << #x << = << x << endl #define file(FILENAME) freopen(FILENAME .in , r , stdin), freopen(FILENAME .out , w , stdout) #define LINE() cout << LINE = << __LINE__ << endl #d... |
#include <bits/stdc++.h> using namespace std; struct edge { int u, v; long long c; bool operator<(const edge& other) const { return c < other.c; } }; vector<int> parent; vector<int> size; int get(int v) { if (parent[v] == v) { return v; } return parent[v] = get(parent[v]); } ... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 300500; int n, dp[N]; vect... |
#include <bits/stdc++.h> using namespace std; long long n, ns, a[1111]; void ok(long long x) { long long l = 0, r = min(2000000000ll, (1ll << 62) / (x + 1) + 1); while (l < r) { long long m = (l + r) / 2; if (m * (m - 1) / 2 + m * x >= n) r = m; else l = m + 1; if (... |
#include <bits/stdc++.h> using namespace std; char num[200001]; int numLen, m, temp, answer = 0; int stepArr = 1; int main() { cin >> num >> m; numLen = strlen(num); answer += (num[numLen - 1] - 48) % m; for (int i = numLen - 2; i >= 0; i--) { stepArr = (stepArr * 10) % m; answer +... |
#include <bits/stdc++.h> template <typename T> T mymax(T x, T y) { return (x > y ? x : y); } using namespace std; const int N = 100005; const long long inf = 1e18; vector<int> graph[N], cost[N]; int n, m; long long dis[N]; struct node { int nd, c; node(int _nd, int _c) { nd = _nd; ... |
#include <bits/stdc++.h> const int N = 150; int n; double p[N]; void init() { std::cin >> n; for (int i = 1; i <= n; i++) { scanf( %lf , &p[i]); p[i] /= 100.0; } } void work() { static double f[N]; for (int i = 1; i <= n; i++) { f[i] = 1.0; } double answer = 1.0... |
#include <bits/stdc++.h> using namespace std; int s[51]; int main() { int n, g, check = 0, t = 0, q = 0; cin >> n; g = (n * (n - 1)) / 2; pair<int, int> can[g - 1]; for (int i = 0; i < g - 1; i++) { cin >> can[i].first >> can[i].second; s[can[i].first]++; s[can[i].second]++; ... |
#include <bits/stdc++.h> using namespace std; #pragma optimize( -O3 ) string to_string(string s) { return + s + ; } string to_string(const char* s) { return to_string((string)s); } string to_string(const bool& b) { return (b ? true : false ); } template <typename A, typename B> string to_string(... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int S, n, tot; int fa[2100], a[2100][2100], p[2100 * 2100 / 2]; vector<int> E[2100]; void EXT() { printf( NO n ); exit(0); } int get(int x) { if (fa[x] == x) return x; return fa[x] = get(fa[x]); } void dfs(int ... |
#include <bits/stdc++.h> using namespace std; int top; int t[10000]; long long sum[100000]; int ans[5002][5002]; const int MOD = 1e9 + 7; int main() { int n, a, b, k; scanf( %d%d%d%d , &n, &a, &b, &k); if (a < b) top = b - 1; else top = abs(n - b); for (int i = 1; i <= top;... |
#include <bits/stdc++.h> using namespace std; int level(int n, int sum[]) { int i; for (i = 1; i < 11; i++) { if (n > sum[i - 1] && n <= sum[i]) { return i; } } } int number(int n, int l, int sum[]) { int st = sum[l - 1] + 1; return n - st + 1; } int main() { int ... |
#include <bits/stdc++.h> using namespace std; int n; double p[110], S; int main() { scanf( %d , &n); for (int i = 0; i <= n; i++) scanf( %lf , p + i); for (int i = 0; i < n; i++) for (int j = i + 1; j <= n; j++) if (i * 2 <= n && n <= j * 2) S = max( S, (n * 0.5... |
#include <bits/stdc++.h> using namespace std; struct dn { int c, z; } a[500001], b[500001]; int s1[500001], s2[500001]; int aa, bb; int flag; struct da { int x, y; }; vector<da> ans; void jh(int u, int v) { if (!flag) ans.push_back((da){s1[u], s2[v]}); else ans.push_back(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 51; const int tot = maxn * maxn; long long input[maxn]; long long dp[maxn][tot][maxn]; long long dp2[maxn][tot][maxn]; long long comb[maxn + 1][maxn + 1]; int N, M; void init() { cin >> N; for (int i = 0; i < N; i++) { cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { long int a, b, c; cin >> a >> b >> c; a = abs(a) + abs(b); if (a > c) cout << NO << endl; else { if ((c - a) % 2 == 0) cout << YES << endl; else cout << NO << endl; } } |
#include <bits/stdc++.h> using namespace std; int main() { string a; for (int i = 0; i <= 9; i++) { cout << i << endl; cout << flush; a = ; getline(cin, a); if (a == no ) { continue; } else { if (a == don t think so || a == great! || a == don t tou... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; vector<int> v[N]; int num[N]; int q[N]; int cnt; int check(int mid) { int t = num[0] + mid, res = 0, tot = 0; for (int i = 1; i <= 100000; i++) { for (int j = 0; j <= max(-1, num[i] - t); j++) tot++, res += v[i][j]; } ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const long long INF = 1e17 + 7; const int N = 1e4 + 7; const int M = 5e6 + 7; long long x[N], y[N]; long long ax, ay, bx, by, a, b, t; signed main() { ios::sync_with_stdio(false); cin >> x[0] >> y[0] >> ax >> ay >> bx >> by; ... |
#include <bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int main() { fastio(); long long int a, b; long long int mx = INT_MIN; long long int n, mn = INT_MAX; cin >> n; long long int ar[n]; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int len(pair<int, int> xy) { return xy.first + xy.second; } pair<int, int> jump(pair<int, int> xy, int len) { if (len == 0) return xy; auto [x, y] = xy; if (len > x + y) return {0, 0... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; vector<int> nums, fact; int a, b, n; void precomp() { fact.resize(n + 1); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = 1ll * fact[i - 1] * i % mod; } void gener() { int _max = log10(max(a, b) * n); queue<int>... |
#include <bits/stdc++.h> using namespace std; struct num { static const int MA = 1e9 + 7, MB = 1e9 + 9; int a, b; num() {} num(int x) : a(x), b(x) {} num(int a, int b) : a(a), b(b) {} num operator+(const num& x) const { return num((a + x.a) % MA, (b + x.b) % MB); } num operator... |
#include <bits/stdc++.h> using namespace std; int main() { int n, h, count = 0; cin >> n >> h; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] > h) count += 2; else count += 1; } cout << count; } |
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; vector<int> s(6); for (int i = 0; i < 6; i++) { if ((1 << i) & a) s[i]++; } int res = 0; res += (16 * s[0]); res += (2 * s[1]); res += (8 * s[2]); res += (4 * s[3]); res += s[4]; res += ... |
#include <bits/stdc++.h> using namespace std; int l[6]; int main() { int n, m, a; cin >> m >> n; for (int i = 0; i < m; i++) { for (int i = 1; i <= n; i++) { cin >> a; l[i] = max(l[i - 1], l[i]) + a; } cout << l[n] << ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int Inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int qwq = 1 << 19; int N, Q; int a[qwq]; struct Query { int r1, c1, r2, c2, id; Query(int r1, int c1, int r2, int c2, int id) : r1(r1), c1(c1), r2(r2), c2(c2), id(id)... |
#include <bits/stdc++.h> int main() { float h, l; scanf( %f %f , &h, &l); float x = (l * l + h * h) / (2 * h) - h; printf( %f n , x); return 0; } |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); int n; std::cin >> n; std::vector<std::vector<bool> > g(n, std::vector<bool>(n, 0)); for (int row = 0; row < n; row++) { std::string s; std::cin >> s; for (int col = 0; col < s.size(); col++) { g... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int a[111][111][111]; int color[111][111][111], cc; char second[111]; void visit(queue<pair<pair<int, int>, int> >* q, int x, int y, int z) { if (a[x][y][z] == 1 && color[x][y][z] != cc) { color[x][y][z] = cc; q->push(make_pair(make_... |
#include <bits/stdc++.h> using namespace std; const long long N = 1005; long long n, m, q, ans; bool vizitat[N][N]; long long dp[N][N][2]; bool verifica(long long i, long long j) { if (i < 1 || j < 1 || i > n || j > m) return false; return true; } long long cnt(long long i, long long j) { lo... |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ff first #define ss second void solve() { int n; cin>>n; int sum=0; int cnt=1; while(sum<n) { sum+=cnt; cnt+=1; } if(sum-1==n) cout<<cnt; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int ar[n + 5]; int br[n + 5]; int mark[200005]; memset(mark, 0, sizeof mark); for (int i = 0; i < n; i++) { cin >> ar[i]; br[i] = ar[i]; } sort(br, br + n, greater<int>()); int sum... |
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm( rdtsc : =A (tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } void precalc() {} const int inf = (int)1.01e9; const int n = 4;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.