solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <class T>
T abs(T &x) {
return (x >= 0) ? (x) : (-x);
}
template <class T>
T sqr(T &x) {
return (x) * (x);
}
template <class T>
T min(T &a, T &b) {
return (a < b) ? (a) : (b);
}
template <class T>
T max(T &a, T &b) ... | 2 |
#include <iostream>
int main() {
long long b = 100, n, k=0;
std::cin >> n;
while (b < n) {
b += b/100;
k++;
}
std::cout << k;
} | 0 |
#include <iostream>
#include <string>
using namespace std;
int main(){
string s, strCopy;
while (getline(cin, s)) {
for(int j=0 ; j<26 ; j++){
for(int i=0 ; i<s.size() ; i++){
if(s[i]>='a' && s[i]<='z'){
s[i] = (s[i]=='z')? 'a' : s[i] + 1;
}
}
if( s.find( "the" ) != string::npos || s.find( "t... | 0 |
#include <bits/stdc++.h>
using namespace std;
void preprocess(void) { return; }
int main(void) {
preprocess();
int t;
t = 1;
for (int z = 1; z <= t; z++) {
long long s, e, ti;
scanf("%lld", &s), scanf("%lld", &e), scanf("%lld", &ti);
int n;
scanf("%d", &n);
vector<long long> arrival(n);
... | 2 |
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<vector<int> > a;
const int MAX = 15;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
bool valid(int x, int y) {
return 0 <= x && x < n && 0 <= y && y < n;
}
void Rotate() {
in... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long max_int;
vector<int> product, sum;
long long Round_up(long long a, long long b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
long long Good_count(long long cur_product, long long cur_sum, int index) {
long long answer = 0;
if ... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 17;
const int INF = 1e9 + 7;
const int MOD = 1e8 + 7;
const double eps = 1e-9;
const double pi = 3.14159265359;
int p[N / 2], cost[N / 2], n, k, m;
map<string, int> w;
long long ans = 0;
int dsu_get(int v) { return (v == p[v]) ? v : (p[v] = dsu_get(p[v])... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
string s;
cin >> s;
string match = "WUB";
string::size_type i;
while ((i = s.find(match)) != string::npos) {
s.replace(i, match.size(), " ");
}
stringstream stream(s);
string res;
while (stream >> res) {
cou... | 1 |
#include <bits/stdc++.h>
using namespace std;
int A,B;
int main(){cin>>A>>B;if(A+B>9){cout<<"error";}else{cout<<A+B;}} | 0 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int MaxN = 5e5 + 17;
const int INF = 1e9 + 17;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const double pi = 3.14159265359;
long long check2(long long n, long long m) {
... | 3 |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const int maxn = 200010;
int IN() {
int c, f, x;
while (!isdigit(c = getchar()) && c != '-')
;
c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0');
while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0';
return !f ? x : -x... | 2 |
#include <bits/stdc++.h>
using namespace std;
char a,b,c,d;
int main() {
cin>>a>>b>>c>>d;
if (a==b || b==c || c==d)
cout<<"Bad"<<endl;else cout<<"Good"<<endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
long long cnt = 0;
bool ck[100005];
int vec[100005];
long long _gcd(long long x, long long y) {
if (x == 0)
return y;
else
return _gcd(y % x, x);
}
void dfs(int ind, int vv) {
ck[ind] = true;
cnt++;
if (vec[ind] == vv) return;
if (!ck[vec[ind]]) {
df... | 3 |
#include <stdio.h>
char S[111];
int main()
{
scanf ("%s",S);
for (int i=0;S[i];i++){
if (i % 2 == 0 && S[i] == 'L'){
puts("No"); return 0;
}
if (i % 2 == 1 && S[i] == 'R'){
puts("No"); return 0;
}
}
puts("Yes");
return 0;
}
| 0 |
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <numeric>
using namespac... | 0 |
#include <bits/stdc++.h>
int n;
int days[105];
int states[105][3];
int main() {
for (int i = 0; i < 105; i++) {
states[i][0] = states[i][1] = states[i][2] = 10000;
}
states[0][0] = 1;
std::cin >> n;
for (int i = 0; i < n; i++) {
std::cin >> days[i];
}
if (days[0] == 1 || days[0] == 3) {
states... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000001;
const double EPS = 10e-9;
struct Skills {
int n, A, cf, cm;
long long m;
vector<pair<int, int>> skills;
vector<long long> sum;
Skills(int n, int A, int cf, int cm, long long m) {
this->n = n;
this->A = A;
this->cf = cf;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <class T>
ostream& prnt(ostream& out, T v) {
out << v.size() << '\n';
for (auto e : v) out << e << ' ';
return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
return prnt(out, v);
}
template <cla... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
for (int k = 0; k < t; k++) {
int n, total = 0;
cin >> n;
while (n / 10 > 0) {
total = total + (n - (n % 10));
n = ((n - (n % 10)) / 10) + n % 10;
}
cout << total + (n % 10) << " ";
}
return 0... | 2 |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <functional>
#include <ca... | 0 |
#include <bits/stdc++.h>
using namespace std;
bool check(long long x) {
double a = sqrt(1 + 8 * x) - 1;
return (a > 1 && (a - floor(a) == 0) && !((int(a)) & 1));
}
int main() {
long long n;
cin >> n;
for (long long i = 1; i * (i + 1) / 2 < n; ++i) {
if (check(n - i * (i + 1) / 2)) {
cout << "YES\n";... | 1 |
#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int cas = 1;
int dxx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dyy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, x;
map<int, int> mp;
int log2(int x) {
int p = 0;
while (x > 0) {
p++;
x /= 2;
}
return p;
}
int pow2(int x, int p) {
int sol = 1;
while (p > 0) {
if (p % 2 == 1) sol = sol * x;
x = x * x;
p /= 2;
}
return sol;
}
int main() {
sca... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const long long hh = 523;
const int mod = 1073741824;
multiset<int> s1, s2;
int l[300007], r[300007];
int n;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d%d", l + i, r + i);
s1.ins... | 3 |
#include <bits/stdc++.h>
using namespace std;
int const N = 2e6 + 5, M = 20 + 5, MOD = 1e9 + 7, OO = 0x3f3f3f3f;
int t, n;
long long ans[N];
int main() {
scanf("%d", &t);
ans[1] = 0;
ans[2] = 4;
for (int i = 3; i <= 2e6; i++)
ans[i] = (2 * ans[i - 2] + ans[i - 1] + (i % 3 == 2) * 4) % MOD;
while (t--) {
... | 4 |
#include <bits/stdc++.h>
using namespace std;
const long long int mo = 998244353ll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int test;
cin >> test;
while (test--) {
long long int n, k;
cin >> n >> k;
long long int a[200009], pos[200009];
for (long long int... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int length;
std::cin >> length;
int waysToSplit = 0;
if (length % 2 != 0) {
std::cout << 0;
return 0;
}
length = length / 2;
for (int i = 1; i < length; i++) {
if (i != (length - i)) {
waysToSplit++;
}
}
waysToSplit = way... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, a[100000], mi, ma;
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
mi = min(a[0], a[n - 1]);
ma = 0;
for (i = 1; i < n - 1; i++) {
if (a[i] < a[i + 1]) {
i++;
mi = min(max(a[i], a[i - 1]), mi);
} else
mi ... | 2 |
#include <bits/stdc++.h>
using namespace std;
char a[1005], b[1005];
int main() {
int i, j, n, a1 = 0, b1 = 0;
scanf(" %s", &a);
scanf(" %s", &b);
int tama = strlen(a), tamb = strlen(b);
for (i = 0; i < tama; i++) {
if (a[i] == '1') a1++;
}
for (i = 0; i < tamb; i++) {
if (b[i] == '1') b1++;
}
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int A[101];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, d;
cin >> n >> d;
for (int i = 0; i < n; ++i) cin >> A[i];
sort(A, A + n);
int ans = 1e9;
for (int i = 0; i < n; ++i)
for (int j = i; j < n; ++j)
if (A[j] - A[i] <= d) ans = min(a... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int v1, v2, v3, vm, k1 = 0, k2 = 0, k3 = 0;
cin >> v1 >> v2 >> v3 >> vm;
for (int i = max(v3, vm); i <= 2 * v3 && i <= 2 * vm; ++i)
if (i >= v3 && i >= vm) {
k3 = i;
break;
}
if (k3 == 0) {
cout << "-1";
return 0;
}
for (... | 1 |
#include <bits/stdc++.h>
const int N = 2005;
const int mod = 998244353;
using LL = long long;
int tc, n, a[N], n0, n1, factor[N], ifactor[N];
std::string s[N];
int f0[N][11], f1[N][11], g[N][11];
int pow(int x, int y, int ans = 1) {
for (; y; y >>= 1, x = (LL)x * x % mod)
if (y & 1) ans = (LL)ans * x % mod;
ret... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
const int N = (int)(2e5 + 12);
set<long long> s;
long long k = 0;
unordered_map<int, bool> u[N];
void dfs(int v) {
s.erase(v);
vector<int> a;
for (auto it : s)
if (!u[v][it]) a.push_back(it);
for (auto it : a) s.erase(it);
for (auto it :... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
long long int x, y, l, r;
cin >> x >> y >> l >> r;
vector<long long int> possible;
for (long long int i = 1; i < r; i *= x) {
for (long long int j = 1; j < r; j *= y) {
possible.push_back(i + j);
if (r / y < j... | 2 |
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int cnt = 0;
string s, t;
while (cin >> s) {
t = s;
reverse(t.begin(), t.end());
if (s == t)
++cnt;
}
cout << cnt << endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5, AL = 26;
long long n, a[MAX_N];
vector<int> li, ri, beg[AL], rev[AL];
string second;
long long mrg(int l, int r) {
if (l == r) {
return 0;
}
if (l == r - 1) {
bool b = false;
if (a[l] > a[l + 1]) {
b = true;
swap(a[l]... | 5 |
#include <iostream>
using namespace std;
int main() {
int D, L;
cin >> D >> L;
int ans = D / L;
ans += D % L;
cout << ans << endl;
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,K;cin>>A>>B>>K;
for(int i=A;i<=min(B,A+K-1);i++)cout<<i<<endl;
for(int i=max(B-K+1,min(B,A+K-1)+1);i<=B;i++)cout<<i<<endl;
} | 0 |
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define pii pair<int,int>
int main() {
int n;
while(cin>>n,n) {
vector<pii> v;
for (int i=0;i<n;i++) {
int a, b;
cin >> a >> b;
v.push_back(pii(b,a));
}
sort(v.begin(),v.end());
... | 0 |
#include<bits/stdc++.h>
#define N 100010
using namespace std;
struct no{
int to, cost;
};
int n;
vector<no> G[N];//邻接表
int d[N];
bool used[N];
void bfs(int s){
queue<int> q;
fill(d, d+N, 0);
fill(used, used+N, false);
d[s] = 0;
q.push(s);
while(!q.empty()){
int t = q.front(); q.pop()... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long INF = 1e18;
long long n;
bool ok(char c1, char c2) {
long long x1 = c1 - 'a', x2 = c2 - 'a';
if (x1 < x2) swap(x1, x2);
long long dis = (x1 - x2);
if (dis == 0 || dis == 2)
return true;
else
return false;
}
... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin>>a>>b;
int ans=-1;
for(int i=1;i<1500;i++){
if(i*8/100==a && i/10==b){
ans=i;
break;
}
}
cout<<ans<<endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
long long tra[10000];
int main() {
long long n, m;
char c;
cin >> n >> m >> c;
char s[n + 4][m + 4];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) cin >> s[i][j];
long long sum = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int a[1003];
int main() {
int n, i, f = 0, count = 0;
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
for (i = 1; i < n; i++) {
if (a[i] == a[i + 1] && a[i] != 0) {
if (a[i] == a[i + 2]) {
f = 1;
break;
} els... | 1 |
#include<iostream>
using namespace std;
int main()
{
int x;
cin>>x;
int a=x/100;
x%=100;
if(a*5>=x)
{
cout<<"1"<<endl;
}
else
{
cout<<"0"<<endl;
}
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
int ns = 0, zs = 0;
for (const auto &c : s) {
if (c == 'n') {
++ns;
} else if (c == 'z') {
++zs;
}
}
ostringstream oss;
f... | 1 |
#include <bits/stdc++.h>
using namespace std;
bool codejam = 0;
void solve();
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
long long t = 1;
long long tt = t;
while (t--) {
if (codejam) cout << "Case #" << tt - t << ": ";
solve();
}
retur... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string X;
cin >> X;
for(int i=X.size()/2-1; i>0; i--) {
if(X.substr(0, i) == X.substr(i, i)) {
cout << i*2;
return 0;
}
}
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int l;
cin >> l;
string S;
cin >> S;
int ans = 0;
for(int i = 0; i < l; ++i){
if(S[i] != '.'){
continue;
}
int i1 = i;
int i2 = i;
int h = 0;
while(1){
if(i1 == 0){
break;
}
--i1;
if(S[i1] == 'W... | 0 |
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
int ask(int y)
{
cout << y << '\n';
cout.flush();
int r;
scanf("%d", &r);
return r;
}
int main()
{
int ttt;
cin >> ttt;
whi... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b, long long mod) {
if (b == 0 || a == 1) return mod == 1 ? 0 : 1;
if (b % 2 == 0) {
long long k = powmod(a, b / 2, mod);
return (k * k) % mod;
} else {
long long k = powmod(a, b / 2, mod);
return ((k * k) % mod ... | 2 |
#include <bits/stdc++.h>
using namespace std;
struct no {
no *l, *r;
long long s;
int cnt;
no() : l(nullptr), r(nullptr), s(0), cnt(0) {}
};
typedef no *noptr;
inline int getcnt(const noptr &n) { return n ? n->cnt : 0; }
inline long long gets(const noptr &n) { return n ? n->s : 0; }
void insert(noptr &n, int va... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main () {
char a;
cin >> a;
cout << ((a >= 'a') ? 'a' : 'A');
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxk = 1e3 + 4;
vector<int> values(maxk, 0);
void solve() {
int k;
cin >> k;
cout << values[k - 1] << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int count = 1;
for (int i = 0; i < maxk; i++) {
while (c... | 1 |
#include <bits/stdc++.h>
using namespace std;
bool dp[200005];
int A[200005], back[200005];
long long int sum[200005];
int main() {
int n, C;
scanf("%d", &C);
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &A[i]);
sort(A, A + n);
for (int i = 0; i < n; i++) {
sum[i] = A[i];
if (i > 0) sum[... | 5 |
#include <bits/stdc++.h>
using namespace std;
struct node
{
int d,co,flag;
node (int d, int co, int flag) : d(d) , co(co),flag(flag) {}
friend bool operator < (const node a,const node b)
{
return a.d < b.d;
}
};
multiset<int>M;
vector<node>V;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i = 0 ... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
vector<pair<int, int> > g[N], a[N];
int b[N], cnt;
void dfs(int u, int p, int d, vector<pair<int, int> > &v) {
cnt += b[u];
if (g[u].size() == 1 && d != 0) v.push_back({u, d});
for (auto i : g[u])
if (i.first != p) {
dfs(i.first, u, d + i.s... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long n, now;
long long has1, food[100005];
long long has2, peo[100005];
long long a[100005];
char ch;
long long find(long long x) {
long long l = 1, r = has1, mid;
if (food[r] <= x) return has1 + 1;
while (l < r) {
mid = l + r >> 1;
if (food[mid] <= x)
... | 5 |
#include <bits/stdc++.h>
using namespace std;
struct node {
int pr, va;
} b[200102];
int n, m, js, siz[200102], son[200102][2], val[200102], rnd[200102], rt,
lz1[200102], lz2[200102], ans[200102], st[200102], tot;
inline void pushup(int x) { siz[x] = siz[son[x][0]] + siz[son[x][1]] + 1; }
inline int newnd(int x) ... | 6 |
#include <iostream>
using namespace std;
int main() {
int n, a, p1 = 0, p2 = 0, p4 = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
if (a % 4 == 0) p4++;
else if (a % 2 == 0) p2++;
else p1++;
}
if (p4 >= p1) cout << "Yes";
else if (p1 - p4 == 1 && p2 == 0) cout << "Yes";
else cout <... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long z = 998244353;
long long gcd(long long a, long long b) {
if (a == 0) return b;
if (b == 0) return a;
return gcd(b, a % b);
}
long long power(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) res = (res * a) % z, b--;
a = (a * ... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long int x, k, pol = 0, y[100000];
int dfs(long long int X, long long int K) {
if (pol >= 100000) return 0;
int p;
if (X == 1) {
printf("1 ");
pol++;
} else if (K == 0) {
printf("%I64d ", X);
pol++;
} else {
K--;
for (p = 0; p < 100000... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int a[] = {15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7};
int main() {
int n;
scanf("%d", &n);
printf("%d", a[n]);
return 0;
}
| 1 |
#include <bits/stdc++.h>
const long long oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
int o(int x) { return x % _p; }
long long o(long long x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b;... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
map<int, bool> mp;
map<int, int> weight;
for (int i = 0; i < (int)(n); i++) {
int x;
cin >> x;
weight[i + 1] = x;
}
deque<int> dq;
int sum = 0;
for (int i = 0; ... | 3 |
#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while (getline(ss, x, c)) v.push_back(x);
return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator... | 2 |
#include<stdio.h>
int main()
{
double t1,t2;
while(scanf("%lf%lf",&t1,&t2)>0)
{
if(t1<35.5&&t2<71)
printf("AAA\n");
else if(t1<37.5&&t2<77)
printf("AA\n");
else if(t1<40&&t2<83)
printf("A\n");
else if(t1<43&&t2<89)
printf("B\n");
else if(t1<50&&t2<105)
printf("C\n");
else if(t1<55&&t2<116)... | 0 |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
template <class T>
inline T _abs(T n) {
return ((n) < 0 ? -(n) : (n));
}
template <class T>
inline T _max(T a, T b) {
return (!((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _min... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
vector<int> g[2][maxn];
int fa[2][maxn];
int pp[maxn];
vector<pair<pair<int, int>, pair<int, int> > > gg;
int find(int p) {
if (pp[p] == -1 || pp[p] == p) return pp[p] = p;
return pp[p] = find(pp[p]);
}
int panduan(int u, int x, int y) {
if (f... | 5 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
void initVect(const Point& a, const Point& b) {
x = b.x - a.x;
y = b.y - a.y;
normalize();
}
void rotate(double alp... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, cnt = 0;
string a, b, c;
cin >> a >> b;
for (i = 0; i < a.size(); i++) {
if (a[i] != b[i]) cnt++;
if (cnt % 2 == 0) a[i] = b[i];
}
if (cnt % 2 != 0)
cout << "impossible";
else
cout << a;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n);
for (int i = 0; i < n; ++i) A[i] = i + 1;
int maximum = -1, index = -1;
vector<int> current;
do {
int sum = 0;
for (int i = 0; i < n; ++i) {
for (int j = i; j < n; ++j) {
int minimum... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
int n, d;
cin >> n >> d;
vector<int> vec;
for (int i = 0; i < n; i++) {
char ch;
cin >> ch;
if (ch == '1') vec.push_back(i + 1);
}
int k = 1;
bool fl = false;
int cnt... | 1 |
#include <bits/stdc++.h>
using namespace std;
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 __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | 3 |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[20];
int main() {
scanf("%s",s);
int n=strlen(s),flg=0;
for(int i=1;i<n;i++) if(s[i]!='9') flg=1;
cout<<s[0]-'0'-flg+9*(n-1);
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long ost = 1000000007;
int n;
cin >> n;
long long s = 1;
vector<vector<long long> > x(n + 1, vector<long long>(n + 1));
x[0][0] = 1;
for (int i = 1; i <= n; i++) {
x[i][0] = 1;
f... | 2 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
int n = s.length();
if (!s[n - 1] & 1) {
for (int i = 0; i < n; i++) {
if (s[i] % 2 == 0 && s[i] < s[n - 1]) {
swap(s[i], s[n - 1]);
... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int p[MAXN];
int get(int a) {
if (p[a] == a) {
return a;
}
return p[a] = get(p[a]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
set<pair<long long, int>> cost;
int n, m;
cin >> n >> m;
vector<long long> a(n + 1);
... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200020;
const int MOD = 1000000000;
int add(int a, int b) { return a >= MOD - b ? a - MOD + b : a + b; }
int mul(int a, int b) {
return a ? (b < MOD / a ? a * b : (long long)a * b % MOD) : 0;
}
int sub(int a, int b) { return a < b ? a - b + MOD : a - b; }... | 5 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
const long long MOD2 = (long lon... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
if (k * n > n * (n - 1) / 2) {
cout << -1;
return 0;
}
cout << k * n << endl;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < k; ++j) {
cout << (i + 1)... | 1 |
#include <bits/stdc++.h>
struct Node {
int val, lazy;
};
Node minST[131072 << 1], maxST[131072 << 1];
int savesu[130000];
void upd(int idx, int ss, int ee, int from, int to, int whatmx, int whatmn) {
if (ss == from && ee == to) {
minST[idx].lazy += whatmn;
maxST[idx].lazy += whatmx;
return;
} else {
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x,y;
cin>>x>>y;
string a;
for(int i=0;i<y+2;i++)
a+='#';
cout<<a<<endl;
string b[x];
for(int i=0;i<x;i++){
cin>>b[i];
string c;
c='#'+b[i]+'#';
cout<<c<<endl;
}
cout<<a<<endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const int LEN = 131;
int ants[2][LEN][LEN];
int main() {
int n, t;
cin >> n >> t;
memset(ants, 0, sizeof(ants));
ants[0][LEN / 2][LEN / 2] = n;
int d = 1;
int s = 0;
while (true) {
bool update = false;
memset(ants[d], 0, sizeof(ants[d]));
for (int ... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x20202020;
const int MOD = 1000000007;
inline void read(long long &x) {
char ch;
bool f = 0;
long long a = 0;
while (!((((ch = getchar()) >= '0') && (ch <= '9')) || (ch == '-')))
;
if (ch != '-')
a *= 10, a += ch - '0';
else
f = 1;
... | 2 |
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
// O(n*n + m*m*lim)
int main(){
int lim, n, m, x;
string s;
while(cin >> lim >> n >> m >> x, lim){
vector<int> v[11], dps(1001, 0);
for(int i = 0; i < n; i++){
int a, b;
cin >> s >> a >> b;
... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, i, le, ri;
pair<int, int> a[1000000];
int range[2000210][2], hight[2000010];
bool col1(const pair<int, int> &i, const pair<int, int> &j) {
if (i.first < j.first) return true;
if (i.first > j.first) return false;
return (i.second < j.second);
}
int findR... | 4 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool getmin(T *a, const T &b) {
if (b < *a) {
*a = b;
return true;
}
return false;
}
template <class T>
inline bool getmax(T *a, const T &b) {
if (b > *a) {
*a = b;
return true;
}
return false;
}
template <class T>
inlin... | 4 |
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 19;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-8;
map<long long, i... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int sq = log2(n);
cout << round(pow(2, sq)) << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
{
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
long long cnt = 0;
for (... | 3 |
#include <iostream>
using namespace std;
int main(void){
int n;
cin>>n;
int a[1001] = {0};
for(int i=0;i<=n;i++){
int b=i,j=2;
while(b>1){
if(b%j==0){
b=b/j;
a[j]++;
}else{
j++;
}
}
}
long... | 0 |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int r, s, p; cin >> r >> s >> p;
vector<int> nums;
for (int _ = 0; _ < p; ++_) {
int i, j; cin >> i >> j; --i, --j;
if (j >= s) ++j;
nums.push_back(abs(i - r) + abs(j - s));
}
sort(n... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<string> d(n);
for (int i = 0; i < n; ++i) cin >> d[i];
bool v[1000][1000] = {0};
vector<vector<int> > p;
p.resize(n);
for (int i = 0; i < n; ++i) p[i].resize(m);
for (int i = 0; i < n; ++i)
for (int j = 0; j... | 2 |
#include <bits/stdc++.h>
using namespace std;
void adde(vector<long long int> adj[], long long int u, long long int v) {
adj[u].push_back(v);
adj[v].push_back(u);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(6);
for (int i = 0; i < 6; i++) cin >> a.at(i);
cout << (a.at(1) + a.at(2) + a.at(3)) * (a.at(1) + a.at(2) + a.at(3)) -
a.at(1) * a.at(1) - a.at(3) * a.at(3) - a.at(5) * a.at(5);
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
int n, m, t, a[1005 * 1005];
long long f[1005][1005];
vector<int> v[1005];
long long dfs(int l, int r) {
if (l > r) return 1;
if (~f[l][r]) return f[l][r];
long long gl = 0, gr = 0, g = 0;
int mn = 1e9;
for (int i = l; i <= r; i++) mn = min(mn, a[i]);
int L = v[... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
float a, b, c, d;
float e;
cin >> a >> b >> c >> d;
e = a * d / (a * d + b * c - a * c);
ios::fixed;
cout << setprecision(12) << e;
}
| 2 |
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
const int mod = 1e9+7;
int n,k,f[2010][2010];
ll inv[4001000],fac[4001000],ifac[4001000];
ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
void upd(int &a,ll b){a=(a+b)%mod;}
int main(){
cin>>n>>k;
if(k==1){cout<<1... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.