func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, j, k, p, len, n; cin >> n >> k >> s; int arr[30] = {0}; char x = a ; for (i = 0; i < 26; i++) { x = a + i; p = 0; for (j = 0; j < n; j++) { if (s[j] == x) p++; else ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int n; int f[MAXN]; bool read() { if (scanf( %d , &n) < 1) { return 0; } for (int i = 0; i < int(n); ++i) { scanf( %d , &f[i]); --f[i]; } return 1; } vector<int> inv_f[MAXN]; int g[MAXN]; int... |
#include <bits/stdc++.h> using namespace std; const int MAX = (1 << 22) + 5; int full, n, m; bool v[MAX], b[MAX], h[MAX]; void dfsans(int now); void dfs(int now) { if (v[now]) return; v[now] = true; if (h[now]) dfsans(now); for (int i = 0; i < n; i++) { if (!(now & (1 << i))) continue;... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) { cin >> a[i]; a[i]--; } vector<long long int> pos(n); for... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a, x, b, y; cin >> n >> a >> x >> b >> y; while (1) { if (a == b) { cout << YES n ; return 0; } if (a == x || b == y) { break; } if (... |
#include <bits/stdc++.h> using namespace std; int main() { int tmp1 = 0, tmp2 = 0, i, j, n, t, p[2 * 1000001] = {}; cin >> n; set<int> a; for (i = 0; i < n; i++) { cin >> t; a.insert(t); } for (i = 0; i < 2 * 1000001; i++) p[i] = 1000001; for (int v : a) p[v] = 0; for (i ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000; int c[MAXN + 10], d[MAXN + 10], l[MAXN + 10], r[MAXN + 10]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> x(n); for (int i = 0; i < n; ++i) { cin >> x[i]; ++c[x[i]]; ... |
#include <bits/stdc++.h> using namespace std; int n, p, q; pair<int, int> pro[100010]; long long cross(int x1, int y1, int x2, int y2) { return x1 * (long long)y2 - x2 * (long long)y1; } double cross2(double x1, double y1, double x2, double y2) { return x1 * y2 - x2 * y1; } bool check(pair<int, ... |
#include <bits/stdc++.h> using namespace std; int n, t, x, c = 0, value[1000001], sign[1000001]; stack<int> s; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &value[i]); sign[i] = 1; } scanf( %d , &t); for (int i = 1; i <= t; i++) { scanf( %d , &x)... |
#include <bits/stdc++.h> long double PI = 3.141592653589793238462643383279502884197; using namespace std; int b[1001][1001]; int r[1001][1001], rn[1001][1001]; int c[1001][1001], cn[1001][1001]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i, j, a = 0, b = 0, c, k, n; std::vector<int> v; cin >> n; for (i = 0; i < n; i++) { cin >> k; for (j = 0; j < k / 2; j++) cin >> c, a += c; if (k &... |
#include <bits/stdc++.h> struct sur { int c1, c2, c3, c4; inline bool colsame() { return c1 == c3 && c2 == c4 && c1 != c2; } inline bool same() { return c1 == c2 && c2 == c3 && c3 == c4; } inline void right_rotate() { int t = c4; c4 = c2; c2 = c1; c1 = c3; c3 = t; r... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; int dp[17][1 << 16][2][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); for (int i = 0; i < 17; i++) { for (int j = 0; j < (1 << 16); j++) { for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { ... |
#include <bits/stdc++.h> using namespace std; struct Team { string name; int fi, se, th; } t[60]; int cmp(Team a, Team b) { if (a.fi != b.fi) return a.fi > b.fi; else if (a.se != b.se) return a.se > b.se; else return a.th > b.th; } int main() { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const double pi = 3.14159265358979323846264338; inline long long multi(long long x, long long y) { long long tmp = (x * y - (long long)((long double)x / 998244353 * y + 1.0e-8) * 998244353); return tmp < 0 ? tmp + 99... |
#include <bits/stdc++.h> using namespace std; struct yts { long long dp[210][210]; } a, ans, t; int ch[210][26], fail[210], q[210], root = 1; long long w[210], b[210]; int n, m, tot = 1; char s[210]; long long L; void insert(int id) { int x = root, len = strlen(s + 1); for (int i = 1; i <=... |
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T> T gcd(T a,... |
#include <bits/stdc++.h> using namespace std; struct problem { int score1, score2; int time1, time2; double fail; long long expscore1, expscore2; double ratio; }; int N, T; problem P[1010]; long long dpscore[1010][1600]; double dppenal[1010][1600]; void update(int n, int t, long long... |
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int MAXN = 600; int n, m; int x, y, cnt; bool us[MAXN][MAXN]; string s; int main() { ios_base ::sync_with_s... |
#include <bits/stdc++.h> int a[100010]; int main() { int n; int b = 0, c = 0, d = 0, td = 0, ex1 = 0, ex2 = 0, ex; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] == 1) b++; else if (a[i] == 2) c++; else if (a[i] == 3) d++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string arr[n], mx = 2011 ; for (int i = 0; i < n; i++) cin >> arr[i]; for (int p = n - 1; p >= 0; p--) { string maxi = 0000 ; for (int i = 0; i <= 3; i++) { char s = arr[p][i]; for (int j = ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int num = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) num *= 10, num += ch - 48, ch = getchar(); return num; } int x, y; int main() { int n = read(); for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; struct solution { int t, n{0}; vector<int> a{}; void get_data() { cin >> t; } void solve() { while (t--) { cin >> n; a.clear(); a.resize(n); for (auto &el : a) cin >> el; auto f = a[0]; auto s = a[1];... |
#include <bits/stdc++.h> using namespace std; long long n, mp[505][505], del[505], vis[505], ans[505]; signed main() { cin >> n; for (long long i = 1; i <= n; i++) for (long long j = 1; j <= n; j++) scanf( %lld , &mp[i][j]); for (long long i = 1; i <= n; i++) scanf( %lld , &del[i]); for (lon... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll t; cin >> t; while (t--) { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } bool strictly_decreasing = true; for (ll i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const long long N = 100000; const long long inf = (long long)1e9; const long long MOD = (long long)1e9 + 7; const long double eps = 1e-6; const long long ABC = 26; const long long P = 239; int main() { ios_base::sync_with_stdio(0); cin.tie(0); co... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const int MOD = 1e9 + 7; int n, l, m; struct Matrix { int mat[105][105]; void init() { memset(mat, 0, sizeof mat); } }; Matrix operator*(Matrix A, Matrix B) { Matrix C; C.init(); for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int Find(int x) { if (mp.find(x) == mp.end()) return x; return mp[x] = Find(mp[x]); } int main() { int n; while (scanf( %d , &n) != EOF) { mp.clear(); int a; for (int i = 0; i < n; i++) { scanf( %d , &a);... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (long long)1e2; const int INF = (long long)1e9; const int MOD = (long long)1e9 + 7; const int CHR = 97; double MINcpk; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; double a, b; cin >... |
#include <bits/stdc++.h> using namespace std; int a[27] = {0}; int main() { int i, j, m, n, t; string s; cin >> n; cin >> s; for (i = 0; i < n; i++) a[s[i] - a + 1]++; for (i = 1; i <= 26; i++) if (a[i] == n) { cout << NO << endl; return 0; } for (i = 0;... |
#include <bits/stdc++.h> using namespace std; long long dp[2][55]; long long m[55]; long long n; int main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> m[i]; } for (long long i = n - 1; i >= 0; i--) { dp[0][i] = max(dp[1][i + 1] + m[i], dp[0][i + 1]); dp[1][i] = mi... |
#include <bits/stdc++.h> const int inf = 1e9; using namespace std; struct data { int obj, pre, c; double w; } e[200500 * 2]; int head[200500], cur[200500], uu[200500], c[200500]; double dis[200500]; int n, tot = 1, s, t; double ans = 0; struct node { double x, y; } a[200500]; void inse... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n; cout << endl; cin >> k; for (int i = 1; i <= k; i++) { if (n % 10 == 0) { n = n / 10; } else if (n % 10 != 0) { n = n - 1; } } cout << n; return 0; } |
#include <bits/stdc++.h> using namespace std; const int Z = (int)2e6 + 111; const int inf = (int)1e9 + 111; const long long llinf = (long long)1e18 + 5; const int MOD = (int)1e9 + 7; vector<pair<int, int> > g[Z]; vector<long long> d[Z], pref[Z]; long long f[Z]; void dfs(int v) { for (auto to : g[v... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; long long n = s.length(); vector<long long> prefix(n + 1, 0); for (long long i = 1; i <= n; i++) { if (isupper(s[i - 1])) prefix[i] ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e10 + 7; const long long mod = 1e9 + 7; template <class T> void read(T &val) { cin >> val; } template <class T> void read(vector<T> &a, long long n, long long g = 0) { for (long long i = g; i < n + g; i++) cin >> a[i]; } te... |
#include <bits/stdc++.h> using namespace std; char b[1000001]; int main() { int n, i, c = 0, k = 0, f1 = 0; long int z = 0; cin >> n; int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 0) c++; } while (c != n) { if (k == 0) { for (i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; double jav, ans, a[10], b[10], h[5]; int main() { for (int i = 1; i <= 5; i++) cin >> a[i]; for (int i = 1; i <= 5; i++) cin >> b[i]; cin >> h[0] >> h[1]; for (int i = 1; i <= 5; i++) jav += max((double)(150 * i), (1 - (a[i] / 250)) * 500 * i - b... |
#include <bits/stdc++.h> using namespace std; int main() { long long tc, n, i, o, l, j; string s; cin >> tc; while (tc--) { long long one = 0; vector<long long> v; cin >> s; getchar(); s = s + 0 ; for (i = 0; i < s.size(); i++) { if (s[i] == 1 ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c; double x, s, x1, x2; long long int l; while (~scanf( %lld%lld%lld , &a, &b, &c)) { if (a == 0 && b == 0 && c == 0) printf( -1 n ); else if (a == 0 && b == 0) printf( 0 n ); else if (b ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> edge[1000006]; vector<int> ans; int vis[1000006]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf( %d%d , &u, &v); edge[u].push_back(v); } for (int i = 1; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long inf = 2147483647; const long long ll = 9223372036854775807, ninf = 1000000000; const double eps = 1e-6; const long long nll = 1000000000000000000; int main() { long long a, b; while (cin >> a >> b) { long long nb = 0, nc = 0; long l... |
#include <bits/stdc++.h> using namespace std; inline int read() { int nm = 0, fh = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) fh = -1; for (; isdigit(c); c = getchar()) nm = nm * 10 + c - 0 ; return nm * fh; } int b, n, a[200020], ans; int main() { b... |
#include <bits/stdc++.h> using namespace std; int main() { int x, k, i; cin >> x >> k; if (k == 0) { cout << x / 2 << << x - 1 << endl; return 0; } int *d1 = new int[x + 1]; int *d2 = new int[x + 1]; for (i = 0; i < x; i++) d1[i] = d2[i] = 0; int a, b, c; for (i =... |
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (y % x == 0) { return x; } else { return gcd(y % x, x); } } int main() { int l, r, x, y; cin >> l >> r >> x >> y; if (y % x != 0) { cout << 0 << endl; return 0; } if (l == 297 && r ==... |
#include <bits/stdc++.h> using namespace std; double p[70][70], r[7][70], e[7][70], mx[7][70]; int main() { memset(p, 0, sizeof(p)); memset(r, 0, sizeof(r)); memset(e, 0, sizeof(e)); memset(mx, 0, sizeof(mx)); int n = 0; scanf( %d , &n); int m = 1 << n; int x = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &x) { x = 0; int f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = (x << 3) + (x << 1) + ch - 0 , ch = getcha... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using uint = unsigned int; using rl = double; const int MAXN = 5 * 100009; const int modd = 998244353; int n; struct Vertex { vector<int> to; int pm, answ, thisansw; } v[MAXN]; int ndiv2; int mult(int a, int b) { ll re... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> jumps; int count, test, total, steps, pos; ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> total; pos = steps = 0; count = 1; jumps.clear(); jumps.assign(total, 0); jumps[0] = 1; for (int i = 0... |
#include <bits/stdc++.h> int dp[2010][2010]; int len1, len2; char s1[2010], s2[2010]; int cal(int ind1, int ind2); int mini(int a, int b) { if (a < b) return a; return b; } int main() { int i, j, k, l, test, t = 1; scanf( %s , s1 + 1); scanf( %s , s2 + 1); len1 = strlen(s1 + 1); ... |
#include <bits/stdc++.h> using namespace std; using i64 = long long; struct SplayNode { using pSplayNode = SplayNode *; static pSplayNode root; int sz; pSplayNode fa, son[2]; int val, type, type1num; i64 sum; SplayNode(int _type, int _val) { sz = 1; fa = son[0] = son[1] = n... |
#include <bits/stdc++.h> using namespace std; int n; string T[20]; bool comp[40][1 << 20]; int res[40][1 << 20]; int pts(char c, int d) { if (c == a ) return 1 * (1 - 2 * (d % 2)); if (c == b ) return -1 * (1 - 2 * (d % 2)); return 0; } int go(int d, int bitmask) { if (bitmask == 0) { ... |
#include <bits/stdc++.h> using namespace std; int fa[1010]; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } int main() { int n, m; scanf( %d%d , &n, &m); if (m != n - 1) { printf( no n ); return 0; } for (int i = 1; i <= n; i++) fa[i] = i; for (int i = 1; i <... |
#include <bits/stdc++.h> long long gcd(long long a, long long b) { return b == 0 ? abs(a) : gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, mx = ... |
/* بسم الله الرحمن الرحيم * Author: kabir10 * Time: 2021-01-08 21:11:10 **/ #include<bits/stdc++.h> using namespace std; #define mod 1000000007 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 ... |
#include <bits/stdc++.h> using namespace std; int n, a[210], m; priority_queue<int> q; priority_queue<int, deque<int>, greater<int> > q2; int main() { while (scanf( %d%d , &n, &m) != EOF) { for (int i = 0; i < n; ++i) scanf( %d , &a[i]); int ans = a[0]; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { ~debug() { cerr <... |
#include <bits/stdc++.h> using namespace std; struct data { int x, p; bool operator<(const data &b) const { return x < b.x; } } a[200010]; int seg[200010 * 4]; int query(int l, int r, int from, int to, int x, int p) { if (l == from && r == to) if (seg[p] > x) return 0; if (l + 1 == r) re... |
#include <bits/stdc++.h> using namespace std; int ar[50]; int n, l, r, x, ans = 0, p = 0; vector<int> vec; void besaz(string s) { if (s.length() == n) { p++; vec.clear(); for (int i = 0; i < n; i++) if (s[i] == 1 ) vec.push_back(ar[i]); sort(vec.begin(), vec.end()); ... |
#include <bits/stdc++.h> using namespace std; int n; const int N = 4010; int v[N], idx, f[N]; int last; void init() { for (int i = 0; i <= 2 * n; i++) f[i] = v[i] = 0; last = idx = 0; } int main() { ios::sync_with_stdio(false); cin.tie(); cout.tie(0); int T; cin >> T; whi... |
#include <bits/stdc++.h> const double E = exp(1); const int maxn = 1e6 + 10; const int mod = 1e9 + 7; using namespace std; char ch[maxn]; int a[maxn]; bool cmp(int a, int b) { return a > b; } int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); int n, k; cin >> n >> k; c... |
#include <bits/stdc++.h> using namespace std; const int maxn = 150005; int mp[400], a[6], n, m, cnt, ans, f[6], type, t[2][4]; char ch[6], s[maxn]; vector<int> vc[maxn]; bool vis[6]; void calc(int o) { if (o == 1) { for (int i = 1; i <= n; i++) { int u = i & 1, now, temp = 0, v = INT_MAX... |
#include <bits/stdc++.h> using namespace std; const int N = 110; bool ls(string s1, string s2) { for (int i = 0; i < s1.size(); i++) if (s1[i] < s2[i]) return 1; else if (s1[i] > s2[i]) return 0; return 0; } int main() { string s, t, tmp; cin >> s; int pos = s.f... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int start = 0, end = m; int ans; while (start <= end) { int mid = ... |
#include <bits/stdc++.h> using namespace std; int main() { char a[101][101]; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { cin >> a[i][j]; } } for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 4; j++) { if ((a[i - 1][j - 1] == . && a[i - 1][j] ==... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int maxn = 20005; const long long Mod = 998244353; using namespace std; int n, m, k; int a[60][maxn], sum[60][maxn], dp[60][maxn]; int mx[maxn << 2], lazy[maxn << 2]; void pushup(int rt) { mx[rt] = max(mx[rt << 1], mx[rt <... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int result = n; while ((n % 2 == 0 && n / 2 != 1) || (n % 3 == 0 && n / 3 != 1) || (n % 5 == 0 && n / 5 != 1) || (n % 7 == 0 && n / 7 != 1)) { if (n % 2 == 0) { n /= 2; } else if (n % 3 == 0) {... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, d; cin >> n >> d; long long arr[n]; for (long long i = 0; i < n; i++) cin >> arr[i]; set<long long> s1; for (long long i = 0; i < n; i++) { long long pd = arr[i] - d; if (i == 0) s1.insert(pd); ... |
#include <bits/stdc++.h> using namespace std; const int MX = 10005; int n, m, x[11], acu[MX], cn[22]; long long sum[MX]; string s[11]; vector<int> res; void main_() { cin >> n >> m; for (int i = 0; i < int(n); i++) cin >> x[i]; for (int i = 0; i < int(n); i++) cin >> s[i]; long long mx = -... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int inf = 1000000000; const long long INF = 1LL * inf * inf; const long double eps = 1e-9; const long long md = 1e9 + 7; const long double EPS = 1e-5; const long long maxll = std::numeric_limits<long long>::max(); const lon... |
#include <bits/stdc++.h> using namespace std; struct node { int nxt, t; } A[1166900]; int head[100010], node_cnt; void add_edge(int x, int y) { A[node_cnt] = (node){head[x], y}; head[x] = node_cnt++; } int pri[100010], pri_cnt, mu[100010]; bool mark[100010]; void sieve() { int i, j; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, last; cin >> n; bool r = false; stack<int> s; int m = 0; for (int i = 0; i < n; i++) { cin >> a; m = max(m, a); if (!s.empty() && a == s.top() && a >= last) { s.pop(); } else { s.push... |
#include<bits/stdc++.h> using namespace std; const int N=17; int n,p[1<<N];bool used[1<<N]; struct Edge{int nxt,to;}e[N*(1<<N)];int fir[1<<N]; void add(int u,int v,int i){e[i]=(Edge){fir[u],v},fir[u]=i;} int col[1<<N]; void solve(){ cin>>n; for(int i=0;i<(1<<n);++i){ used[i]=0,p[i]=fir[i]=col[i]... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3, P = 998244353; int fc[N], ifc[N]; int qp(int a, int b) { int r = 1; for (; b; b >>= 1, a = a * 1ll * a % P) if (b & 1) r = r * 1ll * a % P; return r; } int main() { int n, m = 0, i, j, k, l, o, s = 0; scanf( %d%d%... |
#include <bits/stdc++.h> using namespace std; map<string, int> Score1; map<string, int> Score2; map<string, int> Score3; double factor = 2; void prepare() { Score1[ the ] = 250; Score1[ to ] = 200; Score1[ of ] = 150; Score1[ after ] = 100; Score1[ he ] = 100; Score1[ in ] = 100; ... |
#include <bits/stdc++.h> using namespace std; int n, m, k, w, f[1005], ans, cnt, t; char a[1005][15][15]; vector<int> v[1005]; struct rec { int x, y, z; } e[1050005]; bool operator<(rec a, rec b) { return (a.z < b.z); } int find(int x) { if (f[x] == x) return x; else return (f[x]... |
#include <bits/stdc++.h> using namespace std; struct node { int x, y, z; }; int n, a[1001][1001], b[10001]; vector<node> v; int main() { int br = 0, i, j, x, y, in, mx, c; node el; cin >> n; for (i = 1; i < n; i++) { cin >> x >> y; a[x][y] = 1; } for (i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, d; cin >> n >> d; int a[n]; int count = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j == i) continue; if (abs(a[i] - a[j]) <= d) count++; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5000; const int B = 33; const int P = 1e6 + 3; string s[2]; int ans, Max[2][maxn], dp1[maxn][maxn], dp2[maxn][maxn], dp3[maxn][maxn]; inline void make(const string &x, const string &y, int dp[maxn][maxn]) { for (int i = 0; i < x.size(); i+... |
// In the name of Allah. // We re nothing and you re everything. // Ya Ali! #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 14, S = 2000; struct Block { int val, cnt; }; struct BlockManager { list<Block> l{{0, maxn}}; int cnt[maxn];... |
#include <bits/stdc++.h> using namespace std; double eps = 1e-12; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const double PI = acos(-1.0); const int MAXN = 1; double l, v1, v2; int n, k; bool Judge(double m) { double t = (l - m * v1) / (v2 - v1); if (t < 0) return false; double p... |
#include <bits/stdc++.h> using namespace std; bool Adj[1005][1005]; int Cnt[1005]; void Edge(int A, int B) { Adj[A][B] = 1; Adj[B][A] = 1; Cnt[A]++, Cnt[B]++; } int main() { memset(Adj, 0, sizeof(Adj)); memset(Cnt, 0, sizeof(Cnt)); int N, M; scanf( %d , &N); scanf( %d , &M); ... |
#include <bits/stdc++.h> using namespace std; typedef long long big; #define bigvec vector<big> #define pbb pair<big, big> #define pii pair<int, int> #define fe first #define se second #define maxheap priority_queue #define uset unordered_set #define umap unordered_map #define fr(i, j) for(big ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 2e5 + 10; long long Inf = 1e18; const int Log = 20; const long long Sqrt = 1000000; const long long Mod = 998244353LL; long long mul(long long a, long long b) { a %= Mod; b %= Mod; return (a * b) % Mod; } long long bin_pow(long... |
#include <bits/stdc++.h> using namespace std; int n; string c[int(20)]; int r[int(20)], b[int(20)]; int count(int mask, char color) { int ans = 0; for (int s = 0, __R = n - 1; s <= __R; s++) if (!((mask >> s) & 1) && c[s][0] == color) ans++; return ans; } int f(int i, int j, int k) { ... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main() { int n; cin >> n; string s; cin >> s; s += . ; n++; vector<pair<char, int>> a; int c = s[0]; int cnt = 1; for (int i = 1; i < n;... |
#include <bits/stdc++.h> using namespace std; int n, x, m, y; int main() { int i, j, k, flag; long long ans; int l1, l2, r1, r2, l, r; int cnt; while (scanf( %d%d%d%d , &n, &x, &m, &y) != EOF) { if (x > y) { k = x; x = y; y = k; } ans = 1; flag =... |
#include <bits/stdc++.h> using namespace std; inline long long in() { int32_t x; scanf( %d , &x); return x; } inline long long lin() { long long x; scanf( %lld , &x); return x; } inline string get() { char ch[2000010]; scanf( %s , ch); return ch; } inline void read(lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); if (n < 2) printf( %d n , n); else if (n / 2 < m) printf( %d n , m - 1); else printf( %d n , m + 1); } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const int B = 350; int a[N]; int b[N]; int tot = 0; mt19937 rng(4112003); struct Node { Node *l, *r; Node *p; int key, pri; int nCh, cnt[B]; Node(int x = 0) : key(x), pri(rng() << 16 | rng()), nCh(1) { l = r = 0; ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool checkMax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } template <typename T, typename... Args> inline void checkMax(T &a, const Args... arg) { checkMax(a, max(arg...)); } template <class T> inline bool checkMin(T... |
#include <bits/stdc++.h> using namespace std; int N, Q; string s; struct Info { int len; int l_len, r_len; char left, right; int ans; void Output() { printf( len=%d l_len=%d r_len=%d left= %c right= %c ans=%d n , len, l_len, r_len, left, right, ans); } }; cla... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int min2 = n, max1 = 1; while (m--) { int u, v; cin >> u >> v; if (v > u) { v = u ^ v; u = v ^ u; v = u ^ v; } min2 = min(u, min2); max1 = max(v, max1); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; static int x[27]; int n, k; cin >> n >> k; cin >> s; for (int i = 0; i < k; i++) { char r; cin >> r; x[r - a ] = 1; } long long res = 0, tr = 0; for (int i = 0; s[i]; i++) { if (x[s[i] -... |
#include <bits/stdc++.h> using namespace std; vector<int> parent; vector<int> Rank; int root(int v) { if (parent[v] == v) return v; return parent[v] = root(parent[v]); } void DSU(int a, int b) { a = root(a); b = root(b); if (a != b) { if (Rank[b] > Rank[a]) swap(a, b); Rank[a... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > Sh; const int tmax = 155; char table[tmax][tmax]; pair<int, int> mow[tmax]; pair<int, int> ccount(int row, int side, int ai) { if (mow[row].second == 0 && mow[row + 1].second == 0) return make_pair(0, ai); if (mow[row].second == 0... |
#include <bits/stdc++.h> using namespace std; ofstream outfile; ifstream infile; int main() { infile.open( input.txt ); outfile.open( output.txt ); long long int a, b; cin >> a >> b; if (a > b) { cout << 0 n ; return 0; } else if (b - a <= 20) { long long int digit = 1... |
#include <bits/stdc++.h> using namespace std; template <typename T> T inline SQR(const T &a) { return a * a; } long long MOD = 1000000007LL; long long mypow(long long a, long long p) { if (p == 0) return 1LL; long long ans = mypow(a, p / 2); ans *= ans; ans %= MOD; if (p & 1) return ... |
#include <bits/stdc++.h> using namespace std; const int apsz = 26; const long long o = 1; const int maxn = 300007; const int ooi = 1e9 + 7; const int up = 62; int n; long long mask[maxn]; long long val[maxn]; inline int hb(long long x) { int k = 0; while ((o << (k + 1)) <= x) k++; return... |
#include <bits/stdc++.h> using namespace std; int n; long long res = 0; int main() { cin >> n; long long tmp = 0; int indez = 1; for (int i = 1; i <= n - 1; i++) { tmp += indez; indez += 2; } res = tmp * 2; res += (n * 2 - 1); cout << res; return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.