solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int h, m;
char p;
cin >> h >> p >> m;
printf("%lf %lf", 30.0 * (h % 12) + 0.5 * m, 6.0 * m);
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long a[n];
long long sum = 0;
int count = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
sum += a[i];
}
for (int i = 1; i <= 5; ++i) {
if ((sum + i) % (n + 1) != 1) count++;
}
cout << count << endl;
r... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
vector<int> g[MAXN];
int val_at_v[MAXN];
int ans = 0;
pair<int, int> dfs(int v, int k, vector<int> &path) {
path.push_back(v);
int min_depth_subtr = MAXN;
int max_subtr = 0;
if (g[v].empty()) {
val_at_v[v] = 1;
min_depth_subtr = 0;
... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int t = 1;
while (t--) {
long long int x;
cin >> x;
long long int h, m;
cin >> h >> m;
if (h % 10 == 7 || m % 10 == 7) {
cout << "0\n";
return 0;
}
long long int cnt = 0;
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int maxh = 200 * 1000 + 5;
struct item {
int pos, hash;
item(int pos, int hash) : pos(pos), hash(hash) {}
};
bool operator<(item a, item b) { return a.pos < b.pos; }
int n, m, h;
set<item> S[maxh];
map<int, int> M;
int pos[maxh];
int Len[maxh];
int Base[maxh];
boo... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string result = "";
for (int i = 1; i <= n; i++) {
if (i > 1) result += " that ";
if (i % 2 == 0) {
result += "I love";
} else {
result += "I hate";
}
if (i == n) result += " it\n";
}
cout << result;
... | 1 |
#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, num = 0;
bool vis[305], iss[305][305], viss[305];
void init() {
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= n; i++) iss[i][i] = 1;
for (int i = 1; i <= k; i++) {
scanf("%d", &x), vis[x] = 1;
}
num = n - k;
int maxx = (n - 1) * (n - 2) /... | 5 |
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
ll n, t[10000], dp[2][10010];
int main() {
scanf("%lld", &n);
for (ll i = 0; i < n-1; i++) scanf("%lld", &t[i]);
for (ll i = 0; i <= n; i++) dp[0][i] = INF;
dp[0][1] = 0;
for (ll i = 1; i < n; i++) {
... | 0 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 21;
int n;
ll a[maxn];
void read() {
int len;
cin >> len;
for (int i = 0; i < len; ++i) {
ll x;
cin >> x;
if (x != 0) {
a[n++] = x;
}
}
}
ll sum[1 << maxn];
int dp[1 << maxn];
bool can[1 << maxn];
signed m... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n;
int a = 0, b = 0;
long long ans = 0;
vector<vector<int> > v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
v = vector<vector<int> >(n, vector<int>(4, 0));
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[i][1] = s[0]... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
vector<int> g[N];
int main() {
int n;
scanf("%d", &n);
int mx = 0;
for (int i = 0; i < n; i++) {
int len;
scanf("%d", &len);
for (int j = 0; j < len; j++) {
int x;
scanf("%d", &x);
g[i].push_back(x);
mx = ma... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N,sum=0;
cin>>N;
int L[203];
for(int i=0;i<2*N;i++){
cin>>L[i];
}
sort(L,L+2*N);
for(int i=0;i<2*N;i+=2){
sum+=L[i];
}
cout<<sum<<endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 65;
const int MAXS = 32768;
const int P = 1e9 + 7;
template <typename T>
void chkmax(T &x, T y) {
x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
x = min(x, y);
}
template <typename T>
void read(T &x) {
x = 0;
int f = 1;
char c = g... | 6 |
#include <bits/stdc++.h>
const int md = 1e9 + 7, inf = 1e9 + 7;
const long long hs = 199;
const long double eps = 1e-9, pi = acos(-1);
using namespace std;
int rnd() { return ((rand() % (1 << 15)) << 16) + (rand() % (1 << 15)); }
struct node {
node *l, *r;
int val, key;
int sz, tag;
node(int value) {
val = ... | 4 |
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
ll a,b,n;
cin>>a>>b;
n = a+b;
string s;
cin>>s;
for(int i = 0; i < n; i++){
if(s[i] == '?'){
s[i] = s[n-i-1];
}
}
a -= count(s.begin(), s.end(), '0');
b -= count(s.be... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n, k = 0, ans = 0, mx = 0;
cin >> n;
string s;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'x') {
mx++;
} else {
ans += max(0, mx - 2);
mx ... | 2 |
#include<iostream>
int main(){
int a, b, c;
std::cin >> a >> b >> c;
std::cout << (a+b)*c/2;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
long long a[10][10];
int nn;
int num[10];
int d[10];
int row[10];
int col[10];
int dia[10];
long long tot;
int n;
bool rec(int r, int c) {
if (r == n - 1) {
long long rem = tot - col[c];
for (int i = 0; i < nn; i++) {
if (d[i] && num[i] == rem) {
if ... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long n, a[10000], z, b[10000];
bool q;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
z = 0;
for (int j = 0; j < n; j++) {
b[j] = j + 1;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
q = false;
... | 2 |
#include <algorithm>
#include <iostream>
#include <cstdint>
int main() {
std::int64_t X, K, D;
std::cin >> X >> K >> D;
X = std::abs(X);
const auto n = std::min(K, X / D);
X -= n * D;
K -= n;
std::cout << std::abs(X - D * (K & 1)) << std::endl;
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const int MX = 500005;
struct Node {
int mx;
int pa, pb;
int sa, sb;
int len;
} st1[4 * MX], st2[4 * MX];
int lz[4 * MX];
Node operator+(const Node &a, const Node &b) {
Node r = {0, 0, 0, 0, 0, a.len + b.len};
int cen = 0;
if (!a.sb && !b.pa)
cen = a.sa + ... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int i = 0, ans = 0, n, p, k;
cin >> n >> p >> k;
vector<int> prices(n), v(n);
for (i = 0; i < n; i++) cin >> v[i];
sort(v.begin(), v.end());
int pr... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int q;
cin >> q;
for (int i = 0; i < q; i++) {
string st;
cin >> st;
string ans;
char last = 'd';
int ct = 0;
for (auto c : st) {
if (c == '?')
ct += 1;
els... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
struct pt {
long double a, b, c, d, e;
pt() {}
};
pt operator+(pt x, pt y) {
pt z;
z.a = x.a + y.a;
z.b = x.b + y.b;
z.c = x.c + y.c;
z.d = x.d + y.d;
z.e = x.e + y.e;
return z;
}
pt operator-(pt x, pt y) {
pt z;
z.a = ... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
const int inf = 0x3fffffff;
int dp[1 << 20], w[20][20], d[maxn], x[20], a[100];
inline int rightZeroBit(int mask) {
for (int i = 0;; i++) {
if ((mask & (1 << i)) == 0) return i;
}
return -1;
}
int main() {
int n, k, l;
while (scanf("%d%... | 4 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9, MOD = 1e9 + 7;
const int n_ = 210;
long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); }
long long power(long long a, long long n) {
long long p = 1;
while (n > 0) {
if (n % 2) {
p = p * a;
}
n >>= 1;
... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long gcd2(long long m, long long n) {
if (m < n) {
long long tmp = m;
m = n;
n = tmp;
}
if (n == 0) return m;
while (n > 0) {
long long tmp = m % n;
m = n;
n = tmp;
}
return m;
}
int f(int k) {
if (k == 1) return 0;
if (k % 2 == ... | 3 |
#include <iostream>
using namespace std;
int main(){
int n,k[112345],sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>k[i];
sum+=k[i];
}
if(sum%2==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
... | 3 |
#include <bits/stdc++.h>
using namespace std;
struct segtree {
int N;
vector<int> val, sum, add, flt;
segtree(int n) {
N = 1;
while (N < n) N *= 2;
sum.assign(2 * N, 0);
add.assign(2 * N, 0);
flt.assign(2 * N, 0);
init(0, n, 0, N, 0);
}
void init(int a, int b, int l, int r, int k) {
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int r, b;
cin >> r >> b;
cout << (r == b ? "Yes" : "No") << endl;
}
| 5 |
#include <bits/stdc++.h>
using namespace std;
struct node {
double x, y;
} a[1010];
int n;
double solve(int x, int y, int z) {
if (y == 1) x = n;
if (y == n) z = 1;
double A = a[z].y - a[x].y;
double B = a[x].x - a[z].x;
double C = a[z].x * a[x].y - a[x].x * a[z].y;
return fabs(A * a[y].x + B * a[y].y + C... | 4 |
#include<cstdio>
#include<iostream>
#include<bitset>
#include<deque>
#include<algorithm>
using namespace std;
struct Pox
{
int state,cost;
Pox(int state,int cost):state(state),cost(cost){}
};
int main()
{
while(1)
{
int n,U,k,r;
scanf("%d %d",&n,&U);
if(n+U == 0)
break;
int mincost[... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;
const int mod = 1000000007;
const int MOD = 998244353;
const int INF = 1e18 + 18;
vector<int> dx = {-1LL, 0LL, 1LL, 0LL}, dy = {0LL, 1LL, 0LL, -1LL};
void test_case() {
int q;
cin >> q;
int n = 710;
vector<vector<int>> dp(n + 1, vector<in... | 6 |
#include <bits/stdc++.h>
using namespace std;
long long n, dsize;
vector<long long> x,y,d;
string dir = "LUDR";
string solve(int now);
int main(){
cin >> n;
x.resize(n);
y.resize(n);
for(int i = 0;i < n;++i)cin >> x[i] >> y[i];
for(int i = 1;i < n;++i)
if(abs(x[i-1] + y[i-1]) % 2 != abs(x... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, m;
char a[N][N], c[N * N];
int b[N][N];
set<int> e[N * N];
int top;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
void dfs(int x, int y) {
b[x][y] = top;
for (int d = 0; d < 4; ++d) {
int nx = x + dx[d];
int ny = y + dy[d];
if (n... | 5 |
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int g,a,b,c,m,mg;
while(cin >> g) {
if (g==0) break;
mg=9999999;
for (a=0;a<26;a++) for (b=0;b<17;b++) for (c=0;c<51;c++) {
if (a*200+b*300+c*500!=g) continue;
m=(a/5)*1520+(a%5)*380+(b/4)*1870+(b%4)*550+(c/3)*2244+(c%3)*8... | 0 |
#include <bits/stdc++.h>
long long a[200100], dp[200100], s[200100], ans;
int n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%I64d", &a[n - i + 1]);
for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
for (int i = 1; i < n; i++)
dp[i] = ans + s[n],
ans = ((ans) > (-(s[i] + dp[i]))... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ar[101000], dp[101000], dp2[101000], k, kk, ans;
int main() {
scanf("%I64d", &n);
for (i = 1; i <= n; i++) scanf("%I64d", &ar[i]);
dp[0] = 0;
for (i = 1; i <= n; i++) dp[i] = dp[i - 1] + ar[i];
if (dp[n] % 3 != 0) {
printf("0\n");
return... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ans = 0;
int p, q;
for (int i = 0; i < n; i++) {
cin >> p >> q;
if (p <= q - 2) {
ans++;
}
}
cout << ans << endl;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 222;
int arr1[N], arr2[N];
int n, m;
bool solve(int x) {
for (int i = 1; i <= n; i++) {
bool sign = false;
for (int j = 1; j <= m; j++) {
if (((arr1[i] & arr2[j]) | x) == x) {
sign = true;
break;
}
}
if (!sign) ret... | 3 |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;
#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define re... | 0 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n; cin>>n;
if(n%2==0)
{
cout<<((n/2)+1)*((n/2)+1)<<endl;
}
else
{
int x = (n-1)/2;
cout<<(2+x)*(1+x)*2<<endl;
}
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
inline int c(int x) { return (x) * (x); }
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int a[6];
for (int i = 0; i < 6; ++i) cin >> a[i];
cout << c(a[0] + a[1] + a[2]) - c(a[0]) - c(a[2]) - c(a[4]);
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
long long int n, m, ar[1000005], sum, t, tut[1000005];
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> t;
while (t--) {
sum = INT_MAX;
memset(tut, 0, sizeof(tut));
cin >> n;
for (long long int i = 1; i <= n; i++) cin ... | 3 |
#include<stdio.h>
int main(){
int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}
}
| 0 |
#include <bits/stdc++.h>
const int N = 100010;
const int MAX = 1 << 17;
const int moder = 1e9 + 7;
const long long INF = 1e18;
int seg[MAX << 1], lazymult[MAX << 1], lazyadd[MAX << 1];
void addmod(int &a, int b) {
a += b;
a -= a >= moder ? moder : 0;
}
void submod(int &a, int b) {
a -= b;
a += a < 0 ? moder : 0... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, x, t, d;
cin >> n;
while (n--) {
cin >> x;
d = floor(x / 14);
t = x % 14;
if ((t <= 6 && t >= 1) && d >= 1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
string a, b;
int main(int argc, char* argv[]) {
string s;
set<char> pos;
cin >> s;
for (char c : s) {
pos.insert(c);
}
if (pos.size() % 2 == 0) {
cout << "CHAT WITH HER!";
} else {
cout << "IGNORE HIM!";
}
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
long long gcd(int x, int y) {
return !y ? (long long)x : (long long)gcd(y, x % y);
}
bool hts(vector<int> a, vector<int> b) { return a.size() < b.size(); }
int main() {
long long n, k, p, e = 0, o = 0, bit, len, idx = 0;
cin >> n >> k >> p, len = k, k -= p;
vector<i... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
pair<int, int> h[maxn];
int p[maxn];
int ans[maxn];
int in[maxn];
int cal(int x) {
if (x == 1) {
return h[x].first;
}
return max(h[x].first, h[x].second + 1);
}
int main() {
p[1] = 0;
ans[1] = 1;
h[1] = make_pair(0, 0);
int n;
... | 4 |
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,k;
while(cin >> n >> k){
if(!n && !k) break;
int card[n];
rep(i,n) cin >> card[i];
sort( card, ... | 0 |
#include <bits/stdc++.h>
using namespace std;
int N, M, K;
long long dp[2005][2005];
void pri() {
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= K; j++) cout << dp[i][j] << " ";
cout << endl;
}
return;
}
int main() {
cin >> N >> M >> K;
if (0 == K) {
cout << M;
return 0;
}
dp[1][0] = ... | 3 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int INF = 2e9 + 7;
const int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = r... | 3 |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 10e-11;
class VagueDouble {
public:
double vd;
VagueDouble() { vd = nan(""); }
VagueDouble(const double d) { vd = d; }
inline VagueDouble operator+(const VagueDouble VD) const {
return VagueDouble(vd + VD.vd);
}
inline VagueDouble operato... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long n, t;
long long dp[55][55];
long long solve(long long n, int p) {
if (p == 0) return 1;
for (int i = 50; i >= 0; --i) {
if ((1ll << i) & n) {
return dp[i][p] + solve(n - (1ll << i), p - 1);
}
}
return 0;
}
int main(void) {
dp[0][0] = 1;
f... | 5 |
#include <iostream>
using namespace std;
int main() {
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n; cin >> n; cout << a[n-1] << endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
bool array[102][102], in = 1;
scanf("%d%d", &x, &y);
for (long long i = 1; i < x + 1; i++)
for (long long j = 1; j < y + 1; j++) cin >> array[i][j];
while (!(x % 2) && in) {
for (long long i = 1; i < x / 2 + 1; i++)
for (long l... | 2 |
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.writ... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, p;
scanf("%d %d", &n, &p);
long long sum = 0;
long long ans = 0;
int a[100005];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
long long temp = 0;
for (int j = 0; j < n - 1; j++) {
temp += a[j];
ans = m... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const int M = 1000000007;
int n, m;
int a, b;
int d[N];
int pa[N], ran[N];
int vis[N], cnt[N];
set<int> st;
void ini() {
memset(d, 0, sizeof(d));
memset(vis, 0, sizeof(vis));
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i <= n; i++) pa[i] = i,... | 3 |
#include <iostream>
#include <cstdio>
#include <cstring>
#define max_n 200000
using namespace std;
int n,tr[max_n+1][2],tot=1;
long long l;
bool num[100];
char s[max_n+1],*ed;
void ins(int v,char*now){
int&x=tr[v][*now^'0'];
!x&&(x=++tot);
now<ed&&(ins(x,now+1),1);
}
void dfs(int v,int d){
#define k 0
t... | 0 |
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;
int main() {
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
cout << (min(min(a, b), c) + min(d, e) - 50) << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long add(long long x, long long y, long long CMOD = MOD) {
return (x + y + CMOD + CMOD) % CMOD;
}
long long mult(long long x, long long y, long long CMOD = MOD) {
return add(x, 0) * add(y, 0) % CMOD;
}
long long fast_expo(long long x,... | 4 |
#include <bits/stdc++.h>
using namespace std;
struct _ {
_() { ios_base::sync_with_stdio(0); }
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
o << "(" << t.first << ", " << t.second << ")";
return o;
}
template <class T>
string tostring(T first, int len = 0, char c = '0') {
str... | 4 |
#include <bits/stdc++.h>
using namespace std;
int C[200006], A[200006], sp[200006], visit[200006], rev[200006];
vector<int> adj[200006];
int flag, pp;
void dfs(int node) {
if (visit[node]) return;
visit[node] = 1;
rev[node] = 1;
for (int i = 0; i < adj[node].size(); i++) {
if (rev[adj[node][i]]) {
fla... | 4 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vd = vector<double>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvd = vector<vd>;
using vvl = vector<vl>;
template <typename V, typename T>
inline void fill(V& x, ... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long n, ans, mod=1e9+7;
long long p(long long x, long long y){
if(y==1) return (x+mod)%mod;
if(y%2) return (x*p(x, y-1)+mod)%mod;
long long res=p(x, y/2)%mod;
return (res*res+mod)%mod;
}
int main(){
cin>>n;
ans=p(10, n)-2*p(9, n);
ans%=mod;
ans+=p(8, n);
... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 2e5 + 500;
int n;
string E[256], T[256], F[256];
bool flag = true;
void update(string &A, string B) {
if (A == "")
A = B, flag = 1;
else {
if (A.size() > B.size())
A = B, flag = 1;
else if (A.size() == ... | 5 |
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
double tkt[8];
double flg[256][30];
double path[30][30];
int main(){
for(int n, m, p, a, b; cin >> n >> m >> p >> a >> b;){
a--;
b--;
if(n == 0)break;
for(int i = 0; i < 256; i++){
for(int j = 0; j < 3... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int n, k, sx;
char a[5][105];
bool bfs(int sx) {
queue<pair<int, int> > q;
q.push(pair<int, int>(sx, 1));
while (q.size()) {
int x = q.front().first, y = q.front().second;
q.pop();
if (isalpha(a[x][+... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long int a[1000], n, c;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int val;
cin >> n;
long long int f = 1;
a[0] = 1000;
for (long long int i = 1; i <= n; i++) {
cin >> a[i];
val = a[i];
if (f != -1) {
... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int N(5011), A(26);
char a[N];
int c[N][N], dp[N][A], sum[N];
int modulo(1e9 + 7);
int main() {
int n;
cin >> n;
for (int i(0); i <= n; i++) {
for (int j(0); j <= i; j++) {
c[i][j] =
(i == 0 || j == 0) ? 1 : (c[i - 1][j - 1] + c[i - 1][j]) % ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int T, n = 250, mx, si, a[252];
double X, V;
int main() {
scanf("%d", &T);
int i;
while (T--) {
mx = si = 0;
X = V = 0;
for (i = 1; i <= n; i++) scanf("%d", &a[i]), mx = max(mx, a[i]), X += a[i];
X /= n;
for (i = 1; i <= n; i++) si += (a[i] == mx),... | 4 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& num) {
char CH;
bool F = false;
for (CH = getchar(); CH < '0' || CH > '9'; F = CH == '-', CH = getchar())
;
for (num = 0; CH >= '0' && CH <= '9';
num = num * 10 + CH - '0', CH = getchar())
;
F && (num = -num);
}
int s... | 4 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
vector<ll> v(303030);
ll n,k,m,x,y;
string s,t;
int main() {
cin >> n;
ll sum=0;
rep(i,n){
cin >> v[i]; sum+=v[i];
}
ll l=0,ans=1e10;
rep(i,n) l+=v[i]... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c, x, y;
cin >> a >> b >> c >> x >> y;
int ans = INT_MAX;
for (int i = 0; i <= 100000; i++)
{
ans = min(ans, i * 2 * c + max(0, x - i) * a + max(0, y - i) * b);
}
cout << ans << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int maxn = 20;
pair<int, int> a[maxn], help[maxn];
int bin[maxn];
bool vis[maxn];
int ans = INF;
void pr() {
for (int i = 0; i < maxn; i++) {
help[i] = a[i];
bin[i] = 0;
vis[i] = false;
}
}
int main() {
i... | 3 |
#include <bits/stdc++.h>
using namespace std;
struct __s {
__s() {
if (1) {
ios_base::Init i;
cin.sync_with_stdio(0);
cin.tie(0);
}
}
~__s() {
if (!1)
fprintf(stderr, "Execution time: %.3lf s.\n",
(double)clock() / CLOCKS_PER_SEC);
long long n;
cin >> n;
... | 2 |
#include <iostream>
using namespace std;
int main(void){
int a,b;
while(cin >> a >> b) cout << a+b << "\n";
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
char s[2000006];
char t[1000006];
int len[100005], pos[100005];
vector<pair<int, int>> e;
int main() {
int n;
scanf("%d", &n);
int tp = 0;
for (int i = 0; i < n; i++) {
scanf("%s", t + tp);
len[i] = strlen(t + tp);
pos[i] = tp;
tp += len[i];
int ... | 1 |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N,i;scanf("%d",&N);
int a[N];
map<int,int> ml,mr;
for(i=0;i<N;i++) scanf("%d",&a[i]);
int ng = 0;vector<int> ans;
for(i=0;i<N;i++){
ml[a[i]]++;
if(ml[a[i]] == mr[a[i]]) ng--;
else if(ml[a[i]]-1 == mr[a[i]]) ng++;
... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
vector<pair<pair<int, int>, int>> vp;
int ans[222];
bitset<10000005> bt;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vp.resize(n);
int i = 0;
for (auto& x : vp) cin >> x.first.second >... | 4 |
#include <bits/stdc++.h>
using namespace std;
vector<int> edge[1001];
int dist[1001][1001];
int marked[1001], inpath[1001];
void bfs(int u, int n) {
int s = u;
dist[u][u] = 0;
for (int i = 0; i < 1001; i++) {
marked[i] = 0;
}
marked[u] = true;
queue<int> Q;
Q.push(s);
while (((int)(Q.size()))) {
... | 6 |
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};
int main() {
string keys; ... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int mxN = 3e5 + 1, MOD = 1e9 + 7;
int arr[mxN], n, dp[2][mxN];
void solve() {
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i + 2];
for (int i = 0; i < 2; i++)
for (int j = 0; j < n + 2; j++) dp[i][j] = 0;
arr[0] = 1e9;
arr[1] = 1e9;
dp[1][0] = 0;
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int N, M, Two = 1, Res = 1;
int main() {
cin >> N >> M;
while (M--) Two = 2 * Two % 1000000009;
for (int i = 1; i <= N; i++) Res = (1LL) * Res * (Two - i) % 1000000009;
cout << Res;
}
| 1 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;cin>>s;int cnt1=0;
for(int i=0;i<s.length();i++)
{
if(s[i]=='x') cnt1++;
}
if(cnt1>=8) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
} | 0 |
#include<cstdio>
#include<queue>
#include<tuple>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int main(){
int h, w; scanf("%d %d", &h, &w);
char s[50][51];
rep(i, h) scanf("%s", s[i]);
int b = 0;
rep(i, h) rep(j, w){
if(s[i][j] == '#') b+... | 0 |
#include <bits/stdc++.h>
char s[1000], s1[800];
int a[30];
int main() {
int l, sum, i;
while (gets(s)) {
sum = 0;
memset(a, 0, sizeof(a));
l = strlen(s);
for (i = 0; i < l; i++) {
if (s[i] >= 'a' && s[i] <= 'z') {
a[s[i] - 'a']++;
}
}
for (i = 0; i < 26; i++) {
if (... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int n,a,b;
long long poww(long long b,long long p)
{
if(p==0) return 1;
if(p&1) return (b*poww(b,p-1))%MOD;
return poww((b*b)%MOD,p/2);
}
long long nck(int k)
{
long long ans=1;
for(int i=n;i>n-k;i--)
ans=(ans*i)%MOD;
for(int i=2;i<=k;i++)
... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long gcd1(long long a, long long b) {
if (a == 0) return b;
return gcd1(b % a, a);
}
long long modx(long long base, long long ex) {
long long ans = 1LL, val = base;
while (ex > 0LL) {
if (ex & 1LL) ans = (ans * val) % 998244353LL;
val = (val * val) % 99... | 5 |
#include <bits/stdc++.h>
using namespace std;
double esp = 1e-12;
const double PI = acos(-1.0);
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int POS;
struct treepo {
static const int MAXN = 100050;
struct ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
t = 1;
while (t--) {
int n;
cin >> n;
vector<int> a(n), b(n);
set<int> myset;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
myset.insert(a[i... | 1 |
#include <bits/stdc++.h>
using namespace std;
struct node {
int num, x, y;
} s[200005];
int n, q, a[200005], pos[200005], maxn, flag[200005], flag1[200005];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
scanf("%d", &q);
for (int i = 1; i <= q; i++) {
scanf("%d", &s[i].num)... | 2 |
#include<stdio.h>
int main(){
int x,y,s;
while(1){
scanf("%d%d%d",&x,&y,&s);if(x==0&&y==0&&s==0)break;
int max=0;
int ng=0,mg=0;int n=0,m=0;
int X=100+x,Y=100+y;
for(int i=1;i<s;i++){
ng=i*X/100;n=i*Y/100;
for(int j=1;j<=s-i;j++)
{
mg=j*X/100;m=j*Y/100;
if(ng+mg==s&&n+m>max)max=n+m;
}
}
printf("%d\n",max);
}
return ... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
void print(bool a[1005][1005]) {}
bool check1(bool a[1005][1005]) {
int k = 0;
bool res = 1;
for (int i = 1; i < n - 1 && res; ++i)
for (int j = 1; j < m - 1 && res; ++j)
if (a[i][j]) {
if (a[i + 1][j] && a[i][j + 1]) res = 0;
if (!... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 100;
template <typename T>
struct seg_tree {
int S;
T zero;
vector<T> value;
seg_tree<T>(int _S, T _zero = T()) {
S = _S, zero = _zero;
value.resize(2 * S + 1, zero);
}
void set_leaves(vector<T> &leaves) {
copy(leaves.begin(), ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t, x, y, c;
cin >> t;
while (t--) {
cin >> x >> y;
if ((x == 1 && x < y) || (x <= 3 && y > 3)) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
}
}
retur... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 5;
long long a[100005] = {0};
struct round {
long long o;
long long r;
long long ind;
long long flag = 0;
bool operator<(const round& b) const { return o < b.o; }
} r[MAXN];
struct point {
long long x;
long long y;
bool operator<... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.