solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
const int ms = 10 + 10;
pair<int, int> a[ms], b[ms];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x, y;
cin >> x >> y;
for (int i = 0; i < x; ++i) {
cin >> a[i].first >> a[i].second;
if (a[i].first > a[i].second) swap(a[i].first, a[i].se... | 4 |
#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void read(_T &f) {
f = 0;
_T fu = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') fu = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
f = (f << 3) + (f << 1) + (c & 15);
c = getchar();
}
f ... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
vector<int> G[N];
int n, m, L[N], R[N];
bool vis[N];
queue<int> Q;
vector<int> cur;
vector<vector<int> > ans;
void Delete(int x) {
R[L[x]] = R[x];
L[R[x]] = L[x];
}
bool Find(int u, int v) {
vector<int>::iterator it = lower_bound(G[u].begin(), G... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n == 1 || n == 2 || n == 4) {
cout << -1 << endl;
continue;
}
if (n % 3 == 0) {
cout << n / 3 << " " << 0 << " " << 0 << endl;
continue;
} else if (n % 3 =... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
double amin = 10, amax = 1e10;
int num;
const double EPS = 1e-6;
for (int i = 1; i <= (n); i++) {
cin >> num;
amax = min(amax, 10.0 * (1 + num) / i - EPS);
amin = max(amin, num * 10.0 / i);
}
double bmax = (n + 1) * ... | 3 |
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define N 200012
typedef long long ll;
const int p=1e9+7;
int n,m;
int a[N],dp[18][N];
int f[N],inv[N],finv[N],siz[N];
inline int C(int nn,int mm)
{
if(nn==mm||m... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N,M,V,P;
cin >> N >> M >> V >> P;
vector<long long> A(N);
vector<long long> Asum(N+1);
for(int i=0;i<N;i++) cin >> A[i];
A.push_back(1001001001);
sort(A.begin(),A.end());
reverse(A.begin(),A.end());
Asum[0] = 0;
for(int i=1;i<=N;i... | 0 |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {
ios::sync_with_stdio(false);
int n, m;
long long res = 0;
cin >> n >> m;
for (int i = (2); i < (n + 1); i += 2)
for (int j = (2); j < (m + 1); j += 2) res += (n - i + 1) * (m - j + 1);
cout << ... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 100;
const int INF = 1e9;
const double eps = 1e-7;
void solve() {
int n;
cin >> n;
vector<long long> a(n + 1, 0);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.begin() + n);
for (int i = n - 1; i > -1; i--) {
cout ... | 2 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstr... | 0 |
#include<cstdio>
using namespace std;
int main()
{
char ch,ph;
scanf("%c %c",&ch,&ph);
ch==ph?printf("=\n"):(ch>ph?printf(">\n"):printf("<\n"));
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string hola;
string chau = "NO";
int gente[4];
int autos[12];
int choques[4];
int accidentes = 0;
for (int i = 0; i < 4; i++) {
cin >> autos[i * 3];
cin >> autos[i * 3 + 1];
cin >> autos[i * 3 + 2];
cin >> gente[i];
choques[i] ... | 1 |
// 0130
#include <iostream>
#include <deque>
#include <string>
const int C = 'a';
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
string str;
cin>>str;
deque<char> dq;
dq.push_back(str[0]);
int ch[26] = {0};
ch[str[0]-C]++;
for(int j=1;j<str.length();j+=3){
if((str[j] == ... | 0 |
#include <bits/stdc++.h>
using namespace std;
string i2s(int x) {
stringstream ss;
ss << x;
return ss.str();
}
int s2i(string str) {
istringstream ss(str);
int nro;
ss >> nro;
return nro;
}
int n, A[100005], B[100005], a, b;
int main() {
scanf("%d\n", &n);
for (int i = 0; i < n; i++) {
scanf("%d",... | 2 |
#include <bits/stdc++.h>
const long long INF = 1000000007;
const long double cp = 2 * asin(1.0);
const long double eps = 1e-9;
const long long mod = 1000000007;
using namespace std;
int main() {
string s;
long long k, len, mx = 0;
cin >> s >> k;
for (int(i) = 0; (i) < (k); i++) s += '?';
for (int l = 1; l <= ... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int LOG = 19;
int n, m;
int a[N], jl[LOG][N], jr[LOG][N];
int tr[LOG][N << 1], tl[LOG][N << 1];
void build(int id) {
for (int i = 1; i <= m; i++) {
tl[id][i + N] = jl[id][i];
tr[id][i + N] = jr[id][i];
}
for (int i = N - 1; i >= 1;... | 4 |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, l, t;
cin >> n >> l >> t;
vector<int> x(n), w(n);
for (int i = 0; i < n; i++) {
cin >> x... | 0 |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> p(n);
int i;
for (i = 0; i < n; i++) {
cin >> p[i];
}
sort(p.begin(), p.end(), greater<int>());
int result = 0;
for (i = 0; i < n; i++) {
if (p[i] >= i + 1) {
result... | 0 |
#include <bits/stdc++.h>
using namespace std;
namespace IO {
template <typename T>
void __RI(T &x) {
int ch = getchar(), neg = 1;
x = 0;
for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = getchar())
;
if (ch == EOF) return;
if (ch == '-') neg = -1, ch = getchar();
for (; isdigit(ch); ch = getchar()) ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long k, i, j, a, b, q, n;
cin >> n >> k;
a = n / k;
if (a % 2 == 0)
cout << "NO" << endl;
else
cout << "YES" << endl;
return 0;
}
| 1 |
#include<iostream>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
#define N 100001
#define MOD 10007
struct Node{
int id;
int con[2];
int cost[2];
Node():id(-1){}
Node(int id,int con1, int cost1, int con2, int cost2):id(id){
con[0]=con1;con[1]=con2;
cost[0]=cost... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], asum;
vector<int> ans;
int main() {
scanf("%d", &n);
for (int i = 0; i <= n - 1; ++i) scanf("%d", &a[i]);
for (int b = 31; b >= 0; --b) {
ans.clear();
for (int i = 0; i <= n - 1; ++i)
if ((a[i] >> b) & 1 == 1) ans.push_back(a[i]);
i... | 3 |
#include <bits/stdc++.h>
using namespace std;
int n, ans, arr[200001], m, mx;
map<int, int> ma;
int main() {
ios::sync_with_stdio(false);
cin >> n;
arr[1] = 1;
ma[1]++;
for (int i = 2; i <= n; i++) {
cin >> m;
arr[i] = arr[m] + 1;
ma[arr[i]]++;
mx = max(arr[i], mx);
}
for (int i = 1; i <= ... | 1 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w,n;
cin >> h >> w >> n;
int sup=max(h,w);
cout << (n-1)/sup+1 << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int a[100001], b[100001], ans[100001];
map<int, int> M;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i) cin >> b[i];
for (int i = 1; i <= n; ++i) ans[a[i]] = b[i];
for (int i = 1; i... | 6 |
#include <bits/stdc++.h>
using namespace std;
const long long int c = 26;
vector<string> s;
vector<long long int> mp[c];
bitset<c> vis, used;
long long int n, deg[26];
string ans;
bool topological() {
long long int cnt = c;
deque<long long int> q;
for (int i = 0; i < c; i++) {
if (!deg[i] && used[i])
q.... | 2 |
#include <bits/stdc++.h>
int n,b[505*505];
struct note{
int x,i;
}a[505];
bool cmp(note x,note y){
return x.x<y.x;
}
void ex(){
puts("No");
exit(0);
}
int main(){
scanf("%d",&n);
for (int i=1;i<=n;i++) scanf("%d",&a[i].x),a[i].i=i;
int N=n*n;
std::sort(a+1,a+n+1,cmp);
for (int i=1;i<=n;i++){
int now=1;
fo... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, x, y, a[420], p, z = -1;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
p = a[j], x = 1;
for (int k = i, u = a[i] - 1; k <= j; k++)
x += u / a[k],... | 5 |
#include <bits/stdc++.h>
using namespace std;
struct camel {
int x, y;
};
int main() {
int n;
bool r = false;
cin >> n;
camel arr[n];
for (int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
if (arr[i].x + arr[i].y == arr[j].x)
if... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int i;
i = n;
int ans[n + 1];
int prev = -1;
int tot = 0;
while (i >= 2) {
cout << "? " << 1 << " " << i << endl;
int x;
cin >> x;
if (prev != -1) {
ans[i + 1] = prev - x;
} else {
tot = x;
}
... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
struct Node {
int x, y, w;
};
struct Id {
int bl, ps;
};
int n, m, k, q;
int len[N];
int ll[N], rr[N], uu[N], dd[N];
Id id[N][N];
bool fl[N];
vector<Node> v[N];
vector<pair<int, int> > vp[N];
vector<long long> ds[N];
bool in(int x, int l, int r) { re... | 5 |
#include <bits/stdc++.h>
using namespace std;
map<char, bool> m;
vector<long long> v;
long long d[1000006];
int main() {
long long ans = 0, a, b, c;
for (int i = 1; i < 1000001; i++) {
for (int j = i; j < 1000001; j += i) {
d[j]++;
}
}
cin >> a >> b >> c;
for (int i = 1; i <= a; i++) {
for (... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 2e5 + 10;
long long fp(long long a, long long b) {
long long ans = 1;
a %= mod;
while (b) {
if (b & 1) ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans % mod;
}
long long jc[20], jie[N][20], sum[N... | 6 |
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
int flag=0;
for(int i=0;i<=25;i++)
for(int j=0;j<=15;j++)
if(4*i+7*j==n) {
flag=1;
break;
}
if(flag) printf("Yes");
else printf("No");
} | 0 |
#include <iostream>
#include <vector>
using namespace std;
int N, Q;
string str;
vector<char> t, d;
int is_down(int k) {
int pos = k;
for (int i = 0; i < Q; i++) {
if (pos == -1 || pos == N) return pos;
if (str[pos] == t[i]) {
if (d[i] == 'L') pos--;
else pos++;
}
}
return pos;
}
int main() {
cin... | 0 |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
if (ib == ie) {
ib = ibuf;
ie = ibuf + fread(ibuf, 1, BUFF, stdin);
}
return ib == ie ? -1 : *ib++;
}
} // namespace _buff
LL read() {
... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a1, a2;
vector<int> b1, b2;
int subsolve(vector<int>& box, vector<int>& spec) {
int N = (int) box.size();
int M = (int) spec.size();
vector<int> good (M+5, 0);
int cumulate = 0;
for (int i=M-1; i>=0; i--) {
int& sp = spe... | 3 |
#include <iostream>
using namespace std;
int main() {
string s = "CODEFESTIVAL2016";
string v;
cin >> v;
int a = 0;
for (int i = 0; i < 16; i++) {
if (s[i] != v[i])
a++;
}
cout << a << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, j, ans = 0;
cin >> n >> k;
int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
for (i = 0; i < n; i++) {
if (a[i] <= k)
ans++;
else
break;
}
for (j = n - 1; j > i; j--) {
if (a[j] <= k)
ans++;
el... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 60;
const int P = 1e9 + 7;
int n, p;
int f[N][2][2][2];
int col[N];
inline void add(int &x, int y) {
x += y;
if (x >= P) x -= P;
}
inline int pow_mod(int x, int k) {
int res = 1, base = x;
while (k) {
if (k & 1) res = 1LL * res * base % P;
k >>... | 5 |
#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 {
template <class c>
debug& operator<<(const c&... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long optFrom[57];
int main() {
int N;
scanf("%d ", &N);
;
long long K;
cin >> K;
optFrom[N - 1] = 1LL;
optFrom[N - 2] = 2LL;
for (int i = (N - 3); i >= (0); i--) {
optFrom[i] = optFrom[i + 1] + optFrom[i + 2];
}
optFrom[N] = 1LL;
for (int i = ... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000001;
int n, a, t, x;
map<int, map<int, int>> m;
void update(int idx, int val, int x) {
while (idx <= inf) {
m[x][idx] += val;
idx += (idx & -idx);
}
}
int read(int idx, int x) {
int sum = 0;
while (idx > 0) {
sum += m[x][idx];
... | 5 |
#include <bits/stdc++.h>
using namespace std;
int xx[3], yy[3], n, tot[3], sum = 0;
int board[202][202];
int ans[202][202];
int cnt = 0;
int mnx, mxx, mny, mxy;
void init() {
mnx = mny = 2e9;
mxx = mxy = -2e9;
cnt = 0;
memset(board, 0, sizeof(board));
}
bool paint(int sy, int sx, int ly, int lx, int num) {
fo... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int n, w, t1[N], t2[N], cont[N];
set<pair<int, int> > s1, s2;
long long ans = 0;
void take1(int i, int a) {
ans += a;
s1.erase(pair<int, int>(a, i));
if (!cont[i]) {
s1.insert(pair<int, int>(t2[i] - t1[i], i));
s2.erase(pair<int, int>(t2... | 5 |
#include <bits/stdc++.h>
using namespace std;
signed main()
{
int A, B, C, D;
while(cin >> A >> B >> C >> D, A || B || C || D) {
cout << max(0, (B * C - A + D - 1) / D) << endl;
}
return 0;
} | 0 |
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include<climits>
using namespace std;
class LCA{
int n;
std::vector<int> _depth,idx;
static int calcsize(int n){
int res=1;
while(res<n)res<<=1;
return res;
}
int minimum(int a,int b,int k,int l,int r)const{
if(r<=a||b<=l)retur... | 0 |
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
in >> a.first >> a.second;
return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
out << a.first << " " << a.second;
return out;
}
t... | 2 |
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
const int inf = 2e9 + 7;
const long long INF = INT64_MAX;
double eps = 1e-6;
const int mod = 998244353;
const int N = 1e3 + 10;
const double pi = acos(-1.0);
long double res;
double dp[N][N];
double work(int w, int b) {
if (w < 0 || b < 0)... | 4 |
// Do you knOW what it feels like?
// To be TorTured by your own MinD?
// I don't wanna feel the PAIN.
// I BeG you to KILL me, pleASE...
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")
#define F first
#define S second
... | 0 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<int, set<pair<int, int>>> subs;
string s1, s2;
bool mem_can[2][50 + 1][50 + 1][26];
bool in_mem_can[2][50 + 1][50 + 1][26];
bool can(bool one, int s, int e, int c) {
bool& ans = mem_can[one][s][e][c];
if (not in_mem_can[one][s][e][c]) {
if ... | 5 |
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define endl '\n'
const int N=5010;
const ll mod=1000000007;
ll a[N];
ll c[N];
ll dp[N][N];
void solve(){
int n,k,q;cin>>n>>k>>q;
for (int i=1;i<=n;i++) cin>>a[i];
for (... | 4 |
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n, team[101] = { 0 }, name[100] , a, b, c, d, hoz, iya;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
name[i]=1;
for (int i = 1; i <= n*(n - 1) / 2; i++)
{
cin >> a >> b >> c >> d;
if (c > d)
team[a] += 3;
else... | 0 |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long mod = (1e+9) + 7;
const long long sz = 2e5 + 9;
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long ... | 3 |
#include<bits/stdc++.h>
using namespace std;
signed main() {
unordered_map<char, int>a;
string b;
cin >> b;
for (char c:b) {
a[c]++;
}
for (char d = 'a'; d <= 'z'; d++) {
if (a[d] & 1) {
puts("No");
return 0;
}
}
puts("Yes");
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans, s;
int len, L;
inline void check(int y, int m, int d) {
string res = "";
for (int i = 1; i <= 4; ++i) {
res += char(y % 10 + '0');
y /= 10;
}
res += '-';
for (int i = 1; i <... | 2 |
#include <bits/stdc++.h>
using namespace std;
bitset<1 << 17> bad = 0;
bitset<1 << 17> badnw = 0;
int n, p;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> p;
vector<vector<int> > a(p, vector<int>(p));
string s;
cin >> s;
for (int i = 0; i < p; i++)
for (int j = 0; j <... | 6 |
#include <bits/stdc++.h>
using namespace std;
void swapi(int *a, int *b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void swapc(char *a, char *b) {
char temp;
temp = *a;
*a = *b;
*b = temp;
}
template <typename T>
void fscan(T &x) {
x = 0;
bool neg = 0;
register T c = getchar();
if (c == '-') n... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, a;
cin >> n;
vector<long long> v;
for (int i = 0; i < n; i++) {
cin >> a;
v.push_back(a);
}
vector<vector<long long>> ans(n + 1);
set<int> s;
set<int> sind;
f... | 2 |
#include <iostream>
#include <vector>
using namespace std;
int data[100100];
int main(void)
{
int n, L;
cin >> n >> L;
for (int i = 0; i < n; i++){
cin >> data[i];
}
if (n == 1) {
cout << L - data[0] << endl;
return 0;
}
vector <int> a;
bool flag = ((data[0] < data[1]) ? true : false);
for (int i... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char a[100000];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int A = 0, D = 0;
for (int i = 0; i < n; i++) {
if (a[i] == 'A') {
A++;
}
if (a[i] == 'D') {
D++;
}
}
if (A > D) {
cout << "Anton... | 1 |
#include<bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int N;
int t[10000];
int dp[2][5010][2];
int main(){
cin>>N;
for(int i=0;i<N-1;i++)cin>>t[i];
fill_n(**dp,2*5010*2,INF);
dp[0][0][0]=dp[0][1][1]=0;
for(int i=0;i<N-1;i++){
for(int j=0;j<=N/2;j++){
dp[(i+1)... | 0 |
#include <bits/stdc++.h>
using namespace std;
const double clf = 1e-8;
const int MMAX = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
ostream &operator<<(ostream &out, pair<int, int> &p) {
out << p.first << " " << p.second;
}
istream &operator>>(ist... | 1 |
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
cin>>a>>b;
if(a%2&&b%2) cout<<"Odd";
else cout<<"Even";
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string a, b;
cin >> a;
cin >> b;
int cnt1 = 0, cnt2 = 0;
for (int i = 0; i < a.size(); i += 2) {
int x, y;
if (a[i] == '8')
x = 1;
else if (a[i] == '(')
x = 0;
else if (a[i] == '[')
x = 2;
if (b[i] == '8')
y... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
long long dat[MAXN], cur;
int p[MAXN], s[MAXN];
inline int read() {
int x = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
return x;
}
int main() {
i... | 5 |
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;
int main() {
int a;
cin >> a;
for (int b = 0; b < a; b++) {
string c; cin >> c;
if ((c.length() & 1)==0&&c.length()>=6) {
if (c[0] ==... | 0 |
#include <iostream>
using namespace std;
class rout{
char t;
public:
rout(){
t='A';
}
void next(char n){
if(t == 'A'){
if(n == '1'){
t = 'Y';
}else{
t = 'X';
}
}else if(t == 'X'){
if(n == '1'){
t = 'Z';
}else{
t = 'E';
}
}else if(t == 'Y'){
if(n == '1'){
t = 'E';
... | 0 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
#define Rep(i,l,r) for (int i = (l); i <= (r); ++ i)
#define RepD(i,r,l) for (int i = (r); i >= (l); -- i)
#define RepG(i,x) for (int i = hd[x]; i; i = e[i].nxt)
#defi... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long l, r, k;
long long cnt[20][1 << 10][2];
long long sum[20][1 << 10][2];
long long power[20];
long long calc(string s) {
memset(cnt, 0, sizeof(cnt));
memset(sum, 0, sizeof(sum));
cnt[0][0][1] = 1;
int len = s.size();
for (i... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
string s;
unsigned short int n, sf = 0, seatle = 0;
cin >> n >> s;
for (int i = 0; i < n - 1; ++i) {
if (s[i] == 'S' && s[i + 1] == 'F')
sf++;
else if (s[i] == 'F' && s[i + 1] == 'S')
seatle++;
}
if (s... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 1e5 + 5;
int n, m;
int f[51][N];
unsigned long long sum[N];
int l[N], r[N];
unsigned long long g[N];
void add(unsigned long long &a, unsigned long long b) {
a += b;
if (a >= mod) a -= mod;
}
int main() {
cin >> n >> m;
for (i... | 5 |
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long long inf = 8e18;
const int LOG = 22;
long long pw(long long a, long long b, long long M) {
return (!b ? 1
: (b & 1 ? (a * pw(a * a %... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
}
for (int i = 1; i <= n; i++) {
cin >> b;
}
cout << "Karen";
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
int n, tt, a[2501][2501];
bitset<2501> bit[2501], cnt;
pair<int, pair<int, int> > b[2501 * 2501];
void no() {
printf("NOT MAGIC\n");
exit(0);
}
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
scanf("%d", a[i] + j), b[++tt] ... | 6 |
#include <bits/stdc++.h>
using namespace std;
int a[10];
inline long long unsigned turn(string s) {
long long unsigned ans = 0;
for (int i = 0; i < (int)s.size(); i++) {
ans *= 10;
ans += s[i] - '0';
}
return ans;
}
int main() {
long long unsigned k, f, t;
string s;
cin >> k >> s;
f = turn(s);
... | 2 |
#include<iostream>
#include<string>
using namespace std;
int n;
string s;
int c[101];
int l,r,x;
int main(){
cin>>n>>s;
for(int i=0;i<n;i++){
if(s[i]=='(') l++;
else r++;
c[i] = l-r;
if(x>c[i]) x = c[i];
}
for(int i=0;i<-x;i++)
s = '(' +s;
for(int i=0;i<c[n-1]-x;i++)
s+= ')';
... | 0 |
#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9;
class union_find {
public:
union_find(int N)
: par(N, -1)
{}
int root(int x) {
return par[x] < 0 ? x : par[x] = root(par[x]);
}
bool unite(int x, int y) {
x = root(x), y = root(y);
if(x == y) {... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const int MAXN = 2 * 1e5;
int main() {
int n;
cin >> n;
int mini = inf;
int maxi = -inf;
int del = 0;
bool f = true;
for (int i = 0; i < n; i++) {
int c, d;
cin >> c >> d;
if (d == 1) {
if (maxi >= del) f = fals... | 3 |
#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
multiset<int> a, b;
int ha[100005], hb[100005];
void fmain() {
scanf("%d", &n);
for (int(i) = 0; (i) < (int)(n); (i)++) scanf("%d", ha + i);
for (int(i) = 0; (i) < (in... | 3 |
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
multiset<int> s;
int main(){
int h, w, a, b;
cin >> h >> w;
for (int i = 0; i < w; i++)
m[i] = i, s.insert(0);
for (int i = 0; i < h; i++){
cin >> a >> b;
a--;
auto pos = m.lower_bound(a);
int mx = -1;... | 0 |
#include <bits/stdc++.h>
using namespace std;
double Get_d(double a, double b) { return sqrt(a * a + b * b); }
int r, d, x, y, R, n;
int main() {
scanf("%d%d", &r, &d);
int ans = 0;
scanf("%d", &n);
while (n--) {
scanf("%d%d%d", &x, &y, &R);
double D = Get_d(x, y);
if (D - R >= r - d && D + R <= r) ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
int c1 = 0, c2 = 0, c3 = 0;
cin >> a >> b;
for (int i = 1; i <= 6; ++i) {
int m = abs(i - a);
int n = abs(i - b);
if (m == n)
c3++;
else if (m <= n)
c1++;
else
c2++;
}
cout << c1 << " " << c3 << " " <<... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long M = 205;
const long long INF = 1e17;
long long memo[N][M];
vector<long long> entra[N];
vector<long long> sale[N];
long long rang_coin[N];
long long rang_time[N];
long long calc_coin[N];
long long calc_time[N];
long long dp(long l... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3;
const int A = 1e6 + 3;
const int inf = 1e9;
int n, qf, qb, ans, par[A], d[A], minPrime[A], qu[N];
vector<int> a[A];
int main() {
for (int i = 2; i * i < A; i++)
if (minPrime[i] == 0) {
for (int j = i * i; j < A; j += i)
if (minPrim... | 5 |
#include <bits/stdc++.h>
using namespace std;
const long long nInf = -1000000000;
const long long pInf = 1000000000;
const long long mod = 1000000007;
const int MAXN = 1000;
void getdata();
void preproc();
void solve();
int y11, y2, m1, m2, d1, d2;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
in... | 2 |
#include<iostream>
using namespace std;
int main()
{
int n,k,sum=0,x;
cin>>n>>k;
for(int i=0;i<n;i++)
{
cin>>x;
if(x>=k)
sum++;
}
cout<<sum;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, k, s, t;
cin >> n >> k >> s >> t;
vector<long long> c(n);
vector<long long> v(n);
for (int i = 0; i < n; ++i) cin >> c[i] >> v[i];
vector<long long> g(k);
for (int i = 0; i < k; ++i) cin >>... | 1 |
#include<iostream>
#include<iomanip>
int main(){
double a, b, c, d, e, f;
while (std::cin >> a >> b >> c >> d >> e >> f){
double x, y;
y = (a*f - c*d) / (a*e - b*d);
x = (c - b*y) / a;
std::cout << std::fixed << std::setprecision(3) << x << " " << y << std::endl;
}
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int MAX_N = 1e5+10;
int main() {
int n,m; cin>>n>>m;
vector<int> p(MAX_N), y(MAX_N);
vector<vector<int>> yd(MAX_N);
rep(i,m){
cin>>p[i]>>y[i];
p[i]--;
yd[p[i]].push_back(y[i]);
}
rep(i,n) sor... | 0 |
#include<iostream>
using namespace std;
int main(){
int a, b;
int nl = 0;
for ( int i = 0; i < 7; i++ ){
cin >> a >> b;
cout << a - b << endl;
}
} | 0 |
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long n, i, j, ar[100005];
int main() {
long long k;
scanf("%lld", &n);
scanf("%lld", &k);
for (long long i = 0; i < n; i++) scanf("%lld", &ar[i]);
long long cnt = 0;
i = 0, j = n - 1;
while (ar[i] <= k && i < n) {
cnt++;
i... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int &v : a) cin >> v;
vector<bool> mark(n, false);
for (int i = n - 2; i >= 0; i--)
for (int j = i; j < n - 1; j++) {
if (a[j + 1] < a[j] && !mark... | 2 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T first, T second) {
while (second > 0) {
first %= second;
swap(first, second);
}
return first;
}
template <class _T>
inline _T sqr(const _T &first) {
return first * first;
}
template <class _T>
inline string tostr(const _T &a) {
... | 4 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,m;
cin>>n>>x;
int mn=x;
for(int i=0;i<n;i++){
cin>>m;
x-=m;
mn=min(mn,m);
}
cout<<n+x/mn<<endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
int main() {
unsigned long long int i, j, k, a, b, n, k1, k2, count = 0, t, count1 = 0;
char ch[1000], ch1[1000];
scanf("%s %s", ch, ch1);
n = strlen(ch);
for (i = 0; i < n; i++) {
if (ch[i] == ch1[n - 1 - i]) count++;
}
if (count == n)
printf("YES");
else
printf("NO... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000011;
const long long INF = (1 << 29) + 123;
const long long MOD = 1000000007;
const long double PI = 4 * atan((long double)1);
const int MX = 1e5 + 5;
int n;
int first[MX];
void upd(int p, int v) {
while (p < MX) {
first[p] += v;
p += p & -p;... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 5;
const int mod = 1e9 + 7;
int n, m;
int fac[N], invf[N];
inline int po(int x, int k) {
int res = 1;
while (k) {
if (k & 1) res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
k >>= 1;
}
return res;
}
inline int C(int x, int y) {
if ... | 3 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
int arr[n];
unordered_map<int, int> m;
for (int i = 0; i < n; i++) {
cin >> arr[i];
m[arr[i]]++;
}
int maxVal = 0;
for (auto x : m) {
maxVal = max(maxVal, x.second);
}
cout << n - maxVal;
}
int main() { solve()... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.