func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; double probabilitate[150]; double MAX; int N, i, limita; double calcul(int N) { double first = 1.0, second = 0.0; int i; for (i = 0; i < limita; ++i) { second = first * probabilitate[N + i] + second * (1.0 - probabilitate[N + i]); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 100; string s; int f(int id) { string t; for (int j = id; j < s.size(); j++) { t.push_back(s[j]); } t.push_back( # ); for (int j = 0; j < id; j++) { t.push_back(s[j]); } int mx = 0; vector<int> z(t.s... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; struct pt { double x, y, z; }; pt operator+(const pt& a, const pt& b) { pt p = {a.x + b.x, a.y + b.y, a.z + b.z}; return p; } pt operator-(const pt& a, const pt& b) { pt p = {a.x - b.x, a.y - b.y, a.z ... |
#include <bits/stdc++.h> using namespace std; const int N = 4005; int tk[N][2]; int n, m; bool r[N][N]; int deg[N]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; int a, b; for (int i = 1; i <= n; ++i) { deg[i] = -2; ; for (int j = 1; j <= n; ++j) r[i][j] = fal... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; const ll inf = 1LL << 60; vector<ll> dv; void divisor(ll n) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { if (i == n / i)... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; struct SegmentTree { vector<multimap<int, int>> T; SegmentTree(int n) : T(n + 1) {} set<int> availab... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<int> a(n), b(n); for (int i = (0); i < (m); i++) { int x, y; cin >> x >> y; -... |
#include <iostream> #include <vector> #include <string> #include <queue> #include <algorithm> #include <cmath> #include <map> #include <set> #include <unistd.h> #define rep(i,a,n) for(int i = a;i < n;i++) #define fi first #define se second typedef long long ll; using namespace std; const int... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 1e5 + 10, mod = 1e9 + 7; long long a[maxn], d[maxn]; bool mark[maxn]; long long dfs(int v, int p) { mark[v] = 1; if (v == p) return 0; if (mark[a[v]]) return -1; int k = dfs(a[v], p); return (k == -1 ? -1 : k + 1); } in... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); string s, t, p = ; cin >> s >> t; int n = s.size(); int c = 0; for (int i = 0; i < n; i++) if (s[i] != t[i]) c++; if (c % 2) { cout << impossible ; return 0; } for (i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> A, B; for (int i = 1; i <= n; i++) A.push_back(i); long long sum = 0; for (int i = 2; i < n; i++) sum += i * (i + 1); cout << sum << n ; } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : ... |
#include <iostream> #include <vector> #define int long long const int DEN = 100000; const int INF = 100000000000000000; int ceild(int x) { if(x%DEN != 0) { x += DEN-x%DEN; } return x/DEN; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, r; int y1, y2, yw, x, y; scanf( %d%d%d%d%d%d , &a, &b, &c, &x, &y, &r); y2 = b; if (b - a < r) { printf( -1 n ); return 0; } y1 = a + r; yw = c - r; y = 2 * yw - y; double k = (1.0) * (y - y1)... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int cont = 0; for (int i = 0; i < n && s[i] == < ; i++, cont++) ; for (int i = n - 1; i >= 0 && s[i] == > ; i--, cont++) ; cout << cont << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, m; int a[MAXN]; int w[MAXN], h[MAXN]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); scanf( %d , &m); for (int i = 1; i <= m; i++) { scanf( %d%d , &w[i], &h[i]); } long... |
#include <bits/stdc++.h> using namespace std; long long int n, k, m, d; int main() { std::ios::sync_with_stdio(false); long long int best = -1; cin >> n >> k >> m >> d; int x; long long int pre = m; long long int ans = 0; for (int cycles = 1; cycles <= d; cycles++) { long long in... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 2e5 + 10; const ll inf = 1e15 + 42; vector<vector<int> > g(100007); int flg, root, cnt; vector<int> ans; void dfs(int u, int par) { if (flg... |
#include <bits/stdc++.h> using namespace std; int main() { int nofQs; cin >> nofQs; int minSec = INT_MAX; vector<int> custs(nofQs); for (int i = 0; i < nofQs; i++) { cin >> custs[i]; } for (int i = 0; i < nofQs; i++) { int tAmt = 0; for (int j = 0; j < custs[i]; j++) { ... |
#include <bits/stdc++.h> using namespace std; int f[(1 << 20)], cnt[(1 << 20)], n, m; string s; int main() { cin >> n >> m >> s; fill(f + 1, f + (1 << m), INT_MAX); for (int i = 1; i < n; i++) { int a = s[i - 1] - a , b = s[i] - a ; if (a != b) cnt[(1 << a) | (1 << b)]++; } for... |
#include <bits/stdc++.h> using namespace std; #define F first #define S second typedef pair<int, int> pi; typedef long long ll; const ll big = 1e6 + 9; ll GCD(ll a,ll b) { if(!b) return a; return GCD(b, a % b); } ll LCM(ll a,ll b) { return ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) { return (a.second < b.second); } long long int modpower(long long int a, long long int b, long long int c) { long long int res = 1; while (b) { i... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y) { if (y == 0) return 1; else { long long result = power(x, y / 2) % 1000000007; if (y % 2 == 0) return (result % 1000000007 * result % 1000000007) % 1000000007; else return (result... |
#include <bits/stdc++.h> using namespace std; int main() { long n, i, count = 0; cin >> n; double a[n], j, ans = 0; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (i = n - 1; i >= 0; i--) { if (count % 2 == 0) { ans += 3.1415926536 * a[i] * a[i]; ... |
#include <bits/stdc++.h> template <typename T> void read(T& x) { x = 0; int flag = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) flag = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; x *= flag; } using namespace std; const int maxn = 200010;... |
#include <bits/stdc++.h> using namespace std; const int IINF = INT_MAX; const long long LLINF = LLONG_MAX; inline bool LT(double a, double b) { return !(fabs((a) - (b)) < (1e-8)) && a < b; } inline bool LTE(double a, double b) { return (fabs((a) - (b)) < (1e-8)) || a < b; } void compute() {} i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; scanf( %d , &n); printf( %d , n); int idx = 0; for (int i = 2; i <= n; i++) { while (n % i == 0) { n = n / i; printf( %d , n); } } return 0; } |
#include <bits/stdc++.h> using namespace std; const int M = 500 + 5; int board[M][M], dp[M][M]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < m; j++) { board[i + 1][j + 1] = s[j] - 0 + 0; } } ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } template <typename T> ostream &operator<<(ostream &s, const vector<T> &x) { s << [ ; for (auto it : x) { s << it ... |
#include <bits/stdc++.h> inline int read() { int data = 0, w = 1; char ch = getchar(); while (ch != - && !std::isdigit(ch)) ch = getchar(); if (ch == - ) w = -1, ch = getchar(); while (std::isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar(); return data * w; } const int N(1e5 + 1... |
#include <bits/stdc++.h> using namespace std; const int maxLog = 10; const int maxN = 1 << maxLog; const int INF = 0x3c3c3c3c; int f[333]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; vector<int> a(n); f[ > ] = 1; f[ < ] = -1... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, ans; scanf( %lld%lld , &b, &a); ans = (b + 1) % 10; if (a == b) ans = 1; for (long long i = b + 2; i <= a; i++) { if (i % 10 == 0) { ans = 0; break; } ans *= i % 10; } printf( %ll... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, q; cin >> n >> k >> q; vector<int> A(n); set<int> S; for (int i = 0; i < n; ++i) cin >> A[i]; int ty, id; for (int i = 0; i < q; ++i) { cin >> ty >> id; if (ty == 1) { S.insert(A[id - 1]); if... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using uint = unsigned int; using pii = pair<int, int>; using vi = vector<int>; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (a % b == 0) cout << YES n ; else co... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, odd = 0, even = 0; cin >> n; while (n--) { cin >> a; if (a % 2 == 0) { even += 1; } else { odd += 1; } } cout << (odd % 2 == 1 ? odd : even) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { double n, m, a[1001], b[1001], litri = 0, ok = 1; cin >> n >> m; double copie = m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; litri = m / (b[1] - 1); for (int i = n; i >= 1; i--) { m... |
#include <bits/stdc++.h> using namespace std; ifstream fin( test.in ); double i, j, sens, k, o, ta, tb, pasi, p, d, pl, haur, n; int a, b, t, f, c; int main() { cin >> a >> b >> t >> f >> c; k = 1000; ta = a / k; tb = b / k; p = a * t; sens = 1; while (p < c) { n = 0; w... |
#include <bits/stdc++.h> using namespace std; signed main() { char opr[40]; while ((~scanf( %s , opr)) && opr[0] == s ) { int x = 0, y = 1; while (1) { printf( ? %d %d n , x, y); fflush(stdout); char ans[20]; scanf( %s , ans); if (ans[0] == x ) break; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pil = pair<int, ll>; using pli = pair<ll, int>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>; using vb = vector<bool>; using vvb = vector<v... |
#include <bits/stdc++.h> char s[128]; bool ce(char r, char a, char b, char c) { return r == a || r == b || r == c; } bool spcmp(char a, char b, char c) { return ce( A , a, b, c) && ce( B , a, b, c) && ce( C , a, b, c); } int main() { int n, i; scanf( %s , s); for (i = 1; s[i + 1] != 0 ; i++)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k, x, y, res = 0; cin >> n >> k; vector<vector<int>> gr(n + 1); vector<int> deg(n + 1, 0), ch(n + 1, 0), nxt; for (int i = 0; i < n - 1; i++) { cin >> x >> y; gr... |
#include bits/stdc++.h using namespace std; #define ll long long //int r1[5005],r2[5005],l2[5005],l1[5005]; //ll ans[5005][5005]; ll ans1[5005]; ll ans2[5005]; ll last1[5005]; ll last2[5005]; int tag[5005]; ll s[5005]; int main() { int t; cin>>t; while(t--) { i... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-9; int main() { int a, b, c, d; cin >> a >> b >> c >> d; int foo = max(3 * a / 10, a - a / 250 * c); int bar = max(3 * b / 10, b - b / 250 * d); if (foo == bar) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1]; for (int i = 1; i < n + 1; i++) { cin >> a[i]; } int s = 0; int arr[n + 1], max; max = INT_MIN; memset(arr, 0, sizeof(arr)); for (int i = 1; i < n + 1; i++) { if (a[i] == 1) ... |
#include <bits/stdc++.h> using namespace std; const double inf = 1e7; const double eps = 1e-7; int main() { int n, width, height, begin0, begin1; cin >> n >> width >> height >> begin0 >> begin1; vector<pair<int, pair<double, double>>> a(n + 1); a[0] = make_pair(0, make_pair(1, begin1 - begin0));... |
#include <bits/stdc++.h> using namespace std; long long p[10], n, res; int main() { std::ios::sync_with_stdio(0); cin.tie(0); cin >> n; p[1] = 2; p[2] = 3; p[3] = 5; p[4] = 7; res = 0; for (int a = 1; a <= 4; a++) res += n / p[a]; for (int a = 1; a <= 4; a++) for (int... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, x, a, b; cin >> n >> x >> a >> b; int ans = abs(b - a) + x; ans = min(ans, n - 1); cout << ans << endl; } } |
#include <bits/stdc++.h> using namespace std; bool isPal(string s, long long l, long long r) { while (l < r) { if (s[l] != s[r]) return false; l++; r--; } return true; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; string s; cin >> s; ... |
#include <bits/stdc++.h> using namespace std; void test() { cerr << n ; } template <typename T, typename... Args> void test(T x, Args... args) { cerr << x << ; test(args...); } const int MAXN = (int)1e6 + 5; const int MOD = (int)1e9 + 7; void solve() { int n; cin >> n; vector<in... |
#include <bits/stdc++.h> using namespace std; const int MSIZE = 1e3 + 5; const int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; string s; cin >> s; int cnt[26] = {0}; f... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) const int INF = (int)1e9; using namespace std; template <class T> T abs(T x) { return x < 0 ? -x : x; } template <class T> T sqr(T x) { return x * x; } int n; int x[1000], y[1000]; bool used[1000]; void dfs(int v) { ... |
#include <bits/stdc++.h> using namespace std; struct node { int v, c; node *opp, *next; } Map[500]; node *List[110]; int d[110], vd[110]; int e, n; int a[110], p1[110], p2[110], N, M; bool b[100000 + 10]; int prime[100000 + 10], Nprime = 0; void addedge(int i, int j, int c) { Map[++e].v ... |
#include <bits/stdc++.h> using namespace std; long long nC2(int n) { if (n == 0) return 0; return ((long long)n * (n - 1)) / 2; } void solve() { int n, m; scanf( %d %d , &n, &m); long long Kmin, Kmax; int r = n % m; Kmin = nC2((n + m - 1) / m) * r + nC2(n / m) * (m - r); Kmax = n... |
#include <bits/stdc++.h> using namespace std; char a[5001][5001]; int p[5001]; bool u[5001]; int i, j, n, k; int main() { scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %s , &a[i]); for (j = 0; j < n; j++) a[i][j] -= 0 ; } for (i = 0; i < n; i++) for (j = 0; j < n; j++)... |
#include <bits/stdc++.h> using namespace std; const int oo = 1e9; const int mx = 1e3 + 10; const int mxd = (1 << 13) + 10; long long int a[mx], b[mx]; vector<long long int> divs; pair<int, long long int> f[mx][mxd]; long long int gcd(long long int a, long long int b) { if (b == 0) return a; retu... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long q; long long m; cin >> q >> m; long long j = 0; vector<pair<long long, long long>> spells; spells.push_back({0, 0}); for (int i = 0; i < q; i++) { long long k,... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 16; int k; int a[n]; cin >> k; for (int i = 0; i < n; i++) { a[0] = 15; a[1] = 14; a[2] = 12; a[3] = 13; a[4] = 8; a[5] = 9; a[6] = 10; a[7] = 11; a[8] = 0; a[9] = 1; ... |
#include <stdio.h> #include <iostream> #include <vector> #include <unordered_set> #include <math.h> #include <time.h> #include <algorithm> #include <string.h> #include <string> #include <deque> #include <ctype.h> #include <limits.h> #include <map> #include <set> #include <unordered_map> #i... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; int Lower[1000000 + 1], Higher[1000000 + 1]; char Used[1000000 + 1]; long long SumNat(long long n) { long long p = n, q = n + 1; if (p % 2) q /= 2; else p /= 2; return (p) * (q); } long long PrimePi(long long n) { long long v = sq... |
#include <bits/stdc++.h> using namespace std; int n, m, ans, seq[4], d[3005][3005], MaxT[3005][3005], Max[3005][3005], row; vector<vector<int>> g; bool comp(int a, int b) { return d[row][a] > d[row][b]; } bool compT(int a, int b) { return d[a][row] > d[b][row]; } void Dijkstra(int s) { priority_queue<pa... |
#include <bits/stdc++.h> using namespace std; priority_queue<long long int, vector<long long int>, greater<long long int> > q; int main() { int n; scanf( %d , &n); long long int x, sum = 0, ans = 0; for (int i = 1; i <= n; i++) { scanf( %lld , &x); q.push(x); } while (q.size())... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 23; const int INF = 1e9 + 23; const int MOD = 1e9 + 7; struct Mada { long long x, h, p; }; Mada mada[MAX_N]; stack<Mada> Dane; int dp[MAX_N]; int n; bool cmp(Mada a, Mada b) { return a.x < b.x; } int main() { ios_base:... |
#include <bits/stdc++.h> using namespace std; char rep; void query(long long x, long long y) { cout << ? << x << << y << endl; cin >> rep; return; } void solve() { long long x = 0; long long y = 1; while (true) { query(x, y); if (rep == x ) { break; } ... |
#include <bits/stdc++.h> using namespace std; 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; } const int N = 22; const long long INF = 1LL << 60; int n, m, a[N], b[N]; long long dp[N][N], tmp[N... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 69, INF = 1e9 + 85, MOD = 1e9 + 7; int n, k, a, b, q, arr[MAXN], seg[2][MAXN << 2]; void update(int indx, int val, int type, int l = 0, int r = n, int id = 1) { if (indx < l or indx >= r) return; if (r - l == 1) { seg[type][id] =... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t{}; cin >> t; while (t--) { long long int n{}; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; bool visit[n]; ... |
#include <bits/stdc++.h> int main() { int n, p, q; scanf( %d %d %d , &n, &p, &q); char word[n + 1]; scanf( %s , word); if (n == p + q) { printf( 2 n ); for (int i = 0; i < p; ++i) { printf( %c , word[i]); } printf( n ); for (int i = p; i < n; ++i) { p... |
#include <bits/stdc++.h> using namespace std; long long int a, b, c, ans, x[4]; int main() { cin >> a >> b >> c; x[0] = a + b + c; x[1] = a + c + c + a; x[2] = b + c + c + b; x[3] = b + b + a + a; ans = x[0]; for (int i = 1; i < 4; i++) { if (ans > x[i]) ans = x[i]; } cou... |
#include <bits/stdc++.h> const int maxn = 100 + 5; using namespace std; int val[maxn][maxn]; void doit(int x1, int y1, int x2, int y2) { for (int i = x1; i <= x2; i++) { for (int j = y1; j <= y2; j++) { val[i][j]++; } } } int main() { memset(val, 0, sizeof(val)); int n; ... |
#include <bits/stdc++.h> using namespace std; template <class A, class B> inline bool mina(A &first, B second) { return (first > second) ? (first = second, 1) : 0; } template <class A, class B> inline bool maxa(A &first, B second) { return (first < second) ? (first = second, 1) : 0; } const int ... |
#include <bits/stdc++.h> const int MX = 10010896; const int lmt = 3164; const int N = 10000001; using namespace std; long long int extgcd(long long int a, long long int b, long long int& x, long long int& y) { if (b == 0) { x = 1; y = 0; return a; } else { ... |
#include <bits/stdc++.h> using namespace std; int max_height(long long n) { return (long long)(sqrt(24 * n + 1) - 1) / 6; } int main() { int t; cin >> t; while (t--) { long long n; cin >> n; int pyramids = 0; while (1) { long long height = max_height(n); if (!he... |
#include <bits/stdc++.h> const double eps = 1e-7, PI = 3.1415926; const int N = 2e5 + 10; using namespace std; long long n, q, m, k, x, y, a[N], mx = -1, mem[N][3], vis[N][3], mn = 1e9, sum, t; char c[N]; string s, s1, s2; map<int, int> mp; vector<int> vec; long lon... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int ph[N]; int main() { string s; cin >> s; int n = s.size(); for (int i = 1; i <= n; i++) ph[i] = ph[i - 1] + (s[i - 1] >= A && s[i - 1] <= Z ? 1 : 0); int ans = 1e5; for (int i = 0; i <= n; i++) { ans... |
#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; int x; cin >> x; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 0 << n ; return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(15); long long int t; cin >> t; while (t--) { string s; cin >> s; long long int x; cin >> x; long long int n = (long long int... |
#include <bits/stdc++.h> using namespace std; char buf[1 << 21], *p1 = buf, *p2 = buf; template <class T> void read(T &x) { x = 0; int c = getchar(); int flag = 0; while (c < 0 || c > 9 ) flag |= (c == - ), c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ ... |
#include <bits/stdc++.h> using LL = long long; const int N = 100000 + 5; LL D[N], H[N]; int n, m; struct Unit { int l, r; LL Lmax, Rmax, Mmax, sum; void show() { printf( l = %d,r = %d n , l, r); printf( Lmax = %I64d,Rmax = %I64d,Mmax = %I64d,sum = %I64d n , Lmax, Rmax, Mma... |
#include <bits/stdc++.h> using namespace std; void main0(); int main() { clock_t start, end; ios::sync_with_stdio(false); cin.tie(0); main0(); return 0; } const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1}; const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1}; const int N = 5e5 + 5; const int M ... |
#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; const int inf = 999999999; int n; template <typename T> struct SegTree_t { int n; vector<int> tree, A; SegTree_t(int _n) : n(_n), tree(4 * n, 0), A(4 * n, 0) {} T operation(const T &a, const T &b) { return max(a, b); } T query(int node, int l, ... |
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> ar[3001]; const long long INF = 1000000000000000; long long dp[3001][3001]; int func(int pos, int pre) { if (pos > n) return 0; if (dp[pos][pre] != -INF) return dp[pos][pre]; int x = ar[pos].second + func(pos + 1, pos); int ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6, mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, sum = 0; cin >> n; long long x; long long nm = 0; for (long long i = 0; i < n; i++) { cin >> x; nm =... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const int SINF = 0x7fffffff; const long long LINF = 0x3fffffffffffffff; const long long SLINF = 0x7fffffffffffffff; const int MAXN = 30007; const int MAXD = 6; const int MOD = 998244353; int n, d; int a[MAXN][MAXD][MAXD]; in... |
#include <bits/stdc++.h> using namespace std; int a[150005]; int main() { int n, k, q; scanf( %d %d %d , &n, &k, &q); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } multiset<int> t; for (int i = 1; i <= q; i++) { int x, y; scanf( %d %d , &x, &y); if (x == 1) {... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; const int LG = 20; int go[N][LG]; int a[N]; int last[LG]; int main() { int n, qq; scanf( %d %d , &n, &qq); for (int i = 0; i < n; i++) { scanf( %d , a + i); } for (int i = 0; i < LG; i++) { go[n][i] = n; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; long long k; cin >> k; vector<int> a(n); int i; int mx_pos = -1; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] == n) { mx_pos = i; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long d, n, m; cin >> d >> n >> m; vector<pair<long long, long long> > stations(m + 2); stations[0] = pair<long long, long long>(0, 0); for (int i = 1; i <= m; i++) { int x, y; cin >>... |
#include <bits/stdc++.h> using namespace std; const int MAX = 3e5 + 5; vector<int> ic[MAX]; vector<int> adj[MAX]; int used[MAX]; int cn; vector<int> tr; int ans[MAX]; void dfs(int s, int p) { for (int i = 0; i < ic[s].size(); i++) { int u = ic[s][i]; if (!ans[u] || used[ans[u]]) { ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const int Max = 256; const int MaxE = Max * 2; struct edge { int to; edge *s; }; edge E[MaxE], *hd[Max], *cp; int n, k, D[Max]; int mp[Max][Max]; int F[Max][Max]; int A[Max], R[Max]; void addEdge(int x, int y) { cp-... |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; int INF = 2000000000; long long INFF = 8000000000000000000LL; double PI = acos(-1); int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1}; int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1}; inline string IntToString(int a) { char x[100]; sprintf(x, %... |
#include <bits/stdc++.h> using namespace std; int main() { int n, q; scanf( %d %d , &n, &q); string s; cin >> s; int size = s.size(); int cnt = 0; for (int i = 1; i < size; i++) { if (s[i] == . && s[i] == s[i - 1]) cnt++; } while (q--) { int n1; char x; ... |
#include <bits/stdc++.h> using namespace std; int u[1005], v[1005], fa[1005], n, m, k; bool zt[1005][1005]; int getv(int x) { if (x == fa[x]) return x; fa[x] = getv(fa[x]); return fa[x]; } void merge(int x, int y) { x = getv(x); y = getv(y); if (x == y) return; if (x < y) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; long long n, m; int sol[MAXN]; void solve(int l, int r, long long k) { if (l == r) { assert(k == 1); sol[l] = n; return; } int len = r - l + 1; long long cant = (1LL << (len - 1)); if (k <= cant / 2) { ... |
#include <bits/stdc++.h> using namespace std; const double eps = 3e-5; double x, h, l; int main() { cin >> x; for (double h = 1.0; h <= (10.0 + eps); h += 1.0) { if (h + eps < x) continue; l = h / (sqrt((h * h) / (x * x) - 1)) * 2.0; for (double q = 1.0; q <= (10.0 + eps); q += 1.0) { ... |
#include <bits/stdc++.h> using namespace std; void solve(); void precalc(); int main() { string s = change me please ; int t = 1; while (t--) solve(); return 0; } void solve() { int n; cin >> n; vector<int> a(n), h(n); for (int i = 0; i < n; ++i) cin >> a[i] >> h[i]; int... |
#include <bits/stdc++.h> using namespace std; int main() { string A; cin >> A; if (A.size() > 1 and A.size() % 2 == 0) { int x = (A.size() / 2) - 1; cout << A[x]; for (int i = 1; i <= x; i++) { cout << A[x + i] << A[x - i]; } cout << A[2 * x + 1]; } else if (A.s... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 3; const long long INF = 4e18 + 3; vector<long long> v[3]; int r[3]; long long ans; auto iter1 = v[0].begin(); auto iter2 = v[1].begin(); long long X, Y; void rob(int a, int b, int c) { for (auto it : v[b]) { if (it < v[a... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int t = 1; while (t--) { long long int n; cin >> n; vector<long long int> v(n); for (long long int i = 0; i < n; i++) cin >> v[i]; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.