func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; struct point { int x, y; point() {} point(int _x, int _y) : x(_x), y(_y) {} point operator-(const point& other) const { return point(other.x - x, other.y - y); } long long operator/(const point& other) const { return x * 1LL * other.y... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; long long mod1 = 1000000000000000009; long long poww(long long x, long long y) { if (y == 0) return 1; if (x == 1) return 1; if (x == 0) return 0; if (y == 1) return x; long long d = poww(x, y / 2); d %= mod; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0), cin.tie(0); int tt; cin >> tt; while (tt--) { string s; cin >> s; int count = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 1 ) { count++; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print(T a) { for (auto x : a) cout << x << ; cout << n ; } vector<pair<long double, long double> > lines1; vector<long double> dots1; long double intersection(pair<long double, long double> l1, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<long long> f(n); int u, v; long long z; while (m--) { cin >> u >> v >> z; f[--u] -= z; f[--v] += z; } vector<long long> a, b; for (int i = 0; i < n; i++) if (f[i] > ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int mod = 1e9 + 7; int n, m, T, k; int f[80][80][80][80], g[80][80]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 100; const int D = 19; struct QUE { int l, r, len, id; QUE(int _l, int _r, int _len, int _id) { l = _l; r = _r; len = _len; id = _id; } }; struct OPT { int x, y; OPT(int _x, int _y) { x = _x; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; long n, i, k = 0, u = 0, d = 0, l = 0, r = 0; cin >> n; cin >> s; for (i = 0; i < s.size(); i++) { if (s[i] == U ) u++; if (s[i] == D ) d++; if (s[i] == L ) l++; if (s[i] == R ) r++; } k += m... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& a) { in >> a.first >> a.second; return in; } template <typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> a) { out << a.first << << a.second;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool isPrime(long long n) { if (n < 2) return 0; if (n < 4) return 1; if (n % 2 == 0 or n % 3 == 0) return 0; for (long long i = 5; i * i <= n; i += 6) ... |
#include <bits/stdc++.h> using namespace std; string a[200009]; int pre[1 << 20][22], cost[200009], n, m, dp[200009]; int compute(string suf, string pre) { for (int k = int(0); k <= int(m - 1); k++) { int j = k, i = 0; while (j < m) { if (suf[j] == pre[i]) { j++; i++;... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; for (int i = 0; i < a.size(); i++) { a[i] = tolower(a[i]); b[i] = tolower(b[i]); } if (a.compare(b) == 0) cout << 0 << n ; else { for (int i = 0; i < a.size(); i++) {... |
#include <bits/stdc++.h> inline int sbt(int x) { return __builtin_popcount(x); } using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Arg... |
#include <bits/stdc++.h> const int INFI = (1 << 29); const long long INFL = (1LL << 62); using namespace std; long long f[1000010]; void solve() { long long n, k, d, c = 0, r = INFL; cin >> n >> k >> d; vector<long long> v(n); for (long long i = 0; i < n; i++) cin >> v[i]; for (long long i... |
#include <bits/stdc++.h> using namespace std; long long int mod; long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b % 2 == 1) return (power(a, b - 1) * a) % mod; long long int q = power(a, b / 2); return (q * q) % mod; } int32_t main() { ios_base::sync_with... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int i = 2; i < s.size(); i++) { int a = 0, b = 0, c = 0; for (int j = i; j >= i - 2; j--) { if (s[j] == A ) a++; if (s[j] == B ) b++; if (s[j] == C ) c++; } if (a > 0 &&... |
#include <bits/stdc++.h> class point2D { public: long long x, y; point2D() {} point2D(long long x, long long y) : x(x), y(y) {} bool operator<(const point2D &other) const { return ((y == other.y) ? (x > other.x) : (y > other.y)); } }; point2D operator-(const point2D &u, const point2D ... |
#include <bits/stdc++.h> using std::pair; using std::vector; vector<int64_t> ReadInput(std::istream& in_stream = std::cin); void WriteAnswer(size_t min, size_t max, std::ostream& out_stream = std::cout); pair<size_t, size_t> GetRange(const vector<int64_t>& input); int main() { std::ios_base::sync_with_s... |
#include <bits/stdc++.h> using namespace std; int n; int g[30][30]; char s[20]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %s , s); int len = strlen(s); for (int j = 0; j < len; j++) s[j] -= a ; for (int j = 0; j < 26; j++) { if (g[j][s[0]] || j... |
#include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <string> #include <algorithm> #include <cmath> #define LL long long using namespace std; LL T; LL n, arr[300000], cnt[300000], dp[300000]; int main (){ cin >> T; while (T--){ scanf( %lld , &n... |
#include <bits/stdc++.h> using namespace std; int main() { int t; set<string> st; string s; cin >> t; getchar(); while (t--) { getline(cin, s); st.insert(s); } cout << st.size() << endl; } |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 100; int ans[N], link[N]; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; ++i) { int x; cin >> x; int down = max(1, i - k); int up = min(n, i + k... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int ans = 0; string s; cin >> s; if (s.size() % 2 == 0) { for (int j = 0; j < s.size() / 2; j++) { if (s[j] != s[s.size() / 2 + j]) { ans = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, q, a[200010]; struct node { int l, r, color; node(int ll = 0, int rr = 0, int cc = 0) : l(ll), r(rr), color(cc) {} }; node p[200010]; vector<int> vec[200010]; bool cmp(node a, node b) { if (a.l != b.l) return a.l < b.l; return a.r > b.r;... |
#include <bits/stdc++.h> using namespace std; pair<int, int> stations[200001]; int nxt[200001]; int main() { int d, n, m; scanf( %d%d%d , &d, &n, &m); for (int i = 0; i < m; i++) { scanf( %d%d , &stations[i].first, &stations[i].second); } sort(stations, stations + m); stack<int> s;... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int tree[N << 2], Max[N << 2], Min[N << 2], cnt; bool fu[N << 2]; pair<int, int> a[N]; void build(int l, int r, int rt) { if (l == r) { tree[rt] = a[l].first; Max[rt] = Min[rt] = tree[rt]; return; } int m = (l... |
#include <bits/stdc++.h> using namespace std; const int MX = 1212; int num, n, x, i, j, cur, t, s[MX], a[MX][3], r[MX], mx[MX], mxs[MX]; priority_queue<pair<int, int>> q[2]; vector<int> v[MX]; bool u[MX]; int main() { scanf( %d , &n); for (i = 0; i < 3 * n; i++) { scanf( %d , &x); u[x]... |
#include <bits/stdc++.h> using namespace std; int a[405][405]; int q[405 * 405], d[405], t, h, ans; bool vis[405]; int main() { int n, m; scanf( %d %d , &n, &m); while (m--) { int u, v; scanf( %d %d , &u, &v); a[u][v] = a[v][u] = 1; } t = h = 0; q[h++] = 1; vis[1]... |
#include <bits/stdc++.h> using namespace std; long long t, n; char str[200005]; void solve() { long long i, b = 0, c, s = 1, min = 0; char a; a = str[0]; str[n] = str[0]; for (i = 1; i < n; ++i) { if (str[i] != a) { b = i; break; } else { s++; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { scanf( %d%d , &n, &m); if (n == 1 && m == 1) { puts( YES n1 ); return 0; } if ((n == 1 && m <= 3) || (m == 1 && n <= 3) || (n == 2 && m <= 3) || (m == 2 && n <= 3)) { puts( NO ); return 0; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 0; int l, r, n, m, x; cin >> n >> x; int sum; int temp = 0; for (int i = 1; i <= n; i++) { cin >> l >> r; sum = 0; while (1) { t = t + x; if (t >= l) { t = (t - x); sum = ... |
#include <bits/stdc++.h> int main() { int n, k, l, c, d, p, nl, np, a, b, r; scanf( %d %d %d %d %d %d %d %d , &n, &k, &l, &c, &d, &p, &nl, &np); a = (k * l) / (n * nl); b = c * d / n; r = p / (n * np); int x; if ((a < 1) || (b < 1) || (r < 1)) x = 0; else { x = (a < b) ? ((... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } int arr[100009], n, s[100009 << 2]; ... |
#include <bits/stdc++.h> int main(void) { int a[101]; int b, c, d, i, j, count = 0, num, number; scanf( %d %d , &b, &c); for (i = 0; i < b; i++) { scanf( %d , &a[i]); } for (i = 0; i < b - 1; i++) { for (j = i + 1; j < b; j++) { if (a[i] > a[j]) { d = a[i]; ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int a[(int)(1e6 + 10)], b[(int)(1e6 + 10)]; int c[(int)(1e6 + 10)]; int p[(int)(1e6 + 10)]; int rk[(int)(1e6 + 10)]; bool color[(int)(1e6 + 10)]; int find(int x) { return p[x] == x ? x : find(p[x]); } void init() { for (int i = 1; i <= 1e6... |
#include <bits/stdc++.h> const double EPS = 1e-9; using namespace std; template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; } template <class T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; } inline int nxt() { int wow; scanf... |
#include <bits/stdc++.h> int main() { int n, i, x, k, j = 0; scanf( %d%d , &n, &k); for (i = 0; i < n; i++) { for (x = 0; x < n; x++) { if (i == j && x == j) { printf( %d , k); } else printf( 0 ); } j++; printf( n ); } } |
#include <bits/stdc++.h> using namespace std; int n, a[200011], c[200011], isc[200011], cn, pow2[200011] = {1}, seen[200011]; int main() { int ans = 1, mod = 1e9 + 7; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , a + i); pow2[i] = pow2[i - 1] * 2LL % mod; } for (int i... |
#include <bits/stdc++.h> using namespace std; vector<int> teams(200000); int main() { ios_base::sync_with_stdio(false); int N; cin >> N; for (int i = 0; i < N; i++) cin >> teams[i]; for (int i = 0; i < N; i++) { if (teams[i] == 0) { continue; } if (teams[i] >= 2) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p = n + 1; int cnt = 0; cout << ((n + 1) * 3) + 1 << endl; for (int i = 0; i < p; i++) { cout << i << << i << endl; cout << i + 1 << << i << endl; cout << i << << i + 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, s, i, j; cin >> n >> m >> s; long long ans = 0; for (i = 1; i <= n; i += 2) { for (j = 1; j <= m; j += 2) { long long cnt = (n - i + 1) * (m - j + 1); long long tmp = 0; if (i * j == s) { tmp... |
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {... |
#include <bits/stdc++.h> using namespace std; int n, m, tot, res = 0, f[666666], g[666666], q[666666], ans[666666][3]; struct edge { int adj, nex; bool vis; edge(int a_ = 0, int n_ = 0) { adj = a_; nex = n_; vis = false; } } e[666666]; void add(int u, int v) { e[++tot] = ... |
#include <bits/stdc++.h> using namespace std; struct element { char c; int h = 3; }; int n, m; element a[200]; int main() { cin >> n >> a[0].c; for (int i = 1; i < n; ++i) { cin >> a[i].c; if (a[i - 1].c == [ ) { if (a[i].c == [ ) { if (a[i - 1].h == 3) ... |
#include <bits/stdc++.h> using namespace std; const int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; struct date { int arr[3]; void read() { string s; cin >> s; for (int i = 0; i < 3; i++) { arr[i] = (s[i * 3] - 0 ) * 10 + (s[i * 3 + 1] - 0 ); } } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { int result = 0; int a[105]; int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] - result - i > 0) { ... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> v; vector<tuple<int, int, int> > g[300002]; vector<pair<int, long long int> > vv[300002]; vector<pair<long long int, long long int> > V[300002]; long long int dist[300002]; priority_queue<pair<long long int, int>, vector<pair<long long int... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 1; const double pi = acos(-1); int dp[1001][2002][4]; int MOD = 998244353; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.precision(20); int n, k; cin >> n >> k; dp[0][0][0] = 1; dp[0][0][1] = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int h1, m1, h2, m2; scanf( %d:%d %d:%d , &h1, &m1, &h2, &m2); if (m1 < m2) m1 += 60, h2++; if (h1 < h2) h1 += 24; printf( %.2d:%.2d n , h1 - h2, m1 - m2); return 0; } |
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } long long power(long long x, long long y) { long long res = 1; x = x; if (x == 0) return 0; while (y > 0) { if (... |
#include <bits/stdc++.h> using namespace std; vector<long long> primes; bool vis[20000000]; vector<long long> a, b; long long v[20000000]; void genp() { for (long long i = 2; i < 20000000; i++) { if (!vis[i]) { primes.push_back(i); for (long long j = 1; j * i < 20000000; j++) vis[j... |
#include <bits/stdc++.h> using namespace std; const int oo = int(2e9) + 9; const double eps = 1e-9; const double pi = 3.14159265358979323846264338327950; int main() { int p, n; int a[305]; scanf( %d %d , &p, &n); memset(a, -1, sizeof(a)); for (int i = 1; i <= n; i++) { int x; s... |
#include <bits/stdc++.h> using namespace std; int n, m; char a[55][55]; int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1}; vector<pair<int, int> > G[2555]; int vis[2555]; int bfs(int i, int j) { memset(vis, -1, sizeof vis); deque<pair<int, int> > q; q.push_front(make_pair(i * m + j, 0)); in... |
#include <bits/stdc++.h> using namespace std; long long cnt[3], dp[1010][4], n, p; struct seg { long long l, r, v; seg() {} seg(long long _l, long long _r, long long _v) { l = _l, r = _r, v = _v; } }; vector<seg> v; long long cal(long long x, long long y) { if (v[x].v != 0 && v[y].v != 0) re... |
#include <bits/stdc++.h> using namespace std; struct str { long long cnt[26], len = 0; pair<long long, long long> pref = {0, 0}, suf = {0, 0}; str() { memset(cnt, 0, sizeof(cnt)); } str(string s) { memset(cnt, 0, sizeof(cnt)); len = ((int)s.size()); pair<long long, long long> mx = ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; const int inf = 0x7FFFFFFF; template <class T> inline void checkmin(T &a, T b) { if (b < a) a = b; } template <class T> inline void checkmax(T &a, T b) { if (b > a) a = b; } template <clas... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int a[N], ret[N]; pair<pair<int, int>, int> qi[N]; int pen[N]; void update(int ind, int add) { while (ind < N) { pen[ind] += add; ind += ind & (-ind); } } int query(int ind) { int ret = 0; while (ind > 0) { ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; int n, m; long long t[MAX << 2], tag[MAX << 2]; int sz = 1; inline void Period(int k, int l, int r, int a, int b, long long x) { if (a > r || b < l) return; if (a >= l && b <= r) { tag[k] = t[k] = x; return; } ... |
#include <bits/stdc++.h> int n, m; char a[10000]; char b[10000]; int main() { scanf( %s %s , a, b); n = strlen(a); m = strlen(b); int minn = 10000000; for (int i = -m + 1; i < n; i++) { int count = 0; for (int j = 0; j < m; j++) { if (i + j < 0 || i + j >= n) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000000; long long mod = 1000000007LL; long long mod2 = 998244353LL; int t, n; int a[200005]; int dp[200005][2]; int main() { cin >> t; for (int cas = 1; cas <= t; ++cas) { scanf( %d , &n); for (int i = 1; i <= n; ++i) ... |
#include <bits/stdc++.h> using namespace std; mt19937 gen(time(NULL)); const long double eps = 1e-9; const int inf = 1e9; const int mod = 1e9 + 7; const long long infinity = 2 * 1e18; vector<int> g[100005]; int n, m, q; int p2[100005], d[100005], cmp[100005]; int rt[100005]; vector<int> plen[10000... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int inf = 2147483647; const long double pi = acos(-1); inline unsigned long long read() { unsigned long long data = 0, w = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, max_len = 0, tmpl, tmpr; pair<int, int> fmaxl, fminr, smaxl(-1, -1), sminr(-1, -1); cin >> n >> tmpl >> tmpr; fmaxl = make_pair(tmpl, tmpr); fminr = make_pair(tmpl, tmpr); for (int i = 1; i < n; i++) { cin >> tmpl >>... |
#include <bits/stdc++.h> using namespace std; int a[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i, j, k, l, m, n, t, r, cnt; int flag = 0; long long ans = 0, an = 0; t = 1; while (t--) { cin >> n >> m; cout << min(n, m) + 1 << e... |
#include <bits/stdc++.h> using namespace std; int main() { int n, diff = 0; bool flag = 1; scanf( %d , &n); int a[n]; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (i == 1) diff = a[i] - a[i - 1]; } for (int i = 1; i < n; i++) { if (a[i] - a[i - 1] != diff) { ... |
#include <bits/stdc++.h> using namespace std; inline long long sqr(long long x) { return x * x; } mt19937 Random((int)time(0)); inline long long rnd(long long x) { return Random() % x; } const long long INF = (long long)1e9 + 2018; const long long MOD = (long long)1e9 + 7; const long double PI = acos(-1.0... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 7; int T, n, vis[N], can[N]; map<char, int> mp, ha = {{ ? , 0}, { V , 1}, { K , 2}}; char s[N]; bool check(int l) { static int vis[N]; for (int i = 0; i < l; ++i) { int who = ha[s[i]], now = i + l; while (now < n) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s... |
#include <bits/stdc++.h> using namespace std; int n, m, res; int mat[405][405]; int cnt[405][405][4]; bool valid(int x1, int y1, int x2, int y2) { int num = 2; if (x1 == x2) num = 1; if (y1 == y2) num = 0; if (x1 + y1 == x2 + y2) num = 3; return cnt[x1][y1][num] == cnt[x2][y2][num]; } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool upmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <typename T> inline bool upmax(T &x, T y) { return x < y ? x = y, 1 : 0; } const long double eps = 1e-11; const long double pi = acos(-1); const int oo =... |
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; int t; int dp[52][1005][1005]; int dp2[52][1005]; int c[1501][60]; long long f[100]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; dp[0][0][1] = 1; f[0] = 1; for (l... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1]; int i, m, k, l, x, y; for (i = 1; i <= n; i++) cin >> a[i]; cin >> m; for (i = 0; i < m; i++) { cin >> x >> y; a[x - 1] += y - 1; a[x + 1] += (a[x] - y); a[x] = 0; } ... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long t; cin >> t; while (t--) { long long n, m, x, y; cin >> n >> m >> x >> y; if (2 * x < y) y = 2 * x; vector<vector<long long>> gr... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int jou[n + 1]; vector<bool> u(n + 1, false); int k = 1; for (int i = 1; i < n + 1; i++) { cin >> jou[i]; if (u[jou[i]] == false) { u[jou[i]] = true; ... |
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm( rdtsc : =A (tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } const int INF = (int)1.01e9; const long double EPS = 1e-9; void... |
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int n, inv; long long m; long long A[30]; inline int Qpow(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = (long long)ans * a % Mod; b >>= 1; a = (long long)a * a % Mod; } return ans; } inli... |
#include <bits/stdc++.h> using namespace std; int n, m, K, bs[500005], hs[500005], ht[500005], ht2[500005], lpos[500005], rpos[500005], ansl, ansr; bool flag; set<int> S; set<int>::iterator it; struct node { int len, id; } a[500005]; char s[500005], t[500005]; int Hashs(int fr, int to) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; const int inf = 1e9; vector<int> getArray(int *a, int n, int k) { vector<int> ret; for (int i = 0; i < n * k; i++) { if (i < n) ret.push_back(a[i]); else ret.push_back(a[i % n]); } return ret; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; set<int> st; for (int i = 0; i < n; i++) { cin >> a[i]; st.insert(a[i]); } set<int>::iterator it = st.begin(); it++; if (it == st.end()) cout << NO ; else cout << (*... |
#include <bits/stdc++.h> int main() { long a, b, c; scanf( %ld%ld%ld , &a, &b, &c); if (b == a) { printf( YES n ); } else if (c > 0) { if (b < a) { printf( NO n ); } else if (((b - a) % c) == 0) { printf( YES n ); } else { printf( NO n ); } } e... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 100; const long long inf = 0x3f3f3f3f3f; int n; int a[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) { if (i != n) { int q; cout << ? << 1 << << i + 1 << endl; ... |
#include <bits/stdc++.h> using namespace std; long long int n, q; long long int gcd(long long int a, long long int b) { if (b == 0) { return a; } return gcd(b, a % b); } long long int powe(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b % 2 == 1... |
#include <bits/stdc++.h> using namespace std; int mob[2000005], vis[2000005], p[1000005]; long long cnt[2000005], cnt2[2000005], pnum; bool prime[1000005]; long long mod = 1e9 + 7; int read() { char c; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) ; int x = c - 48; for (c = ge... |
#include <bits/stdc++.h> using namespace std; int n; string s; set<vector<int> > DP[10001]; bool R[4]; int main() { cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) if (s[i] == G ) s[i] = 0 ; else if (s[i] == S ) s[i] = 1 ; else if (s[i] == H ) ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, k, d; scanf( %d%d%d , &n, &k, &d); vector<int> v(n); for (int &x : v) { scanf( %d , &x); } map<int, int> m_map; int mn = 0, cnt = 0; for (int i = 0; i < d; i++) { if (m_map[v[i]] == 0) { cnt++; ... |
#include <bits/stdc++.h> #define ll long long using namespace std; int t; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int n; cin >> n; vector<pair<int, int> > a(n + 1); for (int ... |
#include <bits/stdc++.h> using namespace std; int main() { int k; string s; map<char, int> m1; cin >> k >> s; int n = s.length(); for (int i = 0; i < n; i++) { m1[s[i]]++; } map<char, int>::iterator it; int flag = 0; for (it = m1.begin(); it != m1.end(); it++) { i... |
#include <bits/stdc++.h> using namespace std; string dp[5001]; vector<int> win[2001]; int n; string pow2[2001]; void multi2(string &ress, const string &p) { int flag = 0; ress = ; for (int i = 0; i < p.size(); i++) { ress += ((p[i] - 0 ) * 2 + flag) % 10 + 0 ; flag = ((p[i] - 0 ... |
#include <bits/stdc++.h> using namespace std; int n, m, s, ans; int ar[5005]; int cnt[5005]; int ar2[5005]; vector<pair<pair<int, int>, pair<int, int> > > v; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) ar[i] = 1000000000; for (int i = 0; i < m; i++) { int t, l, r, x;... |
#include <bits/stdc++.h> using namespace std; int pot(int n) { if (n == (n & -n)) return n; return (n - (n & -n)); } int main() { int n, b, p; cin >> n >> b >> p; int ans1 = 0, ans2 = p * n; while (n != 1) { int d = pot(n); int e = n - d; n -= (d / 2); ans1 += (d ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; char name[21]; int initials[26]; cin >> n; memset(initials, 0, 26 * sizeof(int)); for (int i = 0; i < n; ++i) { cin >> name; initials[name[0] - a ]++; } int total = 0; for (int i = 0; i < 26; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; long long ans, dp[N]; int ed, n, m; struct node { int w, c; double val; node(int a = 0, int b = 0) : w(a), c(b) {} bool operator<(const node &b) const { return val > b.val; } } a[N], tmp[N]; long long DP() { for (int ... |
#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}; template <class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); } template <class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); } template <cl... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s; for (int i = s.length() - 1; i >= 0; i--) { if (t == ) { t.push_back(s[i]); } else if (t.back() <= s[i]) { t.push_back(s[i]); } } reverse(t.begin(), t.end()); cout << t; } ... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 100010, LOG = 20; int n, m, k, q, u, v, x, y, ... |
#include <bits/stdc++.h> using namespace std; const int h = 17, N = 1 << h; long long t[2 * N]; long long k; long long product(int a, int b) { if (a > b) return 1; if (a % 2 == 1) return (t[a] * product(a + 1, b)) % k; if (b % 2 == 0) return (t[b] * product(a, b - 1)) % k; return product(a / 2... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, mod = 1e9 + 7; int head[N], nxt[N << 1], to[N << 1], num = 0, n, b[N], fa[N], q[N], DFN = 0, k[N], in[N]; inline void link(int x, int y) { nxt[++num] = head[x]; to[num] = y; head[x] = num; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { int flag = 1; for (int j = i - 1; j >= 1 && j >= i - x; j--) { if (a[i] > a[j]) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pr = pair<int, int>; using prll = pair<long, long>; using V = vector<int>; using Vll = vector<long long>; template <typename T, typename TT> pr operator+(pair<T, TT> a, pair<T, TT> b) { return {a.firs... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.