solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100 + 20;
int a[MAX_N];
int P[MAX_N];
int mark[MAX_N];
int n, q;
void dfs(int v, int r) {
mark[v] = 1;
if (v != r && !mark[v + 1] && P[v] < P[v + 1]) dfs(v + 1, r);
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i(0); i < int(n); ... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e6 + 5;
int K;
long long cnt[105];
vector<vector<long long>> iden;
long long mm[N];
vector<vector<long long>> mul(vector<vector<long long>> A,
vector<vector<long long>> B) {
vector<vector<long lon... | 2 |
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1333
inline int read(){
int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=(x<<1)+(x<<3)+c-'0';
c=getchar();
}
return x*f;
}
int a[N][N],n,m;
void Copy(int x,int y... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 111;
const double eps = 1e-8;
const double pi = acos(-1.0);
inline double sqr(double x) { return x * x; }
inline int sgn(double x) { return fabs(x) < eps ? 0 : x > eps ? 1 : -1; }
struct point {
double x, y;
point(double _x = 0, double _y = 0) : x(_x), y(_... | 5 |
#include <bits/stdc++.h>
const long long int mod = 1e9 + 7;
using namespace std;
void myfun() {
long long int n, i;
cin >> n;
map<long long int, long long int> mp;
for (i = 0; i < n; i++) {
long long int a;
cin >> a;
mp[a]++;
}
multiset<long long int> ss;
for (auto it : mp) ss.insert(it.second... | 5 |
#include <bits/stdc++.h>
using namespace std;
const long long nax = 2400000;
char a[nax];
void solve() {
cin >> a;
for (long long x = 0; x < 10; x++) {
for (long long y = 0; y < 10; y++) {
long long b[10];
for (long long i = 0; i < 10; i++) b[i] = 1e9 + 7;
for (long long q = 0; q < 10; q++)
... | 2 |
#include <bits/stdc++.h>
using namespace std;
map<string, pair<long long, long long> > w, bs;
map<string, vector<string> > pck;
map<string, int> tp, vis;
pair<long long, long long> go(string s) {
if (vis.count(s)) return w[s];
vis[s] = 1;
bool in = 0;
pair<long long, long long> res(0, 0);
for (int i = 0; i < ... | 4 |
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
stack<int>st[1000];
int n,tc,q,t;
ll x;
cin>>n>>tc;
while(tc--)
{
cin>>q;
if(q==0)
{
cin>>t>>x;
st[t].push(x);
}
else if(q==1)
{
cin>>t;
if(!st[t].empty())
{
cout<... | 0 |
#include <bits/stdc++.h>
using namespace std;
int a[600002];
int main() {
int n;
scanf("%d", &n);
vector<pair<int, int>> pairs;
vector<int> smaller, bigger;
for (int i = 0; i < n; i++) {
int x, y;
scanf("%d %d", &x, &y);
pairs.push_back({x, y});
a[y] = i + 1;
if (x < y)
bigger.push_b... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[100010], csum[100010], n, adjustment1, adjustment2,
tt[100010];
bool ok[100010];
using namespace std;
const int maxN = 100010;
struct Data {
int sz;
pair<long long, long long> val;
int prior, l, r;
};
struct Treap {
Data node[maxN];
int ... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long zero = 0;
long long fexp(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans = ans * a % 1000000007;
b /= 2;
a = a * a % 1000000007;
}
return ans;
}
long long multiply(long long a, long long b, long long mod) {
return ((... | 3 |
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
//=============ford_fulkerson============================
ll MAX_V = 202;
struct edge {ll to, cap, rev;};
vector<vector<edge>> G(MAX_V);
vector<bool> used(MAX_V, false);
void add_edge(ll from, ... | 0 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>
const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;
int n;
char in[N];
int main(){
scanf("%s", in + 1);
n = strlen(in + 1);
LL... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int v1, v2, t, d;
int Max = 0;
cin >> v1 >> v2 >> t >> d;
Max = v1;
for (int i = 2; i <= t; i++) {
int vail = v1;
for (int j = -d; j <= d; j++) {
int v3 = v1 + j;
int t2 = t - i;
if (t2 * -1 * d + v3 <= v2) {
vail = v... | 2 |
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int NN = 2102020;
int sa[NN];
vector<int> trip[2];
int n, m1, m2, t, nn;
int dp[NN][2];
vector<int> mov;
vector<pii> shot;
int is_trip(int u, int id) {
int it = lower_bound(trip[id].begin(), trip[id].end(), u) - trip[id].begin();
if (it... | 4 |
#include <bits/stdc++.h>
using namespace std;
int n, p, m;
vector<vector<int> > g;
vector<char> used;
vector<long long> c, vs, es;
pair<int, int> dfs(int v) {
used[v] = true;
pair<int, int> ans(1, (int)g[v].size());
for (int u : g[v]) {
if (used[u]) {
continue;
}
pair<int, int> a = dfs(u);
a... | 3 |
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
const int inf = 1034567891;
const long long LL_INF = 1234567890123456789ll;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* na... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n, m, q, in[maxn + 5];
vector<int> g[maxn + 5];
long long res;
long long count(int id) { return 1ll * g[id].size() * in[id]; }
int main() {
scanf("%d %d", &n, &m);
for (int i = 1, u, v; i <= m; ++i) {
scanf("%d %d", &u, &v);
if (u > v) ... | 6 |
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
int main(){
int n;
... | 0 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
int size(T& a) {
return (int)a.size();
}
template <typename T>
T sqr(T a) {
return a * a;
}
const int dx[4] = {+1, -1, 0, 0};
const int dy[4] = {0, 0, +1, -1};
const int MAXN = 1002;
int n, m;
char s[MAXN][MAXN];
bool u[MAXN][MAXN];
int c[MAXN][MAX... | 4 |
/* -*- coding: utf-8 -*-
*
* 2961.cc:
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#inc... | 0 |
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int INF = 1e... | 0 |
#include <bits/stdc++.h>
using namespace std;
template <class A>
void read(vector<A>& v);
template <class A, size_t S>
void read(array<A, S>& a);
template <class T>
void read(T& x) {
cin >> x;
}
void read(double& d) {
string t;
read(t);
d = stod(t);
}
void read(long double& d) {
string t;
read(t);
d = sto... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20, mod = 1e9 + 7;
int n, m, ans[maxn];
map<pair<int, int>, bool> adj;
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
adj[{x, y}] = 1;
}
ans[1] = 1;
for (int i = 2; i <= n; i++) {
ans[i] = ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
cout << s.substr(0, 3) << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
int c2 = 0, c3 = 0;
while (n) {
if (n % 10 == 4)
c3++;
else if (n % 10 == 7)
c2++;
n /= 10;
}
if ((c2 + c3) == 7 || (c2 + c3) == 4)
cout << "YES";
else
cout << "NO";
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
char a[1100000], b[1100000];
int cnt[10][10];
int main() {
int la, lb, i, j, k;
long long ans = 0;
scanf("%s%s", &a, &b);
la = strlen(a);
lb = strlen(b);
for (i = 0; i < la; i++) {
if (a[i] == 'R') a[i] = 0;
if (a[i] == 'G') a[i] = 1;
if (a[i] == 'B'... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
long long n;
string a;
cin >> n;
if (n == 0) cout << "O-|-OOOO" << endl;
while (n) {
a = "OOOOO";
k = n % 10;
if (k >= 5) {
cout << "-O|";
a[k - 5] = '-';
} else {
cout << "O-|";
a[k] = '-';
}
c... | 1 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T1, typename T2>
inline void remin(T1& a, T2 b) {
a = min(a, (T1)b);
}
template <typename T1, typename T2>
inline void remax(T1& a, T2 b) {
a = max(a, (T1)b);
}
const int LOG = 19, maxN = 1 << LOG, mod = 998244353;
templa... | 6 |
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#inc... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, u, v, w, a[maxn], b[maxn], t;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
a[n + 1] = 1e9;
for (int i = 1; i <= m; i++) {
scanf("%d%d%d", &u, &v, &w);
if (u == 1) t++, b[t] = v;
}... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int inches;
inches = n / 3 + (n % 3 > 1);
int feet;
feet = inches / 12;
inches %= 12;
cout << feet << " " << inches << endl;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 10000;
vector<int> lucky;
void dfs(long long x) {
if (x >= 1000000000) return;
if (x) lucky.push_back(x);
dfs(x * 10 + 4);
dfs(x * 10 + 7);
}
long long Inter(long long x1, long long y1, long long x2, long long y2) {
return max(min(y1, y2) - ma... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
long long k;
cin >> n >> k;
vector<long long> w(n);
for (int i = 1; i < n; i++) {
int foo;
long long bar;
cin >> foo >> bar;
foo--;
w[i] = w[foo] ^ bar;
}
sort(w.begin(), w.en... | 6 |
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
string st;
namespace cent {
struct Edge {
int src;
int dst;
int k;
};
using Graph = vector<vector<Edge>>;
class Centroid {
private:
in... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long q, t, v, u, w;
map<long long, long long> cost;
cin >> q;
while (q--) {
cin >> t;
if (t == 1) {
cin >> v >> u >> w;
while (v != u) {
while (u > v) {
cost[u] += w;
u >>= 1;
}
while ... | 3 |
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1e18
using namespace std;
typedef pair<llint, llint> P;
struct BIT{
int size;
vector<llint> bit;
BIT(){size = 0;}
BIT(int s){
size = s;
bit.resize(size+1);
init();
}
void init()... | 0 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fix... | 0 |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)
int md = 1e9 + 7, d[401][401], a[401], b[401], p[401][401];
int main() {
int n, c;
scanf("%d%d", &n, &c);
f(i, 1, n + 1)scanf("%d", a + i);
f(i, 1, n + 1) {
scanf("%d", b + i);
f(j, a[i], b[i] + 1) {
... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, M;
cin>>N>>M;
cout<<(N==M? "Yes\n": "No\n");
} | 0 |
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> ans;
int S(int x) {
int ret = 0;
while(x) {
ret += x % 10;
x /= 10;
}
return ret;
}
bool verify(int x, int y) {
return x * S(y) < y * S(x);
}
void insert(int x) {... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
const int n_ = 5000;
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;
... | 3 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n, x, i, j;
cin >> n >> x;
long long int mm = 0;
long long int mx = 0;
for (i = 0; i < n; i++) {
long long int a, b;
cin >> a >> b;
mm = max(mm, a - b);
mx = max(mx, a);
}
if (x <= mx) {
cout << "1\n";
retur... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 505, kMaxK = 21, kInf = 0x3f3f3f3f;
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };
int n, m, k, w[4][kMaxN][kMaxN], dp[kMaxK][kMaxN][kMaxN];
int resolve(int k, int x, int y) {
if (~dp[k][x][y]) return dp[k][x][y];
if (k == 0) re... | 4 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, l, r;
while (cin >> n >> l >> r) {
vector<int> vmin, vmax;
long long j = 1;
long long minsum = 0, maxsum = 0;
for (long long i = 0; i < l; i++) {
minsum += j;
j *= 2;
}
j = 1;
for (long long i = 0; i < ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, d, count = 0;
cin >> n >> d;
string c;
cin >> c;
int f = 1;
f = f + d - 1;
int flag = 1;
while (1) {
if (c[f] == '1') {
count++;
if (f == n - 1) {
cout << count;
break;
}
flag = f;
f += d;... | 1 |
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06 \
ios::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
const int nax = 1e5+5;
vector<int> edges[nax];
... | 0 |
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
float n, x, y;
cin >> n >> x >> y;
float ans = (n / 100) * y;
ans = ceil(ans);
if (ans <= x)
cout << "0" << endl;
else {
ans = ans - x;
cout << ans << endl;
}
}
| 1 |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int check(int n) {
while (n) {
int t = n % 10;
if (t != 4 && t != 7) return 0;
n /= 10;
}
return 1;
}
int n, a[100005];
int b[100005];
int c[100005];
vector<pair<int, int> > ans;
bool cmp(int i, int j... | 4 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
cin>>a>>b;
for(int i=1;i<=a.size();i++)
{
a=a.substr(a.size()-1,1)+a.substr(0,a.size()-1);
if(a==b)
{
cout<<"Yes"<<endl;
return 0;
}
}
cout<<"No"<<endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
long long t;
t = 1;
for (long long test = 1; test <= t; test++) {
solve();
}
return 0;
}
inline void solve() {
long long n;
cin >> n;
if (n % 2 == 0) {
... | 4 |
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
struct state{
int node,del,dist;
bool operator<(const state& r)const{
return dist>r.dist;
}
};
struct edge{
int to,dist;
};
int main(){
int N,M,C;
while(cin >> N >> M >> C && N){
vector<vector<edge>> g... | 0 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using db = long double;
const int N = 1e5 + 5, MOD = 1e9 + 7;
using ii = pair<int, int>;
int pwr[505];
int dp[2][505][505];
int n, k;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
pwr[0] = ... | 5 |
#include <cstdio>
typedef long long ll;
const int N=1010,p=1e9+7;
char s[N][N];
int n,m,d,c,S,col,row;
ll k;
inline int qm(int x){return x<0?x+p:x;}
template <typename _tp> inline int qpow(int A,_tp B){
int res(1);while(B){
if(B&1)res=1ll*res*A%p;
A=1ll*A*A%p,B>>=1;
}return res;
}
int main(){
scanf("%d%d%lld... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
long long n, h;
cin >> n;
if (n == 0) {
cout << "1\n";
return 0;
}
if (n == 1) {
cout << "4\n";
return 0;
}
h = n / sqrt(double(2.0));
if (h * h + (h + 1) * (h + 1) > n * n) {
cout << h * 8 << "\n"... | 1 |
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
usin... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n, m, S1, S2, cnt1, cnt2, a[2005], ord1[2005], ord2[2005], id1[2005],
id2[2005];
int s2[2005][2005], nxt1[2005][2005], nxt2[2005][2005];
long long dst1[2005], dst2[2005], s1[2005][2005], dp[2005][2005][2],
mn[2005][2005][2];
bool vs1[2005];
struct Edge {
int v... | 4 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
string a, b;
cin >> a >> b;
long long n = a.size();
map<long long, long long> c1, c2;
c1['4'] = 0;
c1['7'] = 0;
c2['4'] = 0;
c2['7'] = 0;
for (long long i = 0; i < a.length(); i++) {
c1[a[i]]++;
c2[b[i]]++;
}
long long ans = 0;
... | 1 |
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<cmath>
#include<time.h>
#include<unordered_map>
#include<bits/stdc++.h>
#define MAXN 2010101
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD=100... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a, b, c;
int cnt[100005];
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++) cnt[i] = 0;
for (int i = 1; i <= m; i++) {
scanf("%d %d %d", &a, &b, &c);
if (cnt[a] == 0 && cnt[b] != 1 && cnt[c] != 1)
cnt[a] = 1;
else if (cn... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const int N = (int)2e5 + 99;
int n, k;
long long a[N], b[N];
bool moze(long long x) {
vector<vector<long long> > ispr(k);
vector<long long> cur(n);
for (int i = 0; i < n; ++i) cur[i] = a[i];
for (int i = 0; i < n; ++i) {
if... | 4 |
#include <bits/stdc++.h>
using namespace std;
string s;
int n, sl[500010 + 1], i, d[500010 + 1], dmax = 0;
string a[500010 + 1];
vector<int> ke[500010 + 1], res[500010 + 1];
void docdl() { cin >> s; }
void build(int u) {
while (sl[u] > 0 && i < n) {
i++;
ke[u].push_back(i);
if (sl[i] > 0) build(i);
sl... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 2100000000;
int main() {
int n;
cin >> n;
vector<pair<int, int> > v(n), g(n);
for (int i = 0; i < n; ++i) {
scanf("%d%d", &v[i].first, &v[i].second);
int x = v... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int K = 20;
int go[K][N];
int tin[N], tout[N];
vector<int> g[N];
int timer = 0;
int perm[N];
int where[N];
pair<int, int> t[4 * N];
int n;
void dfs(int u, int p = 0) {
go[0][u] = p;
tin[u] = timer++;
for (int i = 1; i < K; ++i) {
go[i]... | 3 |
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<functional>
#define NIL (-1)
#define MAX 22
#define MAX_PIECES 10
#define BURIED 1
#define NONE 0
#define PZL 1
using namespace std;
class CPiece{
public:
class piece{
public:
int si, sj;
int H, W;
short m[MAX][... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long ans;
int n, w;
int pos[maxn], v[maxn];
int seq[maxn];
pair<double, double> k[maxn];
map<double, int> rec;
int bit[maxn];
void update(int p) {
while (p <= n) {
bit[p]++;
p += (p & (-p));
}
return;
}
int calc(int p) {
int a... | 5 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>
ll MOD = 1e9+7;
ll inv(ll a, ll b) {
return 1 < a ? b - inv(b % a, a) * b / a : 1;
}
ll fac[100001];
ll C(ll n, ll m){
return (((fac[n]*inv(fac[m],MOD))%MOD)*(inv(... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> m;
void solve() {
m["H"] = 1;
m["HE"] = 1;
m["LI"] = 1;
m["BE"] = 1;
m["B"] = 1;
m["C"] = 1;
m["N"] = 1;
m["O"] = 1;
m["F"] = 1;
m["NE"] = 1;
m["NA"] = 1;
m["MG"] = 1;
m["AL"] = 1;
m["SI"] = 1;
m["P"] = 1;
m["S"] = 1;
... | 6 |
#include <stdio.h>
int main(){printf("%s\n",scanf("%*d/0%*[1-4]/%*d%*s")<0?"Heisei":"TBD");} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.sync_with_stdio(false);
int n;
int a[3001], b[3001], c[3001];
long long d0[3001], d1[3001];
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
for (int i = 0; i < n; i++) cin >> c[i];
d0[0] = a[0];
... | 4 |
#include <bits/stdc++.h>
using namespace std;
int n, a[16];
bool flag;
void dfs(int x, int ans) {
if (x == n) {
if (ans % 360 == 0) {
flag = 1;
}
return;
}
dfs(x + 1, ans + a[x]);
if (ans >= a[x]) {
dfs(x + 1, ans - a[x]);
} else {
dfs(x + 1, 360 + ans - a[x]);
}
return;
}
int ma... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long pow(long long b, long long e, long long m) {
long long t = 1;
for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0;
return t;
}
template <class T>
inline bool chkmin(T &a, T b) {
return a > b ? a = b, true : false;
}
template <class T>
inline bool c... | 1 |
#include <bits/stdc++.h>
using namespace std;
string a;
bool is() {
for (int i = 0; i < a.size() / 2; i++) {
if (a[i] != a[a.size() - 1 - i]) return false;
}
return true;
}
void ins(int n, char b) { a = a.substr(0, n) + b + a.substr(n, a.size()); }
void ele(int n) { a = a.substr(0, n) + a.substr(n + 1, a.size... | 5 |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << '=' << h << endl;
}
template <class TH, c... | 6 |
#include <bits/stdc++.h>
using namespace std;
int n, m, na, nd;
int aa[111], ad[111], b[111];
int not_broke() {
int ans = 0;
for (int i = 1; i <= na; ++i) {
if (m - i + 1 < 1) continue;
int res = 0, tot = 0;
for (int k = 1; k <= i; ++k)
res += b[m - i + k] - aa[k], tot += b[m - i + k] >= aa[k];
... | 4 |
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ref(i,x,y)for(int i=x;i<=y;++i)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
int n,m,a[101][101],id[10010];int vis[101];
int s[101][101],link[101],LK[101];
... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 20;
int n;
vector<int> adj[MAXN];
long long c[MAXN], f[MAXN], g[MAXN];
void get(int v, int p = -1) {
long long m1 = 0, m2 = 0;
for (int u : adj[v])
if (u != p) {
get(u, v);
m1 = max(m1, f[u]);
m2 = min(m2, g[u]);
}
c[v]... | 4 |
#include <iostream>
using namespace std;
int main(){
string s;
cin >> s;
cout << s.substr(0,4) << ' ' << s.substr(4) << endl;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int w, m;
cin >> w >> m;
bool f = true;
int cnt = 0;
if (w == 1) {
if (m <= 100)
cout << "YES";
else
cout << "NO";
return 0;
}
while (((m + 1) % w == 0 || (m - 1) % w == 0 || m % w == 0) && m > 1) {
if (m % w == 0) {
... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int n;
int ans[N];
char str[N];
int main() {
scanf("%d", &n);
scanf("%s", str + 1);
for (register int i = 1; i <= n; ++i)
for (register int j = i + 1; j <= n; ++j)
for (register int k = j + 1; k <= n; ++k)
if (str[i] > str[j] && st... | 5 |
#include <bits/stdc++.h>
using namespace std;
int n, q, m, b[1000000];
struct arr {
int x, y;
};
struct stp {
long long ans, l, r;
vector<arr> pre, suf;
} z;
struct segment_tree {
stp a[1000000];
stp merge(stp x, stp y) {
z.l = x.l, z.r = y.r;
z.ans = x.ans + y.ans;
for (int i = 0, j = x.suf.size(... | 6 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, ar = 200005;
priority_queue<int> q;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int x, k;
cin >> x >> k;
vector<int> vec;
for (int w = 0; w < x; w++) {
int a;
cin >> a;
vec.push_back(a);
}
so... | 3 |
#include <bits/stdc++.h>
using namespace std;
int a[6], l, s;
int main() {
int i;
for (i = 0; i < 6; i++) scanf("%d", &a[i]);
l = a[0] + a[1] + a[2];
s = l * l - a[0] * a[0] - a[2] * a[2] - a[4] * a[4];
printf("%d\n", s);
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 1;
int arr[N];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i];
int mx = 0, cnt;
for (int i = 0; i < n; i++) {
cnt = 1;
for (int j = i; j > 0; j--) {
if (arr[j] < arr[j - 1]) break;
cnt++;
}
for... | 2 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
if(A>=13)
cout<<B;
else if(A<=5)
cout<<0;
else cout<<B/2;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
float d, h, u, e;
cin >> d >> h >> u >> e;
if (u < e * 3.14159 * d * d / 4)
cout << "NO";
else
cout << "YES"
<< "\n"
<< h / (u / (3.14159265 * d * d / 4) - e);
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
return x * x;
}
template <typename T>
T abs(T x) {
return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <typename T>
bool chmin(T& x, const T& y) {
if (x > y) {
x = y;
re... | 5 |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
set<string> se;
int32_t main(){
int n;cin>>n;
string s,tmp;cin>>s;se.insert(s);
for(int i=1;i<n;i++){
cin>>tmp;if(se.count(tmp)||tmp[0]!=s[s.length()-1]){
cout<<"No";
return 0;
}
se.insert(tmp);
s = tmp;
}
cout<<"Yes";
}
| 0 |
#include <cstring>
#include <string>
#include <time.h>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <limits.h>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unor... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long dp[101][101][101];
char txt[101];
int sz;
long long MD = 1000000007;
long long norm(long long &x) { return x %= MD; }
void tran(int t) {
int i, j, k;
auto _1 = dp[t - 2];
auto _0 = dp[t - 1];
auto _2 = dp[t];
for (i = 0; i <= sz; i++) {
for (j = i; j... | 6 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n, k;
string str;
cin >> n >> k;
cin >> str;
long long l = 0, r = 0;
long long cntb = 0;
long long ans1 = 0, ans2 = 0;
while (r < n and l <= r) {
if (str[r] == ... | 3 |
#include <bits/stdc++.h>
const int MOD = 1000000007;
int modpow(int a, int e) {
int ret = 1;
while (e > 0) {
if (e & 1) ret = (1ll * ret * a) % MOD;
a = (1ll * a * a) % MOD;
e >>= 1;
}
return ret;
}
std::vector<int> fact, invfact;
int binco(int n, int k) {
if (k < 0 || k > n) return 0;
int xd = ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
while (q--) {
int n;
cin >> n;
vector<int> v(n + 1, 0);
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
++v[temp];
}
sort(v.rbegin(), v.rend());
int ind = v[0] + 1, ans = 0;
for (int ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int cs[26]={};
char c;
while(cin>>c){
c=tolower(c);
if(isalpha(c))cs[c-'a']++;
}
for (int i = 0; i < 26; i++){
printf("%c : %d\n",i+'a',cs[i]);
}
}
| 0 |
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "vector"
using namespace std;
#define MAXN 2016
#define P 1000000007
int n;
vector<int> G[MAXN];
int A[MAXN] , F[MAXN] , d[MAXN] , s[MAXN] , siz[MAXN];
void dfs( int u , int fa ) {
if( A[u] ) s[u] = d[u] , siz[u] = 1; else siz[u]... | 0 |
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;
const int M = 1000000007;
int main(){
int n;
long long... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, s;
cin >> n >> s;
int sol = 100;
bool ok = 0;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
if (x < s) {
if (y) sol = min(sol, y);
}
if (x < s || (x == s && y == 0)) ok = 1;
}
if (!ok)
cout << "-1\n";... | 1 |
#include <iostream>
#include <vector>
using namespace std;
int c = 0;
void merge(int a[], int l, int m, int r)
{
int n1 = m - l;
int n2 = r - m;
vector<int> L(n1 + 1), R(n2 + 1);
for (int i = 0; i < n1; i++)
L[i] = a[l + i];
for (int i = 0; i < n2; i++)
R[i] = a[m + i];
L[n1] = 1000000001;
R[n2] = 10000... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int i = 1, j;
int x = 0;
while (1) {
if (i % 2 == 1) {
a -= i;
if (a < 0) {
cout << "Vladik\n";
return 0;
}
} else {
b -= i;
if (b < 0) {
cout << "Valera\n";
... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.