func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; unordered_map<int, vector<pair<int, int> > > rows; unordered_map<int, vector<pair<int, int> > > cols; int n, m; int cnum; map<pair<int, int>, int> id; map<pair<int, int>, vector<pair<int, int> > > adj1; unordered_map<int, vector<i... |
#include <bits/stdc++.h> using namespace std; string c1, c2; int main() { int x; cin >> c1 >> c2; for (int i = 0; i < c1.size(); i++) { if (c1[i] < 92) { c1[i] += 32; } if (c2[i] < 92) { c2[i] += 32; } } if (c1 < c2) { x = -1; } else if (c1 > c... |
#include <bits/stdc++.h> const int MAXN = 10010100; const int MAZN = 301010; int ch[MAXN][3]; int n, cnt, cout[MAXN]; int arr[MAZN]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &arr[i]); } for (int i = 1; i <= n; i++) { int tem, p = 0; scanf( %d... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, ans = 0; string s; cin >> n; while (cin >> s) { int cnt = 0; for (int i = 0; i < s.length(); ++i) { if (s[i] >= A && s[i] <= Z ) { ... |
#include <bits/stdc++.h> using namespace std; int gi() { char cc = getchar(); int cn = 0, flus = 1; while (cc < 0 || cc > 9 ) { if (cc == - ) flus = -flus; cc = getchar(); } while (cc >= 0 && cc <= 9 ) cn = cn * 10 + cc - 0 , cc = getchar(); return cn * flus; } const ... |
#include <bits/stdc++.h> const int N = 3003; const long long mod = 998244353; using namespace std; int n; int c; int a[N]; int p[N]; int res[N]; int d[N][N]; int g[N][N]; int f1[N][1 << 12]; void upd(int &x, int y) { x += y; if (x >= mod) { x -= mod; } else if (x < 0) { x... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; const long long inf = 0x3f3f3f3f3f3f3f3f; string s; int a[maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int flag = 0; int n; cin >> n; for (int i = 0... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int MOD = 1000000007; void solve() { int n; cin >> n; vector<vector<int>> dp(4, vector<int>(n + 1, 0)); dp[3][0] = 1; for (int i = 1; i < n + 1; i++) for (int j = 0; j < 4; j++) for (int k = 0; k < 4; k+... |
#include <bits/stdc++.h> using namespace std; long long l, r, n, k; string Bad; int ask(long long l, long long r) { cout << l << << r << endl; cout.flush(); cin >> Bad; if (Bad[0] == B ) exit(0); if (Bad[0] == Y ) { if (l == r) exit(0); return 1; } return 0; } i... |
#include <bits/stdc++.h> using namespace std; const int nn = 100005; const double eps = 1e-10; struct point { double x, y; } a[nn], b[nn]; int n, m, t, l[nn], r[nn]; int h[nn], p[nn]; double R, c[nn]; inline double cp(const point &x, const point &y, const point &z) { return (x.x - z.x) * (y.y ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int k; cin >> k; int days[14]; int ones = 0; for (int i = 0; i < 7; i++) { cin >> days[i]; if (days[i]) ones++; days[i + 7] = days[i]; } int ans = 0... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int c[10000007]; vector<pair<int, int> > x; int temp; vector<int> vt; int main() { scanf( %d %d %d , &m, &k, &n); for (int i = 0; i < m; i++) { scanf( %d , &temp); c[temp]++; if (c[temp] > n) { printf( -1 n ); ... |
#include <bits/stdc++.h> using namespace std; char a[55][55]; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int n, T, m; inline int valid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; } int cyc[55][55][4][2] = {}; int main(void) { scanf( %d%d , &n, &T); for (int i = 0; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, r = 0; char ch = getchar(); while (!isdigit(ch)) f ^= ch == - , ch = getchar(); while (isdigit(ch)) r = (r << 1) + (r << 3) + (ch ^ 48), ch = getchar(); return f ? r : -r; } const int N = 3005, M = 305; int n, m,... |
#include <bits/stdc++.h> using namespace std; int n, m, a[101], b[101], z[101], x, s, k, i, j; int main() { cin >> n >> m; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= m; i++) { cin >> b[i]; s += b[i]; } for (i = 1; i <= n - s + 1; i++) { for (k = i; k <= i + s - 1;... |
#include <bits/stdc++.h> long long cacu(long long l, long long r) { return (r + l) / 2 * ((r - l) / 2 + 1); } int main() { int q, l, r; scanf( %d , &q); while (q--) { long long ans; scanf( %d%d , &l, &r); ans = cacu(l + (l & 1), r - (r & 1)); ans -= cacu(l | 1, r - !(r & 1)... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); template <typename T> void chmin(T &x, const T &y) { if (x > y) x = y; } template <typename T> void chmax(T &x, const T &y) { if (x < y) x = y; } template <typename T> T gcd(T x, T y) { return y ? gcd(y, x % y) : x... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); return (b == 0) ? a : gcd(b, a % b); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = 1 << 29; const int mod = 100000... |
#include <bits/stdc++.h> using namespace std; int N; list<int> adj[1000005]; int T[1000005]; bool visited[1000005]; bool uniq[1000005]; int rev[10000005]; void dfs(int v) { visited[v] = true; for (list<int>::iterator it = adj[v].begin(); it != adj[v].end(); it++) { if (!visited[*it]) dfs(*... |
#include <bits/stdc++.h> using namespace std; int n; void solve() { if (n <= 3) printf( NO n ); else if (n == 4) { printf( YES n ); printf( 2 * 3 = 6 n ); printf( 6 * 4 = 24 n ); printf( 24 * 1 = 24 n ); } else if (n == 5) { printf( YES n ); printf( 1 + 5 = 6 ... |
#include <bits/stdc++.h> using namespace std; const long long INF = LONG_LONG_MAX; const long long NINF = LONG_LONG_MIN; const long long mmod = 1000000007; int32_t main() { long long k; cin >> k; while (k-- > 0) { long long n; cin >> n; string s, t; cin >> s >> t; vec... |
#include <bits/stdc++.h> using namespace std; long long p, k; vector<int> v; int main() { cin >> p >> k; v.push_back(p % k); long long a0 = -p / k; while (1) { long long a1 = -a0 / k; while (a1 * k + a0 < 0) a1++; while (a1 * k + a0 >= k) a1--; if (a1 < k && a1 >= 0) { ... |
#include <bits/stdc++.h> using namespace std; long long a[200010]; long long vis[200010]; long long cnt[200010]; long long n; long long max_n = 0; void solve(long long pos) { vis[pos]++; long long temp1 = pos; long long temp2 = pos; long long step1 = 0; long long step2 = 0; while (... |
#include <bits/stdc++.h> int read() { int x = 0, y = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) y = -1; ch = getchar(); } while (ch <= 9 && ch >= 0 ) x = (x << 3) + (x << 1) + ch - 0 , ch = getchar(); return x * y; } void print(int x) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int x, y, tx, ty, vis[N]; int chk(int x, int y) { for (int i = 0; i < 7; i++) vis[i] = 0; for (int i = 1; i <= tx; i++) ++vis[x % 7], x /= 7; for (int i = 1; i <= ty; i++) ++vis[y % 7], y /= 7; for (int i = 0; i < 7; i++) ... |
#include <bits/stdc++.h> using namespace std; const int N = 207; const int M = 1507; const int inf = INT_MAX; int nx[M], to[M], head[N], cap[M], fl[M], who[N][N], vis[N], es = 2; int a[N], b[N]; int n, m, s, t, turn = 1; int dfs(int u, int mini) { vis[u] = turn; if (u == t) return mini; for ... |
#include <bits/stdc++.h> int main() { int n, t, pos = 0; std::cin >> n >> t; std::vector<std::pair<int, int> > vec; for (int i = 0; i < n; i++) { int x, y; std::cin >> x >> y; vec.push_back(std::make_pair(x, y)); } std::sort(vec.begin(), vec.end()); for (int i = 0; i < n ... |
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 1e8 + 7; const unsigned long long base = 71; const unsigned long long max_n = 2e5 + 400; unsigned long long n, m, k, q; string s; unsigned long long pw[2 * max_n + 200]; unsigned long long save[20][2 * max_n + 200]; unsigned ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2E5 + 77; void putint(int x) { static bool first = true; if (first) { printf( %d , x); first = false; } else printf( %d , x); } struct QUERY { int t, r; } Q[maxn]; int cnt = 0; int N, M, A[maxn], B[maxn], p... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:136777216 ) using namespace std; int bits(int x) { return x == 0 ? 0 : 1 + bits(x & (x - 1)); } const double PI = acos(-1.0); const double eps = 1e-9; const int INF = 1000000000; string nextString() { char buf[1000000]; scanf( %s , buf); ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int mod = (int)1e9 + 7; const long long INF = 1000000000000000000LL; const int WASTE = (int)2e5; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { long long int n, x; cin >> n >> x; cout << 2 * x << endl; } } |
#include <bits/stdc++.h> using namespace std; const int N = 1e3; int n, x[N], d[N], i, j; int main() { cin >> n; for (i = 0; i < n; i++) cin >> x[i] >> d[i]; for (i = 0; i < n; i++) for (j = i + 1; j < n; j++) if (x[i] + d[i] == x[j] && x[j] + d[j] == x[i]) return cout << YES , 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 205; int n; char s[N]; bool ck(int l, int r) { int a = 0, b = 0, c = 0, d = 0; for (int i = l; i <= r; i++) { if (s[i] == U ) a++; else if (s[i] == D ) b++; else if (s[i] == L ) c++; else ... |
#include <bits/stdc++.h> int main() { int n, i; scanf( %d , &n); char s[100]; int a[n], b[n], c[n]; scanf( %s , s); for (i = 0; i < n; i++) { int h = (int)s[i]; a[i] = h - 48; } for (i = 0; i < n; i++) { b[n - i - 1] = a[i]; c[n - i - 1] = a[i]; } i = n ... |
#include <bits/stdc++.h> using namespace std; int main() { string x; cin >> x; string ans, in, dec, exp; int flag = 0; for (int i = 0; i < x.length(); i++) { if (x[i] == . ) flag = 1; else if (x[i] == e ) flag = 2; else if (flag == 0) in += x[i]; ... |
#include <bits/stdc++.h> using namespace std; const int limN = 2e5 + 5; char s[limN]; char arr[2000]; int bu[400]; int main() { int t; scanf( %d , &t); for (int i = 0; i < t; i++) { scanf( %s , s); for (int j = 0; j < 2000; j++) arr[j] = . ; for (int j = 0; j < 400; j++) bu[j]... |
#include <bits/stdc++.h> using namespace std; const int Maxv = 110; int n, m; int val[Maxv][Maxv * Maxv]; int org[Maxv][Maxv]; int dp[Maxv][Maxv * Maxv]; int Len[Maxv]; int main() { int i, j, k; cin >> n >> m; for (i = 1; i <= n; i++) { scanf( %d , &Len[i]); for (j = 1; j <= Len[... |
#include <bits/stdc++.h> using namespace std; long long int n, x, a[100005], ct[100005]; int main() { cin >> n >> x; for (long long int i = 1; i <= n; ++i) cin >> a[i], ct[a[i]]++; sort(a + 1, a + n + 1); long long int ans = 0; for (long long int i = 1; i <= n; ++i) { long long int ch = ... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { long long a, b; cin >> a >> b; if (a < b) puts( -1 ); else printf( %.12f n , (a + b) / (2. * ((a + b) / (2 * b)))); return 0; } |
#include <bits/stdc++.h> using namespace std; const int Mod = (int)1e9 + 7; const int MX = 1073741822; const long long MXLL = 4e18; const int Sz = 1110111; inline void Read_rap() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline void randomizer3000() { unsigned int seed;... |
#include <bits/stdc++.h> using namespace std; long long n; long long ask(long long a, long long b, long long c, long long d) { long long res; cout << ? << a << << b << << c << << d << endl; cout.flush(); cin >> res; return res; } int main() { ios_base::sync_with_stdio(fa... |
#include <bits/stdc++.h> using namespace std; int x[111111]; int y[111111]; int main() { int i, n, m, t; long long xx = 0, yy = 0; scanf( %d , &n); for (i = 1; i <= n; i++) { scanf( %d , &t); x[t] = i; y[t] = n - i + 1; } scanf( %d , &m); for (i = 1; i <= m; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T abs(T t) { return t < 0 ? -t : t; } const unsigned long long modn = 1000000007; inline unsigned long long mod(unsigned long long x) { return x % modn; } const int MAX = 100009; int deg[MAX], ok[MAX]; vector<int> adj[MAX];... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int n; pair<long long, long long> a[maxn + 1]; pair<long long, long long> b; priority_queue<long long, vector<long long>, greater<long long> > q; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { return a > b;... |
#include <bits/stdc++.h> using namespace std; int acc[1002], s[1002]; int main() { int n, t; cin >> n; for (int i = 0; i < n; i++) { cin >> t; s[t]++; } for (int i = 1; i < 1002; i++) { acc[i] = acc[i - 1] + s[i]; } int d; cin >> d; int total = 0; for (int... |
#include <bits/stdc++.h> int main() { std::map<long, long> map; long q, id, leftMAX = 0, rightMAX = 0, firstTime = 0; char c; std::cin >> q; while (q--) { std::cin >> c >> id; if (!firstTime--) { map.insert(std::pair<long, long>(id, 0)); } else { if (c == ? ) ... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) vector<int> up, down; int main() { int T, n; char ch; scanf( %d , &T); while (T--) { scanf( %d , &n); up.clear(); down.clear(); for (int i = 1; i < n; i += 2) { printf( ? %d %d n , i, i ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long a, long b) { return ((a * b) / gcd(a, b)); } long long a[100000]; int main() { long long i, j, k, l, m, n, maxx = 0, g = 0; cin >> n; for (i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); long long a, b, c; cin >> a >> b >> c; if (a > b) swap(a, b); cout << a + min(c, a + b) + min(b, a + c); return 0; } |
#include <bits/stdc++.h> using namespace std; void read(long long &x) { scanf( %lld , &x); } void read(long long &x, long long &y) { scanf( %lld%lld , &x, &y); } void read(long long &x, long long &y, long long &z) { scanf( %lld%lld%lld , &x, &y, &z); } void print(long long x) { printf( %lld , x); } v... |
#include <bits/stdc++.h> using namespace std; template <typename A> ostream &operator<<(ostream &cout, vector<A> const &v); template <typename A, typename B> ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << ( << p.first << , << p.second << ) ; } template <typename A> os... |
#include <bits/stdc++.h> using namespace std; int main() { int i, pos, n, cnt, sz, dummy; vector<int> ans; long long k, tot = 0, examine[100005], temp; scanf( %d %I64d , &n, &k); for (i = 0; i < n; ++i) { scanf( %I64d , &examine[i]); tot += examine[i]; } if (tot < k) pr... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; long long l = s.length(); bool visit[256]; memset(visit, false, sizeof(visit)); int dis = 0, i; for (i = 0; i < l; i++) { if (!visit[s[i]]) ... |
#include <bits/stdc++.h> using namespace std; long long n, a[1000009], m, ans, mx, b[1000009]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> b[i]; if (n % 2 == 0) { if (i <= n / 2) a[b[i] + (n / 2 - i)]++; else a[b[i] + (i - (n / 2) - 1)]++; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int Nmax = 100005; int count_one(vector<int> s) { int ct = 0; int i = 0; while (i < s.size()) { if (s[i] == 1) ++ct; ++i; } return ct; } int count_zero(string s, int index) { int i = 0; in... |
#include <bits/stdc++.h> using namespace std; const unsigned long long base = 133; unsigned long long hash1[200005][26], hash2[200005][26], Pow[200005]; int n, m; char str1[200005], str2[200005]; int main() { scanf( %d%d , &n, &m); scanf( %s%s , str1 + 1, str2 + 1); Pow[0] = 1; for (int i = ... |
#include <bits/stdc++.h> using namespace std; long long n, m, i, j, y, s, ans; char a[2222][2222]; int l[2222][2222], r[2222][2222], u[2222][2222], d[2222][2222]; pair<pair<int, int>, int> st[2444444]; bool f[2222][2222]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m; for (i = 1; i ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5, INF = -1e9; long long down[N], mx[N], up[N], dp[N], sum[N]; unordered_map<long long, vector<long long>> mp[N]; long long n, m, pre[N], suf[N], ans[N]; vector<pair<long long, long long>> adj[N]; bool mark[N]; void dfs_down(long lo... |
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) 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 << t ; err(++it, args...); } template <ty... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 2e5 + 555; int n, m, q, z; pair<long long, int> a[N]; int qt[N]; long long ql[N], qr[N]; long long ans[N]; vector<pair<int, int> > ed[N]; long long bl[N], br[N], arin[N]; int f[N * 20]; const int iu = 18; ... |
#include <bits/stdc++.h> using namespace std; int a[100010]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int i = (n - 1) / 2, j = i + 1; while (i >= 0 || j <= n - 1) { if (i >= 0) cout... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; int aray[100007]; while (scanf( %d %d , &n, &m) != EOF) { for (int i = 1; i < n; i++) { scanf( %d , &aray[i]); } int sum = 0, i = 1; bool flag = false; while (true) { sum = (i + aray[i]); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 333; const long long linf = 1e18 + inf; const int LEN = 6e5 + 5; int n, m, q, len; char str[LEN], s[LEN]; int a[LEN], st[LEN], nd[LEN], suf[LEN], ord[LEN], lcp[LEN], w[LEN], root[LEN], L[LEN], R[LEN]; pair<pair<int, int>, int> C[L... |
#include <bits/stdc++.h> using namespace std; int n, s, ll, v[100011]; int dp[100011]; const int oo = 1 << 28; int seg[400001]; int at, l, r; void add(int n, int s, int e) { if (at < s || at > e || s > e) return; if (s == e) { seg[n] = dp[s]; return; } add(n * 2, s, (s + e) / 2... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10; const int mod = 1e9 + 7; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + c - 0 , c ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e6 + 5; long long int power(long long int base, long long int exp) { long long int res = 1; while (exp) { if (exp % 2) res *= base; base *= base; res %= mod; base %= mod; exp /= 2; ... |
#include <bits/stdc++.h> using namespace std; int const bound = 1e6 + 2, N = 2e5 + 1; long long OO = 1e18; double eps = 1e-6; int oo = 1e9, mod = 1e9 + 7; int n, m, s, app[N][2]; pair<int, int> par[N][2]; vector<int> adj[N], rev[N]; queue<pair<int, int> > q; int vis[N]; void buildpath() { puts... |
#include <bits/stdc++.h> using namespace std; int dp[25][25][5], ans, n, t; int main() { cin >> n >> t; for (int i = 1; i <= 4; i++) for (int j = i + 1; j <= 4; j++) dp[2][1][j]++; for (int i = 3; i <= n; i++) for (int j = 1; j <= t * 2; j++) for (int k = 1; k <= 4; k++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int a = 0, b = 0, k = 2; for (int i = 0; i < n / 2 - 1; i++) { a += k; k *= 2; } for (int i = 0; i < n / 2; i++) { b += k; k *= 2; } ... |
#include <bits/stdc++.h> using namespace std; int k, t, state[16]; unordered_map<unsigned long long, long long> M[10]; unsigned long long tobeull(int state[]) { int tmp[16] = { 0, }; unsigned long long ret = 0; for (int i = 0; i < 16; i++) tmp[i] = state[i]; sort(tmp, tmp + 16); ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, ans = -2; cin >> n; vector<int> v(n); for (auto &a : v) cin >> a; vector<int> max_ele_index; int maxx = 0; for (auto a : v) maxx = max(a, maxx); for (int i = 0; i < n; i++) if (v[i] == maxx) max_ele_index.push_... |
#include <bits/stdc++.h> using namespace std; int a[5100], b[5100]; long long c[5100]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { int d = b[j] ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000 * 1000 * 1000 + 7; const int INF = 2000 * 1000 * 1000; const double EPS = 1e-9; const double pi = acos(-1.0); template <typename T> inline T sqr(T n) { return (n * n); } long long gcd(int a, int b) { while (a && b) { a %=... |
#include <bits/stdc++.h> #pragma hdrstop #pragma argsused using namespace std; int main(int argc, char* argv[]) { int i, j, resp, resn, resv, resl, res, n, a, b; vector<int> x, y; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d %d , &a, &b); x.push_back(a); y.push_back(b);... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long d; cin >> n >> d; vector<long long> v; long long x; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } int count = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++)... |
#include <bits/stdc++.h> using namespace std; int n, k; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; vector<int> c(n);... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( -fgcse ) #pragma GCC optimize( -fgcse-lm ) #pragma GCC optimize( -fipa-sra ) #pragma GCC optimize( -ftree-pre ) #pragma GCC optimize( -ftree-vrp )... |
#include <bits/stdc++.h> using namespace std; char s[1111][1111]; int d[1111][1111]; queue<pair<int, int> > Q; vector<pair<int, int> > v; int n, m, lim; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; void check(int x, int y, int z) { if (x < 0 || x >= n || y < 0 || y >= m) return; if (s... |
#include <bits/stdc++.h> using namespace std; struct less_key { bool operator()(pair<double, int64_t> p1, pair<double, int64_t> p2) { return (p1.first > p2.first) || ((p1.first == p2.first) && (p1.second < p2.second)); } }; struct pair_hash { std::size_t operator()(const pair<int6... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } map<vector<int>, int> S; for (int bit = 0; bit < (1 << 15); bit++) { vector<int> b(n); for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int Time = 0; a -= 2; int Turn = 2; while (a > 0 || b > 0 || c > 0) { if (Turn == 1) { Time++; a -= 2; Turn = 2; } else if (Turn == 2) { Time++; b -... |
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (x == 0) return y; return gcd(y % x, x); } int main() { int n, m, x, g; cin >> n >> m >> x; g = x - 1; for (int i = 1; i < n; ++i) { scanf( %d , &x); g = gcd(g, x - 1); } set<int> second; int... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, f[6]; cin >> a >> b >> c; f[0] = a + b + c; f[1] = a + b * c; f[2] = a * b + c; f[3] = a * b * c; f[4] = (a + b) * c; f[5] = a * (b + c); sort(f, f + 6); cout << f[5]; return 0; } |
#include <bits/stdc++.h> using namespace std; vector<long long int> ar[100005]; long long int vis[100005]; long long int mi; long long int val[100005]; void dfs(long long int a) { vis[a] = 1; mi = min(val[a], mi); for (auto it : ar[a]) { if (vis[it] == 0) { dfs(it); } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int arr[10] = {0}; string s; cin >> n >> s; for (int i = 0; i < n; i++) arr[s[i] - 0 ]++; if ((arr[1] || arr[2] || arr[3]) && (arr[7] || arr[0] || arr[9]) && (((arr[1] || arr[4] || arr[7]) && (arr[3] || arr[6] || arr[... |
#include <bits/stdc++.h> using namespace std; using namespace std; const int INF = 1000000000; const int inf = INF; struct Edge { int from, to, cap, flow, index; Edge(int from, int to, int cap, int flow, int index) : from(from), to(to), cap(cap), flow(flow), index(index) {} }; struct Dinic... |
#include <bits/stdc++.h> using namespace std; int x[505], r[505]; int main() { int i; x[0] = 0; r[0] = 1000000; double dd; int d; for (i = 1; i <= 300; i++) { r[i] = 300 - i + 1; dd = 2 * sqrt(double(r[i - 1])) * sqrt(double(r[i])); d = int(dd + 3); x[i] = x[i - 1] ... |
#include <bits/stdc++.h> using namespace std; int a[200000 + 1]; int n; int b[200000 + 1]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i]] = 0; } int max = -1; int k = 0; int numb; for (int i = n; i > 0; i--) { k = 0; if (b[a[i]] =... |
#include <bits/stdc++.h> using namespace std; const int modulo = 1000000009; long long A(int events, int days) { if (events < days) return 0; long long result = 1; for (int e = events - 1; e >= days; --e) { result *= e; result %= modulo; } for (int i = 0; i < days; i++) { res... |
#include <bits/stdc++.h> using namespace std; double p[100005], e1[100005], e2[100005]; int main() { int n; scanf( %d , &n); for (register int i = 1; i <= n; ++i) scanf( %lf , p + i); for (register int i = 1; i <= n; ++i) { e1[i] = (e1[i - 1] + 1) * p[i]; e2[i] = e2[i - 1] + (e1[i - 1]... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)3e3 + 5; const int INF = (int)1e9; const string T = aeiou ; int dp[MAXN], par[MAXN]; bool space[MAXN]; bool vowel[256]; string s; int n; bool bad(char a, char b, char c) { if (a == b && b == c) { return 0; } if (!... |
#include <bits/stdc++.h> using namespace std; int vis[6000]; int dp[5][100], mp[5][55], num[55]; int main() { int n; cin >> n; for (int i = 1; i <= 2; i++) for (int j = 1; j < n; j++) cin >> mp[i][j]; for (int i = 1; i <= n; i++) cin >> num[i]; memset(dp, 0, sizeof dp); for (int i ... |
#include <bits/stdc++.h> using namespace std; set<string> ss; string s; void readInput() { cin >> s; } void solve() { for (int i = 0; i <= s.length(); i++) { for (char c = a ; c <= z ; c++) { string tmp; tmp += s.substr(0, i) + c + s.substr(i, s.length()); ss.insert(tmp); ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; scanf( %d , &t); while (t--) { scanf( %d , &n); printf( %d n , n - 1); for (int i = 2; i <= n; ++i) printf( %d , i); printf( n ); } } |
#include <bits/stdc++.h> using namespace std; const int MAX_TAILLE = 100 * 1000 + 3; long long T[1]; long long paire[MAX_TAILLE], impaire[MAX_TAILLE]; int n, e, a; long long best; int main() { paire[0] = 0; impaire[0] = 0; int p = 1, ip = 1; cin >> n >> e; T[0] = 0; for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) const long long maxn = 4005, maxk = 1e5 + 2, mod = 1e9 + 7; long long a[maxn]; vector<long long> v; bool mrk[maxn]; int32_t main() { long long t; cin >> t; while (t--) { lon... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int turn = 2 * k + 1; if (n % turn == 0) cout << n / turn << ; else cout << n / turn + 1 << ; double upperbound = (n - 1) % turn + 1; int MAXN = 0; upperbound /= 2; int temp = ce... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, l, r; cin >> n >> l >> r; cout << (n - l) + (int)pow(2, l) - 1 << << (n - r) * ((int)pow(2, r - 1)) + ((int)pow(2, r) - 1) << endl; } |
#include <bits/stdc++.h> using namespace std; inline int read() { char c; int x = 0; int b = 1; do { c = getchar(); if (c == 45) b = -1; } while (c > 57 || c < 48); do x = x * 10 + c - 48, c = getchar(); while (c <= 57 && c >= 48); x *= b; return x; } int n, m, t;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.