solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include<iostream>
using namespace std;
int main(){
int m,f,r;
while(1){
cin>>m>>f>>r;
if(m==-1&&f==-1&&f==-1)break;
if(m==-1||f==-1)cout<<'F'<<endl;
else if(m+f>=80)cout<<'A'<<endl;
else if(m+f>=65)cout<<'B'<<endl;
else if(m+f>=50)cout<<'C'<<endl;
else if(m+f>=30&&r>=50)cout<<'C'<<endl;
else if(m+... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m, a[300005];
bool check(int v) {
int vnow = 0;
for (int i = (int)(1); i <= (int)(n); i++) {
int vl = a[i], vr = a[i] + v;
for (; vnow < m && (vnow < vl || vnow > vr) &&
(vnow + m < vl || vnow + m > vr);
++vnow)
;
if (vnow >=... | 1 |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
int c4 = 0, c7 = 0;
string str1, str2;
cin >> str1 >> str2;
for (int i = int(0); i <= int(str1.size() - 1); i++) {
if (str1[i] == '4' && str2[i] == '7')
c4++;
else if (str1[i] == '7' && str2[i] == '4')
c7++;
}
... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long int expo(long long int a, long long int b) {
long long int r = 1;
a = a % 1000000007;
while (b) {
if (b % 2) r = (r * a) % 1000000007;
a = (a * a) % 1000000007;
b = b / 2;
}
return r;
}
long long int gcd(long long int a, long long int b) {
... | 3 |
/*
* BugHunt.cpp
*
* Created on: Oct 12, 2013
* Author: Hesham
*/
#include<iostream>
#include<string>
#include<map>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<cstring>
#include<bitset>
#include<fstream>
#incl... | 0 |
#include <iostream>
using namespace std;
int a, b, c;
int main() {
cin>>a>>b>>c;
cout<<a+b+c + max(a, max(b,c))*9;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
vector<int> x;
for (int i = 0; i < a; i++) {
int r;
cin >> r;
x.push_back(r);
}
sort(x.rbegin(), x.rend());
int counter = 0;
for (int i = 0; i < a; i += b) counter += (x[i] - 1) * 2;
cout << counter << endl... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, i, j, num[200001];
int main() {
cin >> n;
if (n % 2 == 0) {
cout << "NO";
return 0;
}
cout << "YES\n";
for (i = 1; i <= n; i++) {
if (i % 2) {
num[i] = 2 * i - 1;
num[i + n] = 2 * i;
} else {
num[i + n] = 2 * i - 1;
n... | 3 |
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))
... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 18;
const int MAXQ = 1 << 21;
const int MAXS = 1 << 19;
const int INF = 1 << 30;
void print(vector<int> &v) {
cout << "v = ";
for (int i = 0; i < v.size(); ++i) {
cout << v[i] << " ";
}
cout << endl;
}
vector<int> G[MAXN];
int N, P[MAXN], V... | 3 |
#include <bits/stdc++.h>
using namespace std;
int a[200];
int main() {
int sum1 = 0, sum2 = 0;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x > 0)
sum1 += x;
else
sum2 += x;
}
cout << sum1 - sum2;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
queue<int> cola;
queue<pair<int, int> > ans;
int n, d, k, depth[400005], lasto, nodo, degree[400005];
int main() {
scanf("%d %d %d", &n, &d, &k);
if (n <= d || (k < 2 && n > 2)) {
printf("NO");
return 0;
}
for (int i = 1; i <= d; i++) {
degree[i] = 2;
... | 5 |
#include <bits/stdc++.h>
using namespace std;
int n, K;
map<int, int> Map;
int A[201000], B[201000], w[201000];
vector<int> GG[201000];
int GPV[201000];
int tA[201000];
vector<int> G;
int UF[201000], sss;
int Find(int a) {
if (a == UF[a]) return a;
return UF[a] = Find(UF[a]);
}
void Merge(int a, int b) {
a = Find... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
int t[200010];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
t[0] = 1;
for (int i = 1; i <= n; i++) cin >> t[i];
sort(t + 1, t + n + 1);
if (t[k] == t[... | 3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
ll d, m;
ll a[100];
ll b[100];
ll ans;
int tc, k;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> tc;
while (tc--) {
cin >> d >> m;
k = 0;
for (ll i = 0; (1LL << i) <= d; ... | 2 |
#include <bits/stdc++.h>
using namespace std;
void debug() { cout << endl; }
template <class T, class... U>
void debug(T a, U... b) {
cout << a << " ";
debug(b...);
}
template <class T>
void pary(T l, T r) {
while (l != r) {
cout << *l << " ";
l++;
}
cout << endl;
}
int par[2 * 200005], siz[2 * 200005... | 3 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 1e5 * 5 + 10;
long long id[N];
vector<long long> pos[N];
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long q;
cin >> q;
for (long long i = 0; i... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long t, x, y, a, b, s = 0, v, c = 0;
int main() {
cin >> t;
while (t--) {
cin >> x >> y >> a >> b;
if (x != y) {
v = x > y ? x : y;
if (v == x) {
c = x - y;
s += (c * a);
x -= c;
} else {
c = y - x;
... | 1 |
/**
* D.cpp.c of project "2021_ICPC_NERC_FINAL".
* Created by KMGuan on 2021-04-04 18:26.
*/
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long lon... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s1, s2;
cin >> s1 >> s2;
if (s1 == s2)
cout << s1;
else
cout << "1";
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5 + 17;
const int INF = 1e9 + 17;
int n, x, y;
long long sum, sum2;
int a[MaxN];
int main() {
scanf("%d%d%d", &n, &x, &y);
if (x > y) swap(x, y);
for (int i = 1; i <= n; ++i) scanf("%d", a + i);
sort(a + 1, a + n + 1);
for (int i = n; i >= n - x... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
scanf("%d", &n);
int m = 3;
while (m * (m + 1) / 2 <= n) m++;
vector<vector<int> > v;
v.resize(m);
int now = 0;
for (int i = 0; i < m; i++)
for (int j = i + 1; j < m; j++) {
now++;
v[i].push_back(now);
v[j].push_back(n... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int add(int x) { return x; }
template <typename... T>
int add(int x, T... y) {
x += add(y...);
if (x >= mod) x -= mod;
return x;
}
template <typename... T>
int udd(int &x, T... y) {
return x = add(x, y...);
}
template <typename... T>
int sub... | 3 |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int n;
cin >> n;
for (int i = 2; i <= n; i += 2) {
v.push_back(i);
}
for (int i = 1; i <= n; i += 2) {
v.push_back(i);
}
for (int i = 2; i <= n; i += 2) {
v.push_back(i);
}
cout << v.size() << endl;
for (int i = 0;... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s, c;
cin >> n >> c >> s;
if (s == "week") {
if (n < 5)
cout << 365 / 7;
else if (n > 4 && n != 7)
cout << 365 / 7 + 1;
if (n == 7) cout << 365 / 7;
}
if (s == "month") {
if (n > 29 && n != 31)
cout <<... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9) + 7;
const double eps = 1e-9;
int main() {
string second, a;
cin >> second;
a = second;
reverse((a).begin(), (a).end());
cout << second + a;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
clock_t time_p = clock();
void aryanc403() {
time_p = clock() - time_p;
cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epo... | 2 |
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
int D, E;
while (true) {
cin >> D >> E;
if (D == 0 && E == 0) { break; }
double ans = 1e9;
for (int x = 0; x <= D; x++) {
int y = D-x;
ans = min(ans, abs(E-sqrt((do... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int Max = 1e5 + 5;
int book[Max];
int first[Max];
int nex[Max];
int lst[Max][3];
struct node {
int a1, b1, c1;
};
int ls[Max][3];
int l[Max];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
int m;
map<int, int> ma;
for... | 3 |
#include <bits/stdc++.h>
using namespace std;
const char ans[9][10] = {"x^y^z", "x^z^y", "(x^y)^z", "y^x^z", "y^z^x",
"(y^x)^z", "z^x^y", "z^y^x", "(z^x)^y"};
long double a[9];
long double x, y, z;
int main() {
cin >> x >> y >> z;
a[0] = pow(y, z) * log(x);
a[1] = pow(z, y) * log(x);... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<pair<int, int>> A(n);
vector<int> P;
for (int i = 0; i < n; ++i) {
cin >> A[i].first >> A[i].second;
P.push... | 6 |
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 5;
const long long INF = 1e9;
const long long MOD = 1e9 + 33;
int n, potega = 1;
vector<int> p, q, tree;
vector<int> ord_p, ord_q, show;
void input() {
cin >> n;
while (potega < n) potega *= 2;
p.resize(n + 5);
q.resize(n + 5);
for (in... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int MX_SZ = 2069;
int main() {
ios_base::sync_with_stdio(false);
int k;
cin >> k;
static bool arr[MX_SZ][MX_SZ];
for (int i = 0; i <= k; i++) {
for (int j = 0; j < (1 << i); j++) {
for (int k = 0; k < (1 << i); k++) {
arr[j][(1 << i) + k] =... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int N = -1;
const int mod = 1e9 + 7;
int sum(int a, int b) {
int c = (a + b);
if (c >= mod) c -= mod;
return c;
}
int mul(int a, int b) { return 1ll * a * b % mod; }
void solve() {
int x;
cin >> x;
string s;
cin >> s;
int mx = 2 * x;
int len = ((int)... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 50;
const long long INF = 1e18;
long long a[N << 2], lazy[N << 2];
void pushup(int rt) { a[rt] = min(a[rt << 1 | 1], a[rt << 1]); }
void pushdown(int rt) {
if (lazy[rt]) {
if (a[rt << 1] != INF) {
a[rt << 1] += lazy[rt];
lazy[rt << 1] +... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long int n, m, i;
cin >> n >> m;
long long int a[105], cumu[105], sum = 0;
cumu[0] = 0;
for (i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
cumu[i] = sum;
}
long long int ans = 0, l, r;
for (i = 0... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e6 + 50;
const long long inf = 1e17;
struct Point {
int x, y;
};
int N, R, M, ans;
vector<Point> vec;
vector<int> anw, now;
int dis(int x, int y) { return x * x + y * y; }
bool cmp(Point a, Point b) { return dis(a.x, a.y) >... | 5 |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n, m;
cin >> n >> m;
char a[110][10010];
for (long long i = 0; i <= n + 1; ++i) {
a[i][0] = '#';
a[i][m + 1] = '#';
}
for (long long i = 0; i <= m + 1; ++i) {
a[0][i] = '#';
... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t = 1;
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];
sort(a, a + n);
long long int g = 0;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
long long n, k;
cin >> n >> k;
vector<long long> v;
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
v.push_back(x);
}
sor... | 4 |
/*
__ __ _ __ __
| || | (_) | | | |
_ _ | || |_ _ _ __ ___ __ _ | |_ ___ _ __ __ _ | |
| | | || || __|| || '_ ` _ \ / _` || __| / _ \ | '_ \ / _` || |
| |_| || || |_ | || | | | | || (_| ... | 1 |
#include <bits/stdc++.h>
using namespace std;
bool visited[201][201], start[201][201], cur[201][201];
int n, m, cycVal[201][201], val[1000001];
char board[201][201];
pair<int, int> vec[10], cyc;
string query;
bool valid(int r, int c) { return r >= 0 && r < n && c >= 0 && c < m; }
bool check(int r, int c, int p) {
if ... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<28;
const int MAXN = 11;
int n;
string a[MAXN], b[MAXN];
string src, dst;
int ans;
string change(const string &s, int k) {
string t;
for(int i = 0; i < s.size(); ++i) {
if(s.substr(i, a[k].size()) == a[k]) {
t += b[k];
i += a[k].siz... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int INF = 9e18 + 2e17;
const int inf = 2e9;
const double eps = 1e-10;
const int MX_V = 301;
pair<vector<vector<int> >, vector<vector<int> > > calc(vector<int>& a) {
int n = (int)(a).size();
vector<vector<int> > dp(2 * n * n, vect... | 2 |
#include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return (!b) ? a : gcd(b, a % b);... | 6 |
#include <iostream>
#include <algorithm>
#include <limits>
using ll = long long;
constexpr int MAX_N = 500000;
int N;
std::pair<ll, ll> arts[MAX_N];
int main(){
std::cin >> N;
for(int i = 0; i < N; ++i){
std::cin >> arts[i].first >> arts[i].second;
}
std::sort(arts, arts + N);
for(int i = 0; i < N; ++i... | 0 |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> List;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
auto itr = upper_bound(List.begin(), List.end(), -A);
if (itr == List.end()) List.push_back(-A);
else *itr = -A;
}
cout << List.... | 0 |
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <complex>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define ... | 0 |
#include <bits/stdc++.h>
using namespace std;
int m, n;
int arr[105][105];
bool isSq(long long x) {
long long xx = sqrt(.0 + x);
for (int i = -2; i <= 2; ++i)
if ((xx + i) * (xx + i) == x) return true;
return false;
}
int buf[105];
long long sum[105];
int nn;
bool perebor(int pos) {
if (pos == nn) return is... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
scanf("%d %d", &n, &m);
vector<string> s(n);
for (string &e : s) cin >> e;
vector<vector<int> > a(n, vector<int>(m, 0));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
vector<int> dp(1 << n, (1 << 30))... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, t;
cin >> n >> k >> t;
if (t <= k) {
cout << t;
return 0;
} else if (t > k && t <= n) {
cout << k;
return 0;
} else {
cout << k - (t - n);
return 0;
}
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
struct Node {
vector<Node *> children;
vector<Node *> parents;
ll id = 0;
};
Node *lca(Node *l, Node *r) {
if (l->parents.size() > r->parents.size()) return lca(r, l);
ll lb = 0, ub = l->parents.size();
while... | 4 |
#include <bits/stdc++.h>
using namespace std;
const bool online_judge = true;
const long long inf = 1LL << 60;
long long toInt(string s) {
long long res;
stringstream ss;
ss << s;
ss >> res;
return res;
}
string toString(long long n) {
stringstream ss;
ss << n;
return ss.str();
}
void run() {
long lon... | 2 |
#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
const long long N = 1e5 + 5;
const long long MAXN = 1e7 + 1;
const long long mod = 1e9 + 7;
const long l... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int a[maxn], ans[maxn];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (int i = 0; i < n / 2; i++)
ans[i * 2] = a[i + n / 2], ans[i * 2 + 1] = a[i];
if (n % 2) ans[n - 1] = a[n - 1];
i... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long a[300005];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, i, j;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a[i];
}
long long carry = 0, temp, ans = 0;
for (i = 0; i < n; i++) {
temp = min(a[i] / 2, carry);... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int tt;
cin >> tt;
for (long long int qq = 0; qq <= tt - 1; qq++) {
long long int n;
cin >> n;
long long int counter = 0;
while (n % 5 == 0) {
n = (n / 5) * 4;
counter++;
}
while (n % 3 == 0) {
n = (n / ... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int a, b, c, d, s = 0, s2 = 0;
cin >> a >> b >> c >> d;
s = (a + 2) * 2 + b * 2 - c;
s2 = (c + 2) + (d - 1) * 2;
cout << s + s2 << endl;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
int main() {
cin >> n >> m >> s;
if (n == 1 && m == 1) {
cout << 0;
return 0;
}
if (s[0] != '1' && m > 0) {
s[0] = '1';
m--;
}
for (int i = 1; i < n; i++) {
if (m == 0) break;
if (s[i] != '0') {
s[i] = '0';
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int N;
char buf[20];
string name[10010];
string sep;
vector<string> v[20];
int used[20];
int main(void) {
int sum = 0, i, j;
scanf("%d", &N);
for ((i) = 0; (i) < (int)(N); (i)++) {
scanf("%s", buf);
name[i] = buf;
}
scanf("%s", buf);
sep = buf;
for ((i... | 4 |
#include <cstdio>
#include <map>
using namespace std;
int n, m, a;
map<int, int> mp;
int main() {
scanf("%d", &n);
while(n--) {
scanf("%d", &a);
mp[a]++;
}
scanf("%d", &m);
while(m--) {
scanf("%d", &a);
if(mp[a]==0) return !puts("NO");
mp[a]--;
}
puts("YES");
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int numbers;
cin >> numbers;
int arr[numbers];
int arr2[numbers - 1];
int arr3[numbers - 2];
for (int i = 0; i < numbers; i++) {
cin >> arr[i];
}
for (int k = 0; k < numbers - 1; k++) {
cin >> arr2[k];
}
for (int l = 0; l < numbers -... | 2 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(const T &a) {
return a * a;
}
template <typename T>
inline int nread(vector<T> &a) {
int n;
cin >> n;
a.clear();
a.resize(n);
for (int i = 0; i < n; i++) cin >> a[i];
return n;
}
int main() {
int n, m, s, f;
cin >> n >> m... | 3 |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<int> v;
int bns(int l, int h, int k) {
int ans = -1;
while (l <= h) {
int m = (l + h) / 2;
if (v[m] <= k) {
ans = m;
l = m + 1;
} else
h = m - 1;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false... | 2 |
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace ... | 0 |
#include <bits/stdc++.h>
#define double long double
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int h,w,cnt=0;char a[55][55];
signed main() {
cin>>h>>w;
rep(i,h){rep(j,w)cin>>a[i][j];}
rep(i,h){
rep(j,w){
if(a[i][j]=='.'){
for(int k=-1;k<2;k++){
for(int l=-1;l<2;l++... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, count = 0;
;
cin >> n >> a >> b;
--a, --b;
while (a != b) {
a /= 2;
b /= 2;
n /= 2;
count++;
}
if (n == 1) {
cout << "Final!";
return 0;
}
cout << count;
}
| 2 |
#include <iostream>
using namespace std;
int main() {
int n;
long long x, a[2000], b[2000], ans = 1e18;
cin >> n >> x;
for(int i=0;i<n;i++){
cin >> a[i];
b[i] = a[i];
}
for(int j=0;j<n;j++){
long long s = x*j;
for(int i=0;i<n;i++){
b[i] = min(b[i], a[... | 0 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int type0, type1;
void dfs(int s, bool visited[], vector<int> adj[], int type[], int ctr) {
if (visited[s]) return;
visited[s... | 5 |
#include <bits/stdc++.h>
using ll = long long;
const int MAXN = 5555;
const int MOD = 1000000007;
int fact[MAXN], rev[MAXN];
int dp[33][MAXN];
int sum[MAXN];
int N;
std::string str;
ll power(ll x, ll y, ll m) {
if (y == 0) return 1;
ll p = power(x, y / 2, m) % m;
p = (p * p) % m;
return (y % 2 == 0) ? p : (x * ... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 233;
int pre[maxn][21], last[maxn], a[maxn], val[maxn];
int ch[maxn * 20], lc[maxn * 20], rc[maxn * 20], rt[maxn];
int cnt = 0;
void add(int l, int r, int& cur, int v) {
cnt++;
ch[cnt] = ch[cur] + 1;
lc[cnt] = lc[cur];
rc[cnt] = rc[cur];
cur... | 5 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O0")
#pragma GCC optimize("O1")
long long pw(int a, int b) {
long long ret = 1;
long long mul = a;
while (b > 0) {
if (b & 1) ret *= mul;
mul *= mul;
b /= 2;
}
ret... | 4 |
// 2012/11/19 Tazoe
#include <iostream>
using namespace std;
int main()
{
bool is_prime[1000001];
is_prime[0] = is_prime[1] = false;
for(int i=2; i<=1000000; i++){
is_prime[i] = true;
}
for(int i=2; i*i<=1000000; i++){
if(is_prime[i]){
for(int j=i*i; j<=1000000; j+=i){
is_prime[j] = false;
}
}
... | 0 |
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int t;
while (cin >> t){
while (t / 39 != 0) {
t = t - 39;
}
if (t == 0) {
t = 39;
}
printf("3C%02d\n",t);
}
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, s[N][26], p[N][26], sum[26];
char str[N];
int main() {
scanf("%d", &n);
scanf("%s", str + 1);
for (int i = 1; i <= n; i++)
for (int j = 0; j < 26; j++)
if (j == str[i] - 'a')
s[i][j] = s[i - 1][j] + 1;
else
... | 2 |
#include <bits/stdc++.h>
struct ResItem {
char c;
int pos;
ResItem(char _c, int _pos) {
c = _c;
pos = _pos;
}
};
bool sortfunction(const ResItem& i, const ResItem& j) {
return (i.pos < j.pos);
}
int main(int argc, char* argv[]) {
int k, n;
std::string s;
std::cin >> k >> s >> n;
std::vector<in... | 3 |
#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T& a) {
return a * a;
}
template <typename T>
T inline ABS(const T& a) {
return a < 0 ? -a : a;
}
template <typename T>
T inline MIN(const T& a, const T& b) {
if (a < b) return a;
return b;
}
template <typename T>
T inline MAX(const T& a, const T... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn], p, x, b[maxn];
inline bool check(int y) {
memset(a, 0, sizeof(a));
int temp = 0, T;
a[1] = y;
for (int i = 2; i <= p; i++) {
T = a[i - 1] * x + temp;
a[i] = T % 10;
temp = T / 10;
}
temp = 0;
for (int i = 1; i... | 2 |
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
int sg[5005], occur[5005], good[5005], sg2[5005];
char str[5005];
int main() {
cin >> str;
sg[1] = 1;
for (int i = (2); i < (5005); i++) {
memset(occur, 0, sizeof(occur));
for (int m = (0); m < (i); m++) {
int l = max(m - 1, 0),... | 5 |
#include <bits/stdc++.h>
using namespace std;
string a;
long long int h[256];
int main() {
long long int i, sum = 0;
cin >> a;
for (i = 0; i < a.length(); i++) {
h[a[i]]++;
}
for (i = 0; i < 256; i++) {
sum = sum + h[i] * h[i];
}
cout << sum;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
T x0 = 1, y0 = 0, x1 = 0,... | 4 |
#include<stdio.h>
int n;
int i,j;
int ans;
int order;
typedef struct{
int wl,wr,tl,tr,le,ri;
bool flag;
}t_stick;
t_stick st[100];
int max(int a,int b){
if(a>=b)return a;
else return b;
}
int min(int a,int b){
if(a<=b)return a;
else return b;
}
int gcd(int a,int b){
int x,y;
x=max(a,b);
y=min(a,b);
if(a%b=... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, k;
int low, high, mid;
int l, r;
vector<int> v, vsum;
bool searching() {
l = 0, r = mid;
int ones, zeros;
while (r <= n) {
ones = vsum[r] - vsum[l];
zeros = mid - ones;
if (zeros <= k) {
low = mid + 1;
return true;
} else {
l++... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long p, k;
long long val[111], ans[111];
int main() {
cin >> p >> k;
val[0] = -(p / k);
for (int pw = 0; pw < 100; ++pw) {
if (val[pw] == 0) {
for (int i = pw; i >= 0; --i) {
ans[i + 1] = val[i] + val[i + 1] * k;
}
ans[0] = val[0] * ... | 2 |
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int n,pos;
vector<int>pre,in,post;
void rec(int l,int r){
if(l >= r) return;
int root = pre[pos++];
int m = distance(in.begin(),find(in.begin(),in.end(),root));
rec(l,m);
rec(m + 1,r);
post.push_back... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
printf("%lld\n", (a + b + c) / 2);
}
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vll = vector<long long>;
using vvll = vector<vll>;
template <class T>
using min_queue = prio... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 123456;
long long n, m, x, l, r;
vector<long long> v1;
vector<long long> v2;
long long a1[N];
long long a2[N];
int main() {
scanf("%lld", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &x);
v1.push_back(x);
}
v2 = v1;
sort(v2.begin(),... | 2 |
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tc;
cin >> tc;
while (tc--) {
lint a, b;
cin >> a >> b;
if (a < b) swap(a, b);
if (a == b) cout << 0 << " " << 0 << '\n';
else {
cout << (a - b) << " " << min(a % (a -... | 1 |
#include <bits/stdc++.h>
using namespace std;
int N, Y[50001];
set<int> pos[50001];
set<int> used;
priority_queue<int> q;
int next(int x) {
int temp = x;
while (x != 0) {
if (used.count(x) == 0) return x;
x /= 2;
}
return temp;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> Y[i];
... | 4 |
#include <bits/stdc++.h>
using namespace std;
int C[105][105];
const int mod = int(1e9) + 7;
int qt[10];
long long dp[105][10];
long long solve(int pos, int digit) {
if (digit == 10 && pos == 0) return 1;
if (digit == 10) return 0;
long long &ans = dp[pos][digit];
if (ans != -1) return ans;
ans = 0;
if (dig... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
long long n, q, d[N];
long long a[N << 2], m[N << 2], s[N << 2];
void init() {
for (long long i = 1; i < N; i++) {
for (long long j = i; j < N; j += i) {
d[j]++;
}
}
}
void build(long long t, long long l, long long r) {
if (... | 6 |
#include <bits/stdc++.h>
using namespace std;
int hmt() {
int x = 0;
int c = getchar(), n = 0;
for (; !isdigit(c); c = getchar()) n = (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
if (n) x = -x;
return x;
}
const int N = 300010;
int n, t[4 * N], mem[4 * N];
void tran(int s) {
int x =... | 4 |
#include <bits/stdc++.h>
using namespace std;
int a[1005];
int h;
vector<int> v;
bool chec(int x) {
v.clear();
for (int i = 0; i < x; i++) v.push_back(a[i]);
sort(v.begin(), v.end());
long long p = h;
for (int i = v.size() - 1; i >= 0; i -= 2) p -= v[i];
return (p >= 0);
}
int main() {
ios::sync_with_stdi... | 2 |
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 100000... | 0 |
#include <bits/stdc++.h>
using namespace std;
int N, M, X, Y, dx, dy;
map<pair<int, int>, int> F;
void doit() {
char s[3];
long long ans = 1;
scanf("%d%d%d%d%s", &N, &M, &X, &Y, s), dx = s[0] == 'U' ? -1 : 1,
dy = s[1] == 'L' ? -1 : 1;
for (int i = 1; i <= (N + M) * 2; ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int dp[500003], city[500003];
int main() {
int m, n, maxx, s;
int a[200], ans[200], anss;
while (scanf("%d%d", &m, &n) != EOF) {
memset(ans, 0, sizeof(ans));
for (int i = 1; i <= n; i++) {
maxx = -1;
for (int j = 1; j <= m; j++) {
scanf("%d... | 1 |
#include <bits/stdc++.h>
using namespace std;
int r, n;
int buil[50] = {0};
double sun[50] = {0.0};
void sunset();
double solve();
int main() {
cout << fixed << setprecision(8);
int i, j, le, ri, he;
while(1) {
cin >> r >> n;
for(i = 0; i < 50; ++i) buil[i] = 0;
for(i = 0; i < 50; ++i) sun[i] = -99... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.