func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 100005; char s[45][20] = { Washington , Adams , Jefferson , Madison , Monroe , Adams , Jackson , Van Buren , Harrison , Tyler , Polk , Taylor , Fillmore , Pierce , Buchanan , Lincoln ,... |
#include <bits/stdc++.h> using namespace std; template <class T> bool setmax(T &_a, T _b) { if (_b > _a) { _a = _b; return true; } return false; } template <class T> bool setmin(T &_a, T _b) { if (_b < _a) { _a = _b; return true; } return false; } template... |
#include <bits/stdc++.h> using namespace std; const long long int OO = 2e7; const double EPS = (1e-7); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } bool sort_p(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } int main() { ios_base::sync_with_stdio(0);... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int n, m; bool used[MAXN]; set<int> graph[MAXN]; stack<int> path; vector<int> cycle; int fake; vector<pair<int, int> > edges; vector<pair<int, int> > answer; void EulerCycle(int x) { cycle.clear(); edges.clear(); p... |
#include <bits/stdc++.h> using namespace std; int a, b, maxa; void use_battery(int s) { if (s == 1) a = min(a + 1, maxa); --b; } void use_accum() { --a; } int main() { int ans = 0; int n; cin >> n >> b >> a; maxa = a; vector<int> s(n); for (int i = 0; i < n; i++) cin >> s[i];... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int a[k]; for (auto &it : a) cin >> it; sort(a, a + k, greater<int>()); int declined = max(a[0], 25) - 25; cout << declined; } |
#include <bits/stdc++.h> using namespace std; int d[1000001] = {0}; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0, a, b; i < m; ++i) scanf( %d%d , &a, &b), d[a]++, d[b]++; long long ans = 0; for (int i = 1; i <= n; ++i) { long long de = d[i], ade = n - 1 - de; ans +=... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[200]; int n, x; vector<pair<int, int> > res; int main() { int sum = 0; cin >> n; cin >> a[0].first; a[0].second = 0; sum += a[0].first; for (int i = 1; i < n; i++) { cin >> a[i].first; a[i].second = i; sum... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int m, x, y, a, b; cin >> x >> y >> a >> b; m = abs(x - a) + abs(y - b); if (x != a && y != b) m = m + 2; cout << m << n ; } } |
#include <bits/stdc++.h> #pragma GCC optimize( 03 ) using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char... |
#include <bits/stdc++.h> int main() { int M, N, d; scanf( %d %d , &M, &N); d = (M * N) / 2; printf( %d , d); return 0; } |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 1000000; const int OPAND = 2, OPOR = 3, OPXOR = 4, OPNOT = 5; int n; int op[MAXN]; vector<int> ch[MAXN]; int res[MAXN]; int ans[MAXN]; int dfsres(int at) { if (op[at] == 0 ... |
#include <bits/stdc++.h> using namespace std; long long tab[12], pr[12]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q; cin >> q; long long n, m, w, x; for (int z = 0; z < q; z++) { cin >> n >> m; x = 1; for (long long i = 1; i <= 11; i++) ... |
#include <bits/stdc++.h> using namespace std; int ar[30005]; int diff[30005]; int main() { int t; cin >> t; while (t--) { string ans = YES ; int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[i]; diff[i] = 0; } for (int i = 2; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = 0; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return f ? ... |
#include <bits/stdc++.h> using namespace std; long long modex(long long a, long long p, long long m) { if (!p) return 1; if (p & 1) return a * modex(a, p - 1, m) % m; long long v = modex(a, p >> 1, m); return v * v % m; } namespace fft { struct cpx { double r, i; cpx(double r = 0, doub... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; long long int r = power(a, b / 2) % 1000000007; if (b % 2 == 0) return (r * r) % 1000000007; else return (((r * r) % 1000000007) * a) % 10... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; struct point { int x, y; point() {} point(int x, int y) : x(x), y(y) {} point operator-(point a) { return point(x - a.x, y - a.y); } bool operator<(const point& a) const { return x == a.x ? y < a.y : x < a.x; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 35, L = 10005; int T, k, i, j, n, m; int a[2][N], b[N * 2], bb[N * 2]; char cc[5], ans[L], *ass, out[26][L], *pp[26]; inline void getseq() { int xb = 0; for (j = 0; j < n; ++j) if (a[0][j]) b[xb++] = a[0][j]; for (j = n - 1; j >= ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using pll = pair<ll, ll>; const int N = 100010; int m, n, q[N], a[N]; int main() { scanf( %d , &m); for (int i = 0; i < m; i++) scanf( %d , &q[i]); scanf( %d , &n); for (int i = 0; i < n; i++) sc... |
#include <bits/stdc++.h> using namespace std; int main() { int n, tc; cin >> tc; while (tc-- != 0) { cin >> n; if (n & 1) { cout << 7 ; for (int i = 1; i < n / 2; i++) { cout << 1 ; } } else { for (int i = 1; i <= n / 2; i++) { cout... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5, inf = 1e9 + 7; long long n, k, i, j; long long A[N], l[N], r[N], len[N]; set<pair<long long, long long> > st; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long i, j, a, b, ans = 0, cur; cin >> n;... |
#include <bits/stdc++.h> using namespace std; struct M { int t, x[4]; M(int s, int a, int b, int c, int d = 0) { t = s; x[0] = a; x[1] = b; x[2] = c; x[3] = d; } void p() { printf( %d , t); for (int i = 0; i < (int)(t); ++i) printf( %d , x[i]); printf... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios_base ::sync_with_stdio(false), cin.tie(NULL); int test; cin >> test; while (test--) { int n, k; string s; cin >> s; int a = 1, poss = true; while (poss) { poss = false; ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int mid = 0; int num = 0; int e[21][21]; int flag[21]; void dfs(int x, int sum) { if (x > n) { num = num + 1; return; } dfs(x + 1, sum); for (int y = 1; y <= n; y++) { if (num > k) { break; } i... |
#include <bits/stdc++.h> using namespace std; int main() { double a1, a2; double b1, b2; double c1, c2; cin >> a1 >> b1 >> c1; cin >> a2 >> b2 >> c2; if (fabs(a1) < 1e-14 && fabs(b1) < 1e-14 && fabs(c1) > 1e-14 || fabs(a2) < 1e-14 && fabs(b2) < 1e-14 && fabs(c2) > 1e-14) { cout... |
#include <bits/stdc++.h> using namespace std; int n, a[12], b[20], c[5], u[15], vs, hh; string v[2033333]; void add(int o, int s, int k) { if (s > k) return; if (o == 4) { if (k - s > 2) return; if (k - s && b[s] == 0) return; if (k - s == 2 && b[s] * 100 + b[s + 1] * 10 + b[k] >= 256)... |
#include <bits/stdc++.h> using namespace std; bool win(long long A, long long B) { if (A == 0 || B == 0) return false; if (A > B) swap(A, B); if (!win(A, B % A)) return true; long long N = B / A; long long MOD = A + 1; return ((N % MOD) % 2 == 0); } int main(void) { int T, t; lon... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int *b = new int[n]; int max_val = 0; for (int i = 0; i < n; i++) { cin >> b[i]; if (i == 0) { } else if (i == 1) { b[i] = b[0] + b[1]; max_val = (b[0] > b[1]) ? b[0] : b[1]; } els... |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 1; cin >> n; int x[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n - 1; i++) { if (x[i] != x[i + 1]) { cnt++; } } cout << cnt << endl; return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const long long mod = 1e9 + 7; const long long maxn = 1e5 + 10; long long n, x, y; long long money[maxn]; pair<long long, long long> show[maxn]; multiset<pair<long long, long long> > s; inline long long read() { long long x = 0,... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 9; long long Pow(long long a, long long x) { long long res = 1; while (x) { if (x & 1) res = res * a % mod; a = a * a % mod; x >>= 1; } return res; } long long inv(long long a) { return Pow(a, mod - 2);... |
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T pow(T a, T b, long long m) { T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; ... |
#include <bits/stdc++.h> using namespace std; multiset<long long> mset; void add(long long k) { mset.insert(k); } long long getmin() { return *mset.begin(); } long long getmax() { return *prev(mset.end()); } long long lower(long long k) { if (mset.size() == 0) return -1; if (k < getmin()) return -1;... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5, maxl = 20; bool mark[maxn]; long long sum = 0, cmp, d[maxn]; pair<long long, long long> par[maxn][maxl]; vector<pair<long long, long long> > adj[maxn]; struct Type_Dsu { long long par[maxn], h[maxn]; void make_set(long long ... |
#include <bits/stdc++.h> size_t solve(const std::vector<std::string>& c) { const size_t n = c.size(); size_t count = 0; for (size_t i = 0; i < n; ++i) { for (size_t j = 0; j < n; ++j) { for (size_t k = j + 1; k < n; ++k) { if (c[i][j] == C && c[i][k] == C ) ++count; if... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int main() { vector<int> goh_nakhor[maxn]; int n, k, ans = 0; cin >> n >> k; for (int i = 0; i < k; i++) { int num, tmp; cin >> num >> tmp; if (tmp != 1) ans += num - 1; for (int i = 0; i < num - 1; i++) { ... |
#include <bits/stdc++.h> using namespace std; int n; char color[16]; int r[16], b[16]; int redCount[1 << 16], blueCount[1 << 16]; int dp[1 << 16][2][257]; int calc(int mask, bool noRed, int other) { other = min(other, n * n); if (dp[mask][noRed][other] != -1) return dp[mask][noRed][other]; if ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; struct segment_change { int to_add; segment_change(int _to_add = 0) : to_add(_to_add) {} void reset() { to_add = 0; } bool has_change() const { return to_add != 0; } segment_change combine(const segment_change &other) const... |
#include <bits/stdc++.h> using namespace std; int c1, c2, c3, c4, n, m; int rs1, rs2, rs3, rs4, rs; int a, b; int main() { ios_base::sync_with_stdio(0); ; cin.tie(0); ; cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a; rs1 += min(a * c... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int MOD = 1000000007; const int INF = 0x3f3f3f3f; void add(int &x, int y) { x += y; if (x >= MOD) x -= MOD; } int n, h[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &h[i]); ... |
#include <bits/stdc++.h> inline long long int min(long long int a, long long int b) { return (a < b) ? a : b; } long long int dp[303][303], cost[303][303]; int main() { int n, m, k, o, j, i; scanf( %d %d %d , &n, &m, &o); for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) dp[i][j] = cost[i]... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; const long long inf = 1ll << 60; const long long iinf = 2147483647; const long long mod = 998244353; const long long maxn = 1e3 + 5; long long pw(long long x, long long p) { long long ret = 1; while (p > 0)... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; deque<int> items; int tmp; for (int i = 0; i < k; i++) { cin >> tmp; items.push_back(tmp); } int ans = 0; for (int i = 0; i < n * m; i++) { cin >> tmp; for (int j = 0; ... |
#include <bits/stdc++.h> using namespace std; const unsigned long long x = 31; unsigned long long X[60000]; int Ql[20], Qr[20]; char str[60000], s[60000]; int N; map<unsigned long long, int> T[20]; map<unsigned long long, bool> A; void add(int index, unsigned long long H) { T[index][H] = T[index][H] +... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; scanf( %d , &n); for (i = 1; i <= (n / 2); i++) { if (i & 1) cout << ab ; else cout << ba ; } int k = n / 2; if (n & 1) { if ((k) % 2 == 0) printf( a ); else printf(... |
#include<bits/stdc++.h> using namespace std; int main(){ int t,n,x; set<int> notes; cin>>t; while(t--){ cin>>n; notes.clear(); for(int i=0;i<n;i++){ cin>>x; if(notes.find(x)==notes.end()){ notes.insert(x); }else{ notes.insert(x+1); } } cout<<notes.s... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 7; struct node { long long l, r, i; }; bool cmp(node &a, node &b) { return a.l < b.l; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; t = 1; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const double eps = 1e-9; const int inf = 1e9; int deg[N]; int main() { int t; scanf( %d , &t); while (t--) { int n, x; scanf( %d%d , &n, &x); for (int i = 0; i < n + 10; i++) deg[i] = 0; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << YES n ; for (int i = 1; i <= n; i++) { int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; cout << (2 * ((x1 % 2 + 2) % 2) + (y1 % 2 + 2) % 2) + 1 << n ; } } |
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < 0 || ch > 9 ) && ch != - ) ; if (ch == - ) { int s = 0; while (ch = getchar(), ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 ; return -s; } int s = ch - 0 ; while (ch ... |
#include <bits/stdc++.h> int sm(int a, int b) { if (a % b == 0) return b; else return a % b; } int main() { int n, m, s; scanf( %d%d%d , &n, &m, &s); printf( %I64d , (long long)sm(n, s) * sm(m, s) * ((n - 1) / s + 1) * ((m - 1) / s + 1)); } |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17 + 9; long long n, m; vector<int> num; long long dp[100009][2]; void solve(int tp) { multiset<int> s; multiset<int>::iterator it; if (tp == 0) { for (long long i = 1; i < (m + 1); ++i) { s.insert(num[i]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; pair<int, int> a[n]; for (i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a, a + n); int ans = a[0].first / max(a[0].second - 1, n - a[0].second); for (i = 1; i < n - 1; i++... |
#include <bits/stdc++.h> using namespace std; class substr { public: string str; int id; bool operator<(const substr &a) const { return str > a.str; } }; priority_queue<substr> Q; int main() { string s; int k, n; cin >> s >> k; n = s.length(); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; double dp[1 << 20][20], p[20][20]; bool mark[1 << 20][20]; int n; double mem(int mask, int winner) { if (!mask) return (winner == 1); if (mark[mask][winner]) return dp[mask][winner]; mark[mask][winner] = true; double &ret = dp[mask][winner]; fo... |
#include <bits/stdc++.h> using namespace std; const int inf = int(1e9) + 7; int main() { ios::sync_with_stdio(false); ios_base::sync_with_stdio(false); long long n, m; cin >> n >> m; vector<long long> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } if (n >= 1001) { c... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int dp[100005]; vector<int> t; vector<pair<int, int> > p; int r, n; cin >> r >> n; t.push_back(0); p.push_back(make_pair(1, 1)); for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 10005; void solve() { string s; cin >> s; int n = s.size(); s = a + s; set<int> one, zero; vector<int> ans[n]; for (int i = 0; i < n; i++) zero.insert(i); for (int i = 1; i <= n; i++) { if (s[i] == 0 ) { i... |
#include <bits/stdc++.h> using namespace std; int a[3010], id[3010], num[3010]; vector<int> ans; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } int m; scanf( %d , &m); int need = n - m; while (true) { int tot = 0; memse... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int fl = 1; cin >> s; for (int i = 0; i < s.size(); ++i) { if (s[i] == 1 || s[i] == 2 ) fl = 0; else if (s[i] == 3 && s[s.size() - i - 1] != 3 ) fl = 0; else if (s[i] == 7 && s[s.size() - i... |
#include <bits/stdc++.h> using namespace std; bool debug; const int inf = 1e9 + 5; const int nax = 205; int k; namespace MinCost { struct Edge { int w, c, v, rev; Edge(int _w, int _c, int _v, int _rev) : w(_w), c(_c), v(_v), rev(_rev) {} }; int odl[nax], pot[nax], pop[nax], pop_kraw[nax]; ve... |
#include <bits/stdc++.h> using namespace std; int num[10]; int main(void) { int T, n; scanf( %d , &T); while (T--) { memset(num, 0, sizeof(num)); scanf( %d , &n); num[1] = n / 2; if (n & 01) { printf( 7 ); for (int i = 1; i < num[1]; ++i) printf( 1 ); } el... |
#include <bits/stdc++.h> using namespace std; int tree[2000005] = {0}, num[500005] = {0}, dp[500005] = {1}; void modify(int index, int l, int r, int ql, int qr, int v) { if (ql <= l && qr >= r) { tree[index] = v; return; } int mid = (l + r) >> 1; if (ql <= mid && qr >= l) modify(index ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; long long res = 0; cin >> n >> m >> k; map<int, long long> dp; bool arr[n + 1], s[m + 1]; for (int i = 0; i < n; i++) cin >> arr[i]; arr[n] = 0; for (int i = 0; i < m; i++) cin >> s[i]; s[m] = 0; int ones... |
#include <bits/stdc++.h> using namespace std; string s; int n; signed main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s; vector<pair<int, int>> a; vector<int> p(n, 0), nxt(n, 0); stack<pair<int, int>> S; S.push({0, -1}); for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; set<int> S; void dfs(int Cur, int dgt, int x, int y) { if (dgt == 11) return; if (Cur > 0) S.insert(Cur); dfs(Cur * 10 + x, dgt + 1, x, y); dfs(Cur * 10 + y, dgt + 1, x, y); return; } int main() { int n, Ans = 0; cin >> n; S.insert(... |
#include <bits/stdc++.h> using namespace std; bool deb_mode = 0; class debugger { vector<string> vars; public: template <typename T> debugger &operator,(const T v) { stringstream ss; ss << v, vars.push_back(ss.str()); return *this; } void printall() { int j = 0, l... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf( %d , &n) != EOF) { for (int i = 0; i <= n; i++) { int space = (n - i) * 2; for (int j = 0; j < space; j++) printf( ); if (!i) printf( %d n , 0); else { for (int j = 0; ... |
#include <bits/stdc++.h> using namespace std; int n, l, r, x, y, o, e, w, z, b[50000], aa, bb, ans; vector<int> vec; map<int, int> ma; int main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> l >> r >> x >> y; if (y % x != 0) { cout << 0 << endl; return 0... |
#include<bits/stdc++.h> using namespace std; #define ll long long int main() { ll k,l,r,t,x,y; cin>>k>>l>>r>>t>>x>>y; if(k<l || k>r) { cout<< No <<endl; return 0; } if(x>y) { if(k+y>r) k-=x; t--; if(k<l) return cout<< No <<endl,0; if((k-l)/(x-y) < t ) { cout... |
#include <bits/stdc++.h> using namespace std; const int N = (int)3e5 + 99; const long long INF = (long long)1e18 + 100; int a[N]; int b[N]; long long dp[N][3]; int n; long long calc(long long add, long long pos) { long long &res = dp[pos][add]; if (res != -1) return res; res = INF; if (p... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) { if (s[i] == + ) { cnt++; } else if (s[i] == - && cnt) { cnt--; } } cout << cnt << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; bool judge(int key) { for (int i = 2; i * i <= key; i++) { if (key % i == 0) return false; } return true; } int main() { int n; scanf( %d , &n); if (n & 1 || n == 2) { if (judge(n)) printf( 1 n ); else if (judge(n - ... |
#include <bits/stdc++.h> using namespace std; vector<int> v[3001]; int size1[3001]; map<vector<int>, int> mm; long dis[3001][3001]; void dijkstra(int n) { priority_queue<vector<int>> pq; vector<int> p(3, 0), p1(3); p[0] = 0; p[2] = 1; pq.push(p); long size = 1; while (size) { ... |
#include <bits/stdc++.h> using namespace std; int t, a[2000 + 10][2000 + 10], ans[2000 + 10][2000 + 10], viz[30]; pair<int, int> fs[30], ls[30]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int n, m, l = 0; pair<int, int> aux = {... |
#include <bits/stdc++.h> const int N = 35; int n, m; int A[N][N], F[N][N]; int main() { scanf( %d , &n); m = (n + 1) >> 1; int ans = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { scanf( %d , &A[i][j]); ans += A[i][j]; } for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; const int maxn = 9e2 + 1; int n, m, g[maxn], G, o1[maxn], o2[maxn], deg[maxn]; vector<int> e[maxn], e_s[maxn], r_e_s[maxn], topo, ans, wow[maxn]; vector<pair<int, int> > edge, res; bool mark[maxn]; map<int, int> is[maxn]; void dfs(int v) { mark[v] = 1; ... |
#include <bits/stdc++.h> using namespace std; long long N, K; long long num[3000]; long long OAO[3000]; bool test(long long c) { for (long long Ni = 0; Ni <= N; Ni++) { OAO[Ni] = Ni; for (long long Nj = 0; Nj < Ni; Nj++) { if (Ni != N && abs(num[Ni] - num[Nj]) > (long long)(c) * (Ni - ... |
#include <bits/stdc++.h> using namespace std; int regions[100000][4]; string name[100000][3]; void compareScore(int regionNo, int score, string str) { if (score >= regions[regionNo][0]) { string tempName1 = name[regionNo][0]; string tempName2 = name[regionNo][1]; int tempScore1 = regions[r... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n, sum = 0; cin >> n; vector<long long> v(n), ans, odd; for (long long i = 0; i < n; i++) { cin >> v[... |
#include <bits/stdc++.h> int main() { int n; char a[20]; scanf( %d , &n); scanf( %s , a); char num[10]; for (int i = 2; i < 10; i++) { int c = 0; for (int j = 0; a[j]; j++) if (a[j] >= i + 0 ) c++; num[i] = c; } if (num[7] > 0) { for (int i = 2; i < 7... |
#include <bits/stdc++.h> using namespace std; const int INFINITE = (int)(0xffffffff >> 2); int n; int gs[600]; int dp[600][600]; int run(int l, int r) { if (l > r) return 0; if (l == r) return 1; if (dp[l][r] != INFINITE) { return dp[l][r]; } dp[l][r] = min(dp[l][r], run(l + 1, r) ... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) { cerr << endl; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << , ; err(++it, args...); } namespace fastIO { bool IOerror = 0; ... |
#include <bits/stdc++.h> using namespace std; const int oo = 2139063143; const int N = 1010000; const int P = 1000000007; const long double eps = 1e-7; template <typename T> inline void sc(T &x) { x = 0; static int p; p = 1; static char c; c = getchar(); while (!isdigit(c)) { ... |
#include <bits/stdc++.h> int n, k, a, b, p, na; std::vector<int> avg; long long f(int l, int r) { auto it1 = std::upper_bound(avg.begin(), avg.end(), r); auto it2 = std::lower_bound(avg.begin(), avg.end(), l); if (it2 != avg.end()) na = it1 - it2; else na = 0; long long ans; if... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const long long INFll = 1ll * 1000000000 * 1000000000; const long double PI = 3.141592653589793238462643383279502884197169399375105820974944; int mul(int a, int b,... |
#include <bits/stdc++.h> using namespace std; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2}; int main() {... |
#include <bits/stdc++.h> using namespace std; inline void io() {} int main() { ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); cout << fixed << setprecision(8); long long int n, a, b, c = 0, k; cin >> a >> b >> n; for (int i = 0; i < 10; i++) { if (((a * 10) + i) % b == ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, pos; cin >> n; int arr[n + 1]; for (int i = 1; i <= n; i++) { cin >> pos; arr[pos] = i; } for (int i = 1; i <= n; i++) cout << arr[i] << ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int a, b, n; cin >> a >> b >> n; long long int cnt = 0; while (1) { if (b > a) { a += b; cnt++; } else { b += a; cnt++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> joy; while (n > 0) { int f, t; cin >> f >> t; if (t > k) f = f - t + k; joy.push_back(f); n--; } sort(joy.begin(), joy.end()); cout << joy.back(); } |
#include <bits/stdc++.h> using namespace std; vector<int> v; long long int arr[100001], operation[100001][3], kitnibaar1[100002], kitnibaar[100002], update1[100002], update[100002]; int main() { int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> arr[i]; } for ... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; int n, ans[N], where[N]; long long sz[N]; vector<int> v[N]; bool visit[N]; void init() { scanf( %d , &n); int a, b; for (int i = 0; i < n - 1; ++i) { scanf( %d %d , &a, &b); v[a].push_back(b); v[b].push_back(... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const long long ooo = 9223372036854775807ll; const int _cnt = 1000 * 1000 + 7; const int _p = 1000 * 1000 * 1000 + 7; const int N = 1001005; const double PI = acos(-1.0); const double eps = 1e-9; int o(int x) { return x % _p; } ... |
#include <bits/stdc++.h> using namespace std; int main() { char str[200]; int num, i, j, k; int pre = 0; char temp[10]; cin.getline(str, 200, n ); for (i = 0; str[i] != 0; i++) { num = str[i]; j = 0; while (num != 0) { k = num % 2; temp[j++] = k + 0 ; ... |
#include <bits/stdc++.h> using namespace std; struct triple { int first; int second; int third; void set(int a, int b, int c) { first = a; second = b; third = c; } }; triple t[53][53][8] = {0}; int table[53][53] = {0}; void f(int a, int b, int c) { if (table[a][b] =... |
#include <bits/stdc++.h> using namespace std; const int V = 25; int n, k, sx, sy; bool adj[V][V]; double p[V]; double mat[V * V][V * V]; int id[V][V], deg[V]; double calc_p(int i, int j) { return (i == j) ? p[i] : (adj[i][j]) ? (1 - p[i]) / deg[i] : 0.0; } void gauss(double a[][V * V], int m, in... |
#include <bits/stdc++.h> using namespace std; int dp[1 << 25]; int tick[25][25], value[25][25], cost[25][25]; int n, m; string s[25]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> value[i][j]; for (in... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rnd(time(NULL)); const int N = 25; const int inf = 1e9; const double MAX_T = 1000; const double MIN_T = 1e-5; const int max_mutations = 10; int n, m; vector<int> A, B; vector<vector<int> > best_ans, cur_ans; int best_cost = 0; inline void ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.