func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int ans, t, p, q, i, j, n, m, k, l, r, br1, br0; bool b[36][36]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> t; while (t--) { cin >> n >> m; ans = 0; vector<pair<int, int> > v; for ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; vector<long long> a(n), t(n); vector<pair<long long, long long> > vp; for (int i = 0; i < n; i++) { cin >> a[i]; vp.push_back({a[i], i}); } for (int i = 0; i < n; i++) cin >> t[i]; long lo... |
#include <bits/stdc++.h> using namespace std; map<char, int> m; bool judge(string str) { int count = 0; for (int i = 0; i < 3; i++) { if (str[i] == . ) break; if (str[i] == A && m[ A ] == 0) { m[ A ] = 1; count++; } else if (str[i] == B && m[ B ] == 0) { m[ B... |
#include <bits/stdc++.h> const int MaxN = 1e6 + 255; const long long INF = 1e18 + 7; const int Mod = 1e9 + 7; using namespace std; long long n, a, f[MaxN], ans; int main() { scanf( %lld , &n); for (int i = 1; i <= n; ++i) { scanf( %lld , &a); ++f[a]; } for (int i = 0; i < MaxN; +... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200 * 1000 + 5; pair<long long int, long long int> b[MAXN]; long long int dp[MAXN]; long long int rem[MAXN]; inline pair<long long int, long long int> cst(int x, int y) { long long int tt = ((b[x].first - rem[y] + b[y].second - 1) / b[y].sec... |
#include <bits/stdc++.h> using namespace std; int main() { double ans = 0; long long m, r, i; cin >> m >> r; if (m == 1) { cout << 2 * r; return 0; } for (i = 1; i <= m; i++) { if ((i == 1) || (i == m)) ans += (4 + sqrt(2.) + 2 * (m - 2) * sqrt(2.) + (m - 2) * (m - ... |
#include <bits/stdc++.h> using namespace std; int x[1001], y[1001], a[1001], b[1001]; map<pair<int, int>, int> freq; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; } for (int j = 1; j <= n; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, m, k, a, b; long long x[3], y[3]; for (i = 0; i < 3; i++) cin >> x[i] >> y[i]; cout << 3 << endl; for (i = 0; i < 3; i++) cout << (x[i] + x[(i + 1) % 3]) - x[(i + 2) % 3] << << (y[i] + y[(i + 1) % ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; constexpr auto MOD = 1000000007LL; constexpr auto LINF = (1LL << 60); constexpr auto INF = 2147483647LL; constexpr auto PI = 3.1415926535897932384626433; co... |
#include <bits/stdc++.h> using namespace std; typedef int int2; #define int long long #define pi pair<int, int> #define mp make_pair #define pb push_back #define eb emplace_back #define f first #define s second #define INF 1e18 string printed(int mask) { string res; for (in... |
#include <bits/stdc++.h> using namespace std; int d[1000005]; bool vis[1000005]; vector<pair<int, int> > G[1000005]; void dfs(int u) { for (pair<int, int> x : G[u]) if (!vis[x.first]) { vis[x.first] = 1; dfs(x.second); } } int main() { int n, m; scanf( %d%d , &n, &m... |
#include <bits/stdc++.h> using namespace std; int main() { int i, t, count; long long x, N; scanf( %d n , &t); while (t--) { scanf( %lld n , &N); count = 0; for (i = 1; i < 10; i++) { x = i; while (x <= N) { count++; x *= 10; x += i; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 20; const int Maxmask = (1 << 16); int out[Maxn][Maxn]; bool making[Maxn][Maxmask]; int n; int s; int a[Maxn * Maxn]; int mod; void input() { cin >> n; for (int i = 0; i < n * n; i++) { cin >> a[i]; s += a[i]; } ... |
#include <bits/stdc++.h> const int maxn = 200001, maxf = 19; const long long INF = 0x3f3f3f3f3f3f3f3fLL; int n, q, tot, lnk[maxn], dep[maxn], fa[maxn][maxf]; struct Edge { int v, nxt; } e[maxn << 1]; template <class T> void swap(T& x, T& y) { const T t = x; x = y; y = t; } template <cl... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 1; void solve() { long long n, i = 0, k; cin >> n; long long a[1000], m[1000]; m[0] = 1; a[0] = 1; while (m[i] < n) { a[i + 1] = 2 * a[i]; m[i + 1] = 2 * a[i + 1] - 1; i++; } k = i; if (n ... |
#include <bits/stdc++.h> using namespace std; int aa(int n) { int a = 0; for (int i = 2; i <= n - 1; i++) if (n % i == 0) { a = 1; break; } else a = 0; return a; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { if (aa(i) == 1 && aa(... |
#include <bits/stdc++.h> using namespace std; void blowback() { long long i, j, l, k, n, m, x, y, r, ans = 0, sum = 10e17; string s; long long a, b, c, d; cin >> a >> b >> c >> d; if (a > (b * c)) { cout << -1 n ; return; } k = (2 * a - b * d) / (2 * b * d); l = k + 1; ... |
#include <bits/stdc++.h> using namespace std; const int INF = numeric_limits<int>::max(); const long long LLINF = numeric_limits<long long>::max(); const unsigned long long ULLINF = numeric_limits<unsigned long long>::max(); long long f[1010][1010]; int main() { ios_base::sync_with_stdio(0); cin.tie... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; long long gcd(long long first, long long second) { return !second ? first : gcd(second, first % second); } long long lcm(long long first, long long second) { return (first / ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MODV = 1e9 + 7; int b[1001]; int ans[1005]; vector<pair<int, int> > sorted; vector<pair<int, int> > unsorted; void make_ans(int n) { for (auto it : sorted) { int x = it.first; int y = it.second; for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int n, rec = 0; long long int k; cin >> n >> k; char str[1000005]; cin >> str; for (int h = 0; h < n; h++, rec++) { int pos = h; for (int i = h; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int M = 200005; set<int> nex[M]; int path[M]; int sh[M]; vector<int> edge[M]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int from, to; scanf( %d%d , &from, &to); edge[to].push_back(from); ... |
#include <bits/stdc++.h> using namespace std; int bit[210000], n; void upd(int i) { while (i <= n) bit[i] += 1, i += i & (-i); } void dec(int i) { while (i <= n) bit[i] -= 1, i += i & (-i); } int cal(int i) { int ret = 0; while (i > 0) ret += bit[i], i -= i & (-i); return ret; } in... |
#pragma GCC optimize( O2 ) #include<bits/stdc++.h> #define ll long long //#define int long long #define fi first #define se second #define mpa make_pair #define eb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; mt19937 gen(time(0... |
#include <bits/stdc++.h> const double EPS = 1e-8; using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, vector<T> V) { for (auto v : V) os << v << ; return cout << ; } template <class T> ostream& operator<<(ostream& os, set<T> S) { for (auto s : S) os << s << ; return cout << ; } tem... |
#include <bits/stdc++.h> using namespace std; int t; double pi = acos(-1.0); double d, h, v, e; int main() { scanf( %lf%lf%lf%lf , &d, &h, &v, &e); double r = d / 2; if (pi * r * r * e > v) cout << NO << endl; else { double s = (pi * r * r * h) / (v - pi * r * r * e); cout ... |
#include <bits/stdc++.h> using namespace std; int ans[5001][5001]; int main() { memset((ans), 0, sizeof(ans)); int n, m, l, r; char s[5001]; cin >> n >> m; for (int i = 1; i <= n; i++) { l = r = 0; scanf( %s , s); for (int j = 0; j < m; j++) { if (s[j] == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, fre[11], fre1[11]; string tot, no, cm = , cm1 = ; bool belongs(int x) { int tmp = x, len = 0, i; int tmf[11] = {}; while (tmp > 0) { tmf[(tmp % 10)]++; tmp /= 10; len++; } if (n - len == x) { for (i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long l; typedef pair<int, int> pint; typedef vector<pint> vpint; typedef vector<int> vint; typedef vector<vint> vvint; int n, m, x[123457], cum[1234567]; int ans; map<int, int> mp; int main() { cin >> n; for (int i... |
#include <bits/stdc++.h> using namespace std; int n; struct ma { int x, vt; } a[105]; bool cmp(ma p, ma y) { return p.x < y.x; } int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].x; a[i].vt = i; } sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n / 2; i+... |
#include <bits/stdc++.h> using namespace std; int dp[300005][35], a[300005]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); a[i] /= 100; } for (int i = 0; i <= n; i++) for (int j = 0; j <= 30; j++) dp[i][j] = 1000000000; dp[0][0] =... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; long long arr[t], sum = 0; for (int i = 0; i < t; ++i) { cin >> arr[i]; sum += arr[i]; } if (sum != 0) { cout << YES << endl; cout << 1 << endl; cout << 1 << << t << endl; ... |
#include <bits/stdc++.h> using namespace std; long long global = 0; void test_case(long long); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; int yes = 1; if (yes) cin >> t; else t = 1; for (long long T = 0; T < t; T++) { test_case(T); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1004; int cnk[N][N] = {0}; int mod = 1000000007; void init_cnk() { for (int i = 0; i < N; ++i) { cnk[i][0] = 1; cnk[i][i] = 1; } for (int i = 1; i < N; ++i) { for (int j = 1; j < N; ++j) { cnk[i][j] = (cnk[i - 1]... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 300 * 1000 + 7; const long long MOD = 1000 * 1000 * 1000 + 7; const long long INF = 1000000000000000 + 7; const double PI = 2 * acos(0.0); long long a, b, c; int main(void) { cin >> a >> b >> c; if (a > b || a > c) cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int arr[15]; for (int i = 1; i <= 14; i++) cin >> arr[i]; long long int brr[15]; long long int ans = -1; for (int i = 1; i <= 14; i++) { if (arr[i] == 0) continue; for (int j = 1; j <= 14; j++) brr[j] = arr[j]; ... |
#include <bits/stdc++.h> using namespace std; long long n, k; void search(int cur) { int tot, c[10]; int ok; if (cur == n) tot++; else for (int i = 0; i < n; i++) { ok = 1; c[cur] = i; } for (int j = 0; j < cur; j++) { if (c[cur] == c[j] || cur - c[cur] ... |
#include <bits/stdc++.h> using namespace std; int maxn = 1000000000; int main(int argc, char const *argv[]) { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (a > b) a = a + b, b = a - b, a = a - b; int side = max(2 * a, b); cout << side * side << endl; } ... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int q; cin >> q; while (q--) { int a, b, n, S; cin >> a >> b >> n >> S; int x = min(a, S / n); cout << (S - x * n <= b ? YES : NO ) << n ; } ... |
#include <bits/stdc++.h> using namespace std; int c[400000], t[400000], n, m, x[400000]; int main() { scanf( %d%d , &n, &m); int s = 0; for (int i = 0; i < n; ++i) { scanf( %d%d , &c[i], &t[i]); s += c[i] * t[i]; x[i] = s; } while (m--) { int a; scanf( %d , &a); ... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1000000000000; const double eps = (double)1e-8; const int mod = (int)1000000007; const int maxn = (int)1e6 + 5; int n, res, cnt, z[maxn]; pair<pair<int, int>, pair<int, int> > a[maxn]; vector<int> t[maxn]; vector<pair<int, ... |
#include <bits/stdc++.h> const int Mod = 1001943197; const int Base = 34300; const int MN = 100005, MQ = 100005, S = 500, MS = S + 5; char s[MN], t[MN]; int N, lt, Lim, per[MN]; int pBase[MN]; int Hs[MN], Ht[MN]; inline int Hmerge(int h1, int h2, int l2) { return (int)(((long long)h1 * pBase[l2] + h... |
#include <bits/stdc++.h> using namespace std; char s[100004]; long long k, mod = 1000000007; long long qpow(long long n, long long m) { long long ans = 1; for (; m; m >>= 1) { if (m & 1) ans = ans * n % mod; n = n * n % mod; } return ans; } int main() { scanf( %s %lld , s, &k... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v(6); for (int i = 0; i < 6; ++i) cin >> v[i]; int n; cin >> n; vector<pair<int, int>> a; int num; for (int i = 0; i < n; ++i) { cin >> num; for (int j = 0; j < 6; ++j) { a.push_back({num - v[j], i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; char c; unsigned int mask; int u; vector<unsigned int> ip; set<unsigned int> net; cin >> n >> k; scanf( %c , &c); unsigned int x, x1; for (int i = 0; i < n; i++) { c = 0; x = 0; x1 = 0; ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int t; long long sufa[100010]; long long a[100010]; pair<long long, long long> ab[100010]; long long n, m; int main() { cin >> t; while (t--) { scanf( %lld %lld , &n, &m); for (long long i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> long long mpow(long long a, long long n, long long mod) { long long ret = 1; long long b = a; while (n) { if (n & 1) ret = (ret * b) % mod; b = (b * b) % mod; n >>= 1; } return (long long)ret; } using namespace std; int a[100000 + 5]; map<int, int... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops ) using namespace std; mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 3; int ok[N], tsz[N], dep[N]; vector<int> adj[N], g[N]; multiset<int> mset[N]; int vis[N]; bool flag; void dfs2(... |
#include <bits/stdc++.h> using namespace std; int main() { int vp, vd, t, f, c; cin >> vp >> vd >> t >> f >> c; int vs = vd - vp; if (vp > vd) { cout << 0; return 0; } if (vp == vd) { cout << 0; return 0; } double d = vp * t; d += d / (1.0 * vs) * vp; ... |
#include <bits/stdc++.h> using namespace std; long long n, k, k1, k2, m; int main() { cin >> n >> k; m = n; while (m % 2 == 0) { k1++; m /= 2; } while (m % 5 == 0) { k2++; m /= 5; } for (int i = 1; i <= max(0ll, k - k1); ++i) { n *= 2; } for (int i... |
#include <bits/stdc++.h> using namespace std; int n, m, aa[300005], bb[300005], v[1000005], q; int x[4000005], y[4000005], dx; void build(int l, int r, int i) { if (l + 1 == r) { y[i] = v[l]; return; } int mi = (l + r) / 2; build(l, mi, i * 2); build(mi, r, i * 2 + 1); y[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, maxi, mini; cin >> n; int z[n], o = 0; for (i = 0; i < n; i++) { cin >> z[i]; if (i == 0) { maxi = z[i]; mini = z[i]; } if (i > 0) { if (z[i] > maxi) { o++; maxi =... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int INF = 1e9; const long long LINF = 1LL * INF * INF; const int MAXN = 100007; const double EPS = 1e-7; int A[MAXN]; int main() { ios_base::sync_with_stdio(0); int n, m; cin >> n >> m; if (n == 1 && m ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 5; int n, k, a; int vis_time[MAX], vis_cnt[MAX], ans; struct data { int size, op; bool operator<(data b) const { if (size == b.size) return op > b.op; else return size < b.size; } }; priority_queue<... |
#include <bits/stdc++.h> using namespace std; long long dp[100000 + 25]; struct node { int iz, der; long long tiempo; node() {} node(long long t, int i, int d) { tiempo = t; iz = i; der = d; } }; struct otro { int proct, pos; long long tiemp; otro() {} otr... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int a, b, n, s; cin >> a >> b >> n >> s; if (s - n * min(a, s / n) <= b) cout << YES n ; else cout << NO n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, cnt, ans; int a[410][410], c[160010]; int now, f[2][410][410]; void Init() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) scanf( %d , &a[i][j]); } inline void insert(int x) { if (c[x]) ++cnt; ... |
#include <bits/stdc++.h> using namespace std; const int N = 61; int a[N], n; long long dp[N][2][2], k; long long Dfs(int pos, int x, int y) { if (pos < n - pos + 1) return 1; if (dp[pos][x][y] != -1) return dp[pos][x][y]; long long ans = 0; for (int i = 0; i < 2; i++) if (a[pos] == -1 ||... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; string s1, s2; cin >> n >> s1 >> s2; if (s2 == week ) { if (n == 5 || n == 6) { cout << 53 << endl; } else { cout << 52 << endl; } } else { if (n <= 29) { cout << 12 << ... |
#include <bits/stdc++.h> using namespace std; const int N = 200002; long long sum, ans, nd, T; priority_queue<long long> q; int n, k, b, c, t[N], i, j; int main() { scanf( %d%d%d%d , &n, &k, &b, &c), ans = 1e18; b = min(b, c * 5); for (i = 1; i <= n; i++) scanf( %d , &t[i]); sort(t + 1, t + ... |
#include <bits/stdc++.h> using namespace std; int main() { long long q = 0; vector<long long> a; a.push_back(0); for (long long i = 0; i < 4; i++) { long long te; cin >> te; a.push_back(te); } string s; cin >> s; for (long long i = 0; i < s.size(); i++) { q +=... |
#include <bits/stdc++.h> using namespace std; typedef int64_t g; g n,p[269420],v=1e9+7,T,r,i,k,s; map<g,g> l; int main(){ cin>>T; while(T--){ cin>>n; l.clear(); for(i=0,s=0,p[0]=1,l[0]=1;++i<=n;){ cin>>k; p[i]=(p[i-1]*2+v-p[l[s]-1])%v; l[s]=i; s+=k; }cout<<p[n]<<endl; } } |
#include <bits/stdc++.h> using namespace std; int n, m, p, dp[2][110][110][110], ans; const int mod = 1e9 + 7; int main() { scanf( %d%d%d , &n, &m, &p); for (int i = 1; i <= n; i++) dp[0][i][i][1] = 1; for (int i = 0; i < m - 1; i++) { memset(dp[!(i & 1)], 0, sizeof(dp[!(i & 1)])); for (... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int n_ = 1e5 + 1000; const long double PI = acos(-1.0); long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); } long long power(long long a, long long n) { long long p = 1; while (n > 0... |
#include <bits/stdc++.h> using namespace std; int main() { double d, h, v, e; cin >> d >> h >> v >> e; d /= 2; double vol = d * d * acos(-1) * h; double incre = e * d * d * acos(-1); if (incre >= v) { cout << NO ; return 0; } double ans = vol / (v - incre); if (ans >... |
#include <bits/stdc++.h> using namespace std; int main() { long long n = 0, m = 0; cin >> n >> m; for (long long i = 0; i < n; i++) { for (long long j = 0; j < m; j++) { if (i % 2 == 0) cout << # ; else if ((j == m - 1 && (i - 1) % 4 == 0) || (j == 0 && (i + 1) % 4 == 0)... |
#include <bits/stdc++.h> using namespace std; int co; bool query(int x, int y) { assert(++co <= 60); printf( 1 %d %d n , x, y); fflush(stdout); char st[5]; scanf( %s , st); return st[0] == N ; } int main() { int fst, scnd, n, k; scanf( %d %d , &n, &k); int l = 1, r = n; ... |
#include <bits/stdc++.h> using namespace std; const int dim = 52; char a[dim][dim]; int s[dim][dim]; int dp[dim][dim][dim][dim]; void compute(int i1, int j1, int i2, int j2) { if (dp[i1][j1][i2][j2] != 0x3f3f3f3f) return; int ans = max(i2 - i1 + 1, j2 - j1 + 1); if (s[i2][j2] - s[i1 - 1][j2] - s... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); vector<int> arrNums; int iTemp, nNeed, nNum, i; long long iSum = 0; cin >> nNum >> nNeed; while (nNum--) { cin >> iTemp; arrNums.push_back(iTemp); } sort(arrNums.begin(), arrNums.end()... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; const int INF = 1e9 + 7; int xx[8] = {1, 1, 1, 0, -1, -1, -1, 0}, yy[8] = {1, 0, -1, -1, -1, 0, 1, 1}; int n, m, hd = 0, ti = 0; vector<int> a[N], p[N], dis[N]; char s[N]; int Qux[N * 5], Quy[N * 5]; void bfs() { while (hd != ti)... |
#include <bits/stdc++.h> using namespace std; int n, Bef[201000]; long long w[201000]; map<pair<int, int>, int> Map[201000]; struct Tree { int K[262144 + 262144], T[262144 + 262144]; void init() { for (int i = 0; i < 262144 + 262144; i++) K[i] = -1; } void Put2(int nd, int x) { K[nd] = T... |
#include <bits/stdc++.h> using namespace std; const int N = 10010, M = 15010, inf = 1e9; struct st1 { int to, next, c; } e[M << 1]; struct st2 { int to, next, f, op; } F[1000001]; int n, m, x, y, z, cnt, cnt2, ans, i, col, cyc, S, T, fi[N], c[N], l[N], op[M << 1], d[N + M], f2[N + M], dep[N ... |
#include <bits/stdc++.h> using namespace std; int N, M, M2, B; const int MAXN = 100015; const int MAXM = 20; const int MAXM2 = (1 << 20); char S[MAXN]; int bitc[MAXM2]; int bitl[MAXM2]; int dp[MAXM2]; int cnt[MAXM][MAXM]; int mcnt[MAXM2][MAXM]; int last; int main() { cin >> N >> M >> S; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int a[10005]; int num[10005]; int main() { int n; scanf( %d , &n); int mm = 0; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); num[a[i]]++; mm = max(mm, a[i]); } int nn = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; namespace fastIO { bool IOerror = 0; inline char nc() { static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000; if (p1 == pend) { p1 = buf; pend = buf + fread(buf, 1, 100000, stdin); if (pend == p1) { IOerror = 1; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int m, k; scanf( %d %d , &m, &k); vector<int> a(k, 0); vector<int> t(m - 1), r(m - 1, 0); vector<int> last(k, 0); for (int i = 0; i < k; ++i) { scanf( %d , &a[i]); } int free_num = 0; for (int i = 0; i + 1 < m; ++... |
#include <bits/stdc++.h> using namespace std; struct om_nom { int t; int h; int m; } a[2005]; int n, x; bool eaten[2005]; bool have_candy(int type) { int flag = false; for (int i = 0; i < n; ++i) if (a[i].t == (bool)type && !eaten[i]) { flag = true; break; } ... |
#include <bits/stdc++.h> inline int read() { int f = 1, x = 0; char ch = getchar(); while (!(ch >= 0 && ch <= 9 )) { if (ch == - ) f *= -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return f * x; } int dx[8] ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4 ) using namespace std; const int inf = (int)2e9 + 99999, mod = (int)1e9 + 7; const long long linf = (long long)2e18 + 99999; int kob(int x, int y) { return ((long... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int SQRTN = 320; const int LOGN = 20; const double PI = acos(-1); int n, val; map<int, int> dp; int dp2[N]; int range[N]; bool en[N]; int grundy(long long n) { if (n < 1e6) return dp2[n]; if (dp.find(n) != dp.end()... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, s, c[10000]; cin >> n >> a >> b; for (int i = 1; i <= n; i++) { cin >> c[i]; } s = 0; for (int i = 1; i <= n / 2; i++) { if (c[i] != 2 && c[n - i + 1] != 2 && c[i] != c[n - i + 1]) { cout << -1 << end... |
#include <bits/stdc++.h> using namespace std; long long cross2(long long x1, long long y1, long long x2, long long y2) { return x1 * y2 - x2 * y1; } long long cross(long long i, long long j, long long k, const long long* xx, const long long* yy) { return cross2(xx[j] - xx[i], yy[j] - y... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; bitset<N> b; int p[N]; int cnt[N]; bool was[N]; int main() { int n, k; scanf( %d %d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , p + i); p[i]--; was[i] = false; } for (int i = 1; i <= n; i++)... |
#include <bits/stdc++.h> using namespace std; int n, m, h; int bb[109][109][109]; int a[109], b[109], c[109][109]; int main() { scanf( %d%d%d , &n, &m, &h); for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= h; k++) { bb[i][j][k] = 1; } ... |
#include <bits/stdc++.h> using namespace std; long long a[100001], first, space, op = 1, last; int main() { long long k, n, page; cin >> k >> n >> page; for (int i = 1; i <= n; i++) { cin >> a[i]; } if (n == 0) { cout << 0; return 0; } first = (a[1] - space) / page; ... |
#include <bits/stdc++.h> using namespace std; const int md = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tt{}, T{}; tt = 1; while (tt--) { int n{}, m{}, ans{}, k{}, a{}, b{}, c{}, f{}; cin >> n; if (n == 1) { cout << 1 n ; re... |
#include <bits/stdc++.h> int n; char a[1000005], b[1000005], dic[130]; int main() { dic[ W ] = E ; dic[ E ] = W ; dic[ N ] = S ; dic[ S ] = N ; scanf( %d%s%s , &n, a, b); unsigned int ha = 0, hb = 0, rol = 1, mul = 233; for (int i = n - 2; i >= 0; i--) { if ((ha = a[i] * rol ... |
#include <bits/stdc++.h> using namespace std; using T = int; struct Edge { int from, to; T cost, flow, cap; Edge(int _from = 0, int _to = 0, T _cost = 0, T _cap = 0) : from(_from), to(_to), cost(_cost), flow(0), cap(_cap) {} }; const int N = 7010; const int INF = 0x3f3f3f3f; int n; v... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 200100; const long long INF = 2000000100; const long long MOD = 998244353; long long N, S[MAXN], P[MAXN]; long long B[MAXN]; void update(int ind, long long v) { for (int i = ind; i <= N; i += (i & -i)) { B[i] += v; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> b >> a; a--; b -= a; if (b >= 0 && b % 2 == 0 && a > 0) { cout << Yes << endl; } else if (b == 0 && a == 0) cout << Yes << endl; else cout << No << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793238463; int a[100009], p[200009]; int main() { cin.tie(0); cin.sync_with_stdio(0); int h; cin >> h; for (int i = (0); i <= (h); i++) cin >> a[i]; bool perfect = true; for (int i = 0; i < (h); i++) ... |
#include <bits/stdc++.h> using namespace std; int f(char c1, char c2) { if (c1 == R && c2 == S ) return 1; if (c1 == S && c2 == P ) return 1; if (c1 == P && c2 == R ) return 1; if (c2 == R && c1 == S ) return -1; if (c2 == S && c1 == P ) return -1; if (c2 == P && c1 == R ) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; const int M = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<int> pre(n, 1); for (int i = 1; i... |
#include <bits/stdc++.h> using namespace std; int main() { float a, b, c, d; float mpts; float vpts; cin >> a >> b >> c >> d; mpts = max((3 * a) / 10, a - ((a / 250) * c)); vpts = max((3 * b) / 10, b - ((b / 250) * d)); if (mpts == vpts) { cout << Tie n ; return 0; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 10; const int oo = 1e9; vector<int> g[N], gt[N]; vector<pair<int, int> > b[N], bt[N]; int cost[N][N]; void bfs(int u, int n, vector<int> adj[], vector<pair<int, int> > &b, bool q) { queue<int> Q; vector<int> d(n + 1, oo); d[u] =... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 3; i * i <= n; i = i + 2) { if (n % i == 0) return false; } return true; } int main() { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; cout << (b * d * f > a * c * e || c == 0 && d > 0 || a == 0 && b > 0 && d > 0 ? Ron : Hermione ) << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int m, n, z, n1, m1; int a[10000], b[10000]; int g, j, k, p = 0; int count = 0; cin >> n >> m >> z; n1 = n; m1 = m; if (z <= 10000 && z > 0 && n >= 1 && m >= 1) { while (n <= z || m <= z) { a[j] = n; n =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int n; cin >> n; int a[n]; int ans = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; ans += a[i]; } sum = ans; sort(a, a + n); for (int j =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.