QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425845 | #6452. Ski Resort | lmeowdn | TL | 3979ms | 58792kb | C++14 | 4.6kb | 2024-05-30 17:33:29 | 2024-05-30 17:33:29 |
Judging History
answer
//Shirasu Azusa 2024.5
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=1e5+5;
int n,m,q,p[N],deg[N],fa[N][22],d[N],dfn[N],tick,b[N],sz[N],f[N][7],K,L;
vi e[N],r[N],t[N],g[N];
namespace Reach {
int vst[N],dfn[N],tick,sz[N]; bool rt[N];
vi p; bitset<N> fr[55],to[55];
void dfs(int u) {
dfn[u]=++tick, sz[u]=1; vst[u]=1;
for(int v:e[u]) {
if(vst[v]) rt[u]=1;
else dfs(v), sz[u]+=sz[v];
}
}
void work(int d,int s) {
queue<int>q; fr[d][s]=1; q.push(s);
while(!q.empty()) {
int u=q.front(); q.pop();
for(int v:e[u]) if(!fr[d][v]) fr[d][v]=1, q.push(v);
} to[d][s]=1; q.push(s);
while(!q.empty()) {
int u=q.front(); q.pop();
for(int v:r[u]) if(!to[d][v]) to[d][v]=1, q.push(v);
}
}
bool reach(int x,int y) {
if(dfn[x]<=dfn[y]&&dfn[y]<dfn[x]+sz[x]) return 1;
rep(i,0,(int)p.size()-1) if(fr[i][y]&&to[i][x]) return 1;
return 0;
}
void init() {
dfs(1);
rep(i,1,n) if(rt[i]) p.eb(i);
rep(i,0,(int)p.size()-1) work(i,p[i]);
}
} using Reach::reach;
int lca(int x,int y) {
if(d[x]<d[y]) swap(x,y); if(!x||!y) return x+y;
per(h,18,0) if(d[fa[x][h]]>=d[y]) x=fa[x][h];
per(h,18,0) if(fa[x][h]!=fa[y][h]) x=fa[x][h], y=fa[y][h];
return x==y?x:fa[x][0];
}
int climb(int x,int y) {
per(h,18,0) if(y&(1<<h)) x=fa[x][h]; return x;
}
void buildom() {
queue<int>q; q.push(1); d[1]=1;
while(!q.empty()) {
int u=q.front(); q.pop();
d[u]=d[fa[u][0]]+1, t[fa[u][0]].eb(u);
rep(h,1,20) fa[u][h]=fa[fa[u][h-1]][h-1];
for(int v:e[u]) {
fa[v][0]=lca(fa[v][0],u);
if(!--deg[v]) q.push(v);
}
}
}
void dfs(int u) {
dfn[u]=++tick, sz[u]=1;
for(int v:t[u]) dfs(v), sz[u]+=sz[v];
}
bool cmp(const int &x,const int &y) {return dfn[x]<dfn[y];}
bool chk(int x) {
//cout<<"chk "<<x<<" "<<L<<endl;
for(int y:g[L]) {
//cout<<" "<<y<<" "<<reach(x,y)<<endl;
if(dfn[y]<=dfn[x]&&dfn[x]<dfn[y]+sz[y]) continue;
else if(dfn[x]<=dfn[y]&&dfn[y]<dfn[x]+sz[x]) continue;
else if(reach(x,y)) return 0;
} return 1;
}
void dfs2(int u,int faa,int tp=0) {
//cout<<"DFSX "<<u<<" "<<faa<<endl;
rep(i,0,K) f[u][i]=0; f[u][0]=1; int resu=(u==L?0:chk(u));
if(!b[u]) {
for(int v:g[u]) {
dfs2(v,u,resu);
static int h[10];
rep(i,0,K) h[i]=0;
rep(i,0,K) rep(j,1,K-i) h[i+j]+=f[u][i]*f[v][j];
rep(i,0,K) f[u][i]=h[i];
}
}
if(tp) {
f[u][1]+=d[u]-d[faa];
} else if(resu||u==L) {
int x=u;
per(h,18,0) if(d[fa[x][h]]>d[faa]) {
if(chk(fa[x][h])) x=fa[x][h];
}
f[u][1]+=d[u]-d[x]+1;
}
//cout<<u<<" "<<f[u][0]<<" "<<f[u][1]<<" "<<f[u][2]<<endl;
}
int work() {
rep(i,0,n) g[i].clear();
int k=read(), m=read(); L=0; vi ykn,ako; K=k;
rep(i,1,m) {int u=read(); L=lca(L,u); ykn.eb(u);}
if(k==1) return d[L];
for(int u:ykn) if(u==L) return 0;
sort(ykn.begin(),ykn.end(),cmp);
rep(i,0,m-2) ako.eb(lca(ykn[i],ykn[i+1]));
rep(i,0,m-1) ako.eb(ykn[i]), b[ykn[i]]=1;
sort(ako.begin(),ako.end(),cmp);
ako.resize(m=unique(ako.begin(),ako.end())-ako.begin());
for(int x:ako) g[x].clear();
rep(i,1,m-1) g[lca(ako[i-1],ako[i])].eb(ako[i]);
if(g[L].size()>k) {
for(int x:ako) g[x].clear(), b[x]=0;
return 0;
} dfs2(L,L); for(int x:ako) b[x]=0;
return f[L][k];
}
signed main() {
n=read(), m=read(), q=read();
rep(i,1,m) {
int u=read(), v=read();
e[u].eb(v), r[v].eb(u);
deg[v]++;
}
Reach::init();
buildom(); dfs(1);
rep(i,1,q) printf("%lld\n",work());
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 24164kb
input:
4 4 4 1 2 1 3 2 4 3 4 1 1 4 2 1 4 1 1 3 2 2 3 2
output:
2 0 2 1
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 4ms
memory: 18152kb
input:
8 10 4 1 2 2 3 1 3 3 6 6 8 2 4 2 5 4 7 5 7 7 8 2 3 4 5 6 2 2 6 8 1 1 6 1 1 8
output:
0 0 3 2
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 24532kb
input:
8 9 4 1 2 1 3 3 6 6 8 2 4 2 5 4 7 5 7 7 8 2 3 4 5 6 2 2 6 8 1 1 6 1 1 8
output:
2 0 3 2
result:
ok 4 lines
Test #4:
score: 0
Accepted
time: 2ms
memory: 22192kb
input:
8 8 2 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 2 2 5 7 1 1 8
output:
9 2
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 5ms
memory: 22552kb
input:
8 8 1020 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 4 3 2 4 5 3 6 1 2 3 6 7 8 4 5 2 3 4 5 8 3 4 1 3 4 8 3 3 1 4 6 4 4 1 2 5 6 3 1 2 1 6 1 2 3 4 6 7 4 3 1 5 7 3 4 1 2 6 8 1 1 4 3 5 3 4 5 7 8 2 4 1 4 5 7 1 3 1 2 7 1 3 4 6 8 4 4 1 2 3 8 2 2 3 4 4 3 3 6 8 4 6 1 4 5 6 7 8 4 6 1 2 4 5 6 7 1 4 3 5 7 8 4 4 1 4 6 7 2 1...
output:
0 0 0 0 0 0 0 1 0 0 3 0 0 1 1 0 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 3 1 1 0 0 0 1 0 4 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 2 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 4 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 9 1 0 0 1 1 1 0 0 0 0 0 0 1 0 0 0 0 ...
result:
ok 1020 lines
Test #6:
score: 0
Accepted
time: 4ms
memory: 24300kb
input:
8 9 2 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 4 3 2 2 5 7 1 1 8
output:
3 2
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 22252kb
input:
8 9 1020 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 4 3 1 4 1 2 5 7 4 2 2 4 4 4 2 5 7 8 1 5 2 4 5 6 7 2 4 2 4 6 8 2 6 2 3 4 5 6 8 4 2 2 3 3 3 3 4 8 1 4 2 3 6 7 2 4 1 5 6 8 4 4 2 4 6 8 3 3 1 3 7 4 4 4 5 7 8 4 5 1 2 3 4 5 3 4 1 4 6 7 3 3 3 4 5 2 4 2 3 5 8 2 3 2 6 8 4 1 3 4 2 3 5 2 2 2 6 4 6 1 2 3 4 5 6 2 2 1 5 3...
output:
1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 4 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 3 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 ...
result:
ok 1020 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 24244kb
input:
8 9 2 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 6 2 2 2 5 7 1 1 8
output:
3 2
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 18112kb
input:
8 9 1020 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 6 2 2 5 1 3 5 6 8 4 4 1 3 4 5 2 3 5 7 8 2 3 1 3 5 1 3 1 4 6 1 4 1 3 6 8 4 5 1 3 5 7 8 3 4 1 3 4 7 2 6 1 2 3 6 7 8 2 4 1 5 6 7 2 1 4 4 4 1 4 5 6 1 1 7 2 3 1 3 8 4 3 1 4 8 1 4 3 5 6 7 3 3 1 6 8 1 5 3 4 5 6 7 1 3 1 2 3 3 4 2 4 6 8 4 3 2 4 6 1 6 2 3 4 5 6 7 3 2 5...
output:
0 0 0 0 1 1 0 0 0 0 0 0 4 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 3 0 1 1 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 ...
result:
ok 1020 lines
Test #10:
score: 0
Accepted
time: 0ms
memory: 18144kb
input:
8 9 2 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 4 6 2 2 5 7 1 1 8
output:
2 2
result:
ok 2 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 20516kb
input:
8 9 1020 1 2 1 3 2 4 4 5 5 8 3 6 6 7 7 8 4 6 1 3 2 4 7 4 1 8 4 3 4 7 8 1 5 1 2 6 7 8 1 3 1 5 8 3 7 1 2 3 4 5 6 7 2 6 2 3 4 5 7 8 4 1 4 3 4 3 5 6 8 1 3 2 7 8 1 3 3 5 8 1 3 2 5 8 1 3 1 4 5 2 3 1 3 6 4 4 5 6 7 8 2 3 3 6 7 4 5 2 3 4 5 7 2 5 2 3 4 5 7 4 3 3 6 7 3 4 1 4 5 7 1 5 3 4 5 6 7 3 6 3 4 5 6 7 8 3...
output:
1 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 3 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 0 0 1 1 0 ...
result:
ok 1020 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 22244kb
input:
30 32 70 5 6 2 3 16 17 1 9 1 23 27 28 9 10 10 11 21 22 6 7 28 29 15 30 18 19 19 20 1 16 4 5 13 14 7 8 25 26 29 30 8 30 26 27 22 30 23 24 20 21 12 13 17 18 3 4 11 12 24 25 14 15 1 2 4 4 19 20 21 30 4 4 8 13 22 29 4 4 3 10 19 21 4 4 6 18 19 23 4 4 10 13 18 28 4 4 14 25 26 28 4 4 11 17 22 27 4 4 3 5 14...
output:
0 1715 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 84 140 0 0 0 0 0 0 0 0 0 0 420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 108 0 0 24 105 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 70 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 20224kb
input:
30 32 70 5 6 2 3 16 17 1 9 1 23 27 28 9 10 10 11 21 22 6 7 28 29 15 30 18 19 19 20 1 16 4 5 13 14 7 8 25 26 29 30 8 30 26 27 22 30 23 24 20 21 12 13 17 18 3 4 11 12 24 25 14 15 1 2 3 3 2 11 12 3 3 2 13 26 3 3 10 26 28 3 3 5 7 8 3 3 1 4 12 3 3 9 16 17 3 3 4 19 27 3 3 3 6 9 3 3 11 17 21 3 3 15 25 26 3...
output:
0 20 0 0 0 0 60 0 0 0 0 0 120 0 0 20 0 112 96 0 0 0 18 0 6 0 196 0 28 0 0 14 49 0 0 36 0 24 10 0 0 0 0 75 0 63 0 16 0 0 0 0 90 0 64 0 0 0 84 0 0 0 0 0 0 0 28 0 0 0
result:
ok 70 lines
Test #14:
score: 0
Accepted
time: 3ms
memory: 24296kb
input:
30 32 70 5 6 2 3 16 17 1 9 1 23 27 28 9 10 10 11 21 22 6 7 28 29 15 30 18 19 19 20 1 16 4 5 13 14 7 8 25 26 29 30 8 30 26 27 22 30 23 24 20 21 12 13 17 18 3 4 11 12 24 25 14 15 1 2 2 2 3 25 2 2 7 20 2 2 14 25 2 2 9 20 2 2 9 12 2 2 18 20 2 2 10 13 2 2 7 9 2 2 2 22 2 2 16 26 2 2 5 24 2 2 5 10 2 2 12 1...
output:
6 30 18 5 0 0 0 6 7 4 8 8 0 12 35 0 24 5 6 0 0 0 30 0 0 8 6 3 30 0 2 0 6 0 2 0 5 0 0 0 21 24 1 2 0 0 0 18 49 8 1 15 35 35 12 14 30 20 9 0 0 4 28 0 18 4 14 15 20 0
result:
ok 70 lines
Test #15:
score: 0
Accepted
time: 3ms
memory: 20200kb
input:
30 32 30 5 6 2 3 16 17 1 9 1 23 27 28 9 10 10 11 21 22 6 7 28 29 15 30 18 19 19 20 1 16 4 5 13 14 7 8 25 26 29 30 8 30 26 27 22 30 23 24 20 21 12 13 17 18 3 4 11 12 24 25 14 15 1 2 1 1 20 1 1 15 1 1 28 1 1 29 1 1 25 1 1 2 1 1 19 1 1 13 1 1 22 1 1 9 1 1 17 1 1 18 1 1 24 1 1 10 1 1 3 1 1 12 1 1 1 1 1 ...
output:
6 8 7 8 4 2 5 6 8 2 3 4 3 3 3 5 1 6 5 2 7 4 7 2 8 2 6 7 4 5
result:
ok 30 lines
Test #16:
score: 0
Accepted
time: 24ms
memory: 20448kb
input:
30 32 19405 5 6 2 3 16 17 1 9 1 23 27 28 9 10 10 11 21 22 6 7 28 29 15 30 18 19 19 20 1 16 4 5 13 14 7 8 25 26 29 30 8 30 26 27 22 30 23 24 20 21 12 13 17 18 3 4 11 12 24 25 14 15 1 2 4 4 9 12 13 17 4 4 6 7 11 21 4 4 3 11 17 19 4 4 8 19 25 30 4 4 4 16 23 29 4 4 10 17 19 27 4 4 2 6 25 26 4 4 1 6 15 2...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 432 672 144 72 0 0 0 48 0 0 0 0 0 0 0 0 1764 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 840 0 0 0 0 0 200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 840 0 96 0 0 0 0 0 0 0 336 0 0 0 0 0 36 0 0 0 0 252 0 0 0 0 0 0 0 0 300 0 0 0 0 0 0 0 0 0 0 840 0 0 0 0 0 0 0 0 84 0 0...
result:
ok 19405 lines
Test #17:
score: 0
Accepted
time: 0ms
memory: 22472kb
input:
30 38 70 1 2 2 3 3 4 4 5 5 6 6 7 7 8 1 9 9 10 10 11 11 12 12 13 13 14 14 15 1 16 16 17 17 18 18 19 19 20 20 21 21 22 1 23 23 24 24 25 25 26 26 27 27 28 28 29 16 23 18 23 27 2 28 2 2 9 3 9 15 30 29 30 22 30 8 30 4 4 20 23 29 30 4 4 1 11 26 30 4 4 3 16 18 23 4 4 5 17 19 24 4 4 7 16 18 19 4 4 5 10 18 3...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 70 lines
Test #18:
score: 0
Accepted
time: 4ms
memory: 22140kb
input:
20 23 6195 20 19 7 20 6 9 1 15 17 5 17 4 8 11 8 7 11 6 2 10 8 14 19 12 4 18 14 13 12 14 18 16 5 2 15 3 13 17 16 5 10 9 10 11 3 8 4 4 6 7 15 16 4 4 4 8 10 16 4 4 8 10 15 20 4 4 1 5 9 18 4 4 3 7 14 17 4 4 3 5 16 17 4 4 6 8 10 18 4 4 5 6 11 15 4 4 8 11 15 18 4 4 4 11 18 19 4 4 4 8 11 17 4 4 3 5 6 12 4 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 6195 lines
Test #19:
score: 0
Accepted
time: 5ms
memory: 24520kb
input:
20 19 6195 19 20 6 18 15 11 1 6 20 5 19 9 15 3 18 17 16 7 18 12 6 16 14 8 9 15 10 4 16 13 10 2 9 10 20 14 1 19 2 2 1 6 4 4 5 6 11 12 4 4 1 9 15 19 4 4 11 12 14 18 4 4 6 11 13 17 4 4 4 10 18 19 3 3 5 9 13 4 4 5 11 13 20 4 4 1 9 10 15 4 4 3 5 18 19 4 4 4 10 14 16 4 4 6 7 11 17 4 4 3 10 14 18 4 4 8 10 ...
output:
0 0 0 0 0 0 6 0 0 0 0 0 8 0 0 9 0 0 24 0 0 12 2 0 0 0 6 0 0 0 12 18 0 0 4 0 0 0 0 0 0 0 0 24 0 0 2 0 0 0 0 3 0 0 0 0 0 18 0 0 16 0 0 4 6 27 0 0 0 8 0 0 0 0 0 0 0 24 0 0 8 0 4 0 0 0 6 4 0 0 4 0 0 0 0 1 0 0 0 0 4 0 0 0 0 0 0 0 0 0 1 0 0 6 0 6 8 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 6 0 3 0 4 0 0 9 4 0 0 0...
result:
ok 6195 lines
Test #20:
score: 0
Accepted
time: 7ms
memory: 24264kb
input:
20 19 6195 1 20 12 18 4 15 4 5 14 7 13 16 13 12 19 4 11 13 14 17 7 8 1 19 13 14 19 9 11 2 1 3 16 10 11 6 1 11 4 4 2 9 10 19 3 3 3 7 11 4 4 2 4 8 19 3 3 1 6 13 4 4 3 6 7 13 4 4 1 5 7 17 4 4 3 8 9 15 4 4 2 9 13 17 4 4 3 14 18 20 4 4 2 10 15 16 4 4 2 7 13 16 4 4 3 10 17 18 4 4 2 11 13 17 4 4 4 6 7 14 4...
output:
0 0 0 0 0 0 10 0 2 0 0 8 0 0 0 0 0 0 2 2 0 0 0 0 0 0 3 4 0 2 0 5 0 4 0 0 0 0 3 0 0 0 0 4 0 1 0 4 0 2 2 0 0 0 1 1 3 6 0 8 0 2 0 1 0 0 0 0 0 0 0 0 0 4 0 0 0 6 0 0 0 6 0 0 12 0 4 0 6 0 4 0 0 8 6 6 0 0 0 4 0 2 0 0 0 0 0 0 6 12 4 0 2 12 0 0 0 0 6 0 3 1 3 0 0 0 0 0 2 0 0 2 0 2 0 0 3 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 6195 lines
Test #21:
score: 0
Accepted
time: 3950ms
memory: 54300kb
input:
99998 100000 40018 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 779...
output:
0 0 298286769040 0 0 0 1 1 0 1 0 194683976 0 0 0 0 1 0 1 0 0 0 0 0 1555840698120 0 0 0 1 0 69776636013 0 0 0 1 0 1 0 1 9807 1 1 14289386090658252 1 1 0 8282 38189520 0 0 361 1311799507285176 911661274353 0 1 0 0 0 2542706031866 0 0 0 149344635 0 0 154279471 1 1 1 0 0 1 1 26733661808 544261562 887482...
result:
ok 40018 lines
Test #22:
score: 0
Accepted
time: 1912ms
memory: 54284kb
input:
99998 100000 18405 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 779...
output:
0 118627327608 0 0 0 0 1 1 1 0 0 3978839141992800 0 0 0 500292640075200 1 0 2995892576470080 1 0 0 3503 0 0 0 9321798690233988 0 1 52245492 0 0 20266 0 0 0 53739800 0 31865956400246640 43409382192 0 0 59886792 9355330123030 1 0 1 0 1 298056461795400 212717031912000 249180259392 0 0 2639630431074 0 0...
result:
ok 18405 lines
Test #23:
score: 0
Accepted
time: 335ms
memory: 55172kb
input:
99998 100000 1982 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 7791...
output:
1001950210080 1 142182748260 1 0 0 0 0 3007012336860 0 0 0 1 1 0 0 12263470896 1 0 1 0 6577637700920 0 21072165374 1 0 1 0 229878034749000 1 0 1 1 0 1 0 0 1 1 0 1551841626124800 605328014071872 79137667714560 3746658561084 0 1 595702804349040 1 368128764432 1 19993428928 1 0 0 0 0 1 0 0 801682818750...
result:
ok 1982 lines
Test #24:
score: 0
Accepted
time: 162ms
memory: 55816kb
input:
99998 100000 211 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 77918...
output:
134139450 0 0 1 35252238672 0 0 20463100 44500500 0 0 1 0 0 0 0 0 483935265 0 41147647200 0 69503616 0 19423657440 0 1 0 0 1 1 1 84889 0 18496578800 0 1 4027968 0 1 1 0 0 0 590212224 0 0 5378068 0 1 0 1 0 0 0 1 0 1 320137920 1 0 0 0 5544986944 0 1 1 0 1 0 0 1 0 1348480 1 60384000 1 11867796122624 1 ...
result:
ok 211 lines
Test #25:
score: 0
Accepted
time: 124ms
memory: 57168kb
input:
99998 100000 15 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 77918 ...
output:
0 0 0 0 0 213449804015280 0 0 373516110 1 0 1 0 0 0
result:
ok 15 lines
Test #26:
score: 0
Accepted
time: 3963ms
memory: 53464kb
input:
99998 100000 40003 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 779...
output:
0 0 24723477555562240 1 0 1 0 0 1 69590355 0 0 0 290660564 0 0 0 872824656600 0 1 0 120018411590 0 0 0 0 0 1296 0 0 0 1 0 0 406851372 0 0 0 0 1469 0 0 57692701815 0 0 0 0 212747894766 1 37665390 1 1 2320288257651 0 0 21569 0 0 1 0 1 0 39836748 24359 347 4765 10367 0 0 0 0 0 0 0 27720000 0 0 0 0 1 0 ...
result:
ok 40003 lines
Test #27:
score: 0
Accepted
time: 2656ms
memory: 53632kb
input:
99998 100000 25000 56803 56804 28456 28457 7503 7504 57479 57480 60467 60468 49082 49083 96091 96092 12177 12178 14718 14719 91546 91547 32280 32281 24589 24590 68619 68620 48993 48994 66820 66821 79526 79527 66592 66593 50885 50886 6647 6648 89570 89571 95095 95096 37593 37594 95870 95871 77917 779...
output:
34638752617398800 13087104390091816 18597902661674336 13260707158526208 34039680688570392 40370744515645170 58747123908277920 19010092301438112 1105801092830616 14874839425410176 37091165657763360 112521134825746200 84093565287669300 4185617187981600 14068003514019840 5189876927656344 69803346875316...
result:
ok 25000 lines
Test #28:
score: 0
Accepted
time: 3979ms
memory: 52696kb
input:
99982 100000 40060 429 430 43935 43936 35908 35909 73132 73133 19211 19212 65777 65778 94131 94132 72015 72016 71254 71255 33126 33127 59388 59389 13649 13650 19511 19512 48 49 86111 86112 82237 82238 76191 76192 14637 14638 12313 12314 68813 68814 25386 25387 50390 50391 26817 26818 83709 83710 450...
output:
0 0 1 1 1 1239300 492684720 0 0 0 0 1 0 0 2124 0 1 1 5405405616 0 3907 0 0 0 0 1 0 0 8019748 0 0 0 0 0 6685535118 2656632 0 20659650984 3070446 7507461024 1079111856 0 0 0 0 0 0 0 0 331177980 0 0 0 352 0 1355438565 0 1 4576 0 9283260 0 1518978560 0 0 1 1 1 0 0 0 0 0 0 0 0 1 0 156 0 0 2847285 0 56080...
result:
ok 40060 lines
Test #29:
score: 0
Accepted
time: 1891ms
memory: 52988kb
input:
99982 100000 18191 429 430 43935 43936 35908 35909 73132 73133 19211 19212 65777 65778 94131 94132 72015 72016 71254 71255 33126 33127 59388 59389 13649 13650 19511 19512 48 49 86111 86112 82237 82238 76191 76192 14637 14638 12313 12314 68813 68814 25386 25387 50390 50391 26817 26818 83709 83710 450...
output:
0 0 1 0 0 1 0 0 0 1 1770160 0 3399076 1 0 30953623834452 0 152334476 0 0 8110252368 1 0 0 0 0 1 479 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 21987480 0 0 0 0 1 1 22077527020800 1 0 0 0 0 0 3830 0 0 0 1 0 0 0 0 0 1 0 691 1 8331520483230 1 1 0 1 0 40113082035 0 1 1 4564761300 0 0 0 0 0 6949227 1 0 1016 1351213...
result:
ok 18191 lines
Test #30:
score: 0
Accepted
time: 323ms
memory: 53008kb
input:
99982 100000 1984 429 430 43935 43936 35908 35909 73132 73133 19211 19212 65777 65778 94131 94132 72015 72016 71254 71255 33126 33127 59388 59389 13649 13650 19511 19512 48 49 86111 86112 82237 82238 76191 76192 14637 14638 12313 12314 68813 68814 25386 25387 50390 50391 26817 26818 83709 83710 4500...
output:
0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 7102612 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 495756450 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 ...
result:
ok 1984 lines
Test #31:
score: 0
Accepted
time: 171ms
memory: 54520kb
input:
99982 100000 213 429 430 43935 43936 35908 35909 73132 73133 19211 19212 65777 65778 94131 94132 72015 72016 71254 71255 33126 33127 59388 59389 13649 13650 19511 19512 48 49 86111 86112 82237 82238 76191 76192 14637 14638 12313 12314 68813 68814 25386 25387 50390 50391 26817 26818 83709 83710 45000...
output:
1 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 ...
result:
ok 213 lines
Test #32:
score: 0
Accepted
time: 77ms
memory: 49344kb
input:
99982 100000 13 429 430 43935 43936 35908 35909 73132 73133 19211 19212 65777 65778 94131 94132 72015 72016 71254 71255 33126 33127 59388 59389 13649 13650 19511 19512 48 49 86111 86112 82237 82238 76191 76192 14637 14638 12313 12314 68813 68814 25386 25387 50390 50391 26817 26818 83709 83710 45000 ...
output:
0 0 0 0 0 0 0 0 1 0 0 0 0
result:
ok 13 lines
Test #33:
score: 0
Accepted
time: 3948ms
memory: 57344kb
input:
99998 100003 40077 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 6694 0 41984350 0 0 1 0 23751 0 1 0 1 0 0 1 0 0 0 23668 0 0 0 0 0 12161 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12947 0 0 0 1 1 0 0 0 202 0 0 1 0 0 0 16093 0 0 0 0 1 24184 0 0 0 1 6019 0 0 0 0 0 0 0 0 19160 1 0 0 0 0 21840 12001 0 0 0 0 0 1 8877 0 0 1 1 1 0 0 0 10619 ...
result:
ok 40077 lines
Test #34:
score: 0
Accepted
time: 1876ms
memory: 58124kb
input:
99998 100003 18232 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
0 0 1 0 1 1 0 0 0 12579 1 0 1 1 1 0 0 0 0 0 0 5443 9600 0 1 0 0 0 0 0 0 0 1 1 21489 0 1 1 0 0 0 1 0 0 0 0 1 23994450 0 1 0 0 0 0 9744 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 23023225 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 75260304 0 1 0 0 0 0 0 0 0 0 0 0 0 0 7627 0 1 24576 1...
result:
ok 18232 lines
Test #35:
score: 0
Accepted
time: 317ms
memory: 58792kb
input:
99998 100003 1984 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51...
output:
0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 ...
result:
ok 1984 lines
Test #36:
score: 0
Accepted
time: 121ms
memory: 58356kb
input:
99998 100003 198 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 ...
output:
0 1 0 0 1 0 1 1 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 ...
result:
ok 198 lines
Test #37:
score: 0
Accepted
time: 56ms
memory: 58188kb
input:
99998 100003 17 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...
output:
1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0
result:
ok 17 lines
Test #38:
score: 0
Accepted
time: 3910ms
memory: 56976kb
input:
99998 100003 39850 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
1 0 0 0 0 0 12400 0 1 1 1 0 0 0 0 0 1 0 0 0 0 9617230 1 0 0 0 0 0 0 12776 1 1 0 0 0 0 0 1 0 0 3407 0 0 1039208112150516 0 0 48779016 0 0 0 69035843616 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 1 1 0 1 0 66372150 1 9607 14390 0 0 0 0 0 0 0 1 0 0 0 30299235 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 ...
result:
ok 39850 lines
Test #39:
score: 0
Accepted
time: 2608ms
memory: 55856kb
input:
99998 100003 25000 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
0 0 0 0 0 0 0 0 455861090472660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2789201369093840 0 0 0 0 0 0 0 2061545277789660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 797988378283712 0 0 0 1668993541667100 0 1956836957525280 0 1492705368707520 0 0 0 0 0 0 0 0 0 0 6402650306547684 0 0 0 0 0 2226206025139200 0 0 0 0 0 0 1...
result:
ok 25000 lines
Test #40:
score: 0
Accepted
time: 3957ms
memory: 57768kb
input:
99998 100045 40146 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 17169 0 2967 0 1 16439 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7251 0 991 1 0 1 0 0 0 0 0 4092 1 0 0 0...
result:
ok 40146 lines
Test #41:
score: 0
Accepted
time: 3973ms
memory: 57468kb
input:
99998 100045 40035 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 5...
output:
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 11249 1 0 0 0 24696 0 0 0 0 0 0 0 0 0 0 1 0 0 0 24309 0 1 0 0 0 0 0 0 0 0 0 0 1874 0 0 0 0 0 0 1 5215 0 0 0 0 1 0 0 6710 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 6677 0 0 0 18410 0 0 10942908 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 142...
result:
ok 40035 lines
Test #42:
score: -100
Time Limit Exceeded
input:
100000 99999 100000 5541 8237 18051 93161 39292 28423 39951 50802 70539 55736 21230 93162 93714 96830 97206 75839 80861 45890 85303 44198 7649 61828 34399 6757 16385 14680 52314 72478 16605 76186 58131 9693 31198 16693 75353 46182 34523 41478 48258 38326 93349 90553 14740 67406 66890 98367 51410 734...
output:
21380 20452 31337 30716 12448 29927 39922 2142 609 16691 37451 69645 22177 38667 17458 46523 19883 93319 56400 78603 22007 77996 51467 41195 98987 11487 58108 6736 7606 69893 48088 13469 93494 24074 83925 7251 98879 77731 38874 420 53807 77101 59271 11856 77004 77999 96865 233 28393 68475 91172 5019...