func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int ar[2111111], br[2111111], cr[2111111], dr[2111111]; int main() { cin.sync_with_stdio(false); int n, i, j, x, y, pos, m; cin >> n; for (i = 1; i <= n; i++) { cin >> ar[i]; if (ar[i] == 0) pos = i; } for (i = n + 1; i < n + n; i++... |
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ... |
#include <bits/stdc++.h> int n, m, c[256]; int main() { int a, j; scanf( %d%d , &n, &m); memset(c, -1, sizeof(c)); for (int i = 0; i < n; ++i) { scanf( %d , &a); if (~c[a]) printf( %d , c[a]); else { j = a; while (j && !~c[j - 1] && j > a - m + 1) --j; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; long long a[200000 + 5]; int main() { long long i, j, k, l; long long n, m; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; a[n] = 2000000009; long long maxn = 0; k = 0; for (i = 1; i <= n; i++) { if (... |
#include <bits/stdc++.h> const double pi = 3.141592653589793238462643383279; using namespace std; long long GCD(long long a, long long b) { if (b == 0) return a; return GCD(b, a % b); } int arr[1000010]; int rev[1000010]; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fi... |
#include <bits/stdc++.h> using namespace std; const int N = 2000210; inline int scan() { char c = getchar(); int x = 0; while (c < 0 || c > 9 ) { c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 1) + (x << 3) + c - 0 ; c = getchar(); } return x; } lon... |
#include <bits/stdc++.h> using namespace std; int MAXN = 200000; using namespace std; void RI() {} template <typename... T> void RI(int& head, T&... tail) { scanf( %d , &head); RI(tail...); } int a[200000]; vector<pair<double, double> > lines; double intersection(pair<double, double> a, pair... |
#include <bits/stdc++.h> using namespace std; bool judge(char c) { if (c == a || c == e || c == i || c == o || c == u || c == y ) return false; else return true; } int main() { char a[110]; int n, m = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (i... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) using namespace std; const int N = 2e5 + 7; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; const double eps = 1e-8; const double PI = acos(-1); templat... |
#include <bits/stdc++.h> using namespace std; char s[55][55]; int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, 1, -1}, n, vis[55][55]; bool check(int x, int y) { for (int i = 0; i < 4; i++) { int tx = x + dx[i], ty = y + dy[i]; if (tx < 1 || tx > n || ty < 1 || ty > n || s[tx][ty] == # || vis[tx][ty]) ... |
#include <bits/stdc++.h> using namespace std; bool notis[30] = {false}, mayis[30] = {false}; string str; int main() { int n, flag = 0, cnt = 0, tem, i, j; char p; std::ios::sync_with_stdio(false); cin >> n; for (i = 0; i < n; i++) { cin >> p >> str; if (flag && (p == ! || p == ... |
#include <bits/stdc++.h> using namespace std; long long dp[2005][2005]; string s; long long cnt[2005]; long long powr[2005]; long long solve(int l, int r) { if (dp[l][r] != -1) { return dp[l][r]; } if (l >= r) return 0; dp[l][r] = 0; if (s[l] == ) ) { dp[l][r] += solve(l + 1... |
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long N = 5e5 + 1; bool prime[N]; void solve() { long long n, k; cin >> n >> k; string s; cin >> s; vector<vector<long long>> v(k); long long cnt = 0, c = 0; string t = s; bool f = 0; while... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(begin(v), end(v)); v.erase(unique(begin(v), end(v)), end(v)); n = v.size(); for (int i = 2; i < n; i++) { int a = v[i - 2]; int b = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int a[maxn], b[maxn]; int main() { int n, x, T; cin >> T; while (T--) { cin >> n; set<int> s; s.clear(); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { scan... |
#include <bits/stdc++.h> using namespace std; long long n, sum, ans, a[100005]; inline long long read() { long long q = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = 0; ch = getchar(); } while (isdigit(ch)) { q = (q << 3) + (q << 1) + (ch ^ 48); ... |
#include <bits/stdc++.h> using namespace std; const int N = 66666; const int M = 55; const int sM = 105; const int inf = 1e9 + 7; const double pi = acos(-1); inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, i; scanf( %d , &n); printf( %d , n); for ((i) = 0; (i) < (int)(n - 1); (i)++) printf( %d , i + 1); printf( n ); return 0; } |
#include <bits/stdc++.h> struct City { long long g; long long w; long long gf; long long bg; long long minbg; }; class Data { public: City cities[100000]; int n; int k; long long gifts; long long gas; long long nextGas; int maxL; City* end; City* head; ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > T; int n, sum; vector<pair<int, int> > loc; void input(); void solve(); int main() { input(); solve(); return 0; } void input() { assert(scanf( %d , &n) == 1); T.resize(n); for (int i = 0; i < n; i++) { in... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200000], money, energy, i; scanf( %d , &n); for (i = 0; i <= n - 1; i++) { scanf( %d , &a[i]); } energy = 0; money = a[0]; for (i = 0; i <= n - 2; i++) { if (energy + a[i] - a[i + 1] < 0) { money += a... |
#include <bits/stdc++.h> template <typename A, typename B> inline char smax(A &a, const B &b) { return a < b ? a = b, 1 : 0; } template <typename A, typename B> inline char smin(A &a, const B &b) { return b < a ? a = b, 1 : 0; } template <typename I> inline void read(I &x) { int f = 0, c; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 6; int n, l, r, h[N], b[N], ans[N], S; vector<int> X, Y; int main() { scanf( %d%d%d , &n, &l, &r); for (int i = 1; i <= n; ++i) scanf( %d , h + i), S += h[i]; for (int i = 1; i <= n; ++i) scanf( %d , b + i); int _l = S - r, _r =... |
#include <bits/stdc++.h> using namespace std; const int N = 1000100; int n, p[N]; int mx1[N], mx2[N], ans[N]; int main() { scanf( %d , &n); for (int v, best, i = 2; i <= n + 1; i++) { scanf( %d , p + i); v = i; while (v != 0) { best = max(mx1[v], mx2[v] + 1); if (best... |
#include <bits/stdc++.h> using namespace std; const int MaxD = 1001; vector<int> temp; int main() { int n, w[MaxD] = {0}, h[MaxD] = {0}, maximum = 0, minimum = MaxD, ilgis; unsigned long long ats = 1e18; bool ar; cin >> n; for (int i = 1; i <= n; i++) { cin >> w[i] >> h[i]; if (m... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long int x; cin >> x; cout << 25; } |
#include <bits/stdc++.h> using namespace std; int n, dp[300005], k = 0, b[300005]; vector<int> ke[300005]; void dfs(int u, int par) { if (ke[u].size() == 1 && u != 1) { dp[u] = 1; k++; return; } if (b[u]) dp[u] = 1e9; else dp[u] = 0; for (int v : ke[u]) if... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265359; const long long MOD = (long long)1e9 + 7; const long long MAXN = (long long)2e3 + 10; const long long INF = (long long)2242545357980376863; const long double EPS = (long double)1e-8; long long dp[MAXN][2048]; long long p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t; cin >> t; while (t--) { long long a, b, c; cin >> a >> b >> c; long long ans = (a + b + c) / 2; cout << ans << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> A(n); vector<int> P(n + 1); for (auto &x : A) cin >> x; for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; const long long p = 1e9 + 7; int n, a[2505], mx, s, ch, ans; long long f[100005]; long long ksm(long long x, int y) { long long sun = 1; x %= p; while (y) { if (y & 1) sun = sun * x % p; y >>= 1; x = x * x % p; } return sun; ... |
#include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <set> #include <cstdlib> #include <iostream> #include <map> #include <algorithm> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uii; typedef pair<int, ll> pii; tem... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n / 2 * 3; } |
#include <bits/stdc++.h> using namespace std; void printv(vector<long long int> v) { long long int sz = v.size(); for (long long int i = 0; i < sz; i++) { if (i == sz - 1) cout << v[i] << n ; else cout << v[i] << ; } } void input(long long int a[], long long int sz) ... |
#include <bits/stdc++.h> bool QQQQ; const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}; const int dy[] = {0, 0, -1, 1, 1, -1, 1, -1}; using namespace std; int ttt = 1; int n, k, res = 100256, z, cnt; string s, t, ans; void solve() { cin >> n >> k >> s; ans = s; for (int i = 0; i < n; i++) ans[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(); cin.tie(); int t, n, a, b; cin >> t; while (t--) { int a, b; cin >> a >> b; int c = abs(a - b); int ans = 0; int tmp = c / 5; ans += tmp; c -= tmp * 5; tmp = c ... |
#include <bits/stdc++.h> using namespace std; unsigned long long int dist[1150][1150], visited[1150][1150]; char ans[1050][1050]; void solve() { long long n, i, j, m; cin >> n >> m; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) cin >> ans[i][j]; } int startx, starty, endx, endy; ... |
#include <bits/stdc++.h> using namespace std; int n, k, p[3005], d[3005][3005], p0[3005], p50[3005], p100[3005], ans; queue<int> x, y; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , p + i); if (p[i] == 0) p0[1]++; else if (p[i] == 100) p1... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 0x3f3f3f3f; long long dp[maxn]; int n, m; struct node { int lb, lu; long long w; }; vector<node> ve[maxn]; int lb, lu; long long w, cost[maxn]; struct seg { long long ma, lazy; } tr[maxn << 2]; ... |
#include <bits/stdc++.h> using namespace std; int n, m; int cntrow[21]; int cntcol[6]; vector<int> sol; vector<int> allmasks[6]; bool DP[20][11][11][11][11][11][(1 << 5) + 1]; bool solve(int row, int c1, int c2, int c3, int c4, int c5, int mask) { if (row == m) { int tmp = c1 + c2 + c3 + c4 + ... |
#include <bits/stdc++.h> using namespace std; void f(int& r, int& g, int& b) { if (r >= 3 && g % 3 == 2 && b % 3 == 2) { r += 4; g -= 2; b -= 2; } } int main(void) { int r, g, b; cin >> r >> g >> b; f(r, g, b); f(g, r, b); f(b, r, g); cout << r / 3 + g / 3 + b /... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); int T; cin >> T; while (T--) { int n; cin >> n; n *= 2; vector<int> a(n); for (int &x : a) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int n = str.size(); int fl = 1; vector<char> v; for (int i = 0; i < str.size(); i++) { if (str[i] == / ) { while (str[i] == / ) { i++; } i--; v.push_back( / );... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int k; cin >> k; string s; cin >> s; long long tot = 0; int av[11]; memset(av, 0, sizeof(av)); int ans = 0; for (char a : s) tot += a - 0 , av[9 - (a - 0 )]++; for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; scanf( %d , &n); if (n == 1) printf( 1 n1 n ); else if (n == 2) printf( 1 n1 n ); else if (n == 3) printf( 2 n1 3 n ); else if (n == 4) printf( 4 n2 4 1 3 n ); else { printf( %d n , n); ... |
#include <bits/stdc++.h> using namespace std; int ar[11000111]; int el[5100]; int q, x, k, n; long long t; int min(int a, int b) { if (a < b) { return a; } return b; } int main() { scanf( %d , &n); scanf( %d , &k); for (int i = 0; i < n; ++i) { scanf( %d , &x); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cin.tie(0), cout.tie(0), cout.precision(15); int t; cin >> t; while (t--) { int n, x; set<int> s; cin >> n; for (int i = int(0); i < int(n); i++) { cin >> x; ... |
#include <bits/stdc++.h> using namespace std; int a[10000000], b[10000000], memo[10000000], pos[10000000]; int min(int l, int r) { if (l <= r) { return l; } return r; } int main() { int n, m, i, j, k, ind, p, l, x; fscanf(stdin, %d %d , &n, &m); for (i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; char s[1005]; long long t, ans = 0; int x, l; int main() { scanf( %s , s); int len = strlen(s); for (int i = 0; i < len; i++) { if (isalpha(s[i])) { if (t) { if (l == 2) ans += t; else ans += t ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[1000010]; int n, k; bool r[1000010]; int s[1000010]; int m[1000010]; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < k; i++) { int x, y; scanf( %d %d , &x, &y); g[x].push_back(y); } int v = 0; for (i... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int n, k, a[1010][1010]; vector<pair<int, int>> ans; int main() { int is = 0; ans.clear(); memset(a, 0, sizeof(a)); cin >> n >> k; for (int i = 1; i <= n; ++i) { int cnt = 0; for (int j = 1; j <= n; ++j... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> adjs[510]; char type[510]; bool visited[510]; int dfs(int v, int adj, char c) { visited[v] = true; type[v] = c; int totV = 1; for (int i = 0; i < (adj); i++) { int adjV = adjs[v][i]; if (!visited[adjV] && adjs[ad... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 9; const int L = 301; const int INF = 1e9 + 239; int n; int a[N]; int cnt[N]; vector<int> pos[N]; int mn[2 * N]; void solve(vector<pair<int, int>> v, int &ans) { v.push_back({n - 1, 0}); int prev = -1; int c = 0; mn[N]... |
#pragma GCC optimize ( O3 ) #pragma GCC target ( sse4 ) #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << : << x << n #define debug2(x, y) debug(x), debug(y) #define repn... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:2000000 ) #pragma comment(linker, /HEAP:2000000 ) using namespace std; void print_width(long long x) { std::cout << std::fixed; std::cout << std::setprecision(x); } long long power(long long x, long long y, long long p = 1000000007) { lon... |
#include <bits/stdc++.h> using namespace std; clock_t __stt; inline void TStart() { __stt = clock(); } inline void TReport() { printf( nTaken Time : %.3lf sec n , (double)(clock() - __stt) / CLOCKS_PER_SEC); } template <typename T> T MIN(T a, T b) { return a < b ? a : b; } template... |
#include <bits/stdc++.h> using namespace std; int lastr, lastc; int n, m, a, b; int row1[10], rcnt, ans; int main() { int i, j, k; while (scanf( %d%d%d%d , &n, &m, &a, &b) != EOF) { if (m == 1) { printf( 1 n ); continue; } lastr = (n + m - 1) / m; lastc = n % m;... |
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n; cin >> n; string s = string(n, ( ) + string(n, ) ); cout << s << n ; for (int i = 0; i + 1 < n; ++i) { s[i + 1] = ) ; s[2 * n - 2] = ( ; cout << s << n ; s[2 * n - 2] = ) ... |
#include <bits/stdc++.h> long long minus(long long k) { return (1000000009LL - 1 + k) % 1000000009LL; } long long multiply(long long k) { return (k * 2) % 1000000009LL; } long long multiply(long long a, long long b) { return (a * b) % 1000000009LL; } int main() { int n, m; scanf( %d %d , &n, &m); lo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const long long MOD = 1e9 + 7; set<char> seen; void solve() { int n; cin >> n; string a; string b; cin >> a >> b; for (int i = 0; i < n; i++) { if (a[i] > b[i]) { cout << -1 n ; return; ... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma G++ optimize(2) using namespace std; char nc() { return getchar(); } int read() { int x = 0, y = 1; char c = nc(); while (!isdigit(c)) { if (c == - ) y = -1; c = nc(); } while (isdigit(c)) { x = (x << 1) + (x << 3)... |
#include <bits/stdc++.h> using namespace std; int n, m, k; string s; long long ans; bool flag; struct A { int id, p, s; }; bool comp(A a, A b) { if (a.p > b.p) return true; return false; } void solve() { cin >> n >> m >> k; vector<int> p(n); for (auto i = 0; i < n; i++) cin >... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 3, mod = 1e9 + 7, inf = 3e18 + 7; long long tc, n, m, a, b, c, d, i, j, k; long long A[N], odd[N], even[N]; string s[N]; vector<long long> vec; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> tc;... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y; cin >> x >> y; long long n; cin >> n; n %= 6; if (n == 0) n = 6; long long data[7]; data[1] = x; data[2] = y; for (int i = 3; i <= 6; i++) { data[i] = data[i - 1] - data[i - 2]; } for (in... |
#include <bits/stdc++.h> long long read() { long long res = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) res = res * 10 + ch - 48, ch = getchar(); return res * flag; } void print(long long x) { if (... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; vector<long long> v(n), vec; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i++) { if (v[i] == -1) continue; if (i - 1 >= ... |
// annotshy #include <bits/stdc++.h> #define Task CF #define pb push_back #define MOD 1000000007 #define F first #define S second #define int long long using namespace std; const int maxn = 2005; int n, m, w; int a[maxn][maxn]; int dx[5] = {1, 0, -1, 0}; int dy[5] = {0, 1, 0, -1}... |
#include <bits/stdc++.h> using namespace std; int mx, n, m, sum, hh, la, v[1000001], a[100001], sz[1000010], tot, e[10000001], nt[10000001], hd[1000010]; void build(int x, int y) { tot++; e[tot] = y; nt[tot] = hd[x]; hd[x] = tot; } int main() { int i, j, k; mx = 1e6; scanf( %... |
#include <bits/stdc++.h> using namespace std; long long n, cv; long long level[3501]; long long vis[3501] = {}; vector<long long> graph[3501]; vector<long long> cycles[3501]; vector<long long> z; void dfs_cycle(long long u, long long p, long long color[], long long mark[], long long par... |
#include <iostream> #include <map> #include <set> #include <queue> #include <stack> #include <algorithm> #include <vector> #include <string> #include <iomanip> #include <cmath> #include <cstdio> #include <cstring> #include <climits> #define Buff std::ios::sync_with_stdio(false), cin.tie(0), co... |
#include <bits/stdc++.h> int main() { int t, i, j, k; scanf( %d , &t); int ranges[t][2000]; int len[t]; for (i = 0; i < t; ++i) { scanf( %d , &len[i]); for (j = 0; j < (2 * len[i]); j += 2) { scanf( %d %d , &ranges[i][j], &ranges[i][j + 1]); } } for (i = 0; i < t;... |
#include <bits/stdc++.h> using namespace std; int pp(int n) { for (int i = 2; i <= floor(sqrt(n)); i++) { if (n % i == 0) return i; } return 1; } void solve() { long long int n, k; cin >> n >> k; if (k > n) cout << max(0ll, n - k / 2) << endl; else cout << max(0ll, ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0), cin.tie(0); ; int n, m; cin >> n >> m; vector<vector<char>> v(n, vector<char>(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> v[i][j]; bool st = 1; in... |
#include <bits/stdc++.h> using namespace std; int main() { priority_queue<int, vector<int>, greater<int> > a; int temp; int n, i; int sum = 0; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &temp); a.push(temp); } temp = -1; while (!a.empty()) { if (a.t... |
#include <bits/stdc++.h> int main() { using namespace std; int num, t1, t2, k; cin >> num >> t1 >> t2 >> k; double ms[1000]; double ms2[1000]; for (int i = 0; i < 1000; i++) { ms[i] = 0; ms2[i] = 0; } for (int i = 0; i < num; i++) { int a, b; cin >> a >> b; ... |
#include <bits/stdc++.h> using namespace std; long long int x[1000007], y[1000007], z[1000007], n; string s, S; vector<long long int> v; int main() { { long long int a = 0, b = 0, c = 0, d, e, f, g, i, j, k, l, m, p, q, r, u, w, t, tc, in, mod, loc, diff, val, sz, lo, hi, mid, ... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.141592653589793238462643l; void solve(); int main() { solve(); return 0; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } void solve() { long long a, b, x1, y1, x2, y2; cin >> a >> b >> x1 >> ... |
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, L, R, k, l, kk, ll, l1, r1, l2, r2, x, gcd, lcm; inline long long exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { return x = 1, y = 0, a; } long long t = exgcd(b, a % b, y, x); return y -= a / b * x, ... |
#include <bits/stdc++.h> using namespace std; long long t = 1; template <class myType> void print_arr(myType &arr, long long L, string sep) { for (long long(i) = (0); (i) < (L); ++(i)) { cout << arr[i]; if (i < L - 1) { cout << sep; } } cout << n ; return; } long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; bool arr[26] = {false}; for (int i = 0; i < k; i++) { char c; cin >> c; arr[c - a ] = true; } long long ans = 0; long long co = 0; for (int i = 0; i < n;... |
#include <bits/stdc++.h> inline int gi() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * f; } std::set<std::pair<int, int> > M; struct yyb { int ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e6 + 1; const int INF = 2e9 + 1; const int MOD = (1e9 + 7); void bye(string s = ) { cout << s << n ; exit(0); } signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; cin >> t; ... |
#include <bits/stdc++.h> using namespace std; const bool debug = false; const int maxn = 1002003; const long long magic = 1000 * 1000 * 1000 + 7; int n, k; long long aa[maxn]; struct RMQ { int l, r; RMQ *left, *right; long long res; int resIndex; }; RMQ* build(long long* vs, int l, int... |
#include <bits/stdc++.h> using namespace std; string ans = 1001010111001010 ; int n; int main() { cin >> n; cout << ans[n - 1]; return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int n, k, size[maxn]; bool f[maxn]; long long dp[maxn]; vector<int> g[maxn]; void dfs(int u, int fa) { if (f[u]) size[u] = 1; else size[u] = 0; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> c(n); bool d[2]; for (int i = 0; i < n; i++) { cin >> c[i]; d[c[i] % 2] = 1; } if (d[0] && d[1]) { sort(c.begin(), ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int MAX = 5e5 + 5; const long long MAX2 = 11; const long long MOD = 1000000007; const long long MOD2 = 1000000006; const long long INF = 2e18; const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dc[] = {0, 1, 0, -1, ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const vector<int> mods = {998244353, 1000000007, 1000000009}; const long long inf = 3e18; const double pi = acos(-1.0); const double eps = 0.0000001; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <c... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 0; for (int i = 0; i < n; i++) { int val; cin >> val; if (val >= 0) ans += val; else ans -= val; } cout << ans << endl; } |
#include <iostream> #include <unordered_map> #include <list> #include <queue> #include <string.h> #include <stack> #include <set> #include <unordered_set> #include <map> #include <climits> #include <algorithm> #include <math.h> #include <vector> #include <iomanip> #include <ctype.h> using ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000; int n, t; double p, dp[MAXN + 1][MAXN + 1], ans = 0; int main() { cin >> n >> p >> t; dp[0][0] = 1; for (int i = 0; i < t; i++) for (int j = 0; j <= n; j++) { if (j < n) { dp[i + 1][j + 1] += dp[i][j] * p;... |
#include <bits/stdc++.h> using namespace std; long long q_pow(long long n, long long temp) { long long ans = 1; long long x = temp; while (n) { if (n & 1) { ans *= x; ans %= 1000000007; } x *= x; x %= 1000000007; n /= 2; } return ans; } int main(... |
#include <bits/stdc++.h> using namespace std; struct info { int id, d; bool operator<(const info &rhs) const { return d < rhs.d; } } a[200007]; vector<pair<int, int> > res; priority_queue<info> q; stack<info> st; int main() { int n, m; int k = 0; int M = 0; scanf( %d%d , &n, &m); ... |
#include <bits/stdc++.h> using namespace std; double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int main() { double r, x1, y1, x2, y2; cin >> r >> x1 >> y1 >> x2 >> y2; if (dist(x1, y1, x2, y2) >= r) { printf( %.12f %.12... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; int m = 0; while (n > 9) { n -= 9; m += 9 + n % 10; n /= 10; } cout << m + n << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t, n, i; cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; long long int ans = 0; long long int pre[n + 1]; memset(pre, 0, sizeof(pre))... |
#include <bits/stdc++.h> using namespace std; int n, m; int dx[] = {0, -1, 0, 1}; int dy[] = {-1, 0, 1, 0}; char a[505][505]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i] + 1; bool flag = 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { for... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int fa[N], mx[N], n; vector<int> son[N]; vector<int> ans; bool cmp(const int x, const int y) { return mx[x] < mx[y]; } void dfs(int x) { int s = son[x].size(); for (int i = 0; i < s; ++i) { int& sn = son[x][i]; dfs(sn... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = long double; using str = string; using pi = pair<int, int>; template <class T> using V = vector<T>; template <class T, size_t SZ> using AR = array<T, SZ>; using vi = V<int>; using vb = V<bool>; using vpi = V<pi>; co... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << [ ; for (auto v : V) os << v << ; os << ] ; return os; } template <class T> ostream &operator<<(ostream &os, set<T> S) { os << { ; for (auto s : S) os << s <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.