func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; signed main() { string s; cin >> s; char zero = 0 ; s = 00 + s; long long n = (long long)s.size(); for (long long i = 0; i < n - 2; i++) { long long temp = 100 * (s[i] - zero); for (long long j = i + 1; j < n - 1; j++) { te... |
#include <bits/stdc++.h> using namespace std; int main() { int Q; cin >> Q; while (Q--) { long long n, a, b, ans; cin >> n >> a >> b; double x = b / 2.0; if (x > a) { ans = a * n; cout << ans << endl; } else { if (n % 2 == 0) { ans = n / 2 ... |
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p) { out << ( << p.first << , << p.second << ) ; return out; } template <typename T> ostream& operator<<(ostream& out, vector<T> const& v) { int l = v.size();... |
#include <bits/stdc++.h> using namespace std; long long n, k, x, a, b, i, j, m[1000005], f[1000005]; multiset<long long> s; pair<long long, long long> d[1000005]; vector<long long> v; int main() { ios::sync_with_stdio(0); cin >> n >> k >> x; while (i < n) { cin >> m[i]; i++; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i, count = 0; string str; cin >> str; int len = str.size(); for (i = 0; i < len; i++) { if (str[i] == W && str[i + 1] == U && str[i + 2] == B ) { ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 2e9; int32_t main() { cin.tie(0)->sync_with_stdio(0); long long n, m; string s, t; cin >> n >> m >> s >> t; vector<long long> pi(m, 0), nxt(m, 0); for (long long i = 1; i < m; i++) { { t[i] = char( 0 + (t[i]... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<pair<int, pair<int, int>>> v; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; v.push_back(make_pair(a, make_pair(b, i))); } ... |
#include <bits/stdc++.h> using namespace std; char A[300]; int cnt[5]; char data[5] = ACGT ; int main() { int n; scanf( %d , &n); scanf( %s , A); for (int i = 0; A[i]; i++) { if (A[i] == A ) cnt[0]++; else if (A[i] == C ) cnt[1]++; else if (A[i] == G ) ... |
#include <bits/stdc++.h> using namespace std; int a[2]; string ans[2] = { Vladik , Valera }; int main() { cin >> a[0] >> a[1]; int turn = 0; int sub = 1; while (true) { if (a[turn] - sub >= 0) { a[turn] -= sub; } else { break; } sub++; turn = 1 - tu... |
#include <bits/stdc++.h> using namespace std; int n, m, loc[250] = {}, isi[250] = {}, idx = 0; int kosong() { for (int i = 0, _n = (n); i < _n; i++) if (isi[i] == -1) return i; return -111; } int main() { memset(isi, -1, sizeof isi); scanf( %d %d , &n, &m); for (int i = 0, _n = (m); ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <class T> void dbg(const char* xn, T x) { if (0) cout << xn << : << x << n ; } template <class T, class... TA> void dbg(const char* xn, T x, TA... t) { while (*xn != , ) if (0) cout << *xn++; if (0... |
#include <bits/stdc++.h> using namespace std; const int sz = 5005; long long int x[sz]; long long int a[sz]; long long int b[sz]; long long int c[sz]; long long int d[sz]; int n, s, e; const long long int Max = 1e16; long long int dp[sz][sz]; long long int jumpl(int i) { return x[i] + c[i]; } lo... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int x[maxn], n, m; int main() { int ans = 0, use = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> m; x[m] = 0; } for (int i = 1; i <= n; i++) { cin >> m; x[m] = i; } for (int i = 1; x[i]... |
#include <bits/stdc++.h> const long long int mod = 1000000007; using namespace std; void toh_chaliye_shuru_karte_hain() {} void code_samapti_ki_ghoshna() {} long long int power(long long int a, long long int b, long long int modi) { a %= modi; long long int res = 1; while (b) { if (b % 2) { ... |
#include <bits/stdc++.h> using namespace std; struct segment_change { static const int SENTINEL = numeric_limits<int>::min(); int to_set; segment_change(int _to_set = SENTINEL) : to_set(_to_set) {} bool has_set() const { return to_set != SENTINEL; } void reset() { to_set = SENTINEL; } bool h... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:268435456 ) using namespace std; const string IN_NAME = input.txt ; const string OUT_NAME = output.txt ; template <class T> T abs(T &x) { return ((x) >= 0) ? (x) : (-(x)); } template <class T> T sqr(T &x) { return (x) * (x); } temp... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(0.0) * 2.0; const double eps = 1e-12; const int step[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; template <class T> inline T abs1(T a) { return a < 0 ? -a : a; } template <class T> inline T max1(T a, T b, T c = -1234567, T d = -1... |
#include <bits/stdc++.h> using namespace std; template <typename T> string toString(T x) { if (x == 0) return 0 ; bool negative = x < 0; string res; while (x) { res.push_back( 0 + x % 10); x /= 10; } if (negative) res.push_back( - ); reverse(res.begin(), res.end()); r... |
#include <bits/stdc++.h> using namespace std; int n, m, k, key, MK, MKEY; int MAP[110][110]; int ii, jj; void dfssolve(int pos, int step) { int temp[110]; int cnt, i, j; if (pos > n) { key = 1; k = k < step ? k : step; return; } cnt = 0; for (i = 1; i <= m; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e5 + 5; long long ans = 1e18; map<long long, bool> mp; void solve(long long n, long long cnt) { if (!n) { cout << cnt; exit(0); } string s = to_string(n); sort(s.rbegin(), s.rend());... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, t, d; cin >> n >> m; map<long long, long long> mp; set<pair<long long, long long> > st; vector<long long> a(n), c(n); for (int i = 0; i < n; i++) { cin >> a[i]; mp[i] = a[i]; } for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; void pri(deque<int> arr) { for (int i : arr) cout << i << ; cout << endl; } int main() { string s; cin >> s; int n = s.size(); if (n <= 3) { cout << s[0] << endl; return 0; } deque<int> a1; deque<int> b1; deque<... |
#include <bits/stdc++.h> using namespace std; template <class T> T modulo(T x, T p) { if (x >= 0) return x % p; return p + x % p; } template <class T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a * b / gcd(a, b); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int long long l1, l2, r1, r2, k, ans, l, r; cin >> l1; cin >> r1; cin >> l2; cin >> r2; cin >> k; l = max(l1, l2); r = min(r1, r2); if (r - l < 0) { cout << 0 << endl; return 0; } ans = r - l + 1; ... |
#include <bits/stdc++.h> using namespace std; clock_t __stt; inline void TStart() { __stt = clock(); } inline void TReport() { cerr << fixed << setprecision(3) << nCurrent Case Taken Time : << (double)(clock() - __stt) / CLOCKS_PER_SEC << sec n ; } template <typename T> T MIN(T a, T b) {... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { long long x1, y1, x2, y2; scanf( %lld%lld%lld%lld , &x1, &y1, &x2, &y2); long long lenx = abs(x1 - x2); long long leny = abs(y1 - y2); long long ans = lenx + leny; if (len... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << n % 2; } |
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { vector<long long> vec; for (long long i = 2; i * i <= n; i++) { while (n % i == 0) { vec.push_back(i); n /= i; } } if (n > 1) { vec.push_back(n); ... |
#include <bits/stdc++.h> using namespace std; int n, m, num, cnt; int dat[1009][1009], ans[1000009]; bool vis[1009][1009]; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; int wall[4] = {8, 4, 2, 1}; void dfs(int x, int y) { if (vis[x][y] || x < 0 || x > n || y < 0 || y > m) return; vis[x][... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, ind, sum = 0; cin >> n; long long mas[n]; for (long long i = 0; i < n; i++) { cin >> mas[i]; sum += mas[i]; } cin >> m; long long arr[m]; sort(mas, mas + n); for (long long i = 0; i < m; i++) {... |
#include <bits/stdc++.h> using namespace std; int n, nxt[200010], a[200010], sz[200010][31]; long long ans = 0; map<int, int> mp; inline char gc() { static char *S, *T, buf[1 << 16]; if (T == S) { T = (S = buf) + fread(buf, 1, 1 << 16, stdin); if (T == S) return EOF; } return *S++;... |
#include <bits/stdc++.h> using namespace std; long long n, t, twoc, onec, opt, old; int main() { cin >> n; cin >> t; if (t == 1) onec++; else twoc++; old = t; for (int i = 1; i < n; i++) { cin >> t; if (t == 1) { if (old == 2) onec = 1; els... |
#include <bits/stdc++.h> using namespace std; int ar[1000001]; int main() { int n, k; cin >> n >> k; if (k == n) { cout << -1 << endl; return 0; } if (k == n - 1) { for (int i = 0; i < n; i++) cout << i + 1 << ; cout << endl; return 0; } for (int i = 2;... |
#include <bits/stdc++.h> using namespace std; int pow(int a, int b, int c) { int ret = 1; for (; b; b >>= 1, a = 1LL * a * a % c) if (b & 1) ret = 1LL * ret * a % c; return ret; } const int N = 2e3 + 10, M = 4.05e6 + 10; int h[N], g[N], p[M], n1[M], ee, low[N], dfn[N], dfntot, vis[N], n, m, ... |
#include <bits/stdc++.h> using namespace std; long long int m = 1000000007; long long int n1, n2 = 0, sum = 0; long long int gcd(long long int a, long long int b) { return (b == 0) ? a : gcd(b, a % b); } bool compare(pair<string, long long int> p1, pair<string, long long int> p2) { if (p1.second != ... |
#include <bits/stdc++.h> using namespace std; mt19937_64 mt(time(0)); set<pair<long long, long long> > dp[49]; void insert(set<pair<long long, long long> >& table, long long a, long long b) { if (table.empty()) { table.insert({a, b}); return; } auto it = table.lower_bound({b, LLONG_MAX})... |
#include <bits/stdc++.h> int main() { int n, i; long long cnt[5] = {0}; char ch; scanf( %d , &n); getchar(); cnt[0] = 1; for (i = 0; i < n; i++) { scanf( %c , &ch); if (ch == a ) { cnt[1] = (cnt[1] + cnt[0]) % 1000000007; } else if (ch == b ) { cnt[2] = ... |
#include <bits/stdc++.h> using namespace std; using namespace std; struct node { int l, m, r; }; node t[3000005]; int arr[300005], n, m; long long a[300005]; int sign(long long x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } void cal(int x, int l, int r) { int m = (l ... |
#include <bits/stdc++.h> using namespace std; const int INF = int(1e9); const int MOD = INF + 7; const long long INFll = 1ll * INF * INF; const long double ldINF = 1e+018; const long double EPS = 0.000000001; const int MAXN = 150; const int N = 100001; const int seg[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t = 1; while (t--) { long long int n, d = 0, r = 0; cin >> n; string s; cin >> s; char x; for (long long int i = 0; i < s.length(); i++) ... |
#include <bits/stdc++.h> #define fasterio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define X first #define Y second #define forn(i, n) for(int i=0;i<(n);i++) #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; const int inf = 0x3f3f3f3f; const long l... |
#include <bits/stdc++.h> using namespace std; int l_f, l_h; long long int dp[101][101][11][11]; int getans(int f, int h, int k1, int k2) { int x = 0, y = 0; if ((f + h) == 0) return 1; if (dp[f][h][k1][k2] != -1) return dp[f][h][k1][k2]; if (f > 0 && k1 > 0) x = getans(f - 1, h, k1 - 1, l_h); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; map<string, string> mp; map<string, string>::iterator it; for (int i = 0; i < n; ++i) { string x, y; cin >> x >> y; it = mp.begin(); bool f... |
#include <bits/stdc++.h> using namespace std; pair<int, int> h[100010], h1[100010]; long long cnt[100010], pre[100010], sum[100010]; int num[100010], mx[100010], n, tt, t1; inline int rd() { int x = 0; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) ; for (; ch >= 0 &... |
#include <bits/stdc++.h> using namespace std; int w[505], p[1005], t[5001], was[105]; int main() { int a, b, c, d, f = 0, n, m, x, y, i, j; memset(was, 0, sizeof was); memset(t, 0, sizeof t); scanf( %d %d , &n, &m); for (a = 1; a <= n; a++) scanf( %d , &w[a]); for (a = 1; a <= m; a++) scan... |
#include <bits/stdc++.h> using namespace std; int n; const int maxn = 4001; long long dp[maxn], c[maxn][maxn], s[maxn][maxn], sum[maxn]; long long pow(int k) { if (k == 0) return 1LL; if (k == 1) return 2LL; long long ans = pow(k >> 1); ans *= ans; if (k % 2) ans *= 2LL; return (ans % ... |
#include <bits/stdc++.h> using namespace std; int n, k, a[101], m; int main() { m = 101; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (k % a[i] == 0) m = min(m, k / a[i]); } cout << m; return 0; } |
#include <bits/stdc++.h> using namespace std; int cnt[50]; int main() { int n, k; cin >> n >> k; int aa; for (int i = 0; i < n; i++) { int tmp = 0; for (int j = k - 1; j >= 0; j--) { scanf( %d , &aa); tmp += (aa << j); } cnt[tmp]++; } if (cnt[0]) { ... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; int f = 1; char c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); x *= f; }... |
#include <bits/stdc++.h> using namespace std; vector<int> v[250005]; int visited[250005]; int n, m, x, y; void zero() { for (int i = 0; i <= n + 2; i++) { visited[i] = 0; v[i].clear(); } } void bipartite(int u) { if (visited[u] == 1) { x++; } else if (visited[u] == 2) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( unroll-loops ) using namespace std; using ll = long long; using db = long double; using ii = pair<int, int>; const int N = 1e7 + 5, LG = 19, MOD = 1e9 + 7; const int SQ = 225; const long double EPS = 1e-7; int fast(int b, int ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powermodm(long long x, long long n, long long M) { long long result = 1; while (n > 0) { if (n % 2 == 1) result = (result * x) % M; x = (x * x) % M; n = n / 2; } return result; } long lo... |
#include <bits/stdc++.h> using namespace std; void extgcd(long long a, long long b, long long& x, long long& y) { if (b == 0) { assert(a == 1); x = 1, y = 0; return; } extgcd(b, a % b, y, x); y -= a / b * x; } int inv(int a, int c) { long long x, y; extgcd(a, c, x, y); ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL << i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1 << 18; const int MOD = 2013265921, MAX = MOD / 2; const int gen = 440564289; long long power(long long x, int n) { if (n <= 1) return n ? x : 1LL; long long t = power(x, n / 2); if (n & 1) return (t * t % MOD) * x % MOD; el... |
#include <bits/stdc++.h> using namespace std; int arr[503][503]; int main() { int n, k; cin >> n >> k; int p = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j < k; j++) { arr[i][j] = p++; } } for (int i = 1; i <= n; i++) { for (int j = k; j <= n; j++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 310, INF = (1 << 27); int d[MAXN][MAXN]; int all[20][MAXN][MAXN]; int ans[MAXN][MAXN]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) d[i][j] = INF... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 7; const int mod = 51123987; const int inv2 = mod + 1 >> 1; struct Edge { int to, last, v; } E[maxn]; int fa[maxn]; int len[maxn]; int dep[maxn]; int head[maxn]; int tot; int last; int cnt; int n; char s[maxn]; int ... |
#include <bits/stdc++.h> using namespace std; bool vis[200005]; vector<int> v[200005], ak, d1, dn; vector<int> bfs(int n) { queue<int> q; vector<int> dis(200005); q.push(n); vis[n] = true; dis[n] = 0; while (!q.empty()) { int x = q.front(); q.pop(); for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1050; pair<int, int> a[MAX_N]; int cnt[MAX_N]; int sub[MAX_N]; map<int, int> ids; int inds[MAX_N]; int id = 0; int countplz(int f0, int f1) { memset((sub), 0, sizeof(sub)); ++sub[a[f0].second]; ++sub[a[f1].second]; int ans... |
#include <bits/stdc++.h> using namespace std; class TaskB { public: long long dist(pair<long long, long long> f, pair<long long, long long> s) { return (f.first - s.first) * (f.first - s.first) + (f.second - s.second) * (f.second - s.second); } void solve(std::istream& cin, std::os... |
#include <bits/stdc++.h> using namespace std; int n; string a, b; set<int> A, B; queue<int> qA, qB; map<char, queue<int> > q; vector<pair<int, int> > resp; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; for (int i = 0; i < n; ++i) { if (a[i] == ?... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n; double p[111]; cin >> n; for (int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n); double ans = p[n - 1], notAns = 1 - p[n - 1]; for (int i = n - 2; i >= 0 && ans < notAns; i--) { ans = an... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; long long first, T, mt; long long t[2], p[2], a[2]; long long get(long long ile, long long czas) { if (ile == 0) { return 0; } if (min(ile * mt, ile * t[1]) > czas) { return inf; } if (ile * mt <= czas) {... |
#include <bits/stdc++.h> using namespace std; int main() { int t, T, i, n, k, d, ans, val; cin >> T; vector<int> id(pow(10, 6) + 1, 0); for (t = 0; t < T; t++) { cin >> n >> k >> d; vector<int> v(n); for (i = 0; i < n; i++) cin >> v[i]; ans = n; val = 0; for (i = ... |
#include <bits/stdc++.h> const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; const int MAXN = 55; int n; int a[2][MAXN]; int asum[2][MAXN]; int b[MAXN]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int j = 0; j < 2; j++) fo... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int num[N], tot; int main() { int n, a1 = 2, a2 = 1, ans = 1; cin >> n; while (a1 - a2 <= n) { if (n % (a1 - a2) == 0) ans = a1 - a2; a1 *= 4; a2 *= 2; } cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int k; int values[107]; int n = 0; int ans[107][107]; int cmb[107]; int main() { int i, j, base; cin >> k; for (i = 3; i <= 100; i++) values[i] = i * (i - 1) * (i - 2) / 6; for (i = 2; i <= 100; i++) cmb[i] = i * (i - 1) / 2; i = 3; whi... |
#include <bits/stdc++.h> using namespace std; const int mx = 200, my = 200, tim = 50, mo = 1000000007; const int d[8][2] = {1, 2, -1, 2, 1, -2, -1, -2, 2, 1, -2, 1, -2, -1, 2, -1}; int x, y, n, bfs[mx * my * 4][2], a[mx * 2][my * 2], i, l, r, xx, yy, cnt[tim + 10]; long long K; int main() { scanf(... |
#include <bits/stdc++.h> using namespace std; struct treenode { long long a, b, c; treenode(long long a, long long b, long long c) : a(a), b(b), c(c) {} }; int n, mm, s[111111], m[111111], r[111111], zero[111111], *add; vector<treenode> tree1[4 * 111111], tree2[4 * 111111], *tree; set<pair<int, int>... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; constexpr int INF = 2000000000; constexpr ll LLINF = 900000... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> adj(n); for (int i = 0, u, v; i < m; ++i) { cin >> u >> v; --u, --v; adj[u].push_back(v); adj[v].push_back(u); } set<i... |
#include <bits/stdc++.h> using namespace std; struct edge { int v, w; edge* next; }; const int N = 100010; int n, p, ordcnt; bool vis[N], cut[N]; int ord[N], sum[N], mex[N], q[N], dep[N], digit[N], rdigit[N], rprod[N], prod[N]; edge* g[N]; void add_edge(int u, int v, int w); void calc_... |
#include <bits/stdc++.h> using namespace std; #define fastIO ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #define endl n #define lli long long int #define ld long double #define p_b push_back #define m_p make_pair #define fs first #define sc second #define sz(x) ((lli)x.size()... |
#include <bits/stdc++.h> using namespace std; int time_to_minute(int h, int m) { return h * 60 + m; } void minute_to_time(int t, int& h, int& m) { h = t / 60; m = t % 60; } int main() { ios_base::sync_with_stdio(false); int h, m, a; cin >> h; cin.ignore(1); cin >> m >> a; minut... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, BIT[N]; void update(int idx, int val) { while (idx <= n) { BIT[idx] = max(val, BIT[idx]); idx += idx & -idx; } } int get(int idx) { int ret = 0; while (idx > 0) { ret = max(BIT[idx], ret); idx ... |
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e60; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) {... |
#include <bits/stdc++.h> using namespace std; int n, m; long long dis[100010]; vector<int> mom[100010]; vector<pair<int, int> > vertex[100010]; set<int> q; void readin() { scanf( %d%d , &n, &m); int u, v, c; for (int i = 0; i < m; ++i) { scanf( %d%d%d , &u, &v, &c); vertex[u].push_... |
#include <bits/stdc++.h> using namespace std; static const int INF = 500000000; template <class T> void debug(T a, T b) { for (; a != b; ++a) cerr << *a << ; cerr << endl; } int n; pair<pair<int, int>, int> es[5005]; vector<pair<int, int> > g[5005]; int size[5005]; int cut[5005]; int pr... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { vector<pair<int, int>> st, re; int a, b; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; st.emplace_... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000000007; long long a[1100][1100]; long long b[1100][1100]; long long A(int n, int k); long long B(int n, int k); long long A(int n, int k) { if (a[n][k] != -1) { return a[n][k]; } if (n < k) { return a[n][k] = 0... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); struct Q { int a, b, c; Q(int a, int b, int c) : a(a), b(b), c(c) {} bool operator<(const Q& o) const { if (a == o.a) return c < o.c; return a < o.a; } }; vector<pair<int, int> > ... |
#include <bits/stdc++.h> using namespace std; const int pos[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int n; char s[510][510]; int v[510][510]; vector<pair<int, int> > vec, ans; int operator*(const pair<int, int> &a, const pair<int, int> &b) { return a.first * b.second - a.second * b.first; } pa... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; const int mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, p, b = 0; cin >> n >> p; vector<long long> v; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s == half ) { v.push_back(0); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1005; vector<int> v[MAX]; int dp[105][MAX]; int main() { ios::sync_with_stdio(false); int n, t; cin >> n >> t; for (int i = 0; i < n; i++) { int t, p; cin >> t >> p; v[t].push_back(p); } for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const long long M = 7e2 + 5; const long long mod = 1e9 + 7; char sz[M]; long long a[M], js; inline long long read() { register long long x = 0, y = 1; register char c = getchar(); while (!isdigit(c)) { if (c == - ) y = 0; c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int A[n][m], B[n][m], C[n][m]; vector<int> a, b; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> A[i][j]; a.push_back(A[i][j]); } } for (int i = 0; i < n; i+... |
#include <bits/stdc++.h> using namespace std; int n, q; int x[100100], y[100100]; bool ans[100100]; int par[100100], sz[100100]; int distToPar[100100]; int getpar(int now) { return (par[now] == now) ? now : getpar(par[now]); } bool getdist(int now) { bool ret = (par[now] == now) ? 0 : (getdist(par[n... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int count = 0; for (int i = 0; i < n - 1; i++) { if (s[i] == s[i + 1]) { count++; } } cout << count; } |
#include <bits/stdc++.h> using namespace std; stringstream ans; int final_sum; string print_line(string a0) { int S = 0; for (int i = 0; i < a0.size() - 1; i++) { int digit = a0[i] - 0 ; S += digit; ans << digit << + ; } int digit = a0[a0.size() - 1] - 0 ; S += digit; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read() { T s = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { s = (s << 3) + (s << 1) + ch - 48; ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; int n, m, a[1001000], cnt[1001000], z[1001000]; int main() { ios::sync_with_stdio(false); memset(cnt, 0, sizeof(cnt)); memset(z, 0, sizeof(z)); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] <= m) cnt[a[i]]++; }... |
#include <bits/stdc++.h> using namespace std; signed long long int n, m, k, x, y; signed long long int ct[3], myct; int main() { cin >> n >> m >> k >> x >> y; signed long long int f1, q, val, rem = k; if (n == 1) { f1 = m; q = rem / f1; rem -= q * f1; myct = q; ct[1] = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, mncnt = 1000000000, cnt; string a; string c = ACTG ; cin >> n >> a; for (int i = 0; i <= n - 4; i++) { cnt = 0; string b = a.substr(i, 4); for (int j = 0; j < 4; j++) { int x = c[j] - A ; int y ... |
#include <bits/stdc++.h> using namespace std; int a[12][12], nxt[110]; int id(int x, int y) { if (x & 1) return (10 - x) * 10 + 11 - y; return (10 - x) * 10 + y; } double dp[120]; int main() { for (int i = 1; i <= 10; i++) for (int j = 1; j <= 10; j++) a[i][j] = id(i, j); for (int i = ... |
#include <bits/stdc++.h> using namespace std; struct data { int x, h, p; } a[100005]; int n, x[100005], kq[100005], st[4 * 100005]; void update(int id, int l, int r, int p, int v) { if (l > p || r < p) return; if (l == p && l == r) { st[id] = v; return; } int m = (l + r) >> 1; ... |
#include <bits/stdc++.h> using namespace std; int now[15][3], ans[15][3], nA, nB, nC, minN = 12, cnt, t[13]; void dfs(int a, int b, int c, int num, int jw, int cou, bool ifA, bool ifB) { if (!a && !b && !c && !jw) { minN = num; cnt = cou; memcpy(ans, now, sizeof(now)); return; } ... |
#include <bits/stdc++.h> using namespace std; int mas[1010][1010]; int main() { int N, K; cin >> N >> K; for (int i = 1; i <= N; i++) { int k = 0; for (int j = 1; j <= N; j++) { if (k == K) break; else if (i == j) continue; else if (mas[j][i] || ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.