func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int _ = 2e2 + 20; int n; struct matrix { double a[_][_]; matrix operator*(matrix b) { matrix c; for (int i = 0; i <= n * 2; ++i) for (int j = 0; j <= n * 2; ++j) { c.a[i][j] = 0; for (int k = 0; k <= n * 2; ++k) ... |
#include <bits/stdc++.h> using namespace std; const int N = 3000010; const int inf = 1e9 + 1; int n, k, a[N], b[N]; bool check(long long x) { long long s = 0; for (int i = 1; i <= n; i++) { long long tmp = b[i] - a[i] * x; if (tmp < 0) { s -= tmp; } if (s > k) return fa... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; stack<char> stk; int cnt = 0; for (int i = s.size() - 1; i >= 0; i--) { if (stk.empty()) stk.push(s[i]); else { if (stk.top() == s[i]) { cnt++; stk.pop(); } else... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n]; for (long long i = 0; i <= n - 1; i++) cin >> a[i]; for (long long i = 0; i <= n - 1; i++) if ((a[i] % 2)) a[i] += 1; for (long long i = 0; i <= n - 1; i++) if (!(a[i] % 2)) a[i] -= 1; ... |
#include <bits/stdc++.h> using namespace std; void File_input() { freopen( in.txt , r , stdin); freopen( out.txt , w , stdout); } void FastInputOutput() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); } vector<char> geno[ z + 1]; int t, n; string str; bool vis[ z + 1]... |
#include <bits/stdc++.h> using namespace std; double distance(double x1, double y1, double x2, double y2) { return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } int main() { double ax, ay, bx, by, tx, ty; scanf( %lf%lf%lf%lf%lf%lf , &ax, &ay, &bx, &by, &tx, &ty); int n; scanf( %d , ... |
#include <bits/stdc++.h> using namespace std; struct Activity { int gym, contest; bool gym_used, contest_used; }; int main() { int n; cin >> n; vector<int> v(n); for (int &e : v) cin >> e; vector<Activity> res(n); switch (v[0]) { case 0: res[0].gym = res[0].contest ... |
#include <bits/stdc++.h> using namespace std; void solve() { int a; cin >> a; int b[a]; for (int i = 0; i < a; i++) { cin >> b[i]; } int ind = 0; for (int i = 0; i < a - 1; i++) { if (b[i] > b[i + 1]) { b[0] = b[0] - b[i] + b[i + 1]; if (b[0] < 0) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 60; const int IN = 0; const int AND = 1; const int OR = 2; const int XOR = 3; const int NOT = 4; struct Node { int val, p1, p2; int op; } node[maxn]; int n, p1, p2; string op; bool change[maxn]; int eval(int cur) { ... |
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e13 + 7LL; int reqHigh[100100], grow[100100]; int n, nDay, allow, cut; struct Tree { int id; long long finHigh, timeDie; Tree() { id = finHigh = timeDie = 0; } Tree(int id, long long x) { this->id = id; ... |
#include <bits/stdc++.h> using namespace std; const int N = 105; int n, m, grid[N][N]; int val[N][N]; bool vis[105][105]; int a[105]; int b[105]; int dp[105][105]; int tot; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %d , a + i), tot ^= a[i]; int tmp = 0; f... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char* argv[]) { char str[105]; cin.getline(str, 104); for (unsigned i = 1; i < strlen(str) + 1; i++) { if ((str[i] == str[i - 1]) && (str[i - 1] == / )) { for (unsigned j = i; j < strlen(str); j++) { str[j] = str[j... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; 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) {... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9 + 7, mod = (int)1e9 + 9, pw = 31, N = (int)1e5 + 123, M = (int)1e6 + 123; const double eps = 1e-11; const unsigned long long inf = 5e18 + 1; unsigned long long n, a, b, x, m, ans; bool check = 0; unsigned long long binpow(u... |
#include <bits/stdc++.h> const int N = 7e3 + 5; int n, k[2], a[2][N], cnt[2][N]; bool vis[2][N], win[2][N]; void dfs(int v, int now) { if (vis[v][now]) return; vis[v][now] = 1; int u = v ^ 1; for (int i = 1; i <= k[u]; ++i) { int pre = (now - a[u][i] + n - 1) % n + 1; if (pre == 1) c... |
#include <bits/stdc++.h> using namespace std; const int Z = (int)2e5 + 111; const int inf = (int)1e9 + 111; const long long llinf = (long long)1e18 + 5; const int MOD = (int)1e9 + 7; vector<long long> pref[4 * Z]; vector<int> t[4 * Z]; int a[Z]; void build(int v, int vl, int vr) { if (vl == vr) { ... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e7 + 5; const long long inf = 1e10; const long long mod = 1e9 + 7; long long n; long long a[maxN]; double f[maxN]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (long long i = 1; i <= n; i++) { cin >> a[i]... |
#include <bits/stdc++.h> using namespace std; const int M = 200000; int a[M]; vector<int> all[M]; int main() { int n, m; scanf( %d %d , &n, &m); long long init = 0; for (int i = 1; i <= m; i++) scanf( %d , &a[i]); for (int i = 2; i <= m; i++) init += abs(a[i] - a[i - 1]); for (int i = ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> ans; int power = 1; while (n > 0) { if (n % 10 > 0) { ans.push_back((n % 10) * power); } n /= 10; power *= 10; } cout << ans.size() << endl; for (auto number : an... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, q, a[N], s1[N], t1, s2[N], t2; vector<int> ans1[N], ans2[N]; bool tag[N]; inline void down(int &x, const int y) { x > y ? x = y : 0; } int main() { scanf( %d%d , &n, &q); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]); ... |
#include <bits/stdc++.h> int mod, n, a, b, good; std::set<std::pair<int, int> > set; std::pair<int, int> make_pair(int i, int j) { return {std::min(i, j), std::max(i, j)}; } int main() { scanf( %d%d , &mod, &n); for (int i = 0; i < n; i++) { scanf( %d%d , &a, &b); set.insert(make_pair(... |
#include <bits/stdc++.h> inline int read(void) { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) f = c == - ? -1 : 1, c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c & 15), c = getchar(); return x * f; } inline int getm(long long x, int mod) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y, z, d[200 + 5], nows[200 + 5], fr[200 + 5], en[200 + 5], A[200 + 5], S, T, fa[200 + 5], now, Bh, Ch, B[200 + 5], C[200 + 5], H, un, wn, ToT; struct yyy { int to, w, z; } tmp; struct ljb { int head, h[200 + 5]; yyy f[1000 + 5 ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int ans = 1; for (int i = 2; i <= n; ++i) { ans = 1LL * ans * i % M; } int two = 1; for (int i = 1; i < n; ++i) { t... |
#include <bits/stdc++.h> typedef int iarrN[100003][35]; struct IO { template <typename T> inline IO operator>>(T &n) { n = 0; char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) n = (n << 3) + (n << 1) + (c ^ 48), c = getchar(); re... |
#include <bits/stdc++.h> using namespace std; inline int read() { long long f = 1; long long x = 0; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = (x << 3) + (x << 1) + ch - 0 , ch = getchar()... |
#include <bits/stdc++.h> using namespace std; FILE *in; FILE *out; const int MAX = 131072; const int TREE = 262144; int n; int a[MAX]; int tree[TREE]; void update(int idx, int val) { idx += (TREE >> 1); while (idx) { tree[idx] = max(tree[idx], val); idx >>= 1; } } int query... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; int n, m, gx, gy, len, vis[15][15], ucs; inline bool out(int x, int y) { return x < 0 || x >= n || y < 0 || y >= m; } char s[15][15 + 1]; struct P { int x[9], y[9], step, h; P() { step = 0; } void... |
#include <bits/stdc++.h> using namespace std; int customCeil(int k, int s) { if (k % s == 0) return k / s; return k / s + 1; } int main() { long long int n; cin >> n; long long int arr[n]; for (int i = (0); i < (n); ++i) { cin >> arr[i]; } long long int m; cin >> m; ... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(0); int t; cin >> t; while (t--) { double a, b; cin >> a >> b; cout << fixed << setprecision(15); if (b == 0) { cout << 1 << endl; } else if (a == 0) { cout <<... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <bits/stdc++.h> using namespace std; const int64_t MOD = 998244353; const int64_t N = 2e5 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int64_t mpow(int64_t x, int64_t y) { if (y == 0) return 1; int64_t temp = mpow(x, y / 2); temp *= temp; temp %= MOD; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << ? << 1 << << 3 << endl; int ac; cin >> ac; cout << ? << 1 << << 2 << endl; int ab; cin >> ab; cout << ? << 2 << << 3 << endl; int bc; cin >> bc; int amc = ab - bc;... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define srt(s) sort(s.begin(),s.end()) int main() { ll t; cin>>t; while(t--) { ll n; cin>>n; string s; cin>>s; ll x=0; ll p=0,p1=0; ll mark=0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int f, x; cin >> f; x = f + 1; if (f == 0) { f = 0; } else if (x % 2 == 0) { f = x / 2; } else { f++; } cout << f << end... |
#include <bits/stdc++.h> template <class T1, class T2> inline bool cmin(T1 &a, const T2 &b) { return b < a ? (a = b, true) : false; } template <class T1, class T2> inline bool cmax(T1 &a, const T2 &b) { return a < b ? (a = b, true) : false; } template <class Type> Type read() { Type a; b... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { long long a, b, ans; cin >> a >> b; long long x; x = min(a, b); ans = max(max(a, b), 2 * x); cout << ans * ans << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; long long int modpow(long long int a, long long int n, long long int temp) { long long int res = 1; while (n > 0) { res = (res * res) % temp; if (n & 1) res = (res * a) % temp; n /= 2; } return res; } long long int gcd(long long int... |
#include <bits/stdc++.h> using namespace std; long long int pi = 10000000; vector<long long int> prime(pi), pri; void seive() { long long int i, j, k, l; for (i = 4; i <= pi; i += 2) prime[i] = 1; pri.push_back(2); for (i = 3; i <= pi; i += 2) { if (prime[i] == 0) pri.push_back(i); f... |
#include <bits/stdc++.h> using namespace std; string s[70010]; map<pair<int, int>, int> m; pair<int, int> ans[70010]; int main() { int k = 64, p = 5; int n, i, j, l; cin >> n; for (i = 1; i <= n; i++) cin >> s[i]; for (i = 1; i <= n; i++) for (j = 0; j < 9; j++) { int x = 0; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 10; int f[MAX_N], g[MAX_N], h[MAX_N], pos[MAX_N]; vector<int> adj[MAX_N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int m = 0; for (int i = 1; i <= n; i++) { cin >> f[i]; ... |
#include <bits/stdc++.h> using namespace std; int a, b, xa, ya, xb, yb; int main() { scanf( %d%d%d%d%d%d , &a, &b, &xa, &ya, &xb, &yb); a <<= 1, b <<= 1; int x1 = (xa + ya), y1 = (xa - ya), x2 = (xb + yb), y2 = (xb - yb); int sector_1_x = (x1 / a) - (x1 < 0), sector_1_y = (y1 / b) - (y1 < 0); ... |
#include <bits/stdc++.h> using namespace std; long long M, n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long ttttt = 1; while (ttttt--) { cin >> M >> n; long long a[n], ans[n]; cin >> a[0]; long long ok = -1; if (a[0] <= M * -1) ok =... |
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void ipgraph(int m); void dfs(int u, int par); const int mod = 1000000007; const int N = 1e6, M = N; const int LN = 1e9; long long dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; using namespace std; long long gcd(long long a... |
#include <bits/stdc++.h> using namespace std; int const MOD = 1000000007; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int f[42], when[42]; int main() { int n, k; scanf( %d%d , &n, &k); int s = 1; int c = getchar(); while (c <= 32) { c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int l, d, v, g, r, tmu; double tm, tmod; scanf( %d%d%d%d%d , &l, &d, &v, &g, &r); tmu = (int)((long double)(d / v) / (g + r)); tmod = (double)d / v - tmu * (g + r); if (tmod < g) tm = (double)l / v; else tm = (double)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; cin >> n >> m; int l = 0, r = n + 1; string s, s1; for (int i = 0; i < m; i++) { cin >> s >> s >> s1 >> s >> a; if (s1[0] == r ) l = max(l, a); else r = min(a, r); } int ans = r - l... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; cin >> n >> x >> y; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { int j = i - x; int k = i + y; if (j < 0) j = 0; if (k > n - 1) k = n - 1; int min = INT_MAX, ... |
#include <bits/stdc++.h> using namespace std; void reverseStr(string& str) { int n = str.length(); for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]); } int main() { string str, str1; cin >> str; cin >> str1; reverseStr(str); if (str == str1) { cout << YES << endl; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; void solve() { long long n, m; cin >> n >> m; vector<long long> out(n); long long leafs = n; for (long long i = 0; i < m; ++i) { long long x, y; cin >> x >> y; --x; --y; if (x > y) swap(x,... |
#include <bits/stdc++.h> using namespace std; vector<int> graph[3010]; int cycle[3010]; int cycle_size; bool visited[3010]; bool found_cycle; int dist[3010]; int b, e; void dfs(int node, int father, int c) { if (found_cycle) return; visited[node] = true; for (int i = 0; i < graph[node].siz... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int N = 2e5 + 10; int T, n, a[N], vis[N], d[N], mi, mx; signed main() { cin >> T; while (T--) { cin >> n; mi = 0x3f3f3f3f, mx = -999; for (int i = 1; i <= n; i++) scanf( %d , &a[i]), vis[a[i]] = i; for ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const int MOD = INF + 7; const int XD = 100100; int facts[XD << 1]; void calcFacts(int n) { facts[0] = 1; for (int i = 1; i <= n; ++i) { facts[i] = 1LL * facts[i - 1] * i % MOD; } } int exgcd(int a, int b... |
#include <bits/stdc++.h> using namespace std; int a[200][200], ans, n; bool flag = true; int main() { ios::sync_with_stdio(false); cin >> a[80][80] >> n; while (flag) { flag = false; for (int i = 1; i < 160; i++) for (int j = 1; j < 160; j++) if (a[i][j] >= 4) { ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, m, k; cin >> n >> m >> k; vector<long long int> ans; if (k > 1) { long long int last = 0; for (long long int i = 0; i < k; i++) { ans.push_back(0); } last = n - 1; for (long long int ... |
#include <bits/stdc++.h> using namespace std; vector<int> v[150005]; int Size[150005]; int forbid[150005]; int val[150005]; vector<int> stk; void dfs(int first, int f) { Size[first] = 1; stk.push_back(first); for (auto it : v[first]) { if (it != f && !forbid[it]) { dfs(it, first)... |
#include <bits/stdc++.h> int a, b, c, d, n; char s[4 << 20]; void output() { for (int i = 0; i < n; ++i) if (s[i] == 4 ) a--; else b--; for (int i = 0; i < n; ++i) if (s[i] == 4 ) { while (a) { printf( 4 ); a--; } printf( 4 );... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; const int inf = 0x3f3f3f3f; int n, m; long long ans; long long b[maxn], g[maxn]; bool cmp(int a, int b) { return a > b; } int main() { long long bmx = 0; int flag = 1, cnt = 0; scanf( %d%d , &n, &m); for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n * 2]; for (int i = 0; i < n * 2; i++) { cin >> a[i]; } int room = 0; for (int i = 0; i < n * 2; i++) { if (i % 2 == 0) { if (a[i + 1] - a[i] >= 2) { room++; } }... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int m, n; scanf( %d %d , &m, &n); if (m % n == 0) printf( YES n ); else printf( NO n ); } } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s = ; int f[n]; f[0] = 1, f[1] = 1; if (n > 1 && n < 5) { for (int i = 2; i < 2 * n; i++) f[i] = f[i - 2] + f[i - 1]; int g = 1, k = 0; while (g <= n) { for (int j = 0; j < 2 * n; j... |
#include <bits/stdc++.h> using namespace std; bool check(long long int arr1[], long long int arr2[], long long int m, long long int n) { sort(arr1, arr1 + n); sort(arr2, arr2 + m); for (int i = 0; i < n; i++) if (arr1[i] != arr2[i]) return false; return true; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 10; int read() { int xx = 0, ww = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) ww = -ww; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { xx = 10 * xx + ch - 48; ch = getchar(... |
#include <bits/stdc++.h> using namespace std; int n, m, l, r, x, ans[300300], tree[4 * 300300]; void build(int node, int st, int en) { if (st == en) { tree[node] = 1; return; } build((node << 1), st, (st + en) / 2); build((node << 1) + 1, ((st + en) / 2) + 1, en); tree[node] = tree... |
#include <bits/stdc++.h> struct Nodo { int a; int sgte; } Nodo[100100]; long long aux[50010][510]; long long int cont; int dir[50001]; int n, k; void agregar(int x, int y, int c); void busqueda(int fa, int u); int main() { int x, y, i, t, cargado = 0; scanf( %d %d , &n, &k); for (t... |
#include <bits/stdc++.h> using namespace std; long long k; long long maxi = 0, mini = 0; vector<long long> v[200001]; long long dp[200001]; unordered_map<long long, unordered_map<long long, long long> > dis; long long f(long long parent) { if (dp[parent] > 0) return dp[parent]; dp[parent] = -1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int arr[1009]; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &arr[i]); int x1, y1, x2, y2; for (int i = 0; i < n - 1; i++) { x1 = min(arr[i], arr[i + 1]); y1 = max(arr[i], arr[i + 1]); for (int j =... |
#include <bits/stdc++.h> int a[4 * 4]; int n, n2; std::map<int, int> sums[4 + 1]; void gens(int p, int cnt, int sum, std::map<int, int>& s) { if (cnt == 0) { std::map<int, int>::iterator it = s.find(sum); if (it == s.end()) s[sum] = 1; else ++it->second; return; }... |
#include <bits/stdc++.h> using namespace std; long long bin_pow(long long x, long long y, long long m) { long long ans; if (y <= 0) return 1; ans = bin_pow(x, y / 2, m); if (y % 2 == 0) return (((ans % m) * (ans % m)) % m); return (x % m * ((ans % m * ans % m))) % m; } long long mult(long lo... |
#include <bits/stdc++.h> int num[10000]; int map[2000][2000]; int add(int a, int b, int c) { map[a][b] = 1, map[b][a] = 1; } int vis[2000][2]; int main() { int n; while (scanf( %d , &n) != EOF) { memset(map, 0, sizeof(map)); memset(vis, 0, sizeof(vis)); int i, j; int len = 0; ... |
#include <bits/stdc++.h> using namespace std; int del(int n) { double q = n; if (n % 2 == 0) return 2; for (int i = 3; i < sqrt(q) + 1; i = i + 2) { if (n % i == 0) return i; } return 1; } int main() { int n; cin >> n; long int s; s = n; int de = n; while (n != ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, m; cin >> n >> m; if (m == 0) { cout << 0; return 0; } vector<vector<long long int>> v[n + 1]; long long int in[n + 1]; memset(in, 0, sizeof(in)); for (long long int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(false); cin.tie(nullptr); long long int n; cin >> n; bool prime = true; for (long long int i = 2; i < n && i < 101010; ++i) { if (n % i == 0) { prime = false; } } if (prime) { cou... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 13, M = 1e5 + 13; inline int qread() { int res = 0, flag = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) flag = -1; c = getchar(); } while (isdigit(c)) res = res * 10 + (c - 0 ), c = getchar(); retu... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; void manupulate(string &str) { for (long long int i = 0; i < str.size(); ++i) str[i] -= 48; } bool isprime(long long int n) { if (n <= 1) return false; for (long long int i = 2; i * i <= n; ++i) if (n % i == 0) retur... |
#include <bits/stdc++.h> using namespace std; template <class T> string i2s(T x) { ostringstream o; o << x; return o.str(); } int n, wt[100001], root; bool visited[100001]; pair<long long, long long> mem[100001]; vector<int> adj[100001]; pair<long long, long long> go(int u) { if (visit... |
#include <bits/stdc++.h> using namespace std; const int iINF = 0x3f3f3f3f; const long long lINF = 0x3f3f3f3f3f3f3f3f; inline void read(long long& x) { int f = 1; char c; while (((c = getchar()) < 0 || c > 9 ) && c != - ) ; c == - ? (f = -1, x = 0) : (x = c - 0 ); while ((c = get... |
#include <bits/stdc++.h> using namespace std; double dot(complex<double> a, complex<double> b) { return real(conj(a) * b); } double calcspeed(complex<double> p1, complex<double> p2, complex<double> w, double vmax) { complex<double> r = p2 - p1; double k = dot(r, w) + sqrt(pow(do... |
#include <bits/stdc++.h> using namespace std; const int M = 1e6 + 5, P = 1e9 + 7; long long n, k, m, res, l, T, ans, mi; int dp[2][M], A[M], B[M], sum[M]; int main() { cin >> n >> l >> k; for (int i = 1; i <= n; i++) { scanf( %d , A + i); B[i] = A[i]; } sort(B + 1, B + 1 + n); ... |
#include <bits/stdc++.h> using namespace std; int N, M[55][55], C[55]; int main() { cin >> N; for (int i = 1; i <= N * (N - 1) / 2 - 1; ++i) { int a, b; cin >> a >> b; M[a][b] = M[b][a] = 1; C[a]++; } for (int i = 1; i <= N; ++i) for (int j = i + 1; j <= N; ++j) ... |
#include <bits/stdc++.h> using namespace std; struct line { int x, l; } c[105]; bool cmp(line a, line b) { return a.x < b.x; } int f[105][105][2]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d%d , &c[i].x, &c[i].l); sort(c + 1, c + n + 1, cmp); c[0].x = ... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; vector<string> nums(n); for (int i = 0; i < (int)(n); ++i) cin >> nums[i]; vector<long long> c(m, 1); for (int i = 0; i < (int)(m); ++i) { for (int j = 0; j < (int)(i); ++j) { int match = 1; ... |
#include <bits/stdc++.h> using namespace std; vector<bool> visited; vector<vector<long long> > adj; vector<vector<long long> > rev; vector<long long> order; vector<char> col; void dfs1(long long x) { visited[x] = true; for (auto y : adj[x]) { if (!visited[y]) dfs1(y); } order.push_ba... |
#include <bits/stdc++.h> using namespace std; char s[5000001]; int dp[5000000]; int main() { gets(s); unsigned long long a = 0, l = 0, r = 0, t = 1; for (int i = 0; s[i]; i++) { l = (l * 109) + s[i]; r = r + s[i] * t; t *= 109; if (l == r) dp[i + 1] = dp[(i + 1) / 2] + 1; ... |
#include <bits/stdc++.h> using namespace std; long long MAX = 1000000000; long long MOD = 1000000007; pair<long long, long long> p[100010]; void solve() { long long n; cin >> n; long long d; cin >> d; ; for (long long i = (0); i < (n); i++) { long long in1; cin >> in1; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[100]; for (int i = 0; i < n; i++) cin >> a[i]; int num[101] = {0}; for (int i = 0; i < n; i++) num[a[i]]++; int cnt = 0; for (int i = 1; i <= 100; i++) cnt += num[i] / 2; cout << cnt / 2 << endl; ... |
#include <bits/stdc++.h> using namespace std; int n, i, poz, p[250]; double t, v[250], m[250], x[250], aux, mint, tempv1, tempv2; bool fcomp(int a, int b) { return x[a] < x[b]; } int main() { scanf( %d , &n); scanf( %lf , &t); for (i = 1; i <= n; ++i) scanf( %lf , &x[i]), scanf( %lf , &v[i])... |
#include <bits/stdc++.h> const long long mod = 1e6 + 3; using namespace std; int g = 0; int vis[10]; int a[100005]; int main() { int n; cin >> n; set<int> s; for (int i = 1; i <= n; i++) scanf( %d , a + i), s.insert(a[i]); int p = s.size(); if (p <= 3) { if (p == 1) { p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long k; cin >> k; long long arr[n + 1]; for (long long i = 1; i <= n; i++) { cin >> arr[i]; } set<long long> s; for (long long i =... |
#include <bits/stdc++.h> using namespace std; int n, curbest; int ans[5005], t[5005]; int cnt[5005]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> t[i]; for (int i = 1; i <= n; i++) { curbest = 0; memset(cnt, 0, sizeof cnt); for (int j = i; j <= n; j++) { cnt... |
#include <bits/stdc++.h> using namespace std; int mark[100005]; long long msum[100005]; long long sum[100005]; int c[100005]; long long cs; int main() { long long ans = 0; int i, n, m, x; scanf( %d%d , &n, &m); for (i = 1; i <= n; ++i) scanf( %d , &c[i]); for (i = 1; i <= m; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 103; const int mod = 1e9 + 7; char s[N]; long long g[N], f[N][N][N]; long long qpow(long long a, long long n) { long long ret = 1; while (n) { if (n & 1) ret = ret * a % mod; a = a * a % mod; n >>= 1; } return ret;... |
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, k = 0, i = 0, j = 0; char str[100]; cin >> n >> k; cin >> str; if (k <= n - k) { for (i = 1; i < k; i++) { cout << LEFT << endl; } for (i = 0; i < strlen(str) - 1; i++) { cout << PRINT <<... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6; const int INF = 1e9; const long long linf = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1.0); long long mod = 1e9 + 7; int main() { int n, a; cin >> n >> a; cout << 2 << << 1 << << max(3, min(n, ((n * a + 90) / 180 + 2... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; bool is_prime(long long n) { for (long long i = 2; i * i <= n; ++i) { if (n % i == 0) { return false; } } return true; } vector<long long>... |
#include <bits/stdc++.h> using namespace std; int main() { char a[1000000], b[1000000]; int n; cin >> n >> a; int l = strlen(a); for (int i = 1; i < n; i++) { cin >> b; for (int j = 0; j < l; j++) { if (a[j] == ? ) a[j] = b[j]; else if (b[j] == ? ) ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1000006; int rnk[MAX], parent[MAX], ans[MAX], arr[MAX]; vector<int> comp[MAX]; priority_queue<int> q[MAX]; int find(int x) { if (x == parent[x]) return x; return parent[x] = find(parent[x]); } void merge(int x, int y) { x = find(x... |
#include <bits/stdc++.h> bool office[25][25]; size_t m, n; bool check(size_t x1, size_t y1, size_t x2, size_t y2) { for (size_t x = x1; x <= x2; ++x) { for (size_t y = y1; y <= y2; ++y) { if (office[x][y]) { return false; } } } return true; } bool check(size_t... |
#include <bits/stdc++.h> using namespace std; int a[111111], b[111111], c[111111]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { b[i] = min(a[i], min(b[i - 1] + 1, i)); } reverse(a + 1, a + n + 1); for (int i ... |
#include <bits/stdc++.h> using namespace std; int n; vector<string> s; string ans(200, ); set<string> Set; vector<string> cand; int main() { cin >> n; ans.resize(2 * n - 2); for (int i = 0; i < 2 * n - 2; ++i) { string a; cin >> a; Set.insert(a); s.push_back(a); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.