func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const int N = 100100; int n, a[N], q; int main() { int t; scanf( %d , &t); while (t--) { scanf( %d , &n); set<int> se; for (int i = 1; i <= n; i++) { scanf( %d , a + i); se.insert(a[i]); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9 + 10, MAXN = 1e5 + 10; int seg[4][MAXN * 4]; int n, S, l; void update(int ind) { seg[1][ind] = min(seg[1][((ind)*2)], seg[1][(((ind)*2) + 1)]); seg[2][ind] = max(seg[2][((ind)*2)], seg[2][(((ind)*2) + 1)]); seg[3][ind] = min(seg[3][... |
#include <bits/stdc++.h> using namespace std; int n, l = 0, res = 0, a[100005]; int main() { scanf( %d , &n); a[0] = 0; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); if (a[i] >= a[i - 1]) l++; else { res = max(res, l); l = 1; } } res = max(r... |
#include <bits/stdc++.h> using namespace std; long long int modExp(long long int base, long long int power) { if (power == 0) { return 1; } else { long long int cur = modExp(base, power / 2); cur = cur * cur; cur = cur % 1000000007; if (power % 2 == 1) cur = cur * base; c... |
#include <bits/stdc++.h> using namespace std; struct subject { long long a, b; int c, r, s; bool operator<(subject const &T) const { return c < T.c; } }; int n, m, rex, rey, fx[55][55][105], fy[55][55][105]; long long rat, val, tmp, old, dp[55][55][105], ret; subject a[55]; void trace(int x, i... |
#include <bits/stdc++.h> using namespace std; int main() { int b[100000], c = 0, d, e, f; int a; cin >> a; f = a; for (int i = 0; i < a; ++i) { cin >> b[i]; if (i == b[i]) c = c + 1; } for (int i = 0; i < a; ++i) { if (i != b[i]) { if (b[b[i]] == i) { ... |
#include <bits/stdc++.h> using namespace std; namespace jenga { inline char get_unempty_char() { char ch; while (isspace(ch = getchar())) ; return ch; } const double eps(1e-10), Inf = 1e+64; const int RED = 1, BLUE = 2, GREEN = 3, EMPTY = 0, N = 6, Base = 67, mod = 3000007; i... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > v; int main() { ios_base::sync_with_stdio(false); ; int n; cin >> n; cout << (long long)(n - 2) * (n - 2); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long fast_exp(long long base, long long exp, long long mod) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res * base) % mod; base = (base * base) % mod; exp /= 2; } return res; ... |
#include <bits/stdc++.h> using namespace std; long long A; vector<pair<long long, int> > ls; vector<long long> M2[100000]; vector<long long> ls2; long long my_stp(long long first, int stp) { if (stp == 0) { return 1ll; } long long res = my_stp(first, stp / 2); res = res * res; if (... |
#include <bits/stdc++.h> using namespace std; constexpr int N = 3e3 + 1; int a[N], dp[N][N], nxt[N], prv[N], lst[N]; int main() { cin.tie(0), ios::sync_with_stdio(0); int t, n; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i], --a[i]; } ... |
#include <bits/stdc++.h> int main() { char t[50], s[50]; scanf( %s , t); int l = strlen(t), k = l / 2, j = 0; if (l % 2 == 0) { k = l / 2 - 1; } for (int i = 0; i < l; i++) { s[i] = t[k]; j++; if (i % 2 == 0) { k = k + j; } else { k = k - j; ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) #pragma GCC optimize( -ffloat-store ) const long long INF = 9e18; const long long N = 998244353... |
#include <bits/stdc++.h> using namespace std; int a[4][4]; int main() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { cin >> a[i][j]; } } int flag = 0; if (a[0][3] == 1) { if (a[0][0] == 1 || a[0][1] == 1 || a[0][2] == 1 || a[1][0] == 1 || a[2][1] ... |
#include <bits/stdc++.h> using namespace std; long long t1, t2, t0, a, b, c, d, x1, x2, lo, mid, hi, ans; int fun(long long x1, long long x2) { return (x1 * t1 + x2 * t2 >= t0 * (x1 + x2)); } void fun2(long long x1, long long x2) { long long pt = (t1 * x1 + t2 * x2) * (a + b); long long et = (t1 *... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<string> v; vector<string> res; for (int i = 0; i < n; i++) { string s; cin >> s; v.push_back(s); } bool flag = 0; stri... |
#include <bits/stdc++.h> using namespace std; struct SCIENT { int index; int k; int inv; long long a[200009]; } sc[3]; vector<pair<int, int> > v; int K[3]; int dynam[2100][2100][3]; int recurse(int k1, int k2, int which) { int last; if (k1 == K[1] && k2 == K[2]) last = INT_MI... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long N = 2005; void init() {} long long n, m, k; long long dp[N][N]; void solve() { scanf( %lld%lld%lld , &n, &m, &k); dp[1][0] = m; for (long long i = 2; i <= n; i++) { for (long long j = 0; j < i;... |
#include <bits/stdc++.h> int main() { int T, t, a, b, n, k, temp; scanf( %d , &T); for (t = 0; t < T; t++) { scanf( %d%d%d , &a, &b, &n); k = 0; while (a <= n) { if (a > b) { temp = a; a = b; b = temp; } a += b; k++; } ... |
#include <bits/stdc++.h> using namespace std; long long int chr[1000006]; long long int freq[1000006]; long long int Z[2000006]; void Zalgo(int end) { int l = 1, r = 1; for (int i = 2; i < end; ++i) { if (r > i) { int pre = Z[i - l + 1]; if (pre + i < r) { Z[i] = pre; ... |
#include <bits/stdc++.h> using namespace std; struct InputReader { char buf[1048576]; int p; inline InputReader() { p = 1048576; } inline void Flush() { p = 0; fread(buf, 1, 1048576, stdin); } inline char C() { if (p >= 1048576) Flush(); return buf[p++]; } inl... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18; const long long MOD = (long long)1e9 + 7; long long n, r[200000], a[200000], bad, brd, odd, ll, rr, cnt[200000], cntl[200000], i, j, ans; int main() { scanf( %d , &n); for (i = 0; i < n; ++i) scanf( %d , &r[i]),... |
#include <bits/stdc++.h> using namespace std; int arr[100005]; int dp[100005]; int main() { int n; cin >> n; arr[0] = -2000; for (long long i = 1; i < n + 1; i++) { cin >> arr[i]; dp[i] = 1e9; } dp[0] = 0; int pay = 0; for (long long i = 1; i < n + 1; i++) { int... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; string s[maxn]; map<int, pair<int, int>> mp; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; int correct = 0; for (int i = 0; i < n; i++) { cin >> s[i]; int balance = 0; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int n, a[200005]; long double eps = 1e-11, b[200005], s[200005]; long double f(long double first) { long double mn = 0, ans = 0; for (int i = 1; i <= n; i++) { b[i] = -first + a[i]; s[i] = s[i - 1] + b[i]; ans =... |
#include <bits/stdc++.h> using namespace std; int cnt[1000010] = {}; void pre() { for (int i = 1; i < 1000010; i++) { for (int j = i; j < 1000010; j += i) { cnt[j]++; } } } long long int tree[2 * 1000010]; int n; void build() { for (int i = n - 1; i > 0; i--) { tree[i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e3 + 10, MOD = 1e9 + 7; int n, ans, l = -1, r = 1e4 + 10, mid, mark[MAXN]; pair<int, int> a[MAXN]; bool first; vector<int> adj[MAXN]; inline int Dis(int i, int j) { return abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second); }... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; int a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; sort(a, a + n); sort(b, b + n); int j = 0, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300500; int n, m, q; vector<int> g[maxn]; bool used[maxn]; int p[maxn], sz[maxn], diameter[maxn]; int maxi, maxiV; void dfs(int v, int depth, int p) { if (depth > maxi) { maxi = depth; maxiV = v; } for (size_t i = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1000010; const double eps = 1e-6; const double pi = 4 * atan(1); long long n, a[N], k, res = 1e18; int solve() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; if (n == 2) cout << 1 << endl; else if (n ... |
#include <bits/stdc++.h> using namespace std; int n; char s[1001001]; int p[1001001] = {1}; int v[10][1001001], deg[1001001]; int Rand() { return rand() * rand(); } int main() { scanf( %s , s); n = strlen(s); for (int i = 1; i <= n; i++) { p[i] = p[i - 1] * 10 % 7; } int rlt = 0;... |
#include <bits/stdc++.h> using namespace std; int t, ans, tot = 1, n, temp; bool flag, u[9]; struct none { long long a; int sum; } f[9]; bool cmy(none f1, none f2) { return f1.a > f2.a; } long long fuck(long long x) { int back = 0; for (long long i = 2; i * i <= x; i++) while (x % i ... |
#include <bits/stdc++.h> using namespace std; const int N = 2500 * 4 + 10; int n, k, d, sz; bool isV[2000], M = 0; string arr[N]; set<string> st[N]; string change(string z) { int c = 0; string s = ; for (int i = z.size() - 1; i >= 0; i--) { s += z[i]; if (isV[z[i]]) M = 1, c++; ... |
#include <bits/stdc++.h> using namespace std; inline long long mul(long long x, long long y) { if (x >= (1ll << 60) / y) return (1ll << 60); else return x * y; } int n, m, p; int d[100005]; long long cat[100005], sum[100005]; long long dp[105][100005]; int dq[100005], s, e; int mai... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) const int maxn = 3e5 + 5, N = 1e6 + 5, SQ = 55, base = 879169, mod = 1e9 + 7, INF = 1e9 + 5, lg = 20; const long double eps = 1e-4; struct node { int mn = INF, lz = 0; int c1 = 0... |
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 1; struct node { int w, x, y, z; }; queue<int> q; vector<int> g[N], rg[N]; int d[N][N], rd[N][N], vis[N]; vector<pair<int, int>> fg[N], frg[N]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 5; vector<int> adjList[N]; unordered_set<int> remaining; bitset<N> inQ, nextToQ; vector<int> ans; void solve(int u) { remaining.erase(u); for (auto v : adjList[u]) { remaining.erase(v); } if (!remaining.empty()) {... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double EPS = 1e-6; const string alpha = abcdefghijklmnopqrstuvwxyz ; const long long INFINF = 1e18; const int INF = 1e9; const int maxN = 1e6; int T; void tc() { int N; cin >> N; string second = ; int d = 0... |
#include <bits/stdc++.h> #pragma GCC optimize( O2,Ofast,inline,unroll-all-loops,-ffast-math ) #pragma GCC target( avx,sse2,sse3,sse4,popcnt ) using namespace std; int nxt[100010][26], f[255][255][255], pos[26], n, q, a = 0, b = 0, c = 0; char s[100010], A[255], B[255], C[255]; template <class T> void read... |
#include <bits/stdc++.h> using namespace std; long long n, k, A, B; long long arr[100000]; long long solve(long long l, long long r, long long depth, long long add) { if (l == r) return A; if (depth == 0) return B * (r - l); long long mid = lower_bound(arr + l, arr + r, (1 << (depth - 1)) + ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, q; cin >> n >> m >> q; vector<vector<int> > arr(n); for (int i = 0; i < n; i++) { arr[i].resize(m); } vector<pair<int, int> > did; for (int i = 0; i < q; i++) { int t; cin >> t; if (t == 1) { ... |
#include <bits/stdc++.h> std::mt19937 rng( (int)std::chrono::steady_clock::now().time_since_epoch().count()); struct PT { long long x, y; PT(long long _x = 0, long long _y = 0) : x(_x), y(_y) {} PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); } PT operator-(const PT &p) const { ... |
#include <bits/stdc++.h> const int maxn = 100020, INF = 1 << 29; int n; struct rec { int n, x; } a[maxn]; int al[maxn], ar[maxn]; struct SBT { int root, tot; int d[maxn], l[maxn], r[maxn], s[maxn]; SBT() { s[0] = root = tot = 0; } void prt(int x, int *a, int &w) { if (!x) return; ... |
#include <bits/stdc++.h> using namespace std; void setIO(const string &name = ) { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (name.length()) { freopen((name + .in ).c_str(), r , stdin); freopen((name + .out ).c_str(), w , stdout); } } template <typ... |
#include <bits/stdc++.h> using namespace std; int printx(int x, int a, int b, int c) { if (x == 0) return a; else if (x == 1) return b; else return c; } int main() { long long n; int x; cin >> n >> x; n %= 6; switch (n) { case 0: x = printx(x, 0, 1... |
#include <bits/stdc++.h> using namespace std; string a[100]; int id[30]; vector<int> cn[30]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) { char l1 = - ; char l2 = - ; int j = -1; int s = a[i - 1].size(); ... |
#include <bits/stdc++.h> using namespace std; int dp[26][26]; int main(void) { int n, i, j, a, b, l, ans = 0; char s[20]; memset(dp, 0, sizeof dp); scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , s); l = strlen(s); a = s[0] - a ; b = s[l - 1] - a ; for (j... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; inline void solve() { int n; cin >> n; vector<int> a(n); for (int& e : a) { cin >> e; } long long b = a[0]; for (int i = 0; i < n - 1; ++i) { int d = a[i + 1] - a[i]; if (d < 0) { b += d;... |
#include <bits/stdc++.h> const int N = 4096; int a, n, v[N], h; long long w, c[N * 10]; char s[N]; int main() { std::cin >> a >> s; for (; s[n]; ++n) v[n + 1] = v[n] + s[n] - 0 ; h = v[n]; for (int i = 1; i <= n; ++i) for (int j = 0; j < i; ++j) ++c[v[i] - v[j]]; if (a) { for ... |
#include <bits/stdc++.h> using namespace std; long long f[25], ny[40], ff[40]; int vis[2100000]; int n; long long s; long long ans = 0; void pre() { ny[0] = ny[1] = ff[0] = ff[1] = 1; for (int i = 2; i < 39; i++) { long long t = 1000000007 / i, k = 1000000007 % i; ff[i] = i * t % 10000... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e3 + 10; int N; vector<int> g[maxn]; int sub[maxn][maxn], fa[maxn][maxn]; long long dp[maxn][maxn]; void DFS1(int anc, int v, int p) { sub[anc][v] = 1; for (int u : g[v]) { if (u != p) { fa[anc][u] = v; DFS1(anc,... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, k; cin >> n >> k; string fir; cin >> fir; vector<long long> v; for (long long i = 0; i < fir.size(); ++i) { if (fir[i] == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, l, r, m, ans = 1e9; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> l >> r; ans = min(ans, r - l + 1); } cout << ans << n ; for (int i = 0; i < n; i++) cout << i % ans << ;... |
#include <bits/stdc++.h> using namespace std; int main() { string s; string buf; while (getline(cin, buf)) s += buf; vector<int> a; string hoge; vector<int> cnt; for (int i = 0; i < s.length(); ++i) { if (s[i] == < ) { hoge = ; } else if (s[i] == > ) { if ... |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; if (a >= mod) a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a; if (res >= mod) res %= mod; a = a * a; if (a >= mod) a %= mod; } retur... |
#include <bits/stdc++.h> using namespace std; long long INF = 1e6; long long M = 1e9 + 7; void solve() { long long n; cin >> n; vector<int> a(n), b(n - 1), c(n - 2); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 1; i++) cin >> b[i]; for (int i = 0; i < n - 2; i++) cin ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int lz[N << 2][10]; long long sum[N << 2][10], tmp[10]; void push_up(int rt) { for (int i = 0; i < 10; ++i) sum[rt][i] = 0; for (int i = 0; i < 10; ++i) sum[rt][lz[(rt << 1)][i]] += sum[(rt << 1)][i]; for (int i = 0; i < 10; ++i)... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int cnt[MAXN * 2]; struct state { int len, link, first_pos; bool isClone; map<char, int> next; }; state st[MAXN * 2]; int sz, last; void sa_init() { for (int i = 0; i < sz; i++) st[i].next.clear(); st[0].len = 0;... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const double infd = 2e+9; const int infi = 1ll << 30; const long long infl = 1ll << 60; const int mod = 1e+9 + 7; template <class T> inline T sqr(T x) { return x * x; } int main() { string a, b; int... |
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define vll vector<ll> using namespace std; inline void sol() { ll n, m; cin >> n >> m; vll a(n); for(ll i=0;i<n;i++){ cin >> a[i]; } vector<pair<int,double>> b(m); for(int i=0;i<m;i++){ int r;... |
#include <bits/stdc++.h> using namespace std; long long n, m, ans, u, v, start; string opz; int vis[2][200005]; vector<int> grafo[2][200005]; void dfs(int nodo, int mode) { vis[mode][nodo] = 1; for (auto i : grafo[mode][nodo]) { if (vis[mode][i] == 1) { cout << -1 n ; exit(0);... |
#include <bits/stdc++.h> using namespace std; void handle_io() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void solve() { int P; cin >> P; if (P == 5) cout << 2 << << 4 << endl; else cout << 2 << << P / 2 << endl; } int main() { handle_io(); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e6 + 7, Inf = 1e9 + 7; int n, m, k = Inf, x, l, r, f, a[inf], b[inf], c[inf], d[inf]; map<int, int> p[inf]; vector<int> v; string s; int main() { cin >> n >> s; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 1; i < n; ++i) ... |
#include <bits/stdc++.h> using namespace std; vector<long long> all; void backtrack(long long x, int cnt4, int cnt7) { if (x > 1e10) return; if (cnt4 == cnt7) all.push_back(x); long long nxt = x * 10 + 4; backtrack(nxt, cnt4 + 1, cnt7); nxt = x * 10 + 7; backtrack(nxt, cnt4, cnt7 + 1); }... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 7; const long long mod = 1e9 + 7; int n; int a; int b; string s; int main() { cin >> n >> a >> b; cin >> s; if (s[b - 1] == s[a - 1]) { cout << 0; return 0; } int x = 1e7, y = 1e7; for (int i = b ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int X = 0, w = 1; char ch = 0; while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) X = (X << 3) + (X << 1) + ch - 0 , ch = getchar(); return X * w; } in... |
#include <bits/stdc++.h> using namespace std; const int N = (int)2e3 + 113; long long n, k, cnt = 0; int main() { cin >> k >> n; while (n > k) { if (n % k != 0) { cout << NO ; return 0; } n /= k; cnt++; } if (n == k) { cout << YES << endl << cnt; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const int inf = 0x3f3f3f3f; const int modu = 1e9 + 7; int t, n, m, k, p, q, cnta, cntb; double sum, res, ans; struct pen { int money; int num; int pp; } a[maxn]; vector<int> ve[110]; bool cmp(const pen a, const pen b)... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int T; cin >> T; for (int t = 1; t <= T; ++t) { int64_t n; cin >> n; if (n == 1) { cout << 0 << n ; continue; } int cou... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int main() { ios::sync_with_stdio(0), cin.tie(0); int tt; cin >> tt; while (tt--) { int n, k; cin >> n >> k; int ans = 0; int count = 0; char x; int lwb = 0; bool... |
#include <bits/stdc++.h> using namespace std; vector<int> vec[200010]; int a[200010], b[200010], color[200010]; bool flag = false; void dfs(int now, int pre, int col) { color[now] = col; for (int i = 0; i < vec[now].size(); i++) { int v = vec[now][i]; if (v == pre) continue; if (colo... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)), n_s(1001, vector<int>(1001)), n_c(1001, vector<int>(1001)); vector<int> m_s(1001), m_c(1001); for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; const long long mxn = 2e5; const long long INF = 2e18; const int32_t M = 1000000007; const long double pie = acos(-1); template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << : << arg1 << std::endl; } template <typename A... |
#include <bits/stdc++.h> using namespace std; inline int max2(int a, int b) { return ((a > b) ? a : b); } inline int min2(int a, int b) { return a < b ? a : b; } inline int max3(int a, int b, int c) { return max2(a, max2(b, c)); } long long int gcd(long long int a, long long int b) { while (b) { lon... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-10; template <typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; } template <typename T> void operator>>(vector<T>& a, int b) { while (b--) if (!a.empty()) a.pop_back(); ... |
#include <bits/stdc++.h> using namespace std; int n, q, step[1000000]; long long a[2 * 1000000], pref[2 * 1000000 + 1]; int calcLen(int strt) { int curr = strt, res = 0; while (curr < strt + n) curr += step[curr % n], res++; return res; } int main() { ios::sync_with_stdio(0); cin.tie(0);... |
#include <bits/stdc++.h> using namespace std; int a[60][60]; bool check[60]; int main() { int n, x; cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) { int t = 0; for (int j = 0; j < n; j++) check[a[i][j]] = true; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const long long int mod = 1e9 + 7; const long long int mod1 = 998244353; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long int rand(long long int l, long long int r) { uniform_int_distribution<long l... |
#include<iostream> using namespace std; int main(){ int w,h,n,t; cin>>t; while(t--){ int s=1; cin>>w>>h>>n; int size=w*h; while(size>s){ if(w%2==0 && h%2!=0){ w=w/2; s=s*2; } else if(h%2==0 && w%2!=0){ h=h/2; s=s*2; } else if(w%2==0 && h%2... |
#include <bits/stdc++.h> using namespace std; int main(void) { int xa, ya; int xb, yb; int xc, yc; double k, b, y; scanf( %d %d , &xa, &ya); scanf( %d %d , &xb, &yb); scanf( %d %d , &xc, &yc); if (xa != xb) { k = (double)(yb - ya) / (xb - xa); b = ya - (double)(yb - ya) /... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, inf = 1e9; int n; int a[maxn]; int main() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + 1 + n); long long lsum = 0, rsum = 0; for (int i = 1; i <= n / 2; ++i) lsum += a[i]; for (int i = n /... |
#include <bits/stdc++.h> using namespace std; bool prime(long long n) { for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int main() { long long n, ans; cin >> n; if (prime(n)) ans = 1; else if (n % 2 == 0) ans = 2; else if ... |
#include <bits/stdc++.h> using namespace std; long long i, j, n, c[123456], a[1111234], b[1125678], d[123456], l, ll, s, t, k, m, xh, x, x1, y, z; string p, r, w; map<string, long long> q; int main() { cin >> n >> k >> m; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); cout << a[m] ... |
#include <bits/stdc++.h> using namespace std; int n, m, k, s, bigx[11], bigy[11], smlx[11], smly[11]; int main() { scanf( %d%d%d%d , &n, &m, &k, &s); for (int i = 1; i <= k; i++) bigx[i] = bigy[i] = -2020, smlx[i] = smly[i] = 2 * 2020; for (int i = 0; i < (n); i++) for (int j = 0; j < (m);... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:500000000 ) using namespace std; int A[105]; int f[105]; int main() { int n, i, p, x, y; cin >> n; for (i = 0; i < n; i++) cin >> A[i], f[A[i]] = i; int q; cin >> q; while (q--) { scanf( %d %d %d , &p, &x, &y); if (p ... |
#include <bits/stdc++.h> #include<limits> using namespace std; #define ll long long #define vi vector<int> #define vll vector<long long> #define pi pair<int,int> #define pll pair<ll,ll> #define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL); #define unmap unordered_map #define pb push_back ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 10 * 1000 + 10, maxm = (1 << 17), mod = (int)1e9 + 7, hash = 701, inf = (1 << 29) + 3; const double pi = 3.14159265359, ee = 2.71828; int dis[30][30], d[(1 << 21)], dd[maxn], l[110], n, m, k, u; vector<int> q, bf; void bfs(int v) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<long long> pos, neg, a; for (int i = 0; i < n; i++) { long long x; cin >> x; a.push_back(x); if (x >= 0) pos.push_back(x); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int tree[4 * N]; int n, m; void update(int root, int lo, int hi, int u, int v) { if (v < lo || u > hi) return; if (u <= lo && hi <= v) { tree[root]++; return; } int mid = (lo + hi) / 2, left = root * 2, right = le... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; double ed(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); double ax, ay, bx, by, tx, ty; int n; cin ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> tree[4 * 100005 + 10]; int a[100005]; int dp[100005]; int n, s, l; int f[4 * 100005 + 10]; void init(int node, int b, int e) { if (b == e) { tree[node].first = tree[node].second = a[b]; return; } int mid = (b + e) / 2; ... |
#include <bits/stdc++.h> using namespace std; long long int n; const long long int mod = 1000000007; long long int f(long long int x, long long int k) { long long int res = 1; while (k) { if (k & 1) res = res * x % mod; x = x * x % mod; k >>= 1; } return res; } int main() {... |
#include <bits/stdc++.h> using namespace std; vector<int long long> fact(1000001); int long long sm, a, b, n; bool check() { int long long m = sm; while (m) { if (m % 10 != b && m % 10 != a) return 0; m /= 10; } return 1; } int long long inc(int long long t, int long long p) { ... |
#include <bits/stdc++.h> using namespace std; int main() { double net, res; int d, h, vel, e; cin >> d >> h >> vel >> e; net = e - (vel / (3.14159265358979323846 * d * d / 4.0)); res = -h / net; if (res <= 0 || res > 10000) cout << NO n ; else cout << YES n << fixed << set... |
#include <bits/stdc++.h> using namespace std; int n, m, comp_num; vector<vector<int> > g; vector<bool> used; vector<vector<int> > comp; vector<long long int> dv; vector<long long int> dv_in_comp; vector<int> components; void dfs(int v) { used[v] = true; comp[comp.size() - 1].push_back(v); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long sl = s.length(); long long one = 0; long long two = 0; long long three = 0; long long i; for (i = 0; i < sl; i = i + 2) { if (s[i] - 0 == 1) { one++; } else if (s[i] - 0 =... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; int h[N], ne[N], e[N], idx; int n; long long sz[N], dp[N], ans; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } void dfs(int u, int fa) { sz[u] = 1; for (int i = h[u]; ~i; i = ne[i]) { int j = e[i]; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b, long long& x, long long& y) { cerr << a == << a << b == << b << endl; if (a == 0) { x = 0; y = 1; return b; } long long x1, y1; long long d = gcd(b % a, a, x1, y1); cerr << x1 == ... |
#include <bits/stdc++.h> template <class T> inline void checkmax(T &x, T y) { if (x < y) x = y; } template <class T> inline void checkmin(T &x, T y) { if (x > y) x = y; } template <class T> inline T Min(T x, T y) { return (x > y ? y : x); } template <class T> inline T Max(T x, T y) { ... |
#include <bits/stdc++.h> using namespace std; double Fib(double x, double z); string BinDec(unsigned long long x); string StringInt(long long x); unsigned long long StringInt(string x); unsigned long long BinDec(string x); unsigned long long POWMOD(unsigned long long x, unsigned long long y, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.