func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int a[200], n, k; for (int i = 0; i <= 200; i++) a[i] = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> k; a[k]++; } int kol = 0; for (int i = 1; i <= 198; i++) kol += a[i] / 2; cout << kol / 2; return 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 4000 + 5, mod = 1000000009; int n, x, y; long long P[N], d[N][N]; int main() { scanf( %d , &n); scanf( %d , &x); scanf( %d , &y); for (int i = 0; i <= max(x, y); i++) d[i][0] = 1; for (int i = 1; i <= max(x, y); i++) for (in... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const long long INF = 1ll << 61, Mo = 1e9 + 7; int n, m, t, tu, tp, td; int h[400][400]; int s[400][400], x[400][400], z[400][400], y[400][400]; set<pair<int, int> >::iterator ii; inline int time(int h1, int h2) { if (h1 == ... |
#include <bits/stdc++.h> using namespace std; char BUFFER[100000 + 5]; bool readn(int &n) { return scanf( %d , &n) == 1; } bool readl(long long &n) { return scanf( %I64d , &n) == 1; } bool readd(double &n) { return scanf( %lf , &n) == 1; } bool reads(string &s) { s = ; int n = scanf( %s , BUFFER);... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, w, x, c; cin >> a >> b >> w >> x >> c; long long delta = c - a; if (delta <= 0) { cout << 0 << endl; } else { double k = (1.0 * delta * x - b) / (w - x); long long t = ceil(delta + k); cout << t <<... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); } template <typename T> inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); } template <typename T> inline const T ABS(T a) { return (((a) > 0) ? (a... |
#include <bits/stdc++.h> using namespace std; const int T = 41; const long long X[] = {0, 1, 3, 7, 15, 31, 63, 127, ... |
#include <bits/stdc++.h> using namespace std; int size_n, size_m; set<int> result; vector<char> marks(0); vector<string> mrk(0); int main() { int ii, jj; string str; cin >> size_n >> size_m; marks.resize(size_m); mrk.resize(size_n); cin.ignore(); for (ii = 0; ii < size_m; ii++) m... |
#include <bits/stdc++.h> using namespace std; struct Node { int key, priority; int add = 0; Node *left_child = nullptr, *right_child = nullptr; Node(const int key) : key(key), priority(rand()) {} void propagate() { key += add; if (left_child) left_child->add += add; if (right_c... |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 5; vector<int> adj[mxN]; int n, m, sz[mxN], dp[mxN], dpb[mxN], mn[mxN]; bool bad[mxN]; int ans = 1e9 + 7, V; void dfs1(int v, int par = -1) { sz[v] += bad[v]; for (auto to : adj[v]) { if (par != to) { dfs1(to, v); ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; const int inf = 1000000010; const int MAXN = 300010; struct edge { int u, v, c, t, res; } E[MAXN]; int n, m, k, u, v, x, y, t, a, b, N; int comp[MAXN * 2]; bool mark[MAXN * 2]; int del[MAXN * 2]; int del2[MAXN * 2]; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; bool isprime[MAX]; int a[MAX]; int ans[100005]; vector<int> factor[MAX]; void get_prime() { memset(isprime, 1, sizeof(isprime)); for (int i = 2; i < MAX; i++) { if (isprime[i]) { factor[i].push_back(i); for... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10; const int MOD = 1e9 + 7; bool mark[N]; vector<int> ps, corporator[N]; int primeMul[N], primeCnt[N], nthPower[N], b[N], n, k; int _sum(int, int); int _mul(int, int); int _pow(int, int); void _push(int&, int); int main() { cin... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, maxn = 100007, mod = 1e9 + 7; const long long linf = 0x3f3f3f3f3f3f3f3fLL; const long long P = 19260817; string str; string s; bool flag; int main() { cin >> str; for (int i = 1; i <= 5; i++) { cin >> s; if (s[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; int a[maxn]; int ans[maxn << 1]; int vis1[maxn], vis[maxn]; int main() { int T; scanf( %d , &T); while (T--) { int n; scanf( %d , &n); int res = n; int p = 0; int mex; for (int i = 1; i <= n;... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 1e3 + 10, maxm = 1e6 + 5, maxc = 26; long long sum = 0, mi = 0, ma = 0; int main() { int n, w, num; scanf( %d%d , &n, &w); for (int i = 0; i < n; i++) { scanf( %d , &num); sum += num; mi = ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:36777216 ) template <class T> void chmax(T& l, const T r) { l = max(l, r); } template <class T> void chmin(T& l, const T r) { l = min(l, r); } void reader(int& x) { int k, m = 0; x = 0; for (;;) { (... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long sum = 0; for (int i = 0; i < n / 2; i++) { sum += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]); } cout << sum << e... |
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 1e5 + 1; int r, a, b, m, las[N]; int main() { cin >> a >> b >> m >> r; memset(las, -1, sizeof las); las[r] = 0; for (int i = 1;; ++i) { r = (a * r + b) % m; if (~las[r]) { cout << i - las[r]; re... |
#include <bits/stdc++.h> using namespace std; int n; string s[80000]; unordered_map<string, int> substrings; int main(void) { cin >> n; for (int i = 0; i < n; ++i) { cin >> s[i]; unordered_map<string, bool> used; for (int j = 1; j <= s[i].size(); ++j) { for (int k = 0; k + j ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[3010]; bool maps[3010][3010]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf( %d%d , &u, &v); g[u].push_back(v); maps[u][v] = 1; } int ans = 0; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7, M = 1e6 + 7, fo = 1e6; template <class T> inline void read(T &re) { char ch; while ((ch = getchar()) < 0 || ch > 9 ) ; re = ch - 48; while ((ch = getchar()) >= 0 && ch <= 9 ) re = (re << 3) + (re << 1) + ch - ... |
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; struct uz { long long k, l, id, cnt; long long x, y, m; int i = 1; void add() { l = (l * x + y) % m; i++; } } u[5035]; vector<pair<long long, lon... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); char arr[n + 1]; scanf( %s , arr); int ans[26]; for (int m = 0; m < 26; m++) ans[m] = 0; for (int j = 0; j < n; j++) { int k = arr[j]; if (k > 64 && k < 91) ans[k - 65] = 1; else ans[k - 97] = 1... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; constexpr int Dir4[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; constexpr int Dir8[8][2] = {{-1, -1}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 1}}; constexpr double EPS = 1e-8; const double PI = acos(-... |
#include <bits/stdc++.h> using namespace std; template <typename T> class flow_graph { public: static constexpr T eps = (T)1e-9; struct edge { int from; int to; T c; T f; }; vector<vector<int>> g; vector<edge> edges; int n; int st; int fin; T flow; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int N = 1005; int dp[N][2][N], n, T; struct node { int c, t; node(int c = 0, int t = 0) : c(c), t(t) {} void read() { scanf( %d%d , &t, &c); } bool operator<(const node &b) const { return t > b.t; } } a[N]; int main()... |
#include <bits/stdc++.h> using namespace std; int a[2000]; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; s = string(60, a ); ... |
#include <bits/stdc++.h> using namespace std; struct cs { int to, next; } a[200001]; int aa[400001], head[100001], sum[100001]; bool vi[100001], c[100001]; int n, m, z, y, x, ans, ll, S; void init(int x, int y) { a[++ll].to = y; a[ll].next = head[x]; head[x] = ll; } void dfs(int x, int... |
#include <bits/stdc++.h> using namespace std; int main() { long n, i; cin >> n; long long a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } if (n < 3) { cout << 0 << endl; for (i = 0; i < n; i++) cout << a[i] << ; } else { sort(a, a + n); long l = 0, r = n... |
#include <bits/stdc++.h> using namespace std; long long n, m; vector<pair<long long, long long> > a; vector<pair<long long, long long> > fact(2, {1, 0}); long long pow2(long long i, long long m) { long long r = 1, a = 2, b = i; while (b != 0) { if (b % 2 == 1) { r = (r * a) % m; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; char s[105]; cin >> n; cin >> s; vector<int> v; v.clear(); int cnt = 0; for (int i = 0; i < n; i++) { if (s[i] == B ) { ++cnt; } else { if (cnt != 0) { v.push_back(cnt); ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1; const long long MOD = 1; long long _gcd(long long a, long long b) { if (b == 0) return a; return _gcd(b, a % b); } long long gcd(long long a, long long b) { a = abs(a), b = abs(b); if (a < b) swap(a, b); return _gcd(a, b);... |
#include <bits/stdc++.h> using namespace std; const int M = (int)1e9 + 7; const int N = (int)2e5 + 5; struct trio { long long a; long long b; long long c; }; trio dp[2][N]; long long ps[N]; int main() { cout.precision(15); cout.setf(ios::fixed); int n, k; int i; cin >> n ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, t, s; cin >> n >> k >> t; s = n * k * t / 100; for (int i = 0; i < n; i++) { if (s >= k) { cout << k << ; s -= k; } else if (s > 0) { cout << s << ; s = 0; } else cout... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 100; int a[maxn]; map<pair<int, int>, bool> mp; int main() { ios::sync_with_stdio(false); int N; cin >> N; int M; cin >> M; for (int i = 1; i <= N; i++) cin >> a[i]; for (int i = 1; i <= M; i++) { int x; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; struct SquareMatrix { SquareMatrix(int _n) : n(_n) { data.assign(_n, vector<long long>(_n, 0)); } vector<long long> &operator[](int i) { return data[i]; } const vector<long long> &operator[](int i) const { return data[i]; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300000000; const int BLOCK = 100000; const int NUM = 3000; const int num[] = { 4784, 4194, 4003, 3920, 3831, 3791, 3726, 3667, 3669, 3591, 3642, 3612, 3532, 3554, 3507, 3500, 3517, 3449, 3496, 3432, 3462, 3406, 3394, 3376, 3378, ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 9; const int MAX1 = 1e6 + 9; const double pi = acos(-1); const long long int inf = 1e9; const long long mod = 1e9 + 7; bool prime[MAX]; int pfactors[MAX]; long long int fact[MAX]; long long int ifact[MAX]; long long int mexp(long ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; while (cin >> s >> t) { int n = s.size(); string res; for (int i = n - 1; i >= 0; --i) { char& c = s[i]; ++c; int x = 0; if (c > z ) { c = a ; x = 1; } ... |
#include <bits/stdc++.h> using namespace std; const int M = 210000; struct Node { long long si, fi, ti; } node[M]; int n, m; long long get_num(long long x, long long y, long long z, int dir) { long long sum = 0; if (dir == 1) { if (x <= y) { sum += y - x; if (y <= z) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, tmp; string s; char c; scanf( %d , &n); c = b ; s = a ; for (i = 1000; i >= 2; i--) { tmp = i * (i - 1) / 2; while (n >= tmp) { n -= tmp; for (j = 0; j < i; j++) s.push_back(c); ... |
#include <bits/stdc++.h> using namespace std; long i, n; int main() { scanf( %ld , &n); if (n % 2 != 0) { for (i = 0; i < n - 1; i++) printf( %ld , i); printf( %ld n , n - 1); for (i = 1; i < n; i++) printf( %ld , i); printf( 0 n ); printf( %ld , 1 % n); for (i = 1; i... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100 + 100; int a1, a2, b1, b2; int main() { cin >> a1 >> a2 >> b1 >> b2; if ((b2 >= a1 - 1 && b2 <= 2 * (a1 + 1)) || (b1 >= a2 - 1 && b1 <= 2 * (a2 + 1))) cout << YES << endl; else cout << NO << endl; return 0... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> PII; #define x first #define y second typedef long long ll; const int N=2e5+10; const ll mod=1e9+7; int n,m,k,x; int w[110],ord[110]; bool st[110]; void solve() { int s=0,sum=0; cin>>n>>x; fo... |
#include <bits/stdc++.h> using namespace std; int a[300005], b[300005], f[300005], ori[300005]; queue<int> q; int main() { int n, i, j, k, u, v, up = n; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); } for (i = 1; i <= n; i++) { scanf( %d , &b[i]); } q.pu... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { vector<string> a; int n; cin >> n; a.resize(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = n - 2; i >= 0; --i) { const char *x = a[i].c_str(), *y = a[i + 1].c_str(); int j = 1; while... |
#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; const int N = 1e5 + 2; const int M = 2e6; const int V = 500; const int mod = 0; const int inf = 2e9 + 3; const long long INF = 1e16; int dp[V + 20][N], n, q, a[N]; int calc(int p, int k) { int ans = 0; while (p <= n) { ans++; p = p + a[... |
#include <bits/stdc++.h> char ansStr[1000000]; int nextInt() { char ch; int s, x; do { ch = getchar(); } while (ch <= 32); if (ch == - ) { s = -1; ch = getchar(); } else s = 1; x = 0; while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = ge... |
#include <bits/stdc++.h> using namespace std; vector<int> H; vector<int> L; int a[200001]; bool vis[200001]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } bool T = 0; for (int i = 1; i <= n;) { bool faH = 0, faL = 0; int t... |
#include <bits/stdc++.h> int main() { int a[105][4], n, ans, flag, i, j; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d%d%d%d , &a[i][0], &a[i][1], &a[i][2], &a[i][3]); ans = -1; for (i = 0; i < n; i++) { flag = 0; for (j = 0; j < n; j++) if (a[i][0] < a[j][0] && a[i]... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long T = 1; while (T--) { long long n; cin >> n; vector<pair<long long, long long> > q1, q2, q3, q4; for (long long i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int s = 0; while (n--) { int a, b; cin >> a >> b; s += b - a + 1; } cout << (k - (s % k)) % k << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; bool sign[30010]; int num[2]; int value[30010]; int start[3][2] = {{0, 1}, {0, 2}, {1, 2}}; int n; bool Legal(int pos) { if (pos == n - 1) return true; int d = value[pos + 1] - value[pos]; for (int i = pos + 2; i < n; i++) { if (value[i] - va... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; if ((x == n / 2 || x == n / 2 + 1) and (y == n / 2 || y == n / 2 + 1)) cout << NO << endl; else cout << YES << endl; return 0; } |
#include <bits/stdc++.h> const double eps = (1e-10); using namespace std; int dcmp(long double a, long double b) { return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1; } int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; } int setBit1(int num, int idx) { return num | (1 << idx); } long long ... |
#include <bits/stdc++.h> using namespace std; int s[100], n, r[100], h[100], c[100], mni = -1; bool bad; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> s[i] >> r[i] >> h[i] >> c[i]; for (int i = 0; i < n; i++) { bad = false; for (int j = 0; j < n; j++) { if (s[i] < s[j... |
#include <bits/stdc++.h> using namespace std; bool sorts(pair<long long, long long> a, pair<long long, long long> b) { return a.second < b.second; } int main() { long long n, m, k, t; cin >> n >> m >> k >> t; string s[3] = { Carrots , Kiwis , Grapes }; vector<pair<long long, long long>> ve... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; const int INF = 1e9; vector<int> adj[MAXN], ts; int tin[MAXN], en[MAXN], curt; bool dag; void dfs(int s, int p = -1) { tin[s] = ++curt; for (auto v : adj[s]) { if (tin[v] && !en[v]) { dag = false; return;... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147000000; const int maxn = 4e5 + 10; const int mod = 998244353; int n, I; int a[maxn]; int sum[maxn]; int main() { scanf( %d%d , &n, &I); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } sort(a + 1, a + 1 + n); ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int dist[501][501]; int INF = 1000000000; int s[501][501]; int c[501][501]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { dist[i][j] = INF;... |
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int nega = 1; while (!isdigit(ch)) { if (ch == - ) nega = -1; ch = getchar(); } int ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); } if (nega == -... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 1e5 + 5; const int MAXM = 1e5 + 5; int T, N, M, K, cas; struct Edge { int u, v, w; Edge() {} Edge(int u, int v, int w) : u(u), v(v), w(w) {} bool operator<(const Edge& e) const { return w < e.w; } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 10005; int n, a[N]; int cnt[N]; int main() { int T; srand(time(0)); scanf( %d , &(T)); while (T--) { memset(cnt, 0, sizeof(cnt)); double ex = 0; for (int i = 1; i <= 250; i++) scanf( %d , &(a[i])), cnt[a[i]]+... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 1; const int MAX = 200001; const long long MOD = 1000000007; struct trio { int first; int second; int third; }; struct long_trio { long long first; long long second; long long third; }; double dist_point... |
#include <bits/stdc++.h> using namespace std; const int NV = 105; const int LNV = 11; const int NE = 5015; const int NQ = 1000005; const int intmax = 0x7fffffff; int f[2005]; int a[2005]; int n, m; struct Edge { int ne, y, v; }; struct Edge2 { int x, y, v; }; bool cmp(Edge2 a, Edge2 ... |
#include <bits/stdc++.h> using namespace std; int main() { long long loop = 0, t, n, a, b, c, d; scanf( %lld , &t); while (t--) { loop++; scanf( %lld%lld%lld%lld%lld , &n, &a, &b, &c, &d); if (n * (a - b) > c + d || n * (a + b) < c - d) printf( No n ); else printf... |
#include <bits/stdc++.h> using namespace std; const int N = 200000; int n; bool p[N]; int tot, ans[N][2]; int tmp[N], tmptot; int rem[N], remtot; int main() { scanf( %d , &n); for (int i = 3; i <= n / 2; ++i) if (!p[i] && i % 2) { tmptot = 0; p[i * 2] = 1; for (int ... |
#include <bits/stdc++.h> using namespace std; struct functie { char nume[501]; int par[10], nrPar; }; struct var { char nume[501]; int tip; }; char x[1001], nvar[1001], nquery[1001], varAct[1001]; functie functii[1001]; var vari[1001]; char nfact[1001]; int n, i, j, inceput, b, nrF, ... |
#include <bits/stdc++.h> using namespace std; int z[100005], cnt[100005]; char s[100005]; void solve() { int n, t, L, R; n = strlen(s), L = R = 0; z[0] = n; for (int i = 1; i < n; i++) { if (R < i) { L = R = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L, R-... |
#include <bits/stdc++.h> const double eps = 1e-8; const int oo = 0x3f3f3f3f; using namespace std; long long a, b, c, d; bool read() { if (!(cin >> a >> b >> c >> d)) return false; return true; } void process() { cout << b << << c << << c << endl; } int main() { ios_base::sync_with_st... |
#include <bits/stdc++.h> using namespace std; void calcula(long long int n, long long int m, long long int r[10000], long long int sumar[10000], long long int k, long long int p) { priority_queue<long long int> q; for (int i = 0; i < n; i++) q.push(r[i]); for (int paso = 1; paso <= k; pas... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int oo = 0x3f3f3f3f; const int Mod = 1e9 + 7; const int ... |
#include <bits/stdc++.h> using namespace std; int lft[26]; char s[111111], t[111111]; int n, m; int main() { gets(s); n = (int)strlen(s); for (int i = 0; i < n; ++i) lft[s[i] - a ]++; gets(t); m = (int)strlen(t); for (int i = 0; i < n; ++i) { bool fnd = 0; for (int let = 0... |
#include <bits/stdc++.h> using namespace std; const int size = 100010; const int bound = 100; int n, m, qq; int res[size], arr[size], father[size]; vector<pair<int, int> > edge[size]; pair<int, int> q[size]; map<int, int> ans[size]; int find(int x) { return father[x] == -1 ? x : father[x] = find(fathe... |
#include <bits/stdc++.h> using namespace std; int main() { int h, g, c, n, m, k, l, a[140] = {}; string s; cin >> s; n = s.length(); for (int i = 0; i < s.length(); i++) a[s[i]]++; int res = 0; for (int i = 0; i <= 139; i++) if (a[i] > 0) { res++; } if ((res < 2) ... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5; long long a[N]; int32_t tree[N << 2], bit_cnt[N]; struct seg_tree { long long combine(long long x, long long y) { return max(x, y); } void build(long long l, long long r, long long node) { if (l == r) { tree[node]... |
#include <bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); int t; cin >> t; while (t--) { in... |
#include <bits/stdc++.h> using namespace std; const int N = 100002; int n, m, k, currentOutCost[N], cntOut, cntIn; struct flight { int i, d, c; } in[N], out[N]; multiset<int> a[N]; bool cmp(flight x, flight y) { return x.d < y.d; } int main() { scanf( %d%d%d , &n, &m, &k); for (int i = (1); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, j, ans; cin >> n >> k; int arr[n]; for (i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); ans = 0; for (i = n - 1; i >= 0; i = i - k) { ans += 2 * (arr[i] - 1); } cout << ans; } |
#include <bits/stdc++.h> using namespace std; template <class A, class B> ostream& operator<<(ostream& out, const pair<A, B>& a) { return out << ( << a.first << , << a.second << ) ; } template <class A> ostream& operator<<(ostream& out, const vector<A>& a) { out << [ ; for (auto it = a.be... |
#include <bits/stdc++.h> using namespace std; struct hren { long int pos, ob, tim; }; hren down, up, lin, rech, u1, u2, u3, u4; long long int c, q = 1, f = 1, g = 1; long int n, j, i, timer = 0, x, y, p = 0; void pere1(hren &q) { if (timer == q.tim) { q.pos = 1; q.ob = 1; return;... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e6, mod = 998244353; int arr[101]; int n; bool rot(int idx, int deg) { deg %= 360; if (deg < 0) deg += 360; if (idx == n) return !deg; return rot(idx + 1, deg + arr[idx]) | rot(idx + 1, deg - arr[idx]); } int main() { cin >... |
#include <bits/stdc++.h> using namespace std; int dp[45][45][45][45] = {0}; int sumar[45][45] = {0}; int ar[45][45] = {0}; int check(int i, int j, int p, int q) { int s1 = sumar[p][q]; int s2 = sumar[i - 1][q]; int s3 = sumar[p][j - 1]; int s4 = sumar[i - 1][j - 1]; return ((s1 - s2 - s3 +... |
#include <bits/stdc++.h> char map[55][55]; int main() { int n, ans = 2147483647; std::pair<int, int> s, t; std::queue<std::pair<int, int> > q; std::vector<std::pair<int, int> > vec1, vec2; scanf( %d %d %d %d %d , &n, &s.first, &s.second, &t.first, &t.second); for (int i = 1; i <= n; ++i) sca... |
#include <bits/stdc++.h> using namespace std; int main() { string a, s; int c(0); cin >> a >> s; sort(s.begin(), s.end()), reverse(s.begin(), s.end()); for (int i = 0; i < a.size(); i++) { if (a[i] < s[c]) a[i] = s[c++]; } cout << a << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; char b[101]; int k = 0; for (int i = 0; i < a.length() - 1; ++i) { if (a[i] != a[i + 1] || a[i] != / ) { b[k] = a[i]; ++k; } } if ((k == 0) || (a[a.length() - 1] != / )) { b... |
#include <bits/stdc++.h> using namespace std; long long a[1000006]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long score = 0; for (int i = 0; i < n - 1; i++) score += 1ll * (i + 2) * a[i]; score += a[n - 1] * n; cout << score << end... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; const int mod=1e9+7; const int N=1e6+11; const double eps=0.00000001; bool check(int u,int v){ int a=0,b=0; for(int i=0;i<31;i++){ if(u>>i&1) a++; if(v>>i&1) b++; if(b){ if(!a) return ... |
#include <bits/stdc++.h> using namespace std; int main() { string x, y; cin >> x >> y; const auto n = int(x.size()); auto ok = true; for (auto i = 0; i < n; i++) ok &= y[i] <= x[i]; if (ok) cout << y << endl; else cout << -1 << endl; } |
#include <bits/stdc++.h> using namespace std; int n; int a, b, h, w, ans = INT_MAX, f[int(1e5 + 10)]; bool cmp(int x, int y) { return x > y; } void get_answ(long long x, long long y, int d, bool flag) { if (x >= a && y >= b) { ans = min(ans, d - 1); return; } if (d == n + 1) return; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int Tests = 1; while (Tests--) { long long int N; cin >> N; vector<long long int> A(N); for (long long int i = 0; i < N; i++) cin >> A[i]; if (N == 1) c... |
#include <bits/stdc++.h> using namespace std; long long bigmod(long long b, long long p, long long md) { if (p == 0) return 1; if (p % 2 == 1) { return ((b % md) * bigmod(b, p - 1, md)) % md; } else { long long y = bigmod(b, p / 2, md); return (y * y) % md; } } set<int> vis; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long k, left; cin >> k; long long base = k + 1; vector<long long> v; v.push_back(-1); left = base; for (long long i = 1; i < 2001; i++) { left++; if ... |
#include <bits/stdc++.h> using namespace std; long long jc[100005], fac[12], vp[12], P[12], s, v[100005][12], r[100005][12]; long long n, L, R, p; long long fpower(long long x, long long k) { long long ans = 1; while (k) { if (k & 1) ans = ans * x % p; x = x * x % p; k >>= 1; } ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long Inv[1000005]; void inv(int n) { Inv[1] = 1; for (int i = 2; i <= n; i++) { Inv[i] = (mod - mod / i * Inv[mod % i] % mod) % mod; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; ... |
#include <bits/stdc++.h> using namespace std; int f[100][300] = {0}; int main() { std::ios::sync_with_stdio(false); string s1, s2; cin >> s1 >> s2; int t1 = 0, t2 = 0, q = 0; for (int i = 0; i < s1.length(); i += 1) { if (s1[i] == + ) t1++; else t1--; } for... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } const string dom[2][7] = {{ ......... , ....O.... , O.......O , O...O...O , O.O...O.O , O.O.O.O.O , OOO...OOO }, { ......... , ....O.... , ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 15; struct tree { int l, r, sum; tree *left, *right; tree(int L, int R, int val) { l = L, r = R, sum = val; left = right = NULL; } }; tree *pq[N], *db[N]; tree *update(tree *cur, int l, int r, int ind, int add) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.