func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> long long strange[100001]; int main() { for (int i = 1; i <= 100000; i++) { long long a = i, b = i; while (b) { a *= 10; a += b % 10; b /= 10; } strange[i] = a; } long long k, p; while (scanf( %lld%lld , &k, &p) != EOF) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3fll; int g; bool endswith(string a, string b) { if ((int)((a).size()) < (int)((b).size())) return 0; for (int i = 0; i < (int)((b).size()); i++) if (a[(int)((a).size()) - 1 - i] ... |
#include <bits/stdc++.h> using namespace std; inline int in() { int x; scanf( %d , &x); return x; } const int INF = 1e9 + 10; const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100; const int MN = 3e3 + 10; int n; vector<pair<int, int> > edges[MN]; int ans; int dp1[MN], d... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; while (t--) { long long int n, i, j; cin >> n; long long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline long long int rand(long long int x, long long int y) { ++y; return (rng() % (y - x)) + x; } string to_string(char c) { string second(1, c); return second; } string to_s... |
#include <bits/stdc++.h> const long long N = 1000006; using namespace std; const long long MOD = 1000000007LL; template <typename T> T gcd(T a, T b) { if (a == 0) return b; return gcd(b % a, a); } template <typename T> T power(T x, T y, long long m = MOD) { T ans = 1; while (y > 0) { ... |
#include <bits/stdc++.h> using namespace std; int a[100001], n; inline long long sum(int t) { long long s = 0; for (int i = 1; i <= n; ++i) s += min(a[i], t); return s; } int main() { int i, j, l, r, m, t = 1; int nr = 0; long long k, s = 0, smin; scanf( %d %I64d , &n, &k); for... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000; int n, m, k, start = MAXN + 1; int type[MAXN + 3], a[MAXN + 3], counter[MAXN + 3], stc[MAXN + 3]; bool check[MAXN + 3]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &type[i]); for (int i = 1; i <= n;... |
#include <bits/stdc++.h> using namespace std; long long l, r, ans; vector<long long> lucky; void lu(int f, int s) { string x = ; for (int i = 0; i < f; i++) x += 4 ; for (int i = 0; i < s; i++) x += 7 ; do lucky.push_back(atoll(x.c_str())); while (next_permutation(x.begin(), x.end())); ... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; int a[33]; string s; int main() { for (int i = 0; i < 26; ++i) scanf( %d , &a[i]); cin >> s; int len = s.length(); vector<long long> v(len + 1); for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int arr[101][101]; int row[101], col[101]; for (int i = 0; i <= n - 1; i++) { row[i] = col[i] = 0; } int temp; for (int i = 0; i <= n - 1; i++) { for (int j = 0; j <= n - 1; j++) { ... |
#include <bits/stdc++.h> using namespace std; int m, n, k, t; int a[100001]; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < n; ++i) { scanf( %d , &t); a[i % k] += t; } m = 0; for (int i = 1; i < k; ++i) if (a[i] < a[m]) m = i; printf( %d n , m + 1); } |
#include <bits/stdc++.h> using namespace std; vector<int> vec[1000006], V; struct Node { int x, y, w; bool operator<(const Node& a) const { return y < a.y; } } node[500006]; int n; struct Info { long long len, mx, w; int p; Info() {} Info(long long _len, long long _mx, long long _w, ... |
#include <bits/stdc++.h> int main() { int t, arr[110], i, l, s, m, n, j; scanf( %d , &t); l = -1; s = 1001; for (i = 0; i < t; i++) scanf( %d , &arr[i]); for (i = 0; i < t; i++) { for (j = i + 1; j < t; j++) { if (arr[j] < arr[i]) { s = arr[j]; arr[j] = arr[i]... |
#include <bits/stdc++.h> using namespace std; int n, m, a[3010][6010], fa[18010000]; int dx[9] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[9] = {-1, 0, 1, -1, 1, -1, 0, 1}; inline int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f = ch == - , ch = getchar(); while (isdigit(ch)) x ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], i; for (i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 1; return 0; } int lmarr[n + 1], rmarr[n + 1]; lmarr[0] = INT_MIN; rmarr[n] = INT_MAX; for (i = 0; i <... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t ope... |
#include <bits/stdc++.h> using namespace std; int n, l, r; vector<pair<int, int> > G[100005]; int seq[100005], cnts, siz[100005], rch[100005], num[100005]; bool vis[100005]; int rt, Min; void dfs(int now, int ff, int tsz) { int Max = 0; siz[now] = 1; rch[now] = 0; for (int i = 0, v, sz = G... |
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); } using namespace std; int n, m; struct Edge { int u, v, w, id; Edge() {} Edge(int jzp, i... |
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b, long long mod = (long long)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod; } mt19937 rng(chrono::steady_clock::now().time_since_epoch()... |
#include <bits/stdc++.h> using namespace std; inline int Abs(int x) { return x > 0 ? x : -x; } set<int> peo; set<int>::iterator p1, p2; bool vis[200050], boy[200050]; char s[200050]; int a[200050]; struct node { int l, r; int val; node(int a = 0, int b = 0, int c = 0) : l(a), r(b), val(c) {}... |
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { ... |
#include <bits/stdc++.h> using namespace std; long long num[100010]; int main() { int n, q, req; while (~scanf( %d%d%d , &n, &q, &req)) { bool res[100010]; res[0] = true; res[n + 1] = true; for (int i = 1; i <= n; i++) { scanf( %d , &num[i]); if (num[i] <= req) ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; long long int t, n, m; set<long long int> vis; queue<long long int> q; vector<long long int> temp, v[500005], g[500005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); long long int ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int N = (int)1e6 + 7, mod = 1000000007, M = 2e9, lvl = 21; char s[N]; int n, c[10], x[4] = {1, 6, 8, 9}; vector<int> base, a; void push(int x) { a.push_back(x / 100); x %= 100; a.push_back(x / 10); x %= 10; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, num; scanf( %d , &n); int f = 0; int pre = 0; bool ans = 1; for (int i = 0; i < n; i++) { scanf( %d , &num); if ((f == 1 && num > pre) || (f == 2 && num >= pre)) ans = 0; if (num == pre) f = 1; if (num ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> a(n, 0); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> prev(n, 0); prev[0] = 0; ... |
#include <bits/stdc++.h> long long mod = 1e9 + 7, mod2 = 998244353; const int N = int(3e5) + 999; using namespace std; long long fac[10000000]; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long fexp(long long a, long long b, long long m) { long l... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void chkmax(T& x, U y) { if (x < y) x = y; } template <typename T, typename U> inline void chkmin(T& x, U y) { if (y < x) x = y; } int main() { int h, m, s, A, B; scanf( %d%d%d%d%d , &h, &m, &s, &A, &B... |
#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--) { string S; cin>>S; long long int A[100]; long long int x=0; long long int val=0; long long int N=S.length(); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count()); int n, s, d; bitset<N> a[(1 << 20) + 2]; bitset<N> b[(1 << 10) + 2]; bitset<N> mas[33]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, i, k = 0; cin >> n; int a[n]; map<int, int> m; set<int> s; for (i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; k = max(k, m[a[i]]); } for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n, t; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cout << n - i << ; } cout << n ; } } |
#include <bits/stdc++.h> struct help { long int money; long int friends; }; void fusion_sort(struct help *p, long int n); void bablesort(struct help *p, long int n); int main() { long int n, m; scanf( %ld %ld , &n, &m); struct help *p = (struct help *)malloc(sizeof(struct help) * n); f... |
#include <bits/stdc++.h> using LL = long long; const LL Inf = (LL)1e18; const int N = 5000 + 5; int s, e, n; LL x[N], a[N], b[N], c[N], d[N]; LL dp[2][N]; inline LL lo(int p) { return d[p] - x[p]; } inline LL ro(int p) { return x[p] + c[p]; } inline LL li(int p) { return b[p] - x[p]; } inline LL ri(... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; bitset<(int)1e6> us; bool isCyclic(int v, int p = -1) { us.set(v); for (int i = 0; i < g[v].size(); i++) { if (us.test(g[v][i]) && g[v][i] != p) return 0; if (us.test(g[v][i])) continue; bool cures = isCyclic(g[v][i]... |
#include <bits/stdc++.h> using namespace std; int n, m, k; long long num[5005], sum[5005], dp[5005][5005]; int main() { int i, j; while (scanf( %d%d%d , &n, &m, &k) != EOF) { for (i = 0; i < n; i++) { scanf( %I64d , &num[i]); } memset(sum, 0, sizeof(sum)); for (i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 20001; const int MAX_LOG = 20; using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pll = pair<ll, ll>; const double delta = 1e-6; const long long mod = 1e9 + 7; const int magic_const = 1e9; const ll INF ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const int N = 200005; int vis[N], tab[N], i, a, b, sum, n, m, vis0[N], vis1[N]; vector<int> graf0[N], graf1[N]; string s; bool cyc(int w) { vis[w] = 1; for (auto& w2 : graf0[w]) if (vis[w2] == 1) return true; ... |
#include <bits/stdc++.h> using ll = long long; using ld = long double; using namespace std; const int MAXN = 2000228; const ll INF = (1ll << 50); set<pair<ll, ll>> s; void ins(ll x, ll y) {} int main() { ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.ti... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef string str; #define pb push_back #define ppp pop_back #define pii pair<int,int> #define fi first #define se second #define stie std::tie #define vec vector #define forn(i, l, r) for (int i=l; i... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t-- > 0) { int n; cin >> n; vector<vector<int>> a; int b[n + 1]; for (int i = 0; i <= n; i++) b[i] = 0; int count = 0; int s = 0; for (int i = 0; i < n; i++) { vecto... |
//Hare Krishna //author: Dipjoy Basak //dip_10 #include <bits/stdc++.h> using namespace std; #define endl n #define ll long long #define int ll #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss ssecond #define vi vector<int> #define pi pair... |
#include <bits/stdc++.h> using namespace std; double dp[15][15]; int n, t, i, j, ans = 0; void work() { double t; dp[1][1] += 1; for (i = 1; i <= n; i++) { for (j = 1; j <= i; j++) { if (dp[i][j] > 1) { t = dp[i][j] - 1; dp[i][j] = 1; dp[i + 1][j] += t / 2... |
#include <bits/stdc++.h> const double pi = 3.14159265358979323846; using namespace std; long long fastexp(long long a, long long b) { long long ans = 1; long long temp = a; while (b > 0) { if (b & 1) ans *= (temp); temp *= temp; b >>= 1; } return ans; } long long GCD(long... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int x = 0; for (int i = 2; i <= n; ++i) { if (i & 1) x = (x * 3 - 3) % 1000000007; else x = (x * 3 + 3) % 1000000007; } cout << x << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int N; char s[500010]; int c[30][500010]; int then(int x) { return x & -x; } void in(int o, int x, int k) { while (x <= N) { c[o][x] += k; x += then(x); } } int out(int o, int x) { int re = 0; while (x > 0) { re += c[o][x]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s = ; vector<int> fib; fib.push_back(1); fib.push_back(1); for (int i = 2; i < 17; ++i) { fib.push_back(fib[i - 1] + fib[i - 2]); } for (int i = 1; i <= n; ++i) { if (binary_search(fi... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; int l = b.size(); int st = a.size() - 1; int ar[l + 3]; memset(ar, -1, sizeof ar); ar[l] = st + 1; for (int i = l - 1; i >= 0; i--) { while (st >= 0 && a[st] != b[i]) { st--; } ... |
#include <bits/stdc++.h> using namespace std; const long long int N = 60 + 10, M = (1 << 16) + 10, MOD = 1e9 + 7, INF = 2e9 + 10; const long double PI = acos(-1); int n, a[N], in[N], fac[N], msk[N], all; long long int dp[M][N], ans = 1; vector<int> adj[N], S, T; bool mrk[N], ad[N][N]... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MAXN = 3e6 + 9; long long n, k; long long two(long long x) { long long base = 1, ans = 0; while (base * x <= n) { long long f = min(n, base * (x + 1) - 1); ans += f - base * x + 1; base *= 2; } r... |
#include <bits/stdc++.h> using namespace std; bool isused[26]; string s, t; vector<pair<int, int> > v; int abs(int num) { if (num < 0) return -num; else return num; } int main(void) { cin >> s >> t; int slen = s.size(); for (int i = 0; i < slen; i++) isused[(s[i] - a )] = ... |
#include <bits/stdc++.h> using namespace std; int n, m, totx, tot, hangx[2005], liex[2005]; double ans; char s[2005]; long long func(int n, int m, int a[]) { long long ret = 0; for (int i = 1; i <= n; i++) { long long sum = 0, cnt = m - a[i]; for (int j = 1; j <= n; j++) { if (a[j]... |
#include <bits/stdc++.h> using namespace std; long long n, m, a[1000005], ans = 0; inline long long read() { long long red = 0, f_f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f_f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) red = red * 10 + ch... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int res = 0; for (int i = 0; i < k; i++) { int x = 0, y = 0; for (int j = i; j < n; j ... |
#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> const double eps = 1e-10; using namespace std; using ll = long long; using ul = unsigned long long; using PII = pair<int, int>; const int NN = 1011101; const int NZ = 511100; const int MM = 151; const int need = (1 << 30) - 1; int n, m, s, x, i, j, t, a, b, k, c, r, col[NN];... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) { return a; } gcd(b, a % b); } int n, m, a, b, t; bool eo = 0; int main() { cin >> n >> m; n++; m++; for (int i = 1; i <= n; i++) { if (i == 1) cin >> a; else cin >... |
#include <bits/stdc++.h> using namespace std; bool test_cases; void init(bool k) { test_cases = k; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } struct test_cases { void prepare_left(long long *great_left, long long n, long long *a) { stack<long long> st; great_left[... |
#include <bits/stdc++.h> using namespace std; bool solve(vector<int>& arr, int m, int n, int k) { vector<int> dp(n + 1, 0); int last = 0; for (int i = k; i <= n; i++) { int l = dp[i - k] + 1; if (arr[i] - arr[l] <= m) last = i; dp[i] = last; } return dp[n] == n; } int main(... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, INF = N; int n, L, R, ANS_U, ANS_V, ANS; struct st { int nxt, to, w, dis; } ed[N << 1]; int head[N], num; void add(int from, int to, int w) { ed[++num].to = to, ed[num].w = w; ed[num].nxt = head[from]; head[from] = num; ... |
#include <bits/stdc++.h> using namespace std; int light[3000]; int agr[3000]; int main() { int n; scanf( %d , &n); int m = pow(2, n + 1) - 1; for (int i = 2; i <= m; i++) { scanf( %d , &light[i]); } int ans = 0; for (int i = m; i >= 3; i--) { if (i % 2 == 0) continue; ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long k, wyn; long long tab[27][27]; map<long long, long long> odp[27][27]; void back1(int, int, long long); void back2(int, int, long long); int main() { ios_base::sync_with_stdio(0); cin >> n >> m >> k; for (int i = 1; i <= n; i++... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int calc(int a, int x, int n) { return max(0, min(x - (a + 1) / 2, n - a)); } void solve(istream &in, ostream &out) { int n, m, x, y, a, b; in >> n >> m >> x >> y >> a >> b; int d = gcd(a, b); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a, b; cin >> a >> b; n *= 2; int n1 = 0, n2 = 0, q = 0; for (int i = 0; i < n; ++i) if (a[i] == 1 ) if (b[i] == 1 ) q = !q; else ++n1; else if (b[i] == 1 ... |
#include <bits/stdc++.h> using namespace std; int a[300010], p[300010], d[32]; int f[6000010][3], cnt = 1, ans; void insert(int x, int y) { f[x][2]++; if (y > 30) return; if (!f[x][d[y]]) f[x][d[y]] = ++cnt, insert(cnt, y + 1); else insert(f[x][d[y]], y + 1); } void dg(int x, int... |
#include <bits/stdc++.h> using namespace std; bool a[18][18]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) a[i][j] = 1; } map<string, int> mp; string name; vector<string> names(n); for (int i = 0; i < n; i++) { cin >> n... |
#include <bits/stdc++.h> using namespace std; int a[2010], b[2010]; unordered_map<int, int> mp; int main() { int n; scanf( %d , &n); int ans = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); mp[a[i]] = 1; } for (int i = 0; i < n; i++) { scanf( %d , &b[i]); mp... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int n, sum; int cnt[100005], from[100005], to[100005], c[100005]; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) scanf( %d%d , &from[i], &to[i]); for (int i = 1; i <= n; i++) scanf( %d , &c[i]); for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int solve(int t) { int a, b, c, rem = 0, sum = 0; while (t != 0) { rem = t % 10; sum += rem; t /= 10; } if (sum % 4 == 0) return 1; return 0; } int main() { int t, n, flag = 0; cin >> t; while (1) { flag = solv... |
#include <bits/stdc++.h> using namespace std; namespace IO { const int __S = (1 << 20) + 5; char __buf[__S], *__H, *__T; inline char getc() { if (__H == __T) __T = (__H = __buf) + fread(__buf, 1, __S, stdin); if (__H == __T) return -1; return *__H++; } template <class __I> inline void read(_... |
#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; int main() { std::string a; std::getline(cin, a); ; std::string b; std::getline(cin, b); ; int team1 = 0; int team2 = 0; for (int i = 0; i < a.size(); i = i + 2) { if (a[i] == b[i]) { } else if ((a[i] == 8 && b[i] == [ ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, x, y, z; cin >> a >> b >> c >> x >> y >> z; int a1, b1, c1, a2, b2, c2, m = 0, n = 0; if (a > x) { if (abs(a - x) >= 2) { if ((a - x) % 2 == 0) m = m + a - x; else m = m + a - x - 1; ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int R, C; string t[2222]; int s1[2222][2222]; int main() { memset(s1, 0, sizeof(s1)); cin >> R >> C; for (int r = 0; r < (int)R; r++) { cin >> t[r]; for (int c = 0; c < (int)C; c++) { if (t[r][c] == ... |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; int N, K; double L, V1, V2; bool f(double t) { if (L / V1 < t - EPS) return true; int nGroups = N / K; if (N % K != 0) nGroups++; double distByBus = (t * V1 * V2 - L * V2) / (V1 - V2); double tByBus = distByBus / V2; doub... |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int w[1007]; int n, x; int d[107]; int N = 101; int mat[107][107]; void mNoz(int (&a)[107][107], int (&b)[107][107], int (&c)[107][107]) { long long res[107][107]; for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) res... |
#include <bits/stdc++.h> inline char nc() { static char buf[1000000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++; } inline void read(int &x) { static char c; for (c = getchar(); !( 0 <= c && c <=... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define pb push_back #define ff first #define ss second #define all(a) (a).begin(),(a).end() #define fr(i,a,b) for(int i=a;i<b;i++) #define mapit(i,mp) for(auto i = mp.begin(); i!=mp.end(); i++) #define pi... |
#include <bits/stdc++.h> using namespace std; int n; string s; vector<int> pos[26]; int xd[26]; int main() { cin >> s; n = s.size(); for (int i = 0; i < n; i++) { pos[s[i] - a ].push_back(i); xd[s[i] - a ]++; } double ans = 0; for (char c = a ; c <= z ; c++) { i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e+5; bool vis[maxn]; int main() { int T, n, m, l; cin.sync_with_stdio(false); cout.sync_with_stdio(false); cin.tie(0); cout.tie(0); while (cin >> n) { memset(vis, false, sizeof vis); int pos = n; int now = ... |
#include <bits/stdc++.h> using namespace std; vector<int> d[101000]; int k[101000]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &k[i]); for (int j = 0; j < k[i]; j++) { int a; scanf( %d , &a); d[i].push_back(a); } sor... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; if (n <= min(m, k)) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; template <class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); } template <class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); } template <class TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << = << h << endl; } template <... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using uint = unsigned int; template <class T> using V = vector<T>; template <class T> using VV = vector<vector<T>>; template <class T, class U> void chmax(T& x, U y) { if (x < y) x = y; } template <class T, class U> void chm... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = 1; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48); if (f) x = -x; } template <typename F> i... |
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using i32 = int32_t; template <class T, class U> void init_n(vector<T>& v, size_t n, U x) { v = vector<T>(n, x); } template <class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); } template <class T> void read_n... |
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; constexpr int MOD = 1000000007; const int INF = 1 << 30; bool is_prime(int n) { if (n <= 1) return false; for (int i = 2; i * i <= n; i++) { ... |
#include <bits/stdc++.h> inline long long rd() { long long _x = 0; int _ch = getchar(), _f = 1; for (; !isdigit(_ch) && (_ch != - ) && (_ch != EOF); _ch = getchar()) ; if (_ch == - ) { _f = 0; _ch = getchar(); } for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - 0 ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int arr = 2e5 + 10; const int ar = 2e3 + 10; const long double pi = acos(-1); const long double eps = 1e-10; const long long md = 1e9 + 7; #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragm... |
#include <bits/stdc++.h> using namespace std; const int N = int(1e5) + 10, mod = int(1e9) + 7; const long long inf = (long long)(2e18); int n, q; vector<int> g[N]; int first[N], c[N]; long long t[N], a[N], b[N], add[N]; set<pair<long long, int> > all; multiset<long long> st[N]; set<pair<long long, i... |
#include <bits/stdc++.h> using namespace std; struct ask { int l, r, where; } q[210000]; const int mo = 1e9 + 7, N = 1000000; int A[210000], x[210000], pd[1100000], n, m, B[210000], where[1100000], ans[210000]; vector<int> p[1100000]; int quick(int k1, int k2) { int k3 = 1; while (k2) { ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; using LD = long double; const int MX = 1 << 18 | 3; int N, a[MX], Q; LL sum; int main() { ios::sync_with_stdio(0); cout << fixed << setprecision(10); cin >> N >> Q; for (int i = 0; i < (1 << N); i++) cin >> a[i], sum += a[... |
#include <bits/stdc++.h> template <class T> bool read(T &x) { char *s; s = (char *)malloc(10); if (sizeof(x) == 1) strcpy(s + 1, %c ); else if (sizeof(x) == 4) strcpy(s + 1, %d ); else if (sizeof(x) == 8) strcpy(s + 1, %lld ); int k = scanf(s + 1, &x); free(s); ... |
#include <bits/stdc++.h> using namespace std; long long quickMod(long long a, long long b, long long c) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % c; b >>= 1; a = a * a % c; } return ans; } long long Euler(long long x) { long long res = x; for (long lon... |
#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 % m) * (a % m)) % m; b /= 2; a = (... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-8; const int inf = 0x7FFFFFFF; template <class T> void show(T a, int n) { for (int i = 0; i < n; ++i) cout << a[i] << ; cout << endl; } template <class T> void show(T a, int r, int l) { for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { long long p, f, s, w, cntS, cntW; cin >> p >> f >> cntS >> cntW >> s >> w; if (s > w) { swap(cntS, cntW);... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 9; const int MOD = 1e9 + 7; const int MAXN = 300005; long long N, k, m; long long cook[MAXN], t[MAXN], l[MAXN]; vector<int> ch[MAXN]; int good, bad; template <class T, class Operation = plus<T>> struct SegmentTree { int n; v... |
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.