func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int getDaysOfMonth(int m) { if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) return 31; if (m == 2) return 28; return 30; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; string yes = YES n ; string no = NO n ; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; template <typename T> using pair2 = pair<T, T>; using pii = pair<int, int>; using pli = pair<ll, int>; using pll = pair<ll, ll>; mt19937_64 rng(chr... |
#include <bits/stdc++.h> using namespace std; void doicho(int &t1, int &t2) { if (t1 > t2) swap(t1, t2); } void sapxep(pair<double, int> result[], int n) { for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (result[i].first < result[j].first) { swap(result[i].... |
#include <bits/stdc++.h> int main() { char s[22]; scanf( %s , s); int len = strlen(s); int d1 = s[0] - 0 , d2 = 9 - (s[0] - 0 ); if (d1 > d2 && d2 > 0) s[0] = d2 + 0 ; for (int i = 1; i < len; i++) { d1 = s[i] - 0 ; d2 = 9 - (s[i] - 0 ); if (d1 > d2) s[i] = d2 + 0 ; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 61; int n, r; long long a[30], b[30], k[30], p[30]; long long dfs(int u, bool op1) { long long res = -INF; if (u % 2 == 0) res = max(res, inner_product(a, a + n, k, 0LL)); if (u == 0) return res; if (!op1) { for (... |
#include <bits/stdc++.h> using namespace std; long long n, u, col[300005], dp[300005][2]; vector<long long> graph[300005]; void dfs(long long u) { dp[u][col[u]] = 1; for (long long i = 0; i < graph[u].size(); i++) { long long v = graph[u][i]; dfs(v); dp[u][1] = (((dp[u][1] * dp[v][0]) ... |
#include <bits/stdc++.h> using namespace std; bool flag = true; const long long int N = 2e5 + 5; const long long int inf = 998244353; void solve() { long long int i = 0, j = 0, ans = 0, x = 0, y = 0, z = 0; long long int n, k = 0, m = 0, mn = LLONG_MAX, mx = LLONG_MIN; cin >> n >> k; vector<lo... |
#include <bits/stdc++.h> using namespace std; vector<char> v; int n; string s; bool potR() { int freq[1000]; freq[ G ] = 0; freq[ B ] = 0; freq[ R ] = 0; for (int i = 0; i < s.size(); ++i) { ++freq[s[i]]; } int cnt1 = freq[ B ]; int cnt2 = freq[ G ]; if (cnt1 >= 1 && ... |
#include <bits/stdc++.h> using namespace std; long long binpow(long long a, long long b, long long mod) { long long res = 1; while (b != 0) { if (1 & b) res = (res * a) % mod; b >>= 1; a = (a * a) % mod; } return res; } long long mminvprime(long long a, long long b) { return bi... |
#include <bits/stdc++.h> using namespace std; signed main() { string s; cin >> s; long long n = s.size(); long long sum = 0; for (long long i = 0; i < n; i++) { sum += s[i] - 0 ; } string a = s; for (long long i = n - 2; i >= 0; i--) { if (s[i] != 0 ) { string p... |
#include <bits/stdc++.h> using namespace std; long long n, q, pre[1000000], a[1000000], f[100], vis[100], ans, rec[100], temp[100]; int main() { cin >> n >> q; for (long long i = n; i >= 1; i--) pre[i] = pre[i + 1] + n - i + 1; f[0] = 1; for (long long i = 1; i <= 20; i++) f[i] = f[i - 1] * ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long INF = 1e18; const long long N = 1e5 + 100; long long n; long long a[N], dp_right[N], dp_left[N], full_right[N], full_left[N]; signed main() { ios_base::sync_with_stdio(0),... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, l, c, d, p, nl, np; cin >> n >> k >> l >> c >> d >> p >> nl >> np; cout << min(k * l / nl, min(c * d, p / np)) / n << n ; } |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); const double Eps = 1e-6; const int Mod = (int)1e9 + 7; long long Bigmod(long long b, long long p, long long m) { if (p == 0) return 1LL; if (p % 2 == 0) { long long c = Bigmod(b, p / 2, m); return ((c % m) * (c % m... |
#include <bits/stdc++.h> using namespace std; int a[1010101]; int b[1010101]; int c[1010101], d[1010101]; long long dp[1010101][2]; long long l; long long n, k; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> l >> k; for (int i = 0; i < n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; bool check(string s); void multiple(string s, string d); constexpr long long MAXN = 1e5 + 15; int n; string a[MAXN]; string ans = 1 , s; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i]... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; const long double PI = 2 * acos(0.0); const vector<long long int> dx = {1, -1, 0, 0}; const vector<long long int> dy = {0, 0, 1, -1}; vector<long long int> ga(long long int n, bool oneIndexed = false) { vector<long long ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 1; int plot[MAX], n, k; void input() { cin >> n >> k; for (int i = 1; i <= n; i++) scanf( %d , &plot[i]); } int main() { input(); int res = 0, k1 = 0, k2 = 0; for (int i = 1; i <= n; i++) { if (plot[i] != k1) k2++;... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 100000; struct Node { int t; int id; }; bool cmp(Node lhs, Node rhs) { return lhs.t == rhs.t ? lhs.id < rhs.id : lhs.t < rhs.t; } int N, P; Node A[Maxn + 5]; queue<int> q1; priority_queue<int, vector<int>, greater<int> > q2; ... |
#include <bits/stdc++.h> using namespace std; long long ans[100100]; int c[100100]; int v[100100]; int main() { int n, q; scanf( %d%d , &n, &q); for (int i = (0); i < (n); ++i) scanf( %d , &v[i]); for (int i = (0); i < (n); ++i) { scanf( %d , &c[i]); c[i]--; } for (int i = ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { register T sum = 0; register char cc = getchar(); int sym = 1; while (cc != - && (cc > 9 || cc < 0 )) cc = getchar(); if (cc == - ) sym = -1, cc = getchar(); sum = sum * 10 + cc - 0 ; cc = getc... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; cin >> n; map<int, long long> cnt; map<int, long long> last; for (int i = 0; i < n; i++) { int x; cin >> x; map<int, long long> next; last[x]++... |
#include <bits/stdc++.h> const int maxn = 301, maxk = 10, maxs = 1 << 9, INF = 0x3f3f3f3f; int n, a[maxn], c[maxn], tot, fact[maxk], f[maxs], ans = INF; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , a + i); for (int i = 1; i <= n; ++i) scanf( %d , c + i); for (int i = 1, j... |
#include <bits/stdc++.h> using namespace std; struct point { int x, y; } q[1010 * 1010 * 4]; struct node { int next, now; } d[1010 * 1010 * 2]; int c_c[1010], c_r[1010]; int dis[1010 * 1010]; bool vis[1010 * 1010], use_r[1010], use_c[1010]; int n, m; void add_edge_col(int u, int v, int i) { ... |
#include <bits/stdc++.h> using namespace std; int N, K, A, B, Q, x, y, t, ans; int data[200010]; class segleaf { public: int s[2]; } seg[2000010]; void change(int x, int l, int r, int t, int delta) { if (l == r) { data[t] += delta; seg[x].s[0] = min(data[t], B); seg[x].s[1] = mi... |
#include <bits/stdc++.h> using namespace std; int main() { int n, w, b; int a[100]; cin >> n >> w >> b; for (int i = 0; i < n; i++) cin >> a[i]; int mini, maxi; if (w <= b) { mini = w; maxi = b; } else { mini = b; maxi = w; } int st = 0, endi = n - 1, cost... |
#include <bits/stdc++.h> using namespace std; const int N = 10005; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long fact(long long n) { long long ret = 1; for (int i = 1; i <= n; i++) ret *=... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; const int mod = 1e9 + 7; int dp[N][21][2]; int n, f[21][2], two[21], three[2]; long long a, b, c; signed main() { scanf( %d , &n); for (int i = 0; i <= 20; ++i) { if (n < (int)(pow(2, i))) break; for (int j = 0; j <= ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; const int mod = 95542721, magic = 48; int inf = 1e9; int tr[4 * N][magic], lz[4 * N]; int a[N]; void build(int cn, int b, int e) { if (b == e) { int x = a[b]; for (int i = 0; i < magic; i++) { tr[cn][i] = x; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll N = 1e6 + 10; ll n, m, q, v; ll kl, ke; ll l[N]; ll e[N]; void umin(ll &a, ll b) { a = min(a, b); } signed main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> m; cin >> kl >> ke; cin >> v; for (ll i ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int cg(long long int n) { return n ^ (n >> 1); } long long int SUM(long long int a) { return (a * (a + 1) / 2); } bool CAN(int x, int y, int n, ... |
#include <bits/stdc++.h> using namespace std; long long a, fut, duim; int main() { cin >> a; a += 1; fut = a / 36; duim = round((a - fut * 36) / 3); cout << fut << << duim << endl; fclose(stdin); fclose(stdout); } |
#include <bits/stdc++.h> struct itv { int s1; int e1; int s2; int e2; int gr; void up() { gr = (e2 - s2) + 1; if (e1) { gr += (e1 - s1) + 1; }; }; }; std::vector<std::pair<int, int> > aus; void merge(int s1, int s2, int sz) { for (int i = 0; i < sz; i++)... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 5; int n, k; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; int odd = 0, even = 0, ans = 0; for (int i = 0; i < n; i++) { int num; cin >> num; if (num % 2) ... |
#include <bits/stdc++.h> using namespace std; long long v, n, arr[50005], ans, o = 9999, minans; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i]; v = max(arr[i], v); o = min(arr[i], o); ans += arr[i]; } minans = ans; for (int x = 1; x <= n; x++) { ... |
#include <bits/stdc++.h> using namespace std; int T, N, val[53][53], rk[53][53], fr[103]; vector<int> peo[53]; int pos[53]; void go(bool flg) { queue<int> q; for (int i = 1; i <= N; ++i) { peo[i].clear(); for (int j = 1; j <= N; ++j) peo[i].push_back(j); sort(peo[i].begin(), peo[i].e... |
#include <bits/stdc++.h> int main() { long n; scanf( %ld n , &n); std::vector<long> array(n, 0); for (int p = 0; p < n; p++) { scanf( %ld , &array[p]); } bool down = 0, possible = 1; long moves(0); for (int p = 1; p < n; p++) { if (array[p - 1] <= array[p]) { conti... |
#include <bits/stdc++.h> using namespace std; long long a, b, l[3001][3001], dp[3001][3001], mod = 1000000007; char cc; long long find(long long aa, long long bb, long long qq, long long ww) { if (l[aa][bb] == 2) return 0; memset(dp, 0, sizeof(dp)); dp[aa][bb] = 1; for (int i = aa; i <= qq; i++)... |
#include <bits/stdc++.h> using namespace std; int arr[100000], p[100000], b[100000]; vector<int> v[100000]; set<int> s; int main() { int n, cnt = -1; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; p[i] = arr[i]; } sort(p, p + n); int i, j = 0; while (s.size() !=... |
#include <bits/stdc++.h> using namespace std; const int N = 105; int r, s, p; double dp[N][N][N], ans[4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> r >> s >> p; dp[r][s][p] = 1.0; for (int i = r; i >= 0; i--) { for (int j = s; j >= 0; j--) { ... |
#include <bits/stdc++.h> using namespace std; long long getLCM(int a, int b) { int copyA = a, copyB = b; int r = a % b; while (r) { a = b; b = r; r = a % b; } int gcd = b; return 1LL * copyA * copyB / gcd; } int main() { int n, a, b, p, q; cin >> n >> a >> b >> ... |
#include <bits/stdc++.h> using namespace std; const int mx = 1005; bool vis[mx][mx][2]; double dp[mx][mx][2]; double func(int white, int black, int turn) { if (white <= 0) { return 0.0; } if (black <= 0) { if (!turn) return 1.0; return 0.0; } if (vis[white][black][turn]) ... |
#include <bits/stdc++.h> using namespace std; const long long LINF = ~(((long long)0x1) << 63) / 2; const int INF = 0X3F3F3F3F; const double eps = 1e-7; int num[10]; int ok[10]; int main() { int n, k, i, j, v; string s, ans, now, ss; cin >> n >> v; cin >> s; for (i = 0; i < n; i++) num... |
#include <bits/stdc++.h> using namespace std; long long n, m, a[100010], l[100010], r[100010], LS[100010], T; int G[100010][10]; struct MAT { int data[10][10]; MAT() { memset(data, 0, sizeof(data)); } MAT operator*(const MAT& ma) const { MAT ret; for (int i = 1; i <= 3; ++i) for ... |
#include <bits/stdc++.h> using namespace std; const long long mx = 10000007; using pii = pair<long long, long long>; const long long mod = 1e9 + 7; const double pi = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long t; cin >> t; while (t--) { l... |
#include <bits/stdc++.h> using namespace std; int main() { int t; vector<double> vv; vv.push_back(0); for (double i = 1; i <= 400; i++) { vv.push_back(180 / i); } cin >> t; while (t--) { double n; cin >> n; bool is = 0; for (int i = 3; i < vv.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 20, K = (1 << 16) + 5, M = 2005, mod = 998244353; int k, sum, a[N], b[N]; bitset<M> f[K]; inline void dfs(register int s, register int now) { if (!s) return; register int i; for (; now * k <= sum && f[s][now * k]; now *= k) for (i =... |
#include <bits/stdc++.h> using namespace std; int B[1 << 17]; int R[1 << 17]; vector<int> Add(const vector<int>& a, const vector<int>& b) { vector<int> res = a; int i; for (i = (0); i < (int((b).size())); ++i) res.push_back(b[i]); return res; } int main() { int n; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 300005; const long long INF = 0x3f3f3f3f3f3f3f3f; long long n; long long Read() { long long x = 0, f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 ... |
#include <bits/stdc++.h> using namespace std; const int MAX_LN = 20; const int D = 10; const long long INF = 1LL << 60; const double EPS = 1e-9; const double PI = 3.14159265358979; long long n; long long dp[MAX_LN][1 << D][D][D]; long long pat[2][D]; void init(int S, int v0) { long long sdp[20];... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; bool v[N], use[N]; int main() { int n, i, j; long long T; vector<int> p; scanf( %d , &n); for (i = 2; i <= n; ++i) { if (!v[i]) { p.push_back(i); T = i; T *= i; while (T <= n) v[T] = 1,... |
#include <bits/stdc++.h> using namespace std; using namespace rel_ops; const int inf = ~0u >> 2; const long long INF = ~0ull >> 2; const double err = 1e-11; const double pi = acos(-1); inline long long read() { long long x; if (scanf( %lld , &x) == -1) exit(0); return x; } inline double re... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1}; int kx8[] = {1, 1, 2, 2, -1, -1, -2, -2}; int ky8[] = {... |
#include <bits/stdc++.h> using namespace std; long long x, y; long long a[300010]; vector<long long> fac, facn; vector<int> facx, facy; vector<pair<int, int> > facv; vector<long long> check; int n; long long sum[300010]; long long gcd(long long x, long long y) { if (y == 0) return x; return ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tc; cin >> tc; while (tc--) { long long a, b, c, r; cin >> a >> b >> c >> r; if (a > b) swap(a, b); long long left = c - r, right = c + r;... |
#include <bits/stdc++.h> using namespace std; long long f[55]; int a[55]; int main() { int n, i; long long k; f[1] = 1, f[2] = 2; for (i = 3; i <= 50; i++) f[i] = f[i - 1] + f[i - 2]; while (scanf( %d%lld , &n, &k) == 2) { for (i = 1; i <= n;) { if (k <= f[n - i] || i == n) { ... |
#include <bits/stdc++.h> using namespace std; int M = 1e9; int ask(int x, int y) { cout << ? << x << << y << endl; cin >> x; return x; } int main() { int s = ask(1, 1), k; int u, v, l = 1, r = M, mid; while (r > l + 1) { mid = l + r >> 1; k = ask(1, mid); if (k... |
#include <bits/stdc++.h> using namespace std; long long l, r, k, x, y; int main() { scanf( %lld%lld%lld , &l, &r, &k), x = 1; if (k == 1 || l == r || (r - l == 1 && l % 2 && (l ^ r) >= l)) return printf( %lld n1 n%lld n , l, l), 0; for (int i = 0;; i++) { if (x > l) { y = i; ... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 10004, NA = -1, MaxC = 0x3F3F3F3F; int m, n, x; int f(int n, int m, int x) { n -= x + x; m -= x + x; if (n <= 0 || m <= 0) return 0; return (n * m + 1) >> 1; } int main(void) { while (scanf( %d %d %d , &n, &m, &x) != EOF) { ... |
#include <bits/stdc++.h> int arr[500005], st[500005][25], fa[500005][25], bit[500005]; inline int calc(int x, int y) { if (arr[x] <= arr[y]) return x; return y; } inline int query(int l, int r) { if (l < 0 || l > r) return 0; int len = bit[r - l + 1]; return calc(st[l][len], st[r - (1 << len... |
#include <bits/stdc++.h> using namespace std; int n; int num = 0; int cnt[1000] = {0}; int candidate[400005] = {0}; string s; bool check(int added) { if (added % 2) return false; if (n % (added + num)) return false; if ((n / (added + num)) % 2 == 0) return false; return true; } int mai... |
#include <bits/stdc++.h> using namespace std; int r1, c1, r2, c2, a[505][505], N, M, dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1}; bool viz[505][505]; char c; queue<pair<int, int> > Q; bool bfs(int x, int y, int xx, int yy) { Q.push(make_pair(x, y)); while (Q... |
#include <bits/stdc++.h> using namespace std; struct Line { long long a, b; int id; Line(long long a, long long b, int id) : a(a), b(b), id(id) {} bool before(const Line &A, const Line B) { long long p1 = A.b - b, p2 = B.b - b; long long q1 = a - A.a, q2 = a - B.a; if (q1 < 0) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010; long long n, m, k, x, y, z, a, b, c, t1, t2, cnt, p; long long X[MAXN]; ... |
#include <bits/stdc++.h> using namespace std; int deg[10000 + 10]; int main() { int n; cin >> n; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; deg[a - 1]++, deg[b - 1]++; } int ans = 0; for (int i = 0; i < n; i++) ans += deg[i] * (deg[i] - 1) / 2; cout << ans... |
#include <bits/stdc++.h> void build(const std::vector<std::pair<int, int>>& values, std::vector<int64_t>& seg, int node, int start, int end) { if (start == end) { seg[node] = values[start].second; } else if (start < end) { int mid = (start + end) / 2; build(values, seg, 2 * node... |
#include <bits/stdc++.h> const long long int mod = 1000000007; const long long int AM = 2e5 + 5; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int t; cin >> t; while (t--) { long long int n; cin >> n; string s[n + 1]; ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); long long n, a[103][2601] = {}, ans = 0, mod = 1000000007, tmp = 0; string second; char c; vector<pair<int, int> > vp; bool first, f1; bool cmpvp(pair<int, int> p1, pair<int, int> p2) { if (p1.first < p2.first) return 1; i... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { long long int n; cin>>n; long long int sum=0; for(int i=0;i<n;i++) { long long int a; cin>>a; sum+=a; ... |
#include <bits/stdc++.h> using namespace std; int n, a[200005]; map<int, int> mp; int temp, largest_num; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]] = max(mp[a[i]], mp[a[i] - 1] + 1); if (temp < mp[a[i]]) { largest_num = a[i]; temp = mp[... |
#include <bits/stdc++.h> using namespace std; int main() { string second; cin >> second; map<string, string> mp1; for (int i = 0; i < 10; i++) { string s1; cin >> s1; mp1[s1] = to_string(i); } string p = ; string ans = ; for (int i = 0; i < second.length(); i++)... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int x = 0, y = 0, z = 0; for (int i = 0; i < a.length(); i++) { if (a[i] != b[i]) { if (a[i] == 4 ) x++; else y++; } } cout << min(x, y) + abs(x - y); } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; int a[MAXN], pre[MAXN], num[MAXN]; int main() { int n, m; cin >> n >> m; int i; int Biggest = -1, Smallest = 0x7ffffff; for (i = 1; i <= n; i++) { cin >> a[i]; Biggest = max(Biggest, a[i]); Smallest = m... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; struct Node { int value; struct Node *next; } *head = NULL, *tail; struct Query { int index, ans1, ans2; long long round; } queries[maxn]; bool cmp_by_round(const Query &lhs, const Query &rhs) { return lhs.round < ... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); map<char, char> mp = {{ A , A }, { T , T }, { b , d }, { d , b }, { H , H }, { I , I }, { M , M }, { O , O }, { o , o }, {... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, -1, 1, -1, 1}; int dy[] = {-1, 1, 0, 0, 1, 1, -1, -1}; int dz[] = {0, 0, 1, -1, -1, 1, -1, 1}; int kx[] = {2, 2, -2, -2, 1, -1, 1, -1}; int ky[] = {1, -1, 1, -1, 2, 2, -2, -2}; double _distance(double x1, double y1, double x2, double y... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int q; cin >> q; while (q--) { int n; cin >> n; int a = 100000, b = 100000, c = -100000, d = -100000; vector<bool> ok(4, false); for (int ... |
#include <bits/stdc++.h> using namespace std; int n, r, R, k, l, A[100005]; string cad, aux; char x, y; map<int, int> M; struct Res { int X, Y, Z; Res() {} Res(int a, int b, int c) { int F[5]; F[0] = a; F[1] = b; F[2] = c; sort(F, F + 3); X = F[2]; Y = F... |
#include <bits/stdc++.h> const long long N = 1e6 + 10; const long long mod = 1e9 + 7; const long long inf = 0x3f3f3f3f; const double eps = 1e-8; const double pi = acos(-1); using namespace std; namespace geo { long long sgn(double x) { if (fabs(x) < eps) return 0; if (x < 0) return -1; ... |
#include <bits/stdc++.h> using namespace std; const int N = int(2e6) + 12, mod = int(1e9) + 7; int n, z[N]; char second[N]; int Z(string x) { int m = int(x.size()); string t = x; reverse((t).begin(), (t).end()); string second = x + # + t; int res = 0; for (int i = 1, l = 0, r = 0; i ... |
#include <bits/stdc++.h> using namespace std; constexpr int N = 5e5 + 5; vector<int> elm[N]; struct SegTree { struct Dat { int l, r; Dat *lc, *rc; long long lmx, rmx, mx, sum; int len() { return r - l + 1; } void fset(long long kval) { lmx = rmx = mx = sum = kval; } void ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; using namespace std; long long n, m; long long a[((long long)(2e6 + 600))]; int main() { cin >> n >> m; long long l = 0; long long pas = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (i && a[i] == a[i - 1... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; const long long oo = 1LL << 60; const long long kNumMoves = 4; const long long kMoves[kNumMoves][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; int n, v, e; vector<int> a, b; vector<vector<int> > conn, edges; vector<in... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; inline int read() { int x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 0 , ch = getchar(); return x; } int A[maxn], B[maxn], N, MOD, fir, d, l... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t, k; long long int ans; cin >> t; while (t--) { cin >> k; ans = (k / 18) * 30; k = k % 18; if (k == 0) { ans--; } ... |
#include <bits/stdc++.h> using namespace std; int64_t binexp(int64_t base, int64_t exponent) { int64_t res = 1; base = (base + 1000000007) % 1000000007; while (exponent) { if (exponent & 1) { res = (res * base) % 1000000007; } exponent = exponent >> 1; base = (base * base... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int N = 200100; int a[N], t[N]; multiset<int> st1, st2; multiset<int>::iterator it; int sum = 0, nowt = 0, res = 0; int n, m, k; void ins(int x) { sum += a[x]; if (st1.size() < m) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int q, n, x; char a, b; vector<char> v; cin >> q; for (int i = 0; i < q; i++) { x = 0; cin >> n; for (int j = 0; j < n; j++) { cin >> a; v.push_back(a); } if (v[0] < v[n - 1]) { cout ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 100; const int mod = (int)1e9 + 7; const int maxlog = (int)20; const int P = mod; int n, m, q, id[maxn], sq, res, cnt[maxn][500]; long long toadd[505], a[maxn]; long long ans[505]; vector<int> g[maxn]; int main() { ios_bas... |
#include <bits/stdc++.h> using namespace std; const int rlen = 1 << 18 | 1; inline char gc() { static char buf[rlen], *ib, *ob; (ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin)); return ib == ob ? -1 : *ib++; } inline int read() { int ans = 0; char ch = gc(); while (!isdigit... |
#include <bits/stdc++.h> using namespace std; struct segtree { using T = long long; int n; vector<T> node; T e() { return (long long)1e18; } T op(T x, T y) { return min(x, y); } segtree() : segtree(0) {} segtree(int _n) { if (_n <= 1) { n = _n; } else { n = 1 ... |
#include <bits/stdc++.h> using namespace std; int d[101][51][201][2] = {0}; bool used[101][51][201][2] = {false}; int n; int sz; string commands; int rec(int cur, int left, int pos, int dir) { if (cur == sz) { d[cur][left][100 + pos][(dir + 1) % 2] = abs(pos); used[cur][left][100 + pos][(d... |
#include <bits/stdc++.h> using namespace std; const int MAX = 501; int main() { int N, M; cin >> N >> M; int z[MAX][MAX] = {0}; for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) { cin >> z[i][j]; } int k = min(M, N); int ans = -1000000000; int p[MAX][MAX][2] =... |
#include <bits/stdc++.h> using namespace std; const long long LLINF = 1e18; const int INF = 1e9; const int MOD = 20101009; const int HMOD = 999959; const int VMOD = 5000000; const int MAXN = 2e3 + 10; const int MAXM = 5e5 + 10; const int INV = 10050505; const long long LLINV = 1e18; const double e... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105000; const int mod = 1e9 + 7; vector<int> xloc[maxn], po[maxn]; vector<int> side[maxn], blk; long long ans = 1; long long c[maxn][2]; int vis[maxn], vis_cnt; int d[maxn]; long long g[maxn][2][2]; long long f[maxn][2]; void dfs(int... |
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int x = s.length(); x = (x + 1) * 26 - x; printf( %d , x); return 0; } |
#include <bits/stdc++.h> using namespace std; vector<long long int> adj[200005]; vector<int> visited(200005, 0); vector<long long int> ans; void topo(long long int s) { visited[s] = 1; long long int sz = adj[s].size(); for (long long int i = 0; i < sz; i++) { if (visited[adj[s][i]] == 0) top... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; std ::map<int, int>::iterator x, l, s; int main() { int n, p; cin >> n; mp[0] = 0; mp[1 << 30] = 0; for (int i = 0; i < n; i++) { cin >> p; x = mp.lower_bound(p); l = x--; s = x->second > l->second ? x : ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n, N; cin >> m >> n; N = floor((m * n) / 2); cout << N; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.