func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const int maxn = 2e5 + 5; struct node { int idx, p; bool operator<(const node &b) const { return p < b.p; } } ver[100005], hor[100005]; int vcnt, hcnt; vector<node> V1[maxn], V2[maxn]; int tempx[100005], tempy[100005];... |
#include <bits/stdc++.h> using namespace std; int a[105][105], n, m, k; int res, c; 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) cin >> a[i][j]; for (int j = 1; j <= m; ++j) { int ... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long z) { long long ret = 1; while (y > 0) { if (y & 1) ret = (ret * x) % z; x = (x * x) % z; y >>= 1; } return ret; } long long q; map<long long, long long> getFactors(long long num)... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; long long int arr[n]; long long int i; for (i = 0; i <= n - 1; i++) { cin >> arr[i]; } long long int temp = k; ve... |
#include <bits/stdc++.h> using namespace std; const int N = 111111; const int INF = 1000000000, mod = 1000000007; const long long LLINF = 1000000000000000000ll; pair<string, string> a[N]; int p[N]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int n, d, m, cnta = 0, cntb = 0; long long a[MAXN], b[MAXN]; inline bool cmp(long long x, long long y) { return x > y; } int main() { scanf( %d%d%d , &n, &d, &m); for (int i = 1; i <= n; i++) { long long x; scanf( %ll... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, MOD = 1e9 + 7; int main() { vector<int> a(27, -1), b(27, -1), c(27, -1); string str; cin >> str; for (int i = 0; i < (int)str.size(); i++) { if (a[str[i] - a ] == -1) { a[str[i] - a ] = i; c[str[i] - a ] ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template <class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } int N, K; pair<int, int> arr[213]; vector<pair<int, int> > blocks; int dp[100013][2]; int tmp[1000... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long int ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template <class T> inline T modinverse(T a, T M) { return bigm... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int maxn = 1e6 + 10; const int mod = 1e9 + 7; typedef struct p { long long x, y; }; p a[maxn]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %lld %lld , &a[i].x, &a[i].y); ... |
#include <bits/stdc++.h> using namespace std; int main() { int r, c, n, k; cin >> r >> c >> n >> k; int x[n], y[n], res = 0, xi, yi; for (int i = 0; i < n; i++) { cin >> xi >> yi; x[i] = xi - 1; y[i] = yi - 1; } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; long long v[MAX]; long long GCD(long long a, long long b) { if (!b) return a; if (!a) return b; return GCD(b, a % b); } int main() { long long mx = 0; long long n; cin >> n; for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int Read() { char c; while (c = getchar(), (c != - ) && (c < 0 || c > 9 )) ; bool neg = (c == - ); int ret = neg ? 0 : c - 48; while (c = getchar(), c >= 0 && c <= 9 ) ret = ret * 10 + c - 48; return neg ? -ret : ret; } const in... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 11; long long cs[4][N], n, dp[N][4][4]; vector<int> g[N], ord; bool u[N]; void dfs(int v) { u[v] = 1; ord.push_back(v); for (int i = 0; i < g[v].size(); i++) { int to = g[v][i]; if (!u[to]) dfs(to); } } pa... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int sum = 0; for (int i = 0; i < n; ++i) { int l, r; cin >> l >> r; sum += r - l + 1; } int ct = 0; while (sum % k != 0) { ct++; sum++; } cout << ct << endl; } |
#include <bits/stdc++.h> using namespace std; char buff[100010]; int calc() { scanf( %s , buff); int mask = 0; int len = strlen(buff); for (int i = 0; i < len; ++i) mask |= 1 << (buff[i] - a ); return mask; } int main() { int n; scanf( %d , &n); int mask = (1 << 26) - 1; b... |
#include <bits/stdc++.h> const int N = 1e5 + 5; char str[N]; int n, s[N]; long long f[N][11], ans; inline int nex(int i, int j) { return (9 + i * (i - 1) / 2 + j + 1) % 11; } int main() { scanf( %s , str + 1); n = strlen(str + 1); for (int i = 1; i <= n; ++i) s[i] = str[i] - 0 ; for (int i ... |
#include<bits/stdc++.h> #define llu unsigned long long #define ll long long #define l1 int #define u_m unordered_map #define M map #define answer cout<<ans<<endl; #define Sum cout<<sum<<endl; #define sort1(s) sort(s.begin(),s.end()) #define pb(x) push_back(x) #define yes cout<< YES <<endl; #def... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =... |
#include <bits/stdc++.h> using namespace std; set<string> sx; vector<string> vx; int ft; void generate(char str[], int k, int l) { if (k < 0) { str[l] = 0 ; bool status = true; for (int i = 0; i < strlen(str); i++) { for (int j = i + 1; j < strlen(str); j++) { if (str... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<pair<int, int> > road; for (int a = (0); a < (m); a++) { int p, q; cin >> p >> q; if (p > q) swap(p, q); road.push_back(make_pair(p, q)); } int field[101][101]; for (int a =... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 00; const long long inf = 1e9 + 800; long long a[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, r, sum = 0; ; cin >> n >> r; for (long long i = 0; i < (1 << n); i++) ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-11; void fast() { std::ios_base::sync_with_stdio(0); } int n; vector<int> arr; string s; vector<vector<int>> dp; int calc(int i, int state) { if (i == n) return 0; int &ret = dp[i][state]; if ... |
#include <bits/stdc++.h> using namespace std; int head[100005], fa[100005], a[100005]; struct edge { int to, next; } edges[200005]; int em; void addedge(int u, int v) { edges[em].next = head[u]; edges[em].to = v; head[u] = em++; edges[em].next = head[v]; edges[em].to = u; head[v]... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string second; cin >> n >> second; string t = second; bool ok = 1; vector<int> vec; for (int i = 0; i < n; i++) { if (second[i] == W ) continue; if... |
#include <bits/stdc++.h> const int oo = 0x3f3f3f3f; using namespace std; inline int read() { int x = 0, f = 1, hhh = getchar(); while (!isdigit(hhh)) { if (hhh == - ) f = -1; hhh = getchar(); } while (isdigit(hhh)) { x = x * 10 + hhh - 0 ; hhh = getchar(); } retur... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, oo = inf; inline long long read() { register long long x = 0, f = 1; register char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; struct sl { int SC, LC, TS, TL; double p; } a[1005]; struct csl { long double score, tim; } f[1005][1561], ans; double a1, a2, p; int n, m, z, x, y; inline bool cmp(sl x, sl y) { return x.TL * x.p * (1 - y.p) < y.TL... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int maxn = 205; int fail[maxn + 5]; int nxt[maxn + 5][maxn + 5]; long long dp[maxn + 5][maxn + 5][maxn + 5]; char s[maxn + 5]; int n, len; void Get_fail() { fail[0] = -1; int j = 0, k = -1; while (j <= len) ... |
#include <bits/stdc++.h> using namespace std; int N; vector<int> rating; void reading() { cin >> N; rating.resize(N); for (int i = 0; i < N; i++) cin >> rating[i]; } void processing() { for (int i = 0; i < N; i++) { int res = 0; for (int j = 0; j < N; j++) if (rating[i] <... |
#include <bits/stdc++.h> using namespace std; const int MAXW = 1000000; const int INF = 0x3f3f3f3f; const int MOD = 1000000007; const char test[] = test n ; int in(); int tr[100010]; int ls[100010]; int n, m, k; int hav[100010]; int lowbit(int x) { return (-x) & x; } void updata(int in, int val... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; template <typename T> ostream &operator<<(ostream &o, vector<T> &vec) { cout << [ ; for (int i = 0; i < ((int)(vec).size()); i++) { if (i) cout << , ; cout << vec[i]; } cout << ] ; return o; } template <typename T1, typename T2>... |
#include <bits/stdc++.h> int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int n; int map[2010][2010]; int vis[2010][2010]; int as, ac; int go(int x, int y) { vis[y][x] = 1; int r = 1; for (int i = 0; i < 4; ++i) { int nx = x + dx[i], ny = y + dy[i]; if (map[ny][nx] == 0 || vis... |
#include <bits/stdc++.h> using namespace std; const int maxn = 6e3 + 5; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; int main() { int t, n, k; char x; cin >> t; while (t--) { cin >> n >> k; for (int i = 0; i < n % k; i++) { cout << a ; } for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; int n, m, first[200050], nxt[200050], to[200050], tot; void add(int x, int y) { nxt[++tot] = first[x], first[x] = tot, to[tot] = y; } double w[200050], ans, sum[200050]; int fa[200050]; void dfs(int u, int f) { ans += w[f] * (1 - w[u]); for (int i = firs... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const long long INF = 1e17, LINF = 1e12; int n, m, q, x, y; vector<int> g[N], s[N]; int top[N], p[N], dp[N], son[N], sz, d[N]; int tin1[N], tin2[N], tout[N], timer, num[N]; pair<long long, int> og[N]; pair<long long, int> t[4 * N]; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)1e5 + 5; int x[3]; int y[3]; int buf; int main() { buf = 0; cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2]; for (long long i = 0; i < 3; ++i) { if (x[i] < y[i]) { buf = x[i]; x[i] = y[i]; y[i] ... |
#include <bits/stdc++.h> using namespace std; int x[200005]; int main() { memset(x, 0, sizeof(x)); int n = 0; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &x[i]); } sort(x, x + n); double eps = 1e-10, l = 0.0, r = (double)(x[n - 1] - x[0]) / 6.0; int p1 = 0, p2 ... |
#include <bits/stdc++.h> using namespace std; int a[400006]; vector<int> dis; int main() { int i, j, m, n, c, x, l, y, t, bytes; cin >> n >> bytes; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int total = 1; for (i = 1; i < n; i++) { while (i < n && a[i] == a[i - 1]) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 5; int n, f[N]; struct node { int t, d, p, id; bool operator<(const node& other) const { return d < other.d; } } a[N]; vector<int> g[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d %d %d , &a[i... |
#include <bits/stdc++.h> int a[12] = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292}; int main() { long long n; scanf( %lld , &n); printf( %lld n , (n < 12) ? a[n] : 292 + (n - 11) * 49); return 0; } |
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 3e5 + 10; const long long mod = 1e9 + 7; const double PI = acos(-1); inline long long mm(long long x, long long p) { return x >= p ? x -= p : ((x < 0) ? x += p : x); } inline long long ab(long long x) { ret... |
#include <bits/stdc++.h> using namespace std; long long limit = 1e9 + 7; bool cmp(long long a, long long b) { return a > b; } long long myceil(long long a, long long b) { return a / b + bool(a % b); } long long mylog(long long num, long long base) { long long ans = 0; while (num) { ans++; ... |
#include <bits/stdc++.h> using namespace std; long long ans; int F[500005][19 + 1], i, j, m, n, p, k, a[500005], nn, G[500005], Log[500005]; int ST[19 + 1][500005]; void get_ST() { for (i = 1; i <= nn; ++i) ST[0][i] = i; for (i = 1; i <= 19; ++i) for (j = 1; j + (1 << i) - 1 <= nn; ++j) ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int n; int seat[100]; int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> seat[i]; int sum = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a[200010], m = INT_MAX; string s; cin >> n >> s; for (int i = 0; i < n; i++) cin >> a[i]; long long int j = -1; for (long long int i = 0; i < s.length(); i++) { if (s[i] == R ) j = i; else { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n, p, k; cin >> n >> p >> k; auto f = [&](int x) -> int { return ((ll)x * x % p * x % p * x % p - (ll)k * x % p + p) % p; }; map<int, int> cnt; for (int _ = 0; _ < n; _++) { int x; cin ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1 << 16; map<pair<int, int>, int> dp[maxn]; int n, c[20], r[20], b[20], ed, rrr, bbb, ans = 0x3f3f3f3f; int main() { cin >> n; getchar(); for (int i = 1; i <= n; i++) { char ch; cin >> ch >> r[i] >> b[i]; if (ch == R... |
#include <bits/stdc++.h> using namespace std; char p[120], A[10100][120], B[10100][120], res[120]; int SA[110], SB[110], Z[110], Pre[110]; int SS[110], Suf[110]; void Do(int n) { int i, j; printf( ? %d %d n , 1, n); fflush(stdout); for (i = 0; i < n * (n + 1) / 2; i++) { scanf( %s , A[i]... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); inline int cmp(double x, double y = 0, double tol = 1e-8) { return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1; } struct point { double x, y; point(double x = 0, double y = 0) : x(x), y(y) {} point operator+(point q) {... |
#include <bits/stdc++.h> using namespace std; string s1; long long arr2[2000006]; long long dsu(long long x) { return arr2[x] == x ? x : arr2[x] = dsu(arr2[x]); } int main() { char ans[2000006]; long long n, t1, t2, t3, t4, t5; cin >> n; for (int i = 0; i < 2000006; i++) { ans[i] = a ; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; inline long long int rl() { long long int res = 0, neg = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) neg = 1, c = getchar(); while (c >= 0 && c <= 9 ) { res = (res <... |
#include <bits/stdc++.h> using namespace std; int n, m, q, p[200005], a[200005], pi[200005], mra[200005], t; int mar[200005], su[200005], pr[200005], mm[200005], l, lr, r, Ilmm[200005]; vector<int> v[200005]; bool pa; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int MOD = 1e9 + 7; vector<string> vec_splitter(string s) { s += , ; vector<string> res; while (!s.empty()) { res.push_back(s.substr(0, s.find( , ))); s = s.substr(s.find( , ) + 1); } return res; } void ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; const long long pri = 1e9 + 7; long long myPow(long long a, long long b) { long long ret = 1; while (b != 0) { if (b % 2 != 0) { ret = (ret * a) % pri; } a = (a * a) % pri; b /= 2; } return ret; } ... |
#include <bits/stdc++.h> int main() { int x, y; scanf( %d%d , &x, &y); int r2 = x * x + y * y; int r = floor(sqrt(static_cast<double>(r2))); if (r * r < r2 && (r + 1) * (r + 1) > r2 && (r % 2 == 1 && x * y > 0 || r % 2 == 0 && x * y < 0)) { printf( white n ); } else { print... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 250005; vector<int> g[maxn]; int pa[maxn]; int v[maxn]; int dep[maxn]; vector<int> leaf; int n, m, k; void build(int now) { int x = 0, y = 0; for (auto &i : g[now]) { if (i == pa[now]) { con... |
#include <bits/stdc++.h> using namespace std; const int KMAX = 8; const int NMAX = 2505; char mat[NMAX][NMAX]; int psm[NMAX][NMAX], pt1[KMAX], pt2[KMAX]; inline int sum(int x1, int y1, int x2, int y2) { return psm[x2][y2] - psm[x2][y1 - 1] - psm[x1 - 1][y2] + psm[x1 - 1][y1 - 1]; } long long solve(i... |
#include <bits/stdc++.h> using namespace std; int dp[2001][2001]; int f(int i, int j) { if (j < 0 || i < 0 || j > i) return 0; if (dp[i][j] != -1) return dp[i][j]; if (j == i) dp[i][j] = (((long long)i - 1) * (f(i - 1, i - 1) + (long long)f(i - 2, i - 2))) % 1000000007; e... |
#include <bits/stdc++.h> using namespace std; const int MAX = 205; const int INF = 0x3f3f3f3f; string a, b; int dp[MAX][MAX][405]; int call(int x, int y, int s) { if (x >= a.size() and y >= b.size()) return s; if (dp[x][y][s] != -1) return dp[x][y][s]; int ret = INF; if (x < a.size() and y <... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e8; long long inf = 1e15; long long n, m, k, ans, x; long long t[2003], c[2003]; long long dp[2003][4003]; long long f(long long x, long long y) { long long &ret = dp[x][y]; if (ret != -1) return ret; if (x == n + 1 && y < 2000) re... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return x > y ? (x = y, 1) : 0; } const int maxn = 15e3 + 17, maxk = 1e3 + 17, mod = 1e9 + 7, base = 1e7 + 19, ... |
#include <bits/stdc++.h> using namespace std; int need[105]; int main() { int n; cin >> n; int i; for (i = 1; i <= n - 1; i++) { cin >> need[i]; } int a, b; cin >> a >> b; int ans = 0; for (i = a; i <= b - 1; i++) { ans += need[i]; } cout << ans << endl; ... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.size(); if (s[0] == b && s[n - 1] == a ) { s[0] = a ; } else if (s[0] == a && s[n - 1] == b ) { s[n - 1] = a ; } cout << s << n ; } int main() { int t; cin >> t; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin >> n; vector<char> c(n); vector<int> id(n); map<int, bool> state, exist; for (int i = 0; i < n; i++) cin >> c[i] >> id[i]; for (int i = 0; i < n; i++) { if (c[... |
#include <bits/stdc++.h> const int MAX = 3000; const long long MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const long double EPS = 1e-9; const long double PI = acos(-1.0); using namespace std; bool eq(long double a, long double b) { return fabsl(a - b) <= EPS; ... |
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, m, n, s, t, p, q, a, b, aa, bb, d; char c[2222222]; int main() { t = 1; while (gets(c) != 0) { for (i = 0; c[i] != 0; i++) if (c[i] != ) break; if (c[i] == # ) { if (t == 0) puts( ); puts(c); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; long long inf = 1000000005; cin >> n >> m; long long i, j, k; bool a[n + 1][n + 1]; long long deg[n + 1]; for (i = 0; i < n + 1; i++) { deg[i] = 0; for (j = 0; j < n + 1; j++) a[i][j] = false; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int t; cin >> t; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; int d[7] = {0}; d[a] = 1; d[7 - a] = 1, d[b] = 1, d[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int a[N]; int main() { std::ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; vector<int> nrs; for (int i = 0; i < n; ++i) nrs.push_back(a[i]); for (int i = 1; i < 32; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d , &(n)), scanf( %d , &(m)); int a[(100000 + 10)][2]; for (int i(0), _n(n); i < _n; ++i) { scanf( %d , &a[i][1]); if (a[i][1] > 0) a[i][0] = + ; else a[i][0] = - , a[i][1] = -a[i][1]; ... |
#include <bits/stdc++.h> using namespace std; int a[200010], b[200010], n, m, q; vector<pair<int, int> > e[200010]; long long T[800010], d[800010]; long long f[200010]; void push(int id) { T[id << 1] += d[id]; T[id << 1 | 1] += d[id]; d[id << 1] += d[id]; d[id << 1 | 1] += d[id]; d[id] =... |
#include <bits/stdc++.h> using namespace std; int n, t, lim = 16; int w[4], g[1005]; char ch[4][1005]; int num[4][4]; int s[4][4][4]; int dp[1005][16][16][16][16]; int main() { scanf( %d , &n); for (int i = 0; i < 4; i++) scanf( %d , &w[i]); for (int i = 0; i < 4; i++) scanf( %s , ch[i]); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int N = 2e5 + 7; int n, m, i, j, a, b; int check(int x, int y) { int dis1 = abs(x - i); int dis2 = abs(y - j); if (dis1 % a == 0 && dis2 % b == 0) { int p = dis1 / a; int q = dis2 / b; if (p == q) ret... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; const long long INF = 1e18; const long long MOD = 1e9 + 7; const long long N = 2e6 + 10; const long long dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1}; bool TC... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long pow_[20]; long long binpow(long long a, long long n) { long long res = 1; while (n) { if (n % 2 == 1) { res = (a * res) % mod; } a = (a * a) % mod; n /= 2; } return res; } ... |
#include <bits/stdc++.h> using namespace std; int n; long long int k; long long int a[100001]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n / 2; i++) { long long int c = (a[i + 1] - a[i] + a[n - i + 1] ... |
#include <bits/stdc++.h> using namespace std; const long long INFLL = 1e18; const int MAXN = 1e6 + 100; const long long INF = 1e9; const long long mod1 = 1e9 + 7; const long long mod2 = 2e9 + 11; int n; pair<pair<int, int>, pair<int, int> > a = {{0, 0}, {0, 0}}, b... |
#include<bits/stdc++.h> #define ls i<<1 #define rs i<<1|1 #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef vector<int> vct; typedef pair<int,int> pii; const int N=2E5+1; const int inf=1<<30; ll read() { ll a... |
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int main() { int i, j, n, m, t; string s; cin >> t; int cnt = 0; for (i = 0; i < t; i++) { cin >> s; int len = s.size(); string ans; int chk = 1; while (chk == 1) { ans.clear(); chk... |
#include <bits/stdc++.h> using namespace std; long long int ans = 0; vector<int> vx[200005]; bool vu[200005]; int n, k; int dfs(int v, int p) { int aa = 0, aa2 = 0; for (int i = 0; i < vx[v].size(); i++) { if (vx[v][i] == p) continue; int pr = dfs(vx[v][i], v); aa += pr; aa2 ... |
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; Point() {} Point(double _x, double _y) { x = _x; y = _y; } Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); } double operator^(const Point &b) const { return x * b.y - y * b.x; } ... |
#include <bits/stdc++.h> using namespace std; template <class T> T __sqr(const T x) { return x * x; } template <class T, class X> inline T __pow(T a, X y) { T z = 1; for (int i = 1; i <= y; i++) { z *= a; } return z; } template <class T> inline T gcd(T a, T b) { a = abs(a... |
#include <bits/stdc++.h> using namespace std; struct node { int a, b; node() { a = b = 0; } } node[10005]; int main() { int n, v; cin >> n >> v; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; node[a].a += b; } int ans = 0; for (int i = 1; i <= 3001; i++)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 100; const long long inf = (1LL << 30 - 1); pair<int, int> A[maxn]; int fa[maxn], X[maxn], Y[maxn], Hx[maxn], Hy[maxn], ans[maxn]; int FindSet(int x) { return fa[x] == x ? x : fa[x] = FindSet(fa[x]); } void UnionSet(int u, int v) { u... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> num(n + 1); for (int i = 1; i <= n; i++) cin >> num[i]; if (num[1] % 2 == 0 || n % 2 == 0 || num[n] % 2 == 0) { cout << No ; return 0; } cout << Yes ; return 0; } |
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 17; char ch[N]; int n, r[N], b[N]; int sr, sb, red[1 << N], blue[1 << N], f[1 << N][123]; int main() { std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> ch[i] >> r... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> table; table.insert(pair<string, int>( void , 0)); while (n--) { string cmd; cin >> cmd; if (cmd == typedef ) { string from, to, raw; cin >> from >> to; int dep... |
#include <bits/stdc++.h> using namespace std; int main() { long long MAX = pow(2, 32) - 1; int n; cin >> n; stack<int> fors; long long val = 0; long long num = 1; int i = 0; while (i != n) { string str; cin >> str; if (str == add ) { val += num; } els... |
#include <bits/stdc++.h> using namespace std; const long long N = 2005; const long long mod = 1e9 + 7; const long long INF = 1e18 + 1; long long goal, n, m; long long umbrella[N], rain[N], cache[N][N]; pair<long long, long long> a[N], b[N]; long long dp(long long x, long long y) { if (x == goal) ret... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, cnt; vector<int> e[N]; vector<pair<int, int> > ans; void init() { scanf( %d , &n); for (int i = 1, x, y; i < n; ++i) { scanf( %d %d , &x, &y); e[x].push_back(y); e[y].push_back(x); } } void dfs(int x... |
#include <bits/stdc++.h> using namespace std; long long a, b, c; long long x, y, z, n; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { cin >> n; a = 1234567; b = 123456; c = 1234; for (int i = 0; i * a <= n; i++) { for (int j = 0; i * a + j * b ... |
#include <bits/stdc++.h> const int NUM = 200005; const int MAXV = 1e6 + 100; int blen, n, t, l, r, val; int a[NUM], vcnt[MAXV]; long long int ans[NUM], answer; struct query { int l, r, ind; } qs[NUM]; bool query_cmp(query a, query b) { if (a.l / blen != b.l / blen) return a.l < b.l; return a... |
#include <bits/stdc++.h> using namespace std; int main() { string s, a; a = hello ; cin >> s; int i, j, k = 0; for (i = 0, j = 0; j < a.size(); i++) { if (i >= s.size()) break; if (s[i] == a[j]) { j++; } } if (j == a.size()) cout << YES << endl; els... |
#include <bits/stdc++.h> using namespace std; int inf; const double eps = 1e-8; const double pi = acos(-1.0); template <class T, class T2> int chkmin(T &a, T2 b) { return a > b ? a = b, 1 : 0; } template <class T, class T2> int chkmax(T &a, T2 b) { return a < b ? a = b, 1 : 0; } template <... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int k = 0; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == a ) { k++; } } if (2 * k <= s.length()) { cout << 2 * k - 1; } else { cout << s.length(); } } |
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } int GETi() { int i; scanf( %d , &i); return i; } template <class T> T sqr(T val) { return val * val; } int W, H; int TX[2][100001]; int TY... |
#include <bits/stdc++.h> using namespace std; inline void optimizeIO() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const int nmax = 150005; const long long LINF = 1e17; int ara[110]; set<int> SET; int main() { optimizeIO(); int n; cin >> n; for (int i = 1; i <= n; i++) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.