func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; int a[100005]; int n; int solve() { sort(a, a + n); int i = n - 1; int sum = 0; while (i >= 0 and a[i] >= 0) sum += a[i--]; if (sum % 2) return sum; int j = i; while (j >= 0 and abs(a[j]) % ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); long long TC = 1; cin >> TC; while (TC--) { int n, f = 1, c = 0; cin >> n; int a[n], feq[110] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long i, j, k, n, m, ans = 0; string a, b; cin >> n >> a >> b; for (i = 0; i < n / 2; i++) { int j = n - i - 1; if (a[i] == b[i] && a[j] == b[j]) cont... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, z, t1, t2, t3, ts, te; cin >> x >> y >> z >> t1 >> t2 >> t3; ts = abs(x - y) * t1; te = t3 * 2 + abs(x - z) * t2 + t3 + abs(x - y) * t2; if (ts >= te) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> typedef struct Segment { int start; int last; int Xor; } segment; using namespace std; vector<segment> V; int score(segment s) { if (s.last == s.start) return s.Xor; else { int value = 0; for (int i = s.start + 1; i < s.last;) { if (V[i].s... |
#include <bits/stdc++.h> using namespace std; bool ch1(int t, int da, int db, int a, int b, int x) { for (int i = 0; i <= t - 1; i++) { for (int j = 0; j <= t - 1; j++) { if (((a - i * da + b - j * db == x) && (a - i * da >= 0 && b - j * db >= 0)) || a - i * da == x || b -... |
#include <bits/stdc++.h> using namespace std; int n, m, f[2001] = {0}; bool p, a[2001][2001]; string st; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> st; for (int j = 0; j < m; j++) if (st[j] == 1 ) { a[i][j + 1] = true; f[j + 1]++; ... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int main() { fast(); long long n; cin >> n; char a[n + 10]; for (int i = 1; i <= n; ++i) cin >> a[i]; long long func[15]; for (int i = 1; i <= 9; ++i) ... |
#include <bits/stdc++.h> using namespace std; const int N = 400005; int n, m, k, s, t, a[N], b[N]; int ans; long long p; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int j = 0; j < 25; ++j) { for (int i ... |
#include <bits/stdc++.h> using namespace std; int t; long long l[200002], c[200002]; long long minx, maxx, miny, maxy; string s; bool check(long long l[], int n) { int Min = 0, Max = 0; int last = 0, first = 0; for (int i = 1; i <= n; i++) { if (l[i] < Min) { first = i; Min... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; int n, a, b, c; string s; map<pair<int, pair<int, int> >, int> dic; bool bo1 = false, bo2 = false, bo3 = false; void dfs(int a, int b, int c) { pair<int, pair... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const int MX = 3003; const int M = 998244353; char s[MX], t[MX]; int n, m, ans, dp[MX][MX]; int f(int i, int j) { if (i < 1 && j > n) return 1; ... |
#include <bits/stdc++.h> using namespace std; int day[13] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; int sec, n, k, dd, mm, h, s, m, now; string str; queue<int> q; int main() { cin >> sec >> k; getline(cin, str); while (scanf( 2012-%d-%d %d:%d:%d: , &mm, &dd, &h, &m, &s) != ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:128000000 ) using namespace std; map<string, int> a; map<string, int>::iterator ii, jj; string s; int main() { int k, i, v, u, j, n, m, d, d2, y, r, p, t1, t2, x, l, t, z, fl, to; cin >> n; for (i = 1; i <= n; i++) { cin >> s >> p; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; priority_queue<int> pq{}; for (int i{1}; i <= n; ++i) pq.push(i); vector<pair<int, int>> ans{}; for (int i{0}; i < n - 1; ++i) { int mx1{pq.top()}; pq.pop(); int mx2{pq.top()}; pq.pop(); ... |
#include <bits/stdc++.h> using namespace std; int p[200] = {0}; int main() { string a; int m; cin >> m; cin >> a; int n = a.length(); for (int i = 0; i < n; i++) { if (a[i] != ? ) p[a[i] - a ] = 1; if (a[i] != ? && a[i] - a >= m) { cout << IMPOSSIBLE << endl; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200005; int v[MAXN], l[MAXN], r[MAXN]; int ST[4 * MAXN]; int L[4 * MAXN]; int n; void _update(int node, int lo, int hi, int i, int j, int val) { if (L[node]) { ST[node] = max(ST[node], L[node]); if (hi != lo) { L[2 * no... |
#include <bits/stdc++.h> using namespace std; int a[4]; int main() { cin >> a[0] >> a[1] >> a[2] >> a[3]; sort(a, a + 4); if (a[0] + a[1] > a[2] || a[1] + a[2] > a[3]) { cout << TRIANGLE ; return 0; } else if (a[0] + a[1] == a[2] || a[1] + a[2] == a[3]) { cout << SEGMENT ; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } bool isin( const pair<long long, tuple<long long, long long, long long> >& elem) { return get<1>(elem.second) == 0; } bool isout( const pair<long long, tuple<long long, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 400010; inline int max(int a, int b) { return a > b ? a : b; } int head[maxn], cnt, sz[maxn], n, mx_sz, top[maxn], ans[maxn]; vector<int> vt; struct ed { int to, next; } e[maxn * 2]; void ad(int x, int y) { e[cnt] = (ed){y, head[x]};... |
#include <bits/stdc++.h> using namespace std; int x[3010], y[3010]; vector<int> py[3010]; int L[3010], R[3010], q, k; void nxt(int &u, int k = 1) { while (k-- > 0) u = R[u]; } void pre(int &u, int k = 1) { while (k-- > 0) u = L[u]; } long long res = 0; struct node { int x, y; bool op... |
#include <bits/stdc++.h> using namespace std; struct flight { int d, f, t, c; }; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); vector<flight> flights(m); for (int i = 0; i < m; i++) { scanf( %d %d %d %d , &flights[i].d, &flights[i].f, &flights[i].t, &flights[i].c... |
#include <bits/stdc++.h> using namespace std; class classcomp { public: bool operator()(const int &l, const int &r) const { return l < r; } }; long long mod = 1000000007; void matrixmul(int p, int q, int r, long long *a, long long *b, long long *c) { int i, j, k; for (i = 0; i < p; i++) { ... |
#include <bits/stdc++.h> using namespace std; int v[1010][10], rez[1010]; int main() { int n, nr = 0, l = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { int p = 0; for (int j = 1; j <= 5; j++) scanf( %d , &v[i][j]); } if (n > 200) { printf( 0 ); return 0; } ... |
#include <bits/stdc++.h> const int maxn = 1e5 + 1; int n, m, l = 1; long long a; char s[maxn]; int main() { scanf( %d%d%s , &n, &m, s + 1); for (int i = 1; i <= n; i++) if (s[i] != s[i - 1]) a += n * (m - 1); for (int i = 2; i <= n; i++) if (l == 1 && s[i] != s[i - 1] || l > 1 && s[i] ... |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; cin >> t; vi v(t); for (int i = 0; i < t; i++) { cin >> v[i]; } int m = t; priority_queue<int> qi; for (int i = 0; i < t; i++... |
#include <bits/stdc++.h> using namespace std; int main() { int s, v1, v2, p1, p2; scanf( %d%d%d%d%d , &s, &v1, &v2, &p1, &p2); if (v1 * s + p1 * 2 < v2 * s + p2 * 2) printf( First n ); if (v1 * s + p1 * 2 > v2 * s + p2 * 2) printf( Second n ); if (v1 * s + p1 * 2 == v2 * s + p2 * 2) printf( Frie... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int ans = 2; for (int i = 1; i < n; ++i) { if (a[i] - a[i - 1] > 2 * d) ans += 2; else if (a[i] - a[i - 1] == 2 * d) ++an... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int N = 10; int n, k; int a[1005]; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; int nn = n; for (int i = 0; i < k; i++) { cin >> a[i]; while (a[i] >= 4 && nn > 0) { a[i] -= 4;... |
#include <bits/stdc++.h> using namespace std; int main() { long int n; scanf( %ld , &n); long long int a[n], i, x = 0, b[n], j; for (i = 0; i < n; i++) { scanf( %lld , &a[i]); } b[0] = 1; for (i = n - 2, j = 1; i >= 0; i--, j++) { if (a[i] < a[i + 1]) { b[j] = b[j - 1... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<long long int> v(n); for (long long int &x : v) cin >> x; for (int i = 0; i < n; i++) { if (i % 2) v[i] = -abs(v[i]); else v... |
#include <bits/stdc++.h> using namespace std; int main() { char c[100005]; scanf( %s , c); vector<char> v; int count[26]; int instk[26]; memset(count, 0, sizeof(count)); memset(instk, 0, sizeof(instk)); int find = 0; for (int i = 0; c[i] != 0; i++) count[c[i] - a ]++; while ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long a, b, x, y; cin >> a >> b >> x >> y; long long distX = x - a, distY = y - b; cout << distX * distY + 1 << n ; } } |
#include <bits/stdc++.h> using namespace std; const int N = 2005; int n, m; int id[N * 2][N * 2]; map<int, int> mp; vector<int> l[N * 2], e[N * 2]; vector<int> ord; pair<int, int> a[N]; int dp[N * 2][N * 2]; pair<int, int> DP[N * 2][N * 2]; void type(int i, int j) { if (DP[i][j].second == 0) {... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const long long mod = 998244353; long long ksm(long long a, long long b) { long long ans = 1LL; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } int a[N], c[N], tmp[N],... |
#include <bits/stdc++.h> using namespace std; vector<int> dvsr; void get(long long n) { for (int i = 1; i <= sqrt(n); i++) { if (n % i == 0) { dvsr.push_back(i); if (i != n / i) dvsr.push_back(n / i); } } } int main() { std::ios::sync_with_stdio(false); cin.tie(NULL... |
#include<bits/stdc++.h> using namespace std; #define int long long #define fast_io ios_base::sync_with_stdio(0);cin.tie(0) #define mod 1e9 + 7 #define pb push_back #define vi vector<int> int32_t main(){ fast_io; int t;cin>>t; while(t--){ int n;cin>>n; set<int> s; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string str; cin >> str; set<char> a; for (int i = 0; i < n; i++) { a.insert(tolower(str[i])); } if (a.size() == 26) { cout << YES << endl; } else { cout << NO << endl; } retu... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int h, m; cin >> h >> m; long long int t = h * 60 + m; long long int a = 1440 - t; cout << a << endl; } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); long long int t = 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int T, n, m, vis[maxn], cnt[maxn]; char s[maxn]; bitset<maxn> b[maxn]; queue<pair<int, int>> Q; int main() { scanf( %d , &T); while (T--) { scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { b[i].reset(), ... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9 + 9; bool cmp(const pair<int, int> &a, const pair<int, int> &b) { return a.first < b.first; } int main() { int n, m; cin >> n >> m; vector<pair<int, int> > k(n); for (int(i) = (0); (i) < (n); ++(i)) { cin >> k[i].f... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1000 * 1000 * 1000; const long long inf64 = 1ll * inf * inf; const long long mod = 1e9 + 7; mt19937 rng(0); long long binpow(long long a, long long p, long long mod = 998244353) { if (p == 0) return 1; if (p % 2 == 0) { long l... |
#include <bits/stdc++.h> using namespace std; vector<long long> X; map<long long, pair<int, long long> > M; pair<int, long long> go(long long x) { if (x <= 1) return {x, x}; if (M.find(x) != M.end()) return M[x]; int i = upper_bound(X.begin(), X.end(), x) - X.begin() - 1; int p1, p2; long lo... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; int main() { ios_base ::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; if (n == 1) { cout << 2; return 0; } if (n == 2) { cout << 3; return 0; } long long in... |
#include <bits/stdc++.h> using namespace std; ifstream in( in.txt ); ofstream out( out.txt ); long long a[1000006], b[1000006]; long long fortza(long long n, long long put) { if (!put) return 1; if (put == 1) return n; if (put & 1) return (fortza((n * n) % 998244353, put / 2) * n) % 998244353; ... |
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, z, x, y; cin >> x1 >> y1 >> z; x = x1 - y1 + z; y = x1 - y1 - z; if (x > 0 && y > 0) cout << + << n ; else if (x < 0 && y < 0) cout << - << n ; else if (x == 0 && y == 0) ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10, lgN = 29, INF = 2e9; int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> using namespace std; long long N, K; long long Top, Bot, H[200005], cnt[200005]; long long hcnt[200005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> K; Top = 0, Bot = 2e5; for (int i = 0; i <= N - 1; i++) { cin >> H[i]; cnt[H[i]]++... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n, l, r; cin >> n; while (n-- && cin >> l >> r) { if (l * 2 > r) cout << YES ; else cout << NO ; cout << endl; } } |
#include <bits/stdc++.h> using namespace std; long long n; int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n; long long a = (n + 2) * (n + 1) * n / 6, b = (n + 4) * (n + 3) * (n + 2) * (n + 1) * n / 120; cout << a * b; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1005, maxk = 12; string s, t; long long d[maxn][maxn][maxk][2]; long long n, m, k; int main() { ios_base::sync_with_stdio(false); cin >> n >> m >> k >> s >> t; for (long long i = 0; i <= n; i++) { for (long long j = 0; j ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, i, m, k, x, pc = 0, c = 0; cin >> n >> m >> k; long long int p, f; queue<long long int> q; for (i = 0; i < m; i++) { cin >> x; q.push(x - 1); } x = 0; while (!q.empty()) { f = q.front(); ... |
#include <bits/stdc++.h> using namespace std; int n, a, b, ed; double p, M; long long T; vector<pair<double, double> > v; pair<double, double> sta[100004]; double cros(pair<double, double> a, pair<double, double> b) { return (b.second - a.second) / (a.first - b.first); } double r[100004], ret; d... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; string ans; ans += s[0]; for (int i = 1; i <= s.length() - 2; i = i + 2) { ans += s[i]; } ans += s[s.length() - 1]; cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[101], t = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; t += a[i]; } int ans = 0; for (int j = 1; j <= 5; j++) { int k = t + j, i = 0; while (k) { k--; if (!k) break; ... |
#include <bits/stdc++.h> using namespace std; int n; double w[507][507], e[507][507], a[507][507]; void dfs(int sco, int l, int r, int p) { if (l == r) { w[p][l] = 1; e[p][l] = sco; return; } int mid = (l + r) >> 1; dfs(sco / 2, l, mid, p << 1); dfs(sco / 2, mid + 1, r, (p ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; map<int, vector<int>> frec; for (int i = 0; i < n; i++) { int val; cin >> val; frec[val].push_back(i); } int x = 0; vector<int> ans(n); for (... |
#include <bits/stdc++.h> using namespace std; const int MM = 2e5 + 5; int n, k, a, b, q, pref[MM], suff[MM], cnt[MM]; void upd(int bit[], int x, int v) { for (; x < MM; x += x & -x) { bit[x] += v; } } int get(int bit[], int x) { int res = 0; for (; x > 0; x -= x & -x) res += bit[x]; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e+5 + 10; long long b[MAXN], l[MAXN], r[MAXN], o[MAXN], dp[MAXN]; int main() { int n; cin >> n; for (int i = 0; i < n - 1; i++) { cin >> b[i]; } for (int i = 1; i < n; i++) { l[i] = b[i - 1] - (b[i - 1] % 2) + l[i - ... |
#include <bits/stdc++.h> using namespace std; void solve(); signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int64_t t; cin >> t; while (t--) solve(); return 0; } vector<vector<int64_t>> to; vector<bool> bobCan, parcouru; vector<int64_t> pId; int64_t... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int mul(long long int x, long long int y) { return (x * 1ll * y) % mod; } long long int add(long long int x, long long int y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; return x; } lo... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char c = a ; for (int i = 0; i < s.size(); i++) { if (s[i] == z + 1) continue; else if (s[i] != c) { cout << NO n ; return 0; } else { for (int j = i; j < s.size(); j+... |
#include <bits/stdc++.h> using namespace std; const long long max_n = 1e6 + 20; long long n, m, k, ans, sum; long long a[max_n]; long long mark[max_n]; vector<long long> v, adj[max_n], jda[max_n]; void dfs(long long v) { mark[v] = 1; if (adj[v].size() == 2) ans = -1; for (auto i : adj[v]) { ... |
#include <bits/stdc++.h> using namespace std; long long a[111111], ans[111111]; int n, kk; int main() { scanf( %d , &n); for (int i = (1); i <= (n); ++i) scanf( %I64d , &a[i]); sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); for (int i = (1); i <= (n); ++i) a[i] += a[i - 1]; scanf( %d... |
#include <bits/stdc++.h> int main() { unsigned long long no_of_paths; unsigned long long no_of_arrangements; scanf( %I64u , &no_of_paths); no_of_arrangements = (no_of_paths) * (no_of_paths - 1) / 2 * (no_of_paths - 2) / 3 * (no_of_paths - 3) / 4 * (no_... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, mod = 1, cnt = 0, i, min; cin >> n; vector<int> v{1, 5, 10, 20, 100}; while (n) { min = INT_MAX; for (i = 0; i < 5; ++i) { if (n / v[i] >= 1) { if (min > n / v[i]) { min = n / v[i]; ... |
#include <bits/stdc++.h> using namespace std; int t = 1000001; class myData { public: int t; int x; int y; int d; myData(int t, int x, int y, int d) : t(t), x(x), y(y), d(d) {} bool operator<(const myData &a) const { return (this->t < a.t); } }; long long exponentMod(long long A, lo... |
#include <bits/stdc++.h> using namespace std; long long T, m, n, q, w, mi, ma, cnt, s, t, fi, cc, e, r, z, x, an, anx, any, cx, cy; long long d[5][2]; int main() { scanf( %I64d%I64d , &m, &n); scanf( %I64d%I64d , &e, &r); scanf( %I64d%I64d , &cx, &cy); for (int i = 0; i < 4; i++) { q... |
#include <bits/stdc++.h> using namespace std; class sparse_table { vector<int> values; vector<int> maxk; vector<vector<int> > st; void build(const vector<int>& a) { values = a; int n = a.size(); st.resize(maxk[n] + 1); st[0].resize(n); for (int i = 0; i < n; i++) st[0][... |
#include <bits/stdc++.h> using namespace std; const long long B = 360; const long long N = 100005; long long block(long long x) { return x / B; } long long offset(long long x) { return x % B; } deque<long long> a[B]; signed c[B][N]; long long n, q; signed main() { ios::sync_with_stdio(false); ... |
#include <bits/stdc++.h> using namespace std; struct Point { int x; int y; }; int main() { int n; cin >> n; Point P[n]; for (int i = 0; i < n; i++) { cin >> P[i].x >> P[i].y; } int val; if (n < 2) val = -1; else if (n == 2) { if (P[0].x != P[1].x && P[0]... |
#include <bits/stdc++.h> using namespace std; int q, n; int par[1 << 20][32], dep[1 << 20]; int da[500000]; void add(int v) { par[n][0] = par[n + 1][0] = v; dep[n] = dep[n + 1] = dep[v] + 1; for (int i = (int)(0); i < (int)(20); i++) par[n][i + 1] = par[n + 1][i + 1] = par[par[n][i]][i]; }... |
#include <bits/stdc++.h> using namespace std; int mat[1005][1005]; int main() { int n; scanf( %d , &n); for (int i = (0); i < (n); i++) { for (int j = (0); j < (n); j++) { scanf( %d , &mat[i][j]); } } int akt = 0; for (int i = (0); i < (n); i++) akt = (akt + mat[i][i]) ... |
#include <bits/stdc++.h> using namespace std; const double pi = 3.14159265358979323846; void rw() {} int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<long long> s; long long n, c, f, se; cin >> n; s.push_back(4); s.push_back(7); for (int i = 0; i < s... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, k = 0; long long x, y, z = 0; long long hsl[1002]; cin >> a; for (int i = 1; i <= a; i++) { y = 0; z = 0; cin >> b >> k >> x; if (x % 2 == 0) { y = x / 2; z = x / 2; } else { ... |
#include <bits/stdc++.h> using namespace std; pair<long long int, long long int> a[500001]; int main() { ios::sync_with_stdio(false); cout << fixed << setprecision(10); long long int i, j, n, f; double lo, mid, hi, ans = -1, last; cin >> n; for (i = 1; i <= n; i++) cin >> a[i].first >> a[i... |
#include <bits/stdc++.h> using namespace std; struct st { int t, l, r, p; bool operator<(const st& B) const { return t < B.t; } } a[100005]; int N, M, K, s[100005]; vector<st> u[100005], v[100005]; long long b[100005], ans[100005]; int sum(int x) { int d = 0; for (int i = x; i; i -= i & -i... |
#include <bits/stdc++.h> using namespace std; int main() { int i, x, n, k, m = 0, f = 0, j = 1; int a[26]; string s; cin >> s; n = s.length(); cin >> k; k = k + n; for (i = 0; i < 26; i++) { cin >> a[i]; m = max(m, a[i]); } for (i = 0; i < n; i++) { f = f + ... |
#include <bits/stdc++.h> using namespace std; long long modInverse(long long a, long long m) { long long m0 = m; long long y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long q = a / m; long long t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; ... |
#include <bits/stdc++.h> const double pi = 3.1415926535897932384626433832795; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } using namespace std; void ifd() {} void tme() {} int main() { ifd(); string s, t, tmp; getline(cin, s); vector<string> d; vector<i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 1; int n, m, tin[N], up[N], dw[N]; bool ans[N]; vector<int> edge[N], redge[N]; void topo() { queue<int> q; for (int i = 1; i <= n; i++) if (!tin[i]) q.push(i); while (q.size()) { int at = q.front(); q.pop(); ... |
#include <bits/stdc++.h> const long long inf = 1e18; using namespace std; int n; long long x[100005]; long long lb, ub, mid; long long sum, S; long long cnt[3]; int main(void) { cin >> n; for (int i = 1; i <= n; i++) cin >> x[i]; lb = inf, ub = -inf; for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0; int d = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == A ) a++; else d++; } cout << (a == d ? Friendship : (a > d ? Anton : Danik )); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long N; cin >> N; vector<long long> V; long long Sum = N; for (long long i = 0; i < N; i++) { long long X; cin >> X; V.push_back(X); } long long L = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; long long s, total, ans, leaves[maxn]; int n; vector<pair<long long, long long>> tree[maxn]; void dfs(int u, int prev, priority_queue<pair<long long, pair<long long, long long>>>& pq) { leaves[u] = (long long)(tree[u].si... |
#include <bits/stdc++.h> using namespace std; const int OO = (int)1e9 + 1; const int MAX = 1e5 + 1; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x, arr[3] = {}; cin >> n; for (int i = 0; i < n; i++) { cin >> x; arr[x]++; } if (!arr[1]) c... |
#include <bits/stdc++.h> using namespace std; int n, ans, reg[26] = {1}; char s[100][100]; bool dfs(int dep) { if (reg[dep] == n) return true; if (dep >= ans || reg[dep] > n) return false; ++dep; for (int i = -1; i < (dep); ++i) for (int j = 0; j < (dep); ++j) { int ii = i; ... |
#include <bits/stdc++.h> using namespace std; string tostring(int x) { ostringstream o; o << x; return o.str(); } int toint(string s) { istringstream st(s); int i; st >> i; return i; } const int mod = 1e9 + 7; const int N = 1e6 + 10; const int inf = 2e9; const double eps = ... |
#include <bits/stdc++.h> long long gi() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) f ^= ch == - , ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return f ? x : -x; } std::mt19937 rnd(time(NULL)); template <class T> void cxk(T& a, T b) {... |
#include <bits/stdc++.h> using namespace std; const int N = 11; const long long MOD = 1000000007LL; int dp[N][N][3]; long long t[N][N]; int cnt[N], c[N]; int n; string s; long long ans = 0; void init() { for (int i = 0; i <= n; ++i) { for (int k = 1; k <= 6; ++k) { if (cnt[i] < k) ... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int n; vector<set<int> > g(200000); vector<int> used(200000); int main() { int n, m, k; cin >> n >> m >> k; vector<int> x(m); vector<int> y(m); for (int i = 0; i < m; i++) { cin >> x[i] >> y[i]; x[i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, val; cin >> n; vector<int> vet; for (int i = 0; i < n; i++) { cin >> val; vet.push_back(val); } sort(vet.begin(), vet.end()); vector<int> ans; while (ans.size() < n) { ... |
#include <bits/stdc++.h> using namespace std; int Max(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ b; } int Min(int a, int b) { return (((b - a) >> (32 - 1)) & (a ^ b)) ^ a; } long long GCD(long long a, long long b) { return b != 0 ? GCD(b, a % b) : a; } long long LCM(long long a, long long b) {... |
#include <bits/stdc++.h> using namespace std; int stack[90], n, k, ans, bag, a[90], tim[90]; int vec[90][90], zoom[90]; bool vis[90]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); vec[a[i]][0]++; vec[a[i]][vec[a[i]][0]] = i; } for (int... |
#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; long long r = (n * (n - 1)); r = (r >> 1); if (r > k) { for (long long i = 0; i < n; i++) { cout << 0 << << i <... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5001; long long x11[10]; long long y11[10]; long long x22[10]; long long y22[10]; long long deltax[10]; long long deltay[10]; int main() { bool flag1 = 0; bool flag2 = 0; bool flag3 = 0; for (int i = 0; i < 4; i++) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; int main() { ll n; cin >> n; vector<ll> a(n + 1); ll curr = 0; vector<ll> iseven(2); ll ans = 0; for (int i = 1; i <= n; i++) { ll x; cin >> x; x = __builtin_popcountll(x); a[i] = x; c... |
#include <bits/stdc++.h> using namespace std; struct Seg { int sa, ea, sb, eb; } p[200005]; int cmp(Seg &a, Seg &b) { if (a.ea != b.ea) return a.ea < b.ea; else return a.sa < b.sa; } int n, mx[4 * 200005], mi[4 * 200005]; void creat(int l, int r, int k) { if (l == r) { mx... |
#include <bits/stdc++.h> using namespace std; int tem; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) scanf( %d , &arr[i]); int flag = 1; for (int i = 0; i < n - 1; i++) { if (abs(arr[i] - arr[i + 1]) > 1... |
#include <bits/stdc++.h> void lire_input() { freopen( input.txt , r , stdin); } void ecrire_output() { freopen( output.txt , w , stdout); } using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) { for (int i = 0; i < n; i++) { printf( %d , i); } printf( n );... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.