func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long arr[100005], tree[100005], used[100005], l[100005], r[100005], d[100005], b[100005], query[100005], x, y, n, m, k; template <class T> inline T lowbit(T n) { return (n & -n); } void update(long long s[], int index, long long val) { while (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; char t, w; cin >> n; cin >> t >> w; bool ok = true; if (t == w) ok = false; for (i = 0; i < n; i++) for (j = 0; j < n; j++) { if (i == 0 && j < 2) continue; char x; cin >> x; if ... |
#include <bits/stdc++.h> using namespace std; int prime(int n) { int i; for (i = 3; i * i <= n; i += 2) { if (n % i == 0) return 0; } return 1; } int m, i; int main() { scanf( %d , &m); if (m < 9) { printf( 1 n%d , m); return 0; } printf( 3 n3 ); m -= 3; ... |
#include <bits/stdc++.h> using namespace std; struct Order { char d; int p; int q; }; int main() { int n, s; Order a[1001]; cin >> n >> s; for (int i = 0; i < n; i++) { cin >> a[i].d >> a[i].p >> a[i].q; } map<int, int> bmp, smp; for (int i = 0; i < n; i++) { ... |
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define debug(a) cout<<a<< n #define maxn 200009 /// I wanna be withma youlu #define MOD 1000000007 #define F first #define S second #define rep(i, a, b) for(ll i = a; i < (b); ++i) #define per(i, b, a) for(ll i = b-1; i>=a ; i--) ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (y > x) x = y; } const long long inf = (long long)1e18 + 17; const long long iinf =... |
#include <bits/stdc++.h> using namespace std; const long long N = 5e5; long long pr(long long a, long long b, long long c) { if (b == 0) return 1LL; long long ans = 1; while (b > 0) { if (b % 2) ans = ((ans % c) * (a % c)) % c; a = ((a % c) * (a % c)) % c; b /= 2; a %= c; ... |
#include <bits/stdc++.h> int main(void) { int n, b = 0, p = 0, m, i = 0, matches = 0; scanf( %d , &n); scanf( %d , &b); scanf( %d , &p); m = n; while (m != 1) { matches = matches + m / 2; m = m / 2 + m % 2; } printf( %d %d , b * (matches * 2) + matches, p * n); return 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n, arr[200002], cum[200002]; long long int res = 1000000000000LL, count = 0LL, i, j, m; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &arr[i]); } for (i = 1; i <= n; i++) { cum[i] = arr[i]; } for (i ... |
#include <bits/stdc++.h> using namespace std; long long MOD; long long getFibb(long long n) { long long a11 = 1, a12 = 1, a21 = 1, a22 = 0; long long r11 = 1, r12 = 0; long long q11 = 0, q12 = 0, q21 = 0, q22 = 0; while (n > 0) { if (n & 1) { q11 = (r11 * a11 + r12 * a21) % MOD; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, res, s, a, b; cin >> n; res = n - 1; for (i = 1; i < n; i++) { s = 0; a = n; b = i; while (a != b) { if (a > b) a = a - b; else b = b - a; s++; } if (a... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; const int INF = 1e9 + 7; long long int arr[MAX]; signed main() { cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(0); long long int n1, n2; cin >> n1 >> n2; string a, b; cin >> a >> b; long long int ans =... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i, j, n, k, l, s = 0, m = 0, p = 0, r = 0; cin >> n; int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; s += a[i]; if (a[i] == 0) p++; if (a[i] < -1) r++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; scanf( %d%d , &n, &t); string s; cin >> s; string s1 = , s2 = ; bool ck = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == . ) ck = 1; else if (ck) s2 += s[i]; else s1 +... |
#include <bits/stdc++.h> using namespace std; const int N = 1100000; long long arr[N]; long long b[N]; long long n, m, w; bool ok(long long x) { memset(b, 0, sizeof(b)); long long remain = m; long long c = 0; for (int i = 0; i < n; i++) { c += b[i]; if (c + arr[i] < x) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const int MAXN = 510; char grid[MAXN][MAXN]; int n, k; int component[MAXN][MAXN]; int size[MAXN * MAXN]; int orig_size[MAXN * MAXN]; int last_taken[MAXN * MAXN]; int dr[] = {1, 0,... |
#include <bits/stdc++.h> using namespace std; long long par[200005], sz[200005]; long long root(long long x) { return (x == par[x] ? x : (par[x] = root(par[x]))); } long long ans = 0; void join(long long x, long long y) { ans -= sz[root(y)] * (sz[root(y)] - 1) / 2; ans -= sz[root(x)] * (sz[root(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000007; vector<int> rec[100008]; int dp[2][100008], a[100008]; int fun(int minn, int val) { int ll = 0, rr, ss = rec[val].size(); if (ss == 0) return maxn; else if (rec[val][0] >= minn) return rec[val][0] + 1; rr = ... |
#include <bits/stdc++.h> using namespace std; int n, m; int dp[3333]; bool d[3333]; int a[3333]; bool f[3333]; int qu[3333]; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; d[x] = true; } m = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; const long long N = (long long)(2e5), MOD = 1e9 + 7; const long long INF = 1e17; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int cnt = 0; string copy; copy += s[0]; for (int i = 1; i < s.size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; long double PI = acos((long double)-1.0); const long double eps = 1e-9; namespace io_impl { inline bool maybe_digit(char c) { return c >= 0 && c <= 9 ; } struct io_s { private: bool negative; bool ok = true; char ch = next_char(); int preci... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<int> a((size_t)n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<pair<int, int>> b((size_t)q); for (int i = 0; i < q; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k; while (cin >> n >> k) { vector<long long> a(n); long long total = 0; for (auto &i : a) { cin >> i; total += i; } sort(a.begin(), a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, h; scanf( %d%d%d , &n, &m, &h); h--; n--; int cnto = 0, cntr = 0, tot; for (int i = 0; i < m; i++) { int t; scanf( %d , &t); if (i == h) cntr = t - 1; else cnto += t; } if (n ... |
#include <bits/stdc++.h> using namespace std; long long int sum; long long int cnt; long long int maxs; long long int a[100001]; map<long long int, long long int> jilu; long long int maxa(long long int a, long long int b) { return a > b ? a : b; } int main() { int i, n; while (scanf( %d , &n) !=... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, n; scanf( %d%d%d , &x, &y, &n); for (int i = 0; i < n; i++) y += x ^= y ^= x ^= y; printf( %d n , x); } |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 15; const int mod = 998244353; char s[N]; int len; int depth[N]; vector<int> adj[N]; int dp[N][2]; int add(int x, int y) { return ((x + y) % mod + mod) % mod; } int mul(int x, int y) { return (long long)x * y % mod; } int mypow(int ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; long long T, n, m; char s[maxn]; int main() { cin >> n; cin >> s + 1; int sign = 0, x = 0, y = 0, ans = 0; for (int i = 1; i <= n; i++) { if (s[i] == U ) y++; else if (s[i] == R ) x++; ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long llinf = 0x3f3f3f3f3f3f3f3f; template <typename INint> inline void IN(INint &first) { first = 0; int f = 1; char c; cin.get(c); while (c < 0 || c > 9 ) { if (c == - ) f = -1; cin.get(c)... |
#include <bits/stdc++.h> using namespace std; long n, m; vector<long> clauses[100000 + 1]; vector<long> variables[100000 + 1]; long long ans[2] = {0}; bool check_clauses[100000 + 1] = {false}; long long dp_path[100000 + 1][2][2]; long long dp_cycle[100000 + 1][2][2][2]; void path_component(long start_... |
#include <bits/stdc++.h> int n, h; int dynamics[1001][2][31][31][31]; int progress(int a) { return (a == 0 || a == h - 1) ? 0 : a + 1; } inline void add(int& a, int b, int mod) { a = (a + b) % mod; } int main(int argc, char* argv[]) { std::cin >> n >> h; if (h == 1) dynamics[1][1][0][0][0] = 4; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 11; int sdis(int x, int y, int xx, int yy) { int dx = x - xx; int dy = y - yy; return dx * dx + dy * dy; } int main() { int ax, ay, ar, bx, by, br; while (cin >> ax >> ay >> ar >> bx >> by >> br) { int ds = sdis(ax, a... |
#include <bits/stdc++.h> using namespace std; const long long INFL = 1LL << 60; const long long INF = INFL; long long MOD = 1000000007; vector<long long> dy = {0, -1, 0, 1, 1, 1, -1, -1, 0}; vector<long long> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0}; void pres(double A, long long x = 10) { cout << fixed <<... |
#include <bits/stdc++.h> int main(void) { int t; long long int a, b, k, p, s; scanf( %d , &t); for (int i = 0; i < t; i++) { scanf( %lld , &a); scanf( %lld , &b); scanf( %lld , &k); s = k / 2; if ((k % 2) == 0) { p = (a - b) * (s); } if ((k % 2) == ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int a[maxn]; int t[maxn], l[maxn], r[maxn]; int n, m, ans; void solve(int k) { int tot = 0; if (k == 1) { for (int i = 2; i <= n; i++) if (a[i] < a[i - 1]) tot++; } else { for (int i = 2; i <= n; i++) { ... |
#include <bits/stdc++.h> int scan() { int noRead = 0; char p = getchar(); for (; p < 33;) { p = getchar(); } while (p > 32) { noRead = (noRead << 3) + (noRead << 1) + (p - 0 ); p = getchar(); } return noRead; } long long int lscan() { long long int noRead = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)2E5 + 5; int n, x, y; vector<int> Adj[maxN]; int deg[maxN]; bool avail[maxN]; bool marked[maxN]; int Count[maxN]; int DFS(int u) { marked[u] = true; Count[u] = 0; int cnt = 0; for (int i = 0, sz = Adj[u].size(); i < sz... |
#include <bits/stdc++.h> using namespace std; int n, m, l, r, deg[100005], num; int main() { scanf( %d%d , &n, &m); for (int i = 1; i < n; i++) { scanf( %d%d , &l, &r); deg[l]++; deg[r]++; } for (int i = 1; i <= n; i++) if (deg[i] == 1) num++; printf( %.7f n , (double)2... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 500005; const long long inf = 0x3f3f3f3f3f3f3f3f; const long long MOD = 100000007; const double eps = 1e-10; long long qpow(long long a, long long b) { long long tmp = a % MOD, ans = 1; while (b) { if (b & 1) { ans *=... |
#include <bits/stdc++.h> using namespace std; int n, a[100005], dp[100005][5]; bool solve(int i, int j) { if (i == n - 1) return true; if (dp[i][j] == -1) { bool ans = false; if (a[i] < a[i + 1]) for (int k = j + 1; k < 5; k++) ans |= solve(i + 1, k); else if (a[i] > a[i + 1]) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long k, b, n; long long z = 1, t; cin >> k >> b >> n >> t; for (int i = 0; i < n; i++) { if (z > t) { cout << n - i + 1 << endl; return 0; } z = z * k + b; } if (z <= t) cout << 0 << endl;... |
#include <bits/stdc++.h> using namespace std; int main() { int k, r, r2; cin >> k; if (k % 2 == 0) cout << 4 << << k - 4; else cout << k - 9 << << 9; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)(1e9 + 17); const long long mod = (long long)(1e9 + 7); int n, k; string s, t; int dp[201][201][201]; int recurse(int idx, int tot, int ct) { if (tot > k) { return -inf; } if (idx == n) { if (tot > k) re... |
#include <bits/stdc++.h> using namespace std; const long long limit = 1e5 + 1; long long res = 0, ans = 1e17, sum = 0; long long a[limit], cost[limit]; long long n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (long long i = 1; i <= n; i++) cin >>... |
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < 0 || ch > 9 ) && ch != - ) ; if (ch == - ) { int s = 0; while (ch = getchar(), ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 ; return -s; } int s = ch - 0 ; while (ch ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e2 + 2, MAX_K = 1100; int n, k; int Arr[MAX_N]; double ans; double dp[MAX_K][MAX_N][MAX_N]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> k; k = min(k, MAX_K - 1); for (int i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; int n, s1, s2; int x[100001]; bool C(int v) { if (abs(s1 - s2) > v) return false; set<int> st; st.insert(s1); int pos = s2; for (int i = 0; i < n; i++) { if (st.size()) { st.insert(pos); } while (st.size() && abs(*st.beg... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void chkmax(T& x, U y) { if (x < y) x = y; } template <typename T, typename U> inline void chkmin(T& x, U y) { if (y < x) x = y; } const int MAXN = 110000; int n, m, N; int xn; int ans[MAXN], c[MAXN], a[... |
#include <bits/stdc++.h> using namespace std; const int N = 500010; const int LOG = 20; const long long INF = (1ll << 60); int n; int a[N]; vector<int> adj[N]; int par[LOG][N]; void dfs(int u, int p) { par[0][u] = p; for (int i = 1; i < LOG; i++) { par[i][u] = par[i - 1][par[i - 1][u]]; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); double startTime; double gct() { return ((double)clock() - startTime) / CLOCKS_PER_S... |
#include <bits/stdc++.h> using namespace std; const int N = 400, D = 8; int vis[N][N]; int T[30]; bool used[N][N][D][6][31]; struct obj { int x, y, d, t, i; void move() { if (d == 0 || d == 1 || d == 7) x++; if (d == 5 || d == 4 || d == 3) x--; if (d == 1 || d == 2 || d == 3) y++; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using vi = vector<int>; const ll INF = 1e9 + 7; void solution() { int n; cin >> n; if (n == 1) { cout << -1 n ; return; } else { cout << 2 ; n -= 1; while (n--) { cout << 3 ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, logN = 18; int n, q, l, r, tim; struct vec { int x, y, num; bool operator<(const vec &A) const { return x < A.x || x == A.x && y > A.y; } } a[N]; inline long long calc(vec *a) { return a->x + 1LL * tim * a->y; } inline long long c... |
#include <bits/stdc++.h> using namespace std; int ans = 1000000005, rans = 0, bans = 0; int numr[20], numb[20], color[20]; int dp[70005][160]; bool life[70005][160]; int nowr, nowb, tempr, tempb; char s[6]; int nex[20]; void ok(int x) { int now; nowr = nowb = now = 0; while (x) { if ... |
#include<bits/stdc++.h> using namespace std; typedef long double ld; typedef long long int ll; typedef pair<int, int> pi; typedef pair<long long, long long> pll; #define endl n #define ff first #define ss second #define pb push_back #define int long long #define sz(v) (int)v.size() #def... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 55; int n, cnt[N]; vector<pair<int, int> > adj[N]; void dfs(int u, int p, int depth, vector<pair<int, int> > &leaves) { bool leaf = 1; for (auto e : adj[u]) { int v, c; tie(v, c) = e; if (v == p) conti... |
#include <bits/stdc++.h> using namespace std; using i32 = int32_t; using i64 = int64_t; using pii = std::pair<i32, i32>; using pll = std::pair<i64, i64>; int dp[5000]; int iv[5000]; bool used[5000]; int div_up(int a, int b) { return (a + b - 1) / b; } void log_pour(int n, int s, int d) { if (n >... |
#include <bits/stdc++.h> using namespace std; int id[110001]; int ans[1000001]; int main() { int n, m, i, number, t; while (scanf( %d %d , &n, &m) != EOF) { number = 0; memset(id, 0, sizeof(id)); memset(ans, 0, sizeof(ans)); for (i = 0; i < n; i++) { scanf( %d , &t); ... |
#include <bits/stdc++.h> using namespace std; class Task { public: char invert(char c) { if (c == W ) return B ; return W ; } void shift_left(string& s, int k) { int n = s.length(); string t = s; for (int i = 0; i < n; i++) t[i] = s[(i + k) % n]; s = t; } ... |
#include <bits/stdc++.h> using namespace std; const long long N = 101; long long n; pair<long long, long long> a[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (long long i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; long long p; cin >> p; for (l... |
#include <bits/stdc++.h> using namespace std; int main(void) { long long n, k; cin >> n >> k; long long len = (1LL << n) - 1; while (true) { long long mid = len / 2 + 1; if (k == mid) break; if (k > mid) k -= mid; n--; len = (1LL << n) - 1; } cout << n << endl; ... |
#include <bits/stdc++.h> using namespace std; const long long Mod = 1000000007LL; const int N = 3e2 + 10; const long long Inf = 2242545357980376863LL; const long long Log = 30; long long t1, t2, t3; long long Get(long long x, long long y) { if (x < y) return t2; if (x == y) return t1; return t... |
#include <bits/stdc++.h> using namespace std; using std::string; int main() { int n; cin >> n; string s; cin >> s; int f = 0; for (int i = 0; i < s.size() - 1; i++) { if (s[i + 1] < s[i]) { for (int j = i + 1; j < s.size(); j++) s[j - 1] = s[j]; f = 1; break; ... |
#include <bits/stdc++.h> using namespace std; int n, k, q, x; map<int, int> M; map<int, int>::iterator it; int main() { scanf( %d %d , &n, &k); for (int i = (1); i <= (n); i++) { int a; scanf( %d , &a); for (int j = (0); j <= (k); j++) { if (!M.count(a * j)) M[a * j... |
#include <bits/stdc++.h> using namespace std; int n, ans = 0; vector<int> a[100005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { int k, x; cin >> k; while (k--) { cin >> x; a[i].push_back(x); } sort(a[i].begin(), a[i].end()); } a[0] = a[n];... |
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) using namespace std; const long double PI = acos(-1); const int MOD = 998244353, LIM = 2e5 + 5; const long double EPS = 1e-9; const int mod = 1000000007; int main() { double l, p, q; std::cin >> l >> p >> q; double ans = l * p; ans /= p ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, m, t; cin >> n >> k >> m >> t; for (int i = 0; i < t; i++) { int a, b; cin >> a >> b; if (a == 0 && b < k) { k -= b; n -= b; } else if (a == 1 && b <= k) { k++; n++; } else ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)2e5 + 7; const int INF = (int)1e9 + 7; const long long LINF = (long long)1e12 + 7; const int MOD = (int)1e9 + 7; void file() {} inline int readChar(); template <class T = int> inline T readInt(); template <class Tl = long long> in... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int mod = 1e9 + 7; int n, a, b; double ans; vector<vector<int>> g(N); void dfs(int u, int par, int depth) { ans += 1.0 / depth; for (auto v : g[u]) if (v != par) dfs(v, u, depth + 1); } int main() { cin >> n; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005000; int A[maxn], sum[maxn][10]; int dfs(int u) { if (u < 10) return u; if (A[u]) return A[u]; int now = 1, tmp = u; while (u) { if (u % 10 != 0) now *= u % 10; u /= 10; } return A[tmp] = dfs(now); } int m... |
#include <bits/stdc++.h> int tcase, m; long long n; int gao(long long x) { int ret = 0; for (; x; x /= 10) ret += x % 10; return ret; } int main() { scanf( %d , &tcase); while (tcase--) { scanf( %lld%d , &n, &m); if (gao(n) <= m) { printf( 0 n ); continue; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; int n, k, m; int p10[maxn]; inline void init() { p10[0] = 1; for (register int i = 1; i <= 1000; i++) { p10[i] = (p10[i - 1] * 10) % k; } } long long f[1010][110][2]; long long dfs(long long pos, long long statu, bool... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-7; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; int main() { int n, m; cin >> n >> m; string s; int mx = 0; int c = 0; for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = 1LL << 62; const long long mx = 100005; const double eps = 1e-10; long long dx[10] = {1, 0, -1, 0}; long long dy[10] = {0, -1, 0, 1}; long long power(long long a, long long b) { if (b == 0) return 1... |
#include <bits/stdc++.h> using namespace std; int M, K, i, st, ed, ans[2], arr[100005]; int main() { cin >> M >> K; for (i = st = ed = 0; i < M; i++) cin >> arr[i]; sort(arr, arr + M, greater<int>()); while (1) { while ((ed + 1) < M && (arr[st] - arr[ed + 1]) <= K) K -= (arr[st] - ar... |
#include <bits/stdc++.h> long long ar[1000010], fact[1000010]; long long expo(long long x, long long n) { long long res = 1; while (n) { if (n & 1LL) res = (res * x) % 1000000007; x = (x * x) % 1000000007; n >>= 1LL; } return (res % 1000000007); } long long binomial(int n, int ... |
#include <bits/stdc++.h> using namespace std; long long n, q; const long long MXN = 200005; long long arr[MXN]; long long seg[MXN * 4]; void build(long long ind, long long l, long long r) { if (l == r) { seg[ind] = arr[l]; return; } long long m = (l + r) / 2; build(ind << 1, l, m... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int main() { int n; scanf( %d , &n); vector<long long> a(n); for (int i = 0; i < n; i++) { scanf( %lld , &a[i]); } vector<long long> t(n); for (int i = 0; i < n; i++) { scanf( %lld , &t[i]); } ... |
#include <bits/stdc++.h> using namespace std; int n; long long ori[100005]; int main() { scanf( %d , &n); int i = 1; for (i; i <= n; i++) { scanf( %I64d , &ori[i]); } sort(ori + 1, ori + n + 1); i = 1; int ss = n - 2; bool flag = false; for (i; i <= ss; i++) { int... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<pair<int, int>> a(n); vector<int> b(n); vector<int> c(n); for (int i = 0; i < n; i++) { int x; cin >> x; a[i] = {x, i}; } while (k--) { int x, y; cin >> x >> y; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300500; struct node { long long x; int id; node() {} bool operator<(const node ot) const { if (x != ot.x) return x < ot.x; return id < ot.id; } } a[maxn]; long long x[maxn]; long long su[maxn]; int main() { ... |
#include <bits/stdc++.h> using namespace std; long double f[1011][1011]; int m, n; void init() { memset(f, 0, sizeof f); f[1][1] = 1; for (int i = (1), _b = (n - 1); i <= _b; i++) { for (int x = (0), _b = (min(i, m)); x <= _b; x++) if (f[i][x] > 1e-50) { f[i + 1][x] += f[i][x... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 10; long long int vis[N]; vector<vector<int> > v; int dfs(int t) { vis[t] = 1; for (int i = 0; i < v[t].size(); i++) { if (vis[v[t][t]] == 0) { dfs(v[t][i]); } } return 0; } int main() { long lon... |
#include<bits/stdc++.h> using namespace std; const int maxn=1000025; const int mod=998244353; int n,m,i,j,t,k,s,f[maxn],ans,dp[maxn],iv[10]; inline int calc(int x) { int ret=x*1ll*(x-1)%mod*(x-2)%mod*iv[6]%mod;//3 ret=(ret+x*1ll*(x-1))%mod;//2 ret=(ret+x)%mod;//1 //printf( calc %d %d n ,x,ret... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n][3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { cin >> a[i][j]; } } int c = 1; for (int i = 0; i < 3; i++) { int sum = 0; for (int j = 0; j < n; j++) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> edge[80005]; int cnt[80005]; unsigned long long ret; int n; void dfs(int v, int u) { cnt[v] = 1; unsigned long long val = 1ull * n * (n - 1) / 2ull; for (int i = 0; i < edge[v].size(); i++) { int to = edge[v][i]; if (to == u) ... |
#include <bits/stdc++.h> using namespace std; int n; set<string> s; int main() { cin >> n; getchar(); while (n--) { string ss; getline(cin, ss); s.insert(ss); } cout << s.size(); return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 * 100 + 10; int endss[maxn]; int main() { int n, M, T; cin >> n >> M >> T; vector<pair<pair<int, int>, int> > ps(2 * n); for (int i = 0; i < n; i++) { int h, m, s; scanf( %d:%d:%d n , &h, &m, &s); int time = 60... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; const int inf = (int)1e9; const int mod = inf + 7; const double eps = 1e-9; const double pi = acos(-1.0); int n, a[200200], b[200200]; int mx[200200]; set<pair<int, int> > second; vector<int> g[200200]; void r... |
#include <bits/stdc++.h> using namespace std; const int M = (int)1e9 + 7; int a[17]; int c[107][107]; int dp[17][107]; int n; int main() { cin >> n; for (int i = 0; i < 10; i++) cin >> a[i]; for (int i = 0; i <= 100; i++) { c[i][0] = c[i][i] = 1; for (int j = 1; j < i; j++) { ... |
#include <bits/stdc++.h> using namespace std; int n; int a[101101]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); int l = 0, r = n - 1, ans = 0; for (int i = 0; i < n; i++) { if (a[l] < a[i]) { ans++; l++; } else ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> void maximize(T &x, U y) { if (x < y) x = y; } template <class T, class U> void minimize(T &x, U y) { if (x > y) x = y; } template <class T> T Abs(T x) { return (x < (T)0 ? -x : x); } namespace task { const int... |
#include <bits/stdc++.h> using namespace std; int ted[1010]; int main() { memset(ted, 0, sizeof ted); int n; cin >> n; while (n--) { int x; cin >> x; ted[x]++; } int ans = 0; int mx = 0; for (int i = 1; i <= 1000; i++) if (ted[i]) { ans++; mx... |
#include <bits/stdc++.h> using namespace std; int main() { int q; long long N, M, K; cin >> N >> K >> M; vector<long long> A(N); long long s = 0; for (int i = 0; i < N; i++) { cin >> A[i]; s += A[i]; } sort(A.begin(), A.end()); long double res = (long double)(s + min(... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n; cin >> n; vector<long long> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); long long count = 0; while (v.size() > 0) { count++; long long num = v[0]; ... |
#include <bits/stdc++.h> using namespace std; using lld = long long; using pi = pair<int, int>; using pl = pair<lld, lld>; using vi = vector<int>; using vvi = vector<vector<int>>; using vb = vector<bool>; using vc = vector<char>; using vl = vector<lld>; using vp = vector<pi>; using vs = vector<str... |
#include <bits/stdc++.h> using namespace std; const int c = 100005; void solve() { string s; cin >> s; long long o = 0, e = 0, m = 0; long long ans = INT_MAX; long long om = 5, em = 5; for (long long i = 0; i < s.size(); ++i) { if (i & 1) { if (s[i] == ? or s[i] == 1 ) o +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 5; char mp[maxn][maxn]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf( %c , &mp[i][j]); int x1, y1, x2, y2; for (int i = 0; i < n; i++) { bool bb = false; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d = 0, e = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0) { e += a[i - 1] - a[i]; if (e < 0) { d -= e; e = 0; } } else { d += a[0]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int test_time, x = 0; cin >> test_time; for (int i = 0; i < test_time; ++i) { string temp; cin >> temp; for (int j = 0; j < temp.length(); ++j) { if (temp[j] == - ) { x--; break; } else if (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.