QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#382946 | #7769. Axium Crisis | yyyyxh | 100 ✓ | 2110ms | 131940kb | C++14 | 3.3kb | 2024-04-08 20:26:17 | 2024-04-08 20:26:18 |
Judging History
answer
#include <cstdio>
#include <vector>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=x*10+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int N=20,T=2000003,K=10000003,S=1<<17;
typedef pair<int,int> pii;
int n,rt,MskLim;
int hd[N],ver[N<<1],nxt[N<<1],val[N<<1],tot;
void add(int u,int v,int w){
nxt[++tot]=hd[u];hd[u]=tot;ver[tot]=v;val[tot]=w;
}
int tr[T][2],tnum;
int w[N];
struct path{
int u,v,msk;
path(int U,int V,int Msk):u(U),v(V),msk(Msk){}
};
vector<path> vec[T];
void dfs(int u,int fa,int msk,int p){
if(fa) vec[p].emplace_back(rt,u,msk);
for(int i=hd[u];i;i=nxt[i]){
int v=ver[i];
if(v==fa) continue;
int id=(i-1)>>1;
if(val[i]!=1){
if(!tr[p][0]) tr[p][0]=++tnum;
dfs(v,u,msk|(1<<id),tr[p][0]);
}
if(val[i]!=0){
if(!tr[p][1]) tr[p][1]=++tnum;
dfs(v,u,msk|(1<<id),tr[p][1]);
}
}
}
int f[S][N],g[S],tg[S];
int fx[K],fy[K],fv[K],fc;
int gx[K],gt[K],gv[K],gc;
inline void upd(int x,int y,int v){
if(f[x][y]<v){
++fc;fx[fc]=x;fy[fc]=y;fv[fc]=f[x][y];
f[x][y]=v;
if(g[x]<v-y){
++gc;gx[gc]=x;gt[gc]=tg[x];gv[gc]=g[x];
g[x]=v-y;tg[x]=y;
}
}
}
bool vis[N][S];
int lis[N][S],len[N];
int fA[T],gA[T],fB[T],gB[T];
void trav(int p,int d){
if(!p) return;
fA[p]=fc;gA[p]=gc;
for(auto [u,v,msk]:vec[p])
for(int i=msk;i<MskLim;i=(i+1)|msk){
if(!vis[d][i]) vis[d][i]=1,lis[d][len[d]++]=i;
upd(i,d,g[i^msk]+d);
}
trav(tr[p][0],d+1);
trav(tr[p][1],d+1);
fB[p]=fc;gB[p]=gc;
if(d){
for(int it=0;it<len[d];++it){
int x=lis[d][it];
upd(x,d-1,f[x][d]);
if(!vis[d-1][x]) vis[d-1][x]=1,lis[d-1][len[d-1]++]=x;
vis[d][x]=0;
}
len[d]=0;
}
}
void rollback(int fl,int gl){
while(fc>fl) f[fx[fc]][fy[fc]]=fv[fc],--fc;
while(gc>gl) tg[gx[gc]]=gt[gc],g[gx[gc]]=gv[gc],--gc;
}
int tx,ty;
int arr[N],sz,tsz;
int eu[N],ev[N],m;
bool paint(int u,int fa,int goal){
if(u==goal) return 1;
for(int i=hd[u];i;i=nxt[i]){
int v=ver[i];
if(v==fa) continue;
if(paint(v,u,goal)){
w[(i+1)>>1]=arr[tsz--];
return 1;
}
}
return 0;
}
void recall(int p,int d){
if(!p) return;
int las=f[tx][ty];
rollback(fB[p],gB[p]);
if(ty==d-1&&f[tx][ty]<las) ++ty;
arr[++sz]=1;recall(tr[p][1],d+1);--sz;
arr[++sz]=0;recall(tr[p][0],d+1);--sz;
las=f[tx][ty];
rollback(fA[p],gA[p]);
if(ty==d){
for(auto [u,v,msk]:vec[p])
if((tx&msk)==msk&&g[tx^msk]+d==las){
ty=tg[tx^=msk];
++m;eu[m]=u;ev[m]=v;
tsz=sz;paint(u,0,v);
break;
}
}
}
void solve(){
n=read();tnum=1;MskLim=1<<(n-1);m=0;
for(int i=1;i<n;++i){
int u=read()+1,v=read()+1;w[i]=read();
add(u,v,w[i]);add(v,u,w[i]);
}
for(rt=1;rt<=n;++rt) dfs(rt,0,0,1);
for(int s=0;s<MskLim;++s){
for(int i=0;i<n;++i) f[s][i]=!i;
g[s]=1;tg[s]=0;
}
trav(1,0);
tx=MskLim-1;ty=0;
printf("%d\n",f[MskLim-1][0]);
for(int it=0;it<len[0];++it) vis[0][lis[0][it]]=0;
len[0]=0;
recall(1,0);
printf("%d\n",m);
for(int i=1;i<n;++i){
if(w[i]==2) w[i]=1;
printf("%d ",w[i]);
}
putchar('\n');
for(int i=1;i<=m;++i) printf("%d %d\n",eu[i]-1,ev[i]-1);
for(int i=1;i<=n;++i) hd[i]=0;
while(tot) ver[tot]=nxt[tot]=val[tot]=0,--tot;
for(int i=1;i<=tnum;++i) tr[i][0]=tr[i][1]=0,vec[i].clear();
}
int main(){
puts("1");
int tc=read();read();
while(tc--) solve();
return 0;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 7ms
memory: 50800kb
input:
1000 0 4 0 2 0 2 3 0 2 1 0 4 3 2 1 0 2 1 1 2 2 4 0 2 2 0 1 0 3 0 0 4 1 2 1 3 2 0 2 0 1 4 0 2 0 0 3 0 2 1 0 4 0 2 1 0 3 1 0 1 1 4 3 1 0 2 1 2 3 0 2 4 3 1 1 3 0 1 2 3 0 4 1 0 0 2 0 2 2 3 2 4 1 2 0 3 0 0 2 3 2 3 2 1 0 0 2 1 4 3 0 1 1 2 1 2 3 0 4 2 1 0 3 0 1 1 0 1 4 3 2 1 3 1 1 0 1 1 4 1 2 1 1 3 0 3 0 1...
output:
1 3 1 0 0 0 0 1 4 2 1 1 0 0 2 1 3 4 2 1 0 0 0 2 1 3 4 2 1 0 1 0 2 3 1 4 1 0 0 0 1 3 3 1 1 1 1 1 3 4 1 0 0 0 0 2 4 2 1 1 0 0 3 2 1 4 1 0 0 0 1 3 4 1 0 0 0 0 1 3 1 0 1 1 0 4 2 1 1 0 0 3 3 1 4 1 0 1 1 2 3 4 1 1 1 1 0 2 4 2 1 0 1 0 3 3 2 4 1 1 0 0 0 1 4 1 0 0 0 1 2 4 1 0 1 0 0 3 3 1 0 ...
result:
ok Accepted. Good Job!
Test #2:
score: 10
Accepted
time: 11ms
memory: 50800kb
input:
1000 0 4 2 0 0 2 1 0 0 3 0 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 1 0 0 0 1 3 4 1 1 0 0 0 1 6 1 0 1 0 1 0 2 4 4 2 1 0 1 1 3 0 2 4 1 0 0 1 1 3 4 1 1 0 1 3 0 4 1 0 1 0 0 1 5 2 0 1 1 1 1 0 4 1 2 4 2 1 0 0 0 1 2 3 4 2 1 0 1 0 2 2 3 3 1 1 1 1 0 3 3 1 0 1 0 2 4 ...
result:
ok Accepted. Good Job!
Test #4:
score: 10
Accepted
time: 7ms
memory: 50888kb
input:
3000 3 3 0 1 0 1 2 0 4 2 1 1 0 2 0 0 3 1 6 3 4 1 1 4 0 1 5 1 2 1 1 3 0 0 4 0 2 1 1 2 0 1 3 1 4 0 3 1 2 0 1 1 2 0 6 1 2 0 0 3 0 2 5 0 0 2 1 4 2 0 4 2 0 0 2 1 1 3 1 1 4 1 0 1 1 2 0 3 0 1 4 1 3 0 2 1 1 0 2 0 4 1 3 0 2 1 0 1 0 0 4 3 1 0 2 3 0 0 1 1 4 1 0 0 2 0 0 3 0 0 4 2 1 1 1 0 1 2 3 0 4 3 0 1 1 0 0 2...
output:
1 3 1 0 0 0 2 4 2 1 0 1 0 3 0 1 6 2 1 0 1 1 0 1 2 0 5 4 2 1 0 1 0 2 2 3 4 1 1 1 0 1 3 5 2 0 0 0 1 0 1 3 4 5 4 1 0 1 1 0 3 4 1 1 0 1 2 3 4 1 0 1 0 0 3 3 1 0 0 0 0 2 4 1 0 0 1 2 0 3 1 0 0 0 1 3 4 1 1 1 0 3 0 4 1 1 0 0 1 2 6 1 1 0 0 1 0 1 3 4 2 0 1 1 0 3 0 1 4 1 0 1 0 2 3 4 1 0 0 1 0 ...
result:
ok Accepted. Good Job!
Subtask #3:
score: 10
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #5:
score: 10
Accepted
time: 14ms
memory: 51116kb
input:
3000 4 4 2 0 0 1 2 0 1 3 0 4 1 2 2 0 2 2 3 2 2 4 3 1 2 3 2 0 0 2 0 4 0 3 2 2 1 2 0 1 2 4 0 1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3 6 2 1 1 0 1 1 1 3 5 4 6 2 1 0 1 0 1 0 4 0 1 4 2 1 0 1 1 2 0 3 4 1 0 0 0 0 3 6 1 1 0 0 1 1 1 3 3 1 0 0 0 0 1 3 ...
result:
ok Accepted. Good Job!
Subtask #4:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #7:
score: 10
Accepted
time: 44ms
memory: 53416kb
input:
3000 3 8 1 2 1 3 7 0 7 0 1 7 4 0 6 5 0 6 4 1 2 0 0 5 3 1 0 3 2 1 0 1 0 4 0 1 5 3 2 0 4 0 0 4 1 0 2 0 1 6 5 4 1 4 1 1 4 2 1 0 4 1 4 3 1 5 4 1 0 4 3 0 2 1 1 3 0 1 8 3 6 0 1 4 1 2 3 1 0 6 1 0 7 1 2 1 0 7 5 0 8 4 5 0 5 7 0 3 0 0 2 4 1 1 2 0 5 6 0 6 3 1 5 4 1 0 4 0 0 4 3 0 2 4 1 5 1 0 0 1 2 0 2 3 1 0 4 1...
output:
1 8 2 1 0 1 0 0 1 0 1 7 3 5 5 2 0 1 0 1 0 4 0 2 5 1 0 0 0 1 1 3 3 1 1 1 1 1 1 0 3 5 2 0 0 1 1 0 3 3 2 8 1 0 1 1 1 1 0 0 5 4 7 2 0 0 0 1 0 0 1 0 5 7 1 5 2 0 0 0 1 2 3 0 1 5 2 0 0 1 1 0 4 0 3 6 2 1 0 1 0 0 1 5 2 4 6 2 0 1 1 1 0 0 4 1 2 5 1 0 0 0 0 1 1 5 8 1 0 1 1 0 0 1 0 1 7 6 1 0 1 1 1 0...
result:
ok Accepted. Good Job!
Test #8:
score: 10
Accepted
time: 40ms
memory: 53432kb
input:
3000 3 6 3 1 1 1 4 0 1 0 1 1 2 0 5 1 0 6 0 3 1 2 4 1 1 5 1 1 4 0 4 0 0 6 2 5 0 1 5 1 3 4 0 4 0 0 3 2 1 8 2 5 0 6 7 0 0 3 0 6 0 1 1 4 0 7 5 1 3 4 1 11 7 6 1 3 5 1 2 7 1 7 10 0 1 7 0 8 7 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 4 8 2 0 1 0 0 0 0 0 0 1 5 6 8 2 0 0 1 0 0 0 0 2 3 5 7 6 1 0 0 0 0 0 3 5 6 1...
result:
ok Accepted. Good Job!
Test #10:
score: 10
Accepted
time: 53ms
memory: 53724kb
input:
3000 0 6 4 0 0 1 4 1 5 3 0 3 2 1 0 5 1 8 1 7 0 6 1 0 4 2 0 4 1 1 5 4 0 4 3 0 0 4 1 8 3 1 0 2 3 0 3 0 0 4 7 0 5 7 0 7 6 0 7 3 0 6 5 2 2 4 0 2 0 3 2 5 4 2 1 3 2 4 2 3 1 3 0 1 1 3 1 5 0 2 1 2 4 0 1 4 2 3 4 0 6 1 0 0 4 2 0 4 5 0 3 5 0 2 0 0 5 0 1 0 0 2 0 0 3 0 0 4 0 6 1 4 1 1 3 1 1 5 1 0 2 0 1 2 0 5 0 2...
output:
1 6 2 0 1 0 1 1 1 4 4 2 6 3 0 0 0 1 0 0 1 0 4 2 6 3 5 4 1 0 0 0 0 0 0 0 0 6 6 1 0 0 0 0 0 1 2 3 1 1 1 1 0 1 5 2 1 0 1 0 1 4 3 0 6 1 0 0 0 0 0 1 3 3 1 0 0 0 0 1 4 6 2 1 1 1 0 0 3 5 0 4 5 2 1 0 0 0 0 1 3 4 5 3 0 1 0 1 0 2 3 0 5 1 4 6 2 1 1 1 1 1 0 1 2 4 5 7 5 2 0 0 0 1 1 3 2 4 8 2 1 1 0 1...
result:
ok Accepted. Good Job!
Subtask #6:
score: 10
Accepted
Dependency #4:
100%
Accepted
Test #11:
score: 10
Accepted
time: 261ms
memory: 73692kb
input:
3000 3 8 3 5 1 4 1 0 4 6 1 5 6 0 7 5 0 3 2 1 3 0 1 8 1 4 1 0 3 0 7 3 1 5 2 1 5 3 1 5 1 0 6 0 1 8 1 4 1 1 2 1 0 1 0 6 7 1 3 5 1 6 4 0 4 5 0 8 7 0 0 1 4 0 3 1 1 4 2 1 2 6 0 4 5 0 7 3 1 8 7 0 0 5 7 1 4 2 0 1 3 0 2 5 0 6 0 0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ok Accepted. Good Job!
Subtask #7:
score: 5
Accepted
Test #13:
score: 5
Accepted
time: 382ms
memory: 82724kb
input:
3000 1 11 2 5 0 10 2 0 6 2 0 2 8 0 0 2 0 2 1 0 2 4 0 2 9 0 2 3 0 7 2 0 11 7 8 0 6 4 0 1 6 0 2 8 0 8 0 0 6 3 0 9 5 0 5 8 0 1 2 0 9 10 0 8 1 4 0 2 3 0 6 5 0 6 7 0 2 4 0 7 3 0 1 0 0 8 4 0 0 0 5 0 7 2 0 0 2 0 0 6 0 0 1 0 0 3 0 11 5 1 0 7 2 0 9 2 0 4 9 0 0 2 0 8 5 0 0 6 0 3 6 0 4 10 0 1 7 0 7 6 2 0 0 5 0...
output:
1 3 1 0 0 0 0 0 0 0 0 0 0 0 7 8 1 0 0 0 0 0 0 0 0 0 0 3 10 8 1 0 0 0 0 0 0 0 0 5 4 1 0 0 0 0 0 0 0 1 7 8 1 0 0 0 0 0 0 0 0 0 0 3 8 7 1 0 0 0 0 0 0 1 3 5 1 0 0 0 0 0 4 7 1 0 0 0 0 0 0 2 4 11 1 0 0 0 0 0 0 0 0 0 0 5 7 4 1 0 0 0 0 0 0 0 1 2 8 1 0 0 0 0 0 0 0 5 6 4 1 0 0 0 0 0 0 0 0 0 0 0 2 ...
result:
ok Accepted. Good Job!
Subtask #8:
score: 15
Accepted
Test #14:
score: 15
Accepted
time: 2046ms
memory: 129912kb
input:
3000 2 8 4 7 2 4 3 2 3 2 2 4 5 2 1 4 2 6 4 2 0 1 2 8 1 5 2 0 7 2 3 2 2 3 1 2 5 7 2 4 0 2 6 4 2 8 1 3 2 5 3 2 7 6 2 2 6 2 0 7 2 4 6 2 0 5 2 8 5 7 2 2 6 2 1 6 2 4 5 2 4 0 2 0 1 2 7 3 2 11 2 7 2 0 9 2 8 9 2 10 7 2 6 9 2 9 3 2 4 10 2 7 5 2 7 9 2 1 9 2 8 2 6 2 1 5 2 4 1 2 1 3 2 6 1 2 0 1 2 6 7 2 14 2 6 2...
output:
1 7 3 1 0 0 0 0 1 0 4 6 5 7 0 2 8 1 0 0 0 0 0 0 0 2 6 8 2 0 0 0 1 0 0 0 2 6 1 4 8 1 0 0 0 0 0 0 0 2 3 9 4 1 1 0 0 1 0 0 0 0 1 0 1 2 5 3 6 4 8 6 3 0 0 1 0 0 1 1 0 1 3 4 2 5 7 4 1 1 1 1 1 1 0 0 0 1 1 0 1 0 4 1 9 3 11 5 10 6 1 0 0 0 0 0 0 5 6 3 0 0 0 1 0 1 0 4 1 2 3 6 10 2 0 0 1 0 0 0 0 0 1 0 ...
result:
ok Accepted. Good Job!
Test #15:
score: 15
Accepted
time: 2110ms
memory: 131940kb
input:
3000 2 8 0 5 2 2 6 2 2 3 2 4 3 2 1 5 2 1 6 2 7 4 2 8 2 3 2 1 5 2 6 7 2 1 4 2 6 0 2 2 5 2 3 7 2 7 4 3 2 0 6 2 6 1 2 2 4 2 4 5 2 5 6 2 6 2 0 2 1 2 2 2 4 2 4 3 2 2 5 2 7 6 4 2 1 4 2 5 4 2 3 6 2 0 2 2 4 2 2 8 3 4 2 6 3 2 2 3 2 5 3 2 0 7 2 3 0 2 1 3 2 8 1 5 2 1 2 2 2 4 2 1 6 2 0 1 2 7 1 2 3 2 2 8 7 5 2 7...
output:
1 8 1 0 0 0 0 0 0 0 0 7 8 1 0 0 0 0 0 0 0 0 4 6 2 1 1 0 0 0 0 0 6 1 2 6 2 1 0 0 0 0 0 5 1 3 7 2 0 1 0 0 0 0 1 5 0 3 7 3 0 1 0 0 0 0 1 1 5 2 6 4 7 6 3 0 0 1 0 1 1 0 0 1 5 7 3 6 8 2 0 0 0 0 0 0 1 6 7 0 3 11 1 0 0 0 0 0 0 0 0 0 0 5 9 8 2 1 0 0 0 0 0 0 2 6 3 7 8 2 0 0 0 0 1 0 0 4 6 2 7 8 2 0 ...
result:
ok Accepted. Good Job!
Test #16:
score: 15
Accepted
time: 2086ms
memory: 119460kb
input:
3000 2 8 7 2 2 5 2 2 4 2 2 0 2 2 6 2 2 1 2 2 3 2 2 8 6 4 2 4 7 2 0 4 2 3 2 2 3 4 2 5 3 2 5 1 2 8 0 1 2 4 0 2 3 2 2 6 7 2 6 2 2 5 3 2 7 1 2 10 3 1 2 8 3 2 7 3 2 4 3 2 2 3 2 9 3 2 0 3 2 6 3 2 3 5 2 7 2 5 2 3 2 2 5 0 2 2 1 2 6 2 2 4 2 2 8 2 7 2 2 6 2 2 5 2 2 4 2 0 2 2 2 3 2 2 1 2 7 5 2 2 1 5 2 4 2 2 3 ...
output:
1 6 3 1 0 0 1 1 0 0 0 3 1 6 4 5 7 3 0 1 0 1 0 0 0 2 3 0 7 1 6 8 1 0 0 0 0 0 0 0 4 5 7 4 1 1 0 0 0 1 1 0 1 0 5 1 6 2 9 4 7 6 3 0 0 0 1 0 1 1 2 3 4 0 6 6 3 1 0 0 1 1 0 0 0 1 3 4 5 6 7 1 0 0 0 0 0 0 0 1 6 3 0 0 0 1 1 0 0 5 1 3 4 6 8 1 0 0 0 0 0 0 0 2 3 7 1 0 0 0 0 0 0 3 5 8 2 0 0 0 0 0 0 1 0...
result:
ok Accepted. Good Job!
Subtask #9:
score: 10
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Test #17:
score: 10
Accepted
time: 572ms
memory: 97568kb
input:
3000 3 8 1 2 0 4 6 1 2 4 1 3 4 1 4 0 0 5 6 0 4 7 1 8 6 0 0 2 6 1 5 4 1 0 4 1 2 3 0 7 1 1 5 1 0 17 8 7 0 15 7 0 5 7 1 4 5 1 2 5 1 16 5 1 10 16 0 14 5 1 6 2 0 3 5 1 12 7 0 14 0 0 3 1 0 9 5 1 13 5 1 16 11 0 14 4 3 0 2 10 1 12 1 0 9 7 0 6 13 0 5 11 0 8 12 1 6 3 1 4 1 1 0 10 0 2 8 0 7 5 1 0 11 1 8 7 6 0 ...
output:
1 7 2 0 1 1 1 0 0 1 3 0 1 5 8 1 0 1 1 1 0 1 0 3 7 10 4 0 0 1 1 1 1 0 1 0 1 0 0 0 1 1 0 2 1 5 0 8 11 12 15 14 1 0 1 0 0 0 0 1 1 1 0 0 1 1 9 13 7 2 0 0 1 0 0 1 0 7 5 2 1 7 2 1 1 1 1 1 1 0 2 3 6 0 8 2 1 1 1 0 1 1 0 2 5 3 0 7 3 1 1 1 0 0 1 1 0 5 1 2 7 6 8 4 1 0 1 0 0 1 0 0 0 1 0 2 3 8 4 6 7 10 ...
result:
ok Accepted. Good Job!
Test #18:
score: 10
Accepted
time: 528ms
memory: 96272kb
input:
3000 3 8 2 7 0 3 4 0 1 0 0 7 5 1 2 3 1 6 5 0 0 4 1 11 10 5 1 2 5 1 5 9 0 5 0 0 4 1 0 3 5 0 5 1 1 6 5 0 7 5 0 8 1 1 8 3 4 1 1 3 1 7 3 0 5 3 0 5 2 0 6 0 0 0 2 1 7 2 5 1 1 3 1 1 5 0 0 6 1 0 2 0 6 4 0 7 0 3 0 2 6 1 0 4 1 5 1 1 4 6 0 1 3 1 11 1 4 0 9 4 0 10 4 1 4 2 0 7 4 0 7 6 1 4 5 0 8 4 1 4 0 0 4 3 1 6...
output:
1 8 1 0 0 0 1 1 0 1 1 6 8 4 1 1 0 0 0 0 1 0 0 1 8 7 2 6 0 10 3 9 8 2 1 1 0 0 0 0 1 1 7 6 4 7 1 1 1 0 1 0 0 4 3 7 2 0 1 1 1 0 1 2 6 6 5 8 4 0 0 1 0 0 1 0 1 0 1 3 8 6 0 1 10 2 5 6 2 0 1 1 1 0 0 2 4 5 7 2 1 0 0 0 0 0 1 4 5 0 1 11 1 0 1 0 1 0 1 1 0 0 1 0 5 7 3 1 0 0 0 1 0 0 6 1 0 4 3 5 7 2 1 1...
result:
ok Accepted. Good Job!
Subtask #10:
score: 10
Accepted
Dependency #5:
100%
Accepted
Dependency #8:
100%
Accepted
Dependency #9:
100%
Accepted
Test #19:
score: 10
Accepted
time: 822ms
memory: 111560kb
input:
3000 0 8 3 2 0 0 2 1 4 1 1 5 4 0 3 6 1 7 5 1 6 1 0 8 3 1 2 4 5 0 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