func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000 + 10; int mod; int n, m; vector<int> E[MAX_N]; bool v[MAX_N]; int cnt; void dfs(int u) { if (v[u]) return; v[u] = true; ++cnt; for (vector<int>::iterator e = E[u].begin(); e != E[u].end(); ++e) { dfs(*e); } ... |
#include <bits/stdc++.h> using namespace std; struct Edge { int v; int w; Edge* next; void add(int v, int w, Edge*& head) { this->v = v; this->w = w; this->next = head; head = this; } } edges[200100]; Edge* h[100100]; struct Q { int v; int t; bool operat... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long nCrModp_2(long long n, long long r, lo... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int t, n, c_0, c_1, h; string s; cin >> t; for (int i = 0; i < t; i++) { cin >> n >> c_0 >> c_1 >> h; cin >> s; int sum = 0; for (int j = 0; j < n; j++) { sum += s[j] - 0 ; }... |
#include <bits/stdc++.h> using namespace std; int p[1010], vst[1010]; char s[1010][1010]; int main() { int n; scanf( %d , &n); int x = n, ed = 0, pos = 0; for (int i = 1; i <= n; i++) { scanf( %d , p + i); if (p[i] != i) ed = i; for (int j = 1; j <= n; j++) s[i][j] = . ; }... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 100; const int maxK = 5000 + 10; const long long INF = 1e18; int a[maxn], n, k; long long f[maxK][maxK]; long long gao(int i, int j, int len) { int s = i * (n / k) + j * (n / k + 1) + 1; int t = s + len - 1; return a[t] - a[s... |
#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]; long long mx = 1e9 + 9, r = 0; for (int i = n - 1; i >= 0; i--) { a[i] = min(mx, a[i]); r += a[i]; mx = min(mx, max(0ll, a[i] - 1)); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010, M = 100010, SIZE = 26, LEN = 1000010; int n, m, dfk = 0; namespace BIT { int c[LEN]; void Add(int x, int k) { for (; x <= dfk; x += x & -x) c[x] += k; return; } int Sum(int x) { int sum = 0; for (; x; x -= x & -x) sum +=... |
#include <bits/stdc++.h> using namespace std; const int MX = 505, mod = 998244353; int n, m; vector<int> c, pos[MX]; long long mem[2 * MX][2 * MX]; bool isValid(int a, int b) { if (a != pos[c[a]][0] && a != pos[c[a]].back()) return 0; if (b != pos[c[b]][0] && b != pos[c[b]].back()) return 0; for... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3; vector<int> g[1000001]; int p[1000001], c[1000001], a[1000001], sz[1000001], root, n; char sub(string a, string b) { for (int i = 0; i < b.size(); i++) { if (a[i] != b[i]) return a[i]; } ... |
#include <bits/stdc++.h> using namespace std; const int siz = 1000000 + 10; char a[siz]; int main() { int t, n, m = 0, i, l, k; scanf( %d , &t); scanf( %s , a); int len = strlen(a); int z = 0, o = 0; for (l = 0; l < len; l++) { if (a[l] == 1 ) o++; else if (a[l] == ... |
#include <bits/stdc++.h> using namespace std; int n, N, id[6100]; bool judge(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } void work() { if (judge(N)) return; if (N % 2 && !judge(N - 2)) N -= 3, id[3] = 3; for (int... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(), cout.tie(); bool w = false; int cnt = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { int zero = 0, one = 0; if (w && s[i] == 0 ) { cout << 1 << << 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; double t[100001], v[100001], fin[100001]; int main() { double n, a, d; cin >> n >> a >> d; for (int i = 0; i < n; ++i) { cin >> t[i] >> v[i]; } cout.precision(5); for (int i = 0; i < n; ++i) { fin[i] = 2 * d * a <= v[i] * v[i] ? sqr... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int a[N], p[N], d[N]; int main(int argc, char const *argv[]) { int n, gain = 0; scanf( %d n , &n); for (int i = 2; i <= n; i++) scanf( %d , p + i); for (int i = 1; i <= n; i++) d[i] = d[p[i]] + 1; for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; const int N = 503; char thien[N][N]; int n, m, visit[N][N]; vector<pair<int, int> > adj[N][N]; int hang[4] = {-1, 0, 1, 0}; int cot[4] = {0, 1, 0, -1}; struct ds { char type; int u, v; }; vector<ds> Ans; void DFS(int u, int v) { visit[u][v]... |
#include <bits/stdc++.h> using namespace std; int a[1000010], b[1000010]; int f[1000010], g[1000010]; int tmp[1000010]; int ansf[1000010], ansg[1000010]; int main() { int sv, n, m; scanf( %d %d , &sv, &n); int p = 0, q = 0; for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n + 10]; for (int i = 1; i <= n; ++i) scanf( %lld , &a[i]); long long x, y; cin >> x >> y; long long h = x + y; long long sum = 0; for (int i = 1; i <= n; ++i) { sum = sum + y * (a... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e3 + 1; int dp[MAX][4], in[MAX]; int main() { ios::sync_with_stdio(0); int n, ans = 1; cin >> n; for (int i = 0; i < n; ++i) { cin >> in[i]; if (in[i] == 1) dp[i][0] = 1; else dp[i][1] = 1; for... |
#include <bits/stdc++.h> using namespace std; string s[100]; long long C[51][3000][2]; int Count[2000100]; double DP[2000100]; int l; double get(int mask) { int left = Count[mask]; if (left == 0) return 0; if (DP[mask] >= 0) return DP[mask]; double res = 0; int cnt = 0; for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; long long m = 200, ans = 0; while (n--) { long long a, p; cin >> a >> p; m = min(m, p); ans += m * a; } cout << ans... |
#include <bits/stdc++.h> typedef struct mk { int v; struct mk *next; } roy; roy *add(roy *head, int v) { roy *t = (roy *)malloc(sizeof(roy)); t->v = v; t->next = NULL; if (head == NULL) return t; t->next = head; return t; } long long n, a[300010], s[300030], u, v, count; roy ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int s = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + ch - 0 , ch = getchar(); return s * f; ... |
#include <bits/stdc++.h> const int inf = (int)1e9; const int mod = 1e9 + 7; using namespace std; long long a[1011][1011]; int n, m; int id[1000011]; long long k; int d[1000011]; int c[1011][1011]; int now = 0; vector<pair<long long, pair<int, int> > > b; bool cmp(pair<long long, pair<int, int> >... |
#include <bits/stdc++.h> struct val { long long x; int y, d; val *p, *l, *r; } g1[100001], g2[100001], *rt1[100001], *rt2[100001], *nil = g1; struct node { long long x; int y; bool operator<(const node &b) const { return x < b.x; } } a[100001]; struct vale { long long x; int y;... |
#include <bits/stdc++.h> using namespace std; struct number { deque<int> q; map<int, int> db; int curr = 0; }; struct pii { int x, y, id; }; const int S = 300; bool sortFunc(pii a, pii b) { if (a.x / S == b.x / S) return ((a.x / S) & 1 ? a.y > b.y : a.y < b.y); return a.x < b.x; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int MAX = 200005; long long modexp(long long x, long long n) { if (n == 0) return 1LL; if (n % 2 == 0) { long long y = modexp(x, n / 2) % mod; return (y * y) % mod; } return (x * modexp(x, n - 1) % mod... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; char dir[] = { R , L , D , U }; const int MOD = 1e9 + 7; const long long INF = 1e9; void setIO(string filename) { if (fopen((filename + .in ).c_str(), r )) { freopen((filename + .in ).c_str(),... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int flag = 0; for (int i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) { flag = 1; cout << YES << endl; cout << i + 1 << << i + 2; break; return 0... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.length(); s[n - 1] = s[0]; cout << s << n ; return; } int main() { int t; cin >> t; while (t--) { solve(); } return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int inf = (1 << 30) - 1; const ll INF = (1LL << 60) - 1; const double pi = acos(-1.0); const double EPS = 1e-10; tem... |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define x first #define y second #define LL long long #define LD long double #define Complex complex<double> #define y1 ___y1 #define next ___next #define left ___left #define right ___right #define pii pai... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, M; cin >> N >> M; if (N > M) swap(N, M); ll rem = 0; if (N == 1) { rem = min(M % 6, 6 - M % 6); } else { if (N % 2 == 1 && M % 2 == 1) { rem = 1; } else { if (M == 2) { ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int maxn = 2200; LL a[maxn * 2], b[maxn * 2]; using PII = pair<int, int>; constexpr int inf = 1000000000; struct SSPA { struct Edge { int u, v, f, c; }; int n, s, t; vector<Edge> edges; vector<vector<in... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int MOD = 1000000007; unordered_map<int, bool> sp; vector<int> g[MAX]; struct node { int u, v; int cost; node(int _u, int _v, int _cost) { u = _u; v = _v; cost = _cost; } }; bool mst_sort(node &... |
#include <bits/stdc++.h> const long long M = 1000005; const long long mod = 1e9 + 7; using namespace std; long long n, m, a, b, fac[M], Ans; inline long long Fpw(long long Base, long long k) { long long temp = 1; while (k) { if (k & 1) temp = (1LL * temp * Base) % mod; Base = (1LL * Base *... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; int n, m, k; string l[maxn]; int t[maxn], T; int w[5][3]; vector<pair<int, int> > v; pair<pair<int, int>, pair<int, int> > a[maxn]; int vis[24 * 30 * 60 + 10]; int cor[24 * 30 * 60 + 10]; int dp[maxn][24 * 30 * 60 + 10]; in... |
#include <bits/stdc++.h> using namespace std; enum { MAXPOS = 110500, MAXBYTE = 20, MAXN = 7070 }; int q_level[MAXN], q_left[MAXN], q_right[MAXN], q_value[MAXN]; int jump_up[MAXBYTE][MAXPOS], jump_low[MAXBYTE][MAXPOS]; int high[MAXPOS]; void init() { for (int i = 0; (1 << i) < MAXPOS; i++) high[1 << i] ... |
#include <bits/stdc++.h> using namespace std; int a[107]; stack<int> Q[100]; int cmp(int a, int b) { return a > b; } int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } sort(a + 1, a + 1 + n, cmp); int ans = 0; int tmp = -1; ... |
#include <bits/stdc++.h> using namespace std; bool gt(long double a, long double b) { return a > b + 1e-12; } int n, m; vector<pair<bool, pair<int, int> > > pt, org; pair<int, int> o; inline bool left_turn(const pair<int, int> &a, const pair<int, int> &b, const pair<int, int> &c) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int res = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -f; ch = getchar(); } while (isdigit(ch)) { res = res * 10 + ch - 0 ; ch = getchar(); } return res * f; } name... |
#include <bits/stdc++.h> using namespace std; long long int sum(long long int n) { long long int s2um = 0; while (n > 0) { s2um += n % 10; n = n / 10; } return s2um; } long long int answer(long long int n) { long long int x = 0, y = 0; while (10 * y + 9 < n) { y = 10 * ... |
#include <bits/stdc++.h> using namespace std; const int N = 200100; int n, l, r, m, a[N], b[N], c, pos, mi, ma; pair<int, int> t[4 * N]; void build(int v, int tl, int tr) { if (tl == tr) { t[v].first = a[tl]; t[v].second = b[tl]; return; } int tm = (tl + tr) / 2; build(2 * v,... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } in... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long Inf = 1e18; const int N = 2e6 + 10; const int mod = 1e9 + 7; int gi() { int x = 0, o = 1; char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar();... |
#include <bits/stdc++.h> using namespace std; const int MAXARR = 2e5 + 5, MAXVAL = 1e6 + 5, MOD = 1e9 + 7, INF = 2147483647; const long long INFLL = (1LL << 62); int n, d, m; int last[MAXARR]; pair<long long, long long> stop[MAXARR]; stack<pair<long long, long long> > st; long long ans = 0LL; template... |
#include <bits/stdc++.h> using namespace std; signed main() { std::ios_base::sync_with_stdio(0), cin.tie(0); string s, t; cin >> s >> t; int a[26] = {}; int n = s.size(), m = t.size(); for (int i = 0; i < n; ++i) a[s[i] - a ]++; bool ok = 0; if (n < m) { s = ; for (int... |
#include <bits/stdc++.h> using namespace std; int power(int a, int n, int m) { if (n <= 0) return 1; if (n % 2 == 1) { return ((int)(((long long)power(a, n - 1, m) * a) % m)); } else { int k = power(a, n / 2, m); return ((int)(((long long)k * k) % m)); } } int main() { long... |
#include <bits/stdc++.h> const int N = 100005; long long num1[N], num2[N], num3[N]; void init() { memset(num1, 0, sizeof(num1)); memset(num2, 0, sizeof(num2)); memset(num3, 0, sizeof(num3)); for (int i = 1; i < N; ++i) { for (int j = i; j < N; j += i) { num1[j] += 1; } } ... |
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, int>> ordered; deque<pair<int, int>> solutions; vector<bool> stay, check; bool cmp(pair<pair<int, int>, int> &a, pair<pair<int, int>, int> &b) { int A = a.first.second - a.first.first; int B = b.first.second - b.first.first; ... |
#include <bits/stdc++.h> using namespace std; long long funk(long long x, long long y) { bool used[10000]; long long res = 1; for (long long i = 1; i <= 100; i++) used[i] = 0; for (long long i = x + 1; i <= y; i++) { res *= i; for (long long j = 2; j <= y - x; j++) { if (!used[j]... |
#include <bits/stdc++.h> using namespace std; int par[200009]; int flag, sum, ans, cnt, mini, maxi; int main() { int n; scanf( %d , &n); int a[n]; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } sort(a, a + n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++)... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 12; const int Maxm = 105; int n, m, k; string s; int a[Maxn][Maxm], b[Maxn][Maxm], c[Maxn][Maxm]; int res; int main() { scanf( %d %d %d , &n, &m, &k); getline(cin, s); for (int i = 0; i < n; i++) { getline(cin, s); fo... |
#include <bits/stdc++.h> using namespace std; bool comp(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) { return a.first < b.first; } int main() { int n, k; cin >> n >> k; vector<pair<int, pair<int, int> > > book; for (int i = 0; i < n; i++) { pair<int, pair<int, int> > tem... |
#include <bits/stdc++.h> using namespace std; void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t) { cerr << t; } template <class T, class... |
#include <bits/stdc++.h> int p[100100], pt, boo[100100], ans, ma[10][10]; std::vector<int> v[10000][6]; void sol(int d) { if (d == 6) { ans++; return; } int i, j, x = 0, y; for (i = 1; i < d; i++) x = x * 10 + ma[d][i]; for (i = 0; i < v[x][6 - d].size(); i++) { y = v[x][6 - ... |
#include <bits/stdc++.h> int main() { int n, x_num; x_num = 0; std::string x; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> x; if (x.substr(0, 2) == -- || x.substr(1, 2) == -- ) x_num--; else x_num++; } std::cout << x_num; return 0; } ... |
#include <bits/stdc++.h> using namespace std; long long const mod = 998244353; long long const inf = 1e15; long long n, m, k, x; long long w[200004], ans[200004]; pair<long long, long long> t[800003]; void build(long long nd, long long l, long long r) { if (l == r) { t[nd] = {w[l], l}; ret... |
#include <bits/stdc++.h> using namespace std; const int LimitLength = 1e5 + 10; const int oo = 1e9 + 7; const int Shift = a ; vector<vector<int> > F; int Next[LimitLength][27]; int nS, nT; char S[2 * LimitLength], T[LimitLength]; int KMP[2 * LimitLength]; int main() { cin >> S + 1 >> T + 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; const unsigned Upper = (1LL << 32) - 1; unsigned a[maxn], b[maxn]; int main() { int n, K; int i, j; unsigned s, a0, a1, a2, a3; scanf( %d%d , &n, &K); for (i = 0; i < n; ++i) { scanf( %u.%u.%u.%u , &a0, &a1, &a2, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, m; cin >> n >> m; vector<long long int> dp(n + 1); vector<pair<pair<long long int, long long int>, pair<long long int, long l... |
#include <bits/stdc++.h> using namespace std; int x, y, mn, mx, ai; int an[200], ax[200]; int main() { cin >> x >> y; for (int i = 1; i <= x; i++) { cin >> ai; an[i] = ax[i] = ai; } for (int i = 1; i <= y; i++) { sort(an + 1, an + 1 + x); an[1]++; } sort(ax + 1, a... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n), b; for (int i = 0; i < n; i++) cin >> a[i]; b = a; sort(b.begin(), b.end()); int k = 0, set1 = 0; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> const long long mod = 1000000007; const long long Inf = 2 * 1e9; const long long p = 31; using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } int n, k; vector<int> q; vector<vector<int>> a; vect... |
#include <bits/stdc++.h> using namespace std; long long power(long long base, long long pow, long long mo) { long long res = 1; while (pow) { if (pow % 2 != 0) res = (res * base) % mo; base = (base * base) % mo; pow /= 2; } return res; } long long inv(long long i) { return powe... |
#include <bits/stdc++.h> class Scanner { private: static const int BUFFER_SIZE = 10000; char buff[BUFFER_SIZE]; int buffPos, buffLim; public: Scanner() { buffLim = fread(buff, 1, BUFFER_SIZE, stdin); buffPos = 0; } private: inline void flushBuff() { buffLim = f... |
#include <bits/stdc++.h> using namespace std; vector<int> d; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, u; cin >> n >> u; d.resize(n); for (int i = 0; i < n; i++) { cin >> d[i]; } double ans = -1.0; for (int k = 2; k < n; k++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x, p, q, ans = 0, cnt = 0; ; cin >> n >> k >> x; int a[n + 5]; for (int i = 1; i <= n; i++) { cin >> a[i]; } if (n == 1) { cout << x << endl; return 0; } for (int i = n; i > 1; i--) { if ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:667772160 ) using namespace std; struct __isoff { __isoff() { if (0) freopen( input.txt , r , stdin), freopen( output.txt , w , stdout); srand(time(0)); } ~__isoff() {} } __osafwf; const unsigned long long p1 = 31; const unsi... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { int h; cin >> h; int n = (1 << h) - 1; vector<pair<int, int>> c(n + 1); for (int i = 0; i <= n; i++) c[i] = {0, i}; for (int i = 0; i < 420; i++) { int u = ... |
#include <bits/stdc++.h> using namespace std; int N, T, L, R, X, H; unordered_map<int, int> siz; unordered_map<int, pair<int, int> > par; pair<int, int> find(int now) { if (par.count(now)) { pair<int, int> a, b; a = par[now]; b = find(a.first); return {b.first, a.second ^ b.second}... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; template <typename T> void chkmax(T &x, T y) { if (x < y) x = y; } template <typename T> void chkmin(T &x, T y) { if (x > y) x = y; } inline int read() { int x = 0; char c = getchar(); bool f = 0; while (c < ... |
#include <bits/stdc++.h> using namespace std; long long tree[4000005]; long long level[4000005]; long long num[1000005]; long long build(long long at, long long L, long long R) { if (L == R) { tree[at] = num[L]; level[at] = 1; return num[L]; } long long mid = (L + R) / 2, a, b, p... |
#include <bits/stdc++.h> using namespace std; const int N = 4 * 1e5 + 5; vector<int> g[N]; int n, dp[N], res[N]; int dfs(int i, int p = -1) { dp[i] = 1; for (auto j : g[i]) { if (j != p) { dp[i] += dfs(j, i); } } return dp[i]; } int dfs2(int i, int p = -1) { for (au... |
#include <bits/stdc++.h> using namespace std; int n, k, persons, valids; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , &persons); if (persons + k <= 5) { valids++; } } printf( %d , valids / 3); return 0; } |
#include <bits/stdc++.h> const int M = 5500; const double esp = 1e-6; const double PI = 3.14159265359; const int INF = 0x3f3f3f3f; using namespace std; struct node { double x, y, z; } arr[M]; double judge(node x, node y) { return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y) + ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int INF = 1e9 + 7; const int N = 1010; const double pi = 3.1415926; int main() { char str[100010]; while (~scanf( %s , str)) { int len = strlen(str); int idx = INF, sum0 = 0, sum1 = 0; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; set<int> st; int main() { int t, i, j, k, n, m; scanf( %d , &n); for (i = 0; i < n; i++) { int x; scanf( %d , &x); st.insert(x); } int a, b; scanf( %d , &a); scanf( %d , &b); set<int>::iterator it, cit; int ans = 0... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; int p; scanf( %I64d %I64d %d , &n, &k, &p); long long ndiv2 = n / 2; long long ndiv2minus1 = n / 2 - 1; long long nminusk = n - k; for (int i = 0; i < p; i++) { long long x; scanf( %I64d , &x); p... |
#include <bits/stdc++.h> char str1[200], str2[200]; char lenstr1, lenstr2; int dp1[200]; int dp2[200]; int got[200] = {0}; int twice; int twicep; int countc; int calel(int st) { int ite = st; int len = 1; for (int i = 0; i < lenstr2; i++) { int flag = 0; while (str1[st] != str2... |
#include <bits/stdc++.h> using namespace std; int n, a[400 + 2], ans = 1 << 30; int main() { cin >> n; for (register int i = 1; i <= n; i++) cin >> a[i]; for (int i = n; i >= 2; i--) { if (a[i] >= ans) break; for (int j = i; j <= n; j++) { register int num = a[i - 1] - 1, x = 1, t;... |
#include <bits/stdc++.h> using namespace std; int a[101][4]; int main() { int n; cin >> n; int min = 0, ind = 0; for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3]; min = 100000; ind = 0; for (int i = 0; i < n; i++) { bool ust = false; for (int j = ... |
#include <stdio.h> #include <string.h> #include <math.h> #include <limits.h> #include <time.h> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <algorithm> #pragma warning(disable:4996) #pragma warning(disable:6031) #define MAX(X,Y) (X>Y?X:Y) #defin... |
#include <bits/stdc++.h> using namespace std; namespace IO { long long len = 0; char ibuf[(1 << 20) + 1], *iS, *iT, out[(1 << 25) + 1]; inline long long read() { char ch = (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin), (iS == iT ? EOF : *iS++) : *iS++); long long x... |
#include <bits/stdc++.h> using namespace std; int s[10004]; int main() { int k, n1, n2, n3, t1, t2, t3; cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3; for (int i = 0; i < k; i++) { if (i >= n1) { s[i] = max(s[i], s[i - n1] + t1); } if (i >= n2) { s[i] = max(s[i], s[i -... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; n /= 2; if ((x == n || x == n + 1) && (y == n || y == n + 1)) printf( NO ); else printf( YES ); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, k, a[33][33], vis[33]; int dfs(int u, int sum, int lim) { if (sum > lim) return 0; if (u > n) return 1; int ans = dfs(u + 1, sum, lim); for (int v = 1; v <= n && ans < k; v++) if (!vis[v] && a[u][v]) vis[v] = 1, ans += dfs(u + 1... |
#include <bits/stdc++.h> using namespace std; std::vector<long long> v[100009]; long long vis[100009], c = 0; void dfs(long long x) { c++; vis[x] = 1; for (auto i : v[x]) if (!vis[i]) dfs(i); } signed main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long i, n, m, s = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int INF = 0x3f3f3f3f; int n, h, m, k; pair<int, int> arr[maxn]; vector<int> out; int calc(int l, int r, int s) { if (l <= r) { int low = lower_bound(arr + 1, arr + 1 + n, make_pair(l, 0)) - arr; int up = upper_b... |
#include <bits/stdc++.h> using namespace std; int ans[100005], t, n, d; signed main() { cin >> t; while (t--) { scanf( %d , &n); int sum = ans[0] = 1; for (int i = 1; i <= n; ++i) { if (sum + (1 << (i + 1)) > n) { d = i; break; } sum += (1 << i... |
#include <bits/stdc++.h> using namespace std; const int INF = int(1e9); const double EPS = 1e-5; const long long mod = ((long long)1e18) - 131; int n, m, ans = 0; set<string> h; string s; int main() { cin >> s; for (int i = 0; i < s.length(); i++) for (int j = i; j < s.length(); j++) { ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { while (b != 0) { long long c = a % b; a = b; b = c; } return a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } bool C() { long long n, k; cin >> n >> k; lo... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 1e6 + 5; class Tree { public: int son1, son2; int val; int op; bool rev; vector<int> v; } tree[maxn]; int degree[maxn]; queue<int> q; void dfs(int id) { tree[id].rev = 1; if (tree[id... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, N = 1e5 + 10; template <class T> inline bool chkmin(T &A, T B) { return B < A ? A = B, 1 : 0; } template <class T> inline bool chkmax(T &A, T B) { return A < B ? A = B, 1 : 0; } int n, m, A[N], cnt[N], L = 1, R, cur; l... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int getid(string s... |
#include <bits/stdc++.h> using namespace std; const int N = 51; const long long mod = 1e9 + 7; int n, k, n1 = 0, n2 = 0; long long dp[202][N][N][2], C[N][N]; int main() { int x; scanf( %d%d , &n, &k); k /= 50; for (int i = 1; i <= n; i++) { scanf( %d , &x); if (x == 50) n... |
#include <bits/stdc++.h> int main() { int i, j, l, flag; char arr[1000100], arr2[1000100]; gets(arr); l = strlen(arr); for (flag = 0, j = 0, i = 0; i < l - 1; i++) { if (arr[i] == 0 && flag == 0) { flag = 1; continue; } else arr2[j++] = arr[i]; } if (f... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1e9; const long long LINF = INF * (long long)INF + 100; const double EPS = 1e-7; const int MAX = 20 * 1000 + 47; const int MAS = 2 * 1e5 + 10; const int MOD = 998244353; int main() { ios_base::sync_with_std... |
#include <bits/stdc++.h> using namespace std; namespace Flandre_Scarlet { int I() { char c = getchar(); int x = 0; int f = 1; while (c < 0 or c > 9 ) f = (c == - ) ? -1 : 1, c = getchar(); while (c >= 0 and c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return (x ... |
#include <bits/stdc++.h> using namespace std; const int inf(1010101010); int n, k; struct node_t { node_t(char edge, int h) : edge(edge), hier(0), pop(0), h(h) {} char edge; int hier, pop; int h; vector<node_t *> child; }; void ins(node_t *x, char *pos) { x->pop++; if (!pos[0]) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.