QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#27484 | #2562. Fake Plastic Trees 2 | guobo | WA | 5ms | 5184kb | C++14 | 2.1kb | 2022-04-09 16:56:57 | 2022-04-29 06:10:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=1111,maxm=55,mod=998244353,INF=1e9;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
inline int qpow(int a,int b){
int ans=1;
for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
return ans;
}
inline int qmo(int x){return x+(x>>31?mod:0);}
int n,m,el,head[maxn],to[maxn],nxt[maxn],sz[maxn];
ll l,r,d,a[maxn];
vector<ll> f[maxn][maxm],tmp[maxm];
void clear(){
FOR(i,1,n) head[i]=sz[i]=0;
FOR(i,1,n) FOR(j,1,m) f[i][j].clear();
FOR(i,1,el) to[i]=nxt[i]=0;
el=0;
}
inline void add(int u,int v){
to[++el]=v;nxt[el]=head[u];head[u]=el;
}
void dfs(int u,int fa){
if(a[u]<=r) f[u][1].PB(a[u]);
sz[u]=1;
for(int i=head[u];i;i=nxt[i]){
int v=to[i];
if(v==fa) continue;
dfs(v,u);
FOR(j,1,min(m,sz[u]+sz[v])) tmp[j].clear();
FOR(j,1,min(m,sz[u])) FOR(x,0,(int)f[u][j].size()-1) FOR(k,1,min(m-j+1,sz[v])) FOR(y,0,(int)f[v][k].size()-1){
if(f[v][k][y]>=l && j+k<=m) tmp[j+k].PB(f[u][j][x]);
if(f[u][j][x]+f[v][k][y]<=r) tmp[j+k-1].PB(f[u][j][x]+f[v][k][y]);
}
sz[u]+=sz[v];
FOR(j,1,min(m,sz[u])){
f[u][j].clear();
sort(tmp[j].begin(),tmp[j].end());
FOR(k,0,(int)tmp[j].size()-1){
ll x=tmp[j][k];
while(f[u][j].size()>=2 && x-f[u][j][f[u][j].size()-2]<d) f[u][j].pop_back();
f[u][j].PB(x);
}
}
}
}
void mian(){
n=read();m=read()+1;
l=read();r=read();d=r-l;
FOR(i,1,n) a[i]=read();
FOR(i,1,n-1){
int u=read(),v=read();
add(u,v);add(v,u);
}
dfs(1,0);
FOR(i,1,m) putchar(!f[1][i].empty() && f[1][i].back()>=l?'1':'0');
puts("");
clear();
}
int main(){
// freopen("ex_data4.in","r",stdin);
int T=1;
T=read();
while(T--) mian();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5ms
memory: 5116kb
input:
3 4 3 1 2 1 1 1 1 1 2 2 3 3 4 4 3 1 2 1 1 1 1 1 2 1 3 1 4 4 3 0 0 1 1 1 1 1 2 1 3 1 4
output:
0111 0011 0000
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 2ms
memory: 4992kb
input:
100 10 9 18 50 18 0 9 8 11 11 13 16 9 2 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 38 50 4 10 11 13 19 6 14 14 20 14 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 26 50 6 1 12 7 1 12 20 2 0 12 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 29 50 16 13 1 17 20 15 0 3 6 7 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10...
output:
0011000000 0010000000 0100000000 0010000000 0011111000 0111100000 0010000000 0010000000 0100000000 0011111000 0110000000 0011000000 0011111100 0100000000 0010000000 0010000000 0010000000 0011000000 0111000000 0011100000 0100000000 0100000000 0100000000 0011000000 0011000000 0011111000 0011111110 001...
result:
ok 100 tokens
Test #3:
score: 0
Accepted
time: 4ms
memory: 5036kb
input:
100 10 9 23 50 13 10 9 11 14 13 11 9 14 14 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 11 50 11 9 9 9 14 7 9 12 14 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 27 50 14 13 9 13 9 13 9 14 14 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 41 50 8 10 10 13 8 6 12 7 10 5 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 1...
output:
0011000000 0011110000 0010000000 0100000000 0011110000 0100000000 0011110000 0011110000 0011100000 0100000000 0011111100 0100000000 0011100000 0011100000 0100000000 0100000000 0011111000 0011000000 0100000000 0011000000 0011111100 0011100000 0100000000 0100000000 0100000000 0011111000 0011111111 010...
result:
ok 100 tokens
Test #4:
score: 0
Accepted
time: 4ms
memory: 5032kb
input:
100 10 9 17 50 9 8 10 12 12 10 12 10 9 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 19 50 10 9 8 10 12 12 8 11 12 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 46 50 8 8 10 10 10 8 9 10 11 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 9 50 9 8 11 10 11 10 10 11 11 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 ...
output:
0011100000 0011000000 0100000000 0011111110 0011111000 0011111111 0011111000 0100000000 0011110000 0011100000 0100000000 0011100000 0011100000 0100000000 0011110000 0011110000 0011100000 0100000000 0011100000 0011111111 0100000000 0011100000 0011000000 0100000000 0011111100 0011110000 0100000000 001...
result:
ok 100 tokens
Test #5:
score: 0
Accepted
time: 4ms
memory: 5132kb
input:
100 10 9 10 50 10 11 11 10 9 9 11 9 11 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 47 50 9 9 9 11 9 10 10 10 10 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 49 50 9 10 9 11 11 9 11 10 10 9 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 19 50 10 9 11 11 10 11 11 9 9 11 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10...
output:
0011111100 0100000000 0100000000 0011100000 0011110000 0011111111 0011110000 0100000000 0010000000 0100000000 0011111000 0011100000 0100000000 0011110000 0011110000 0011111000 0011111111 0011110000 0011111000 0011110000 0011111100 0011100000 0011000000 0011111111 0100000000 0011111111 0100000000 001...
result:
ok 100 tokens
Test #6:
score: 0
Accepted
time: 4ms
memory: 5036kb
input:
100 10 9 50 50 50 50 50 50 50 50 50 50 50 50 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 50 50 50 50 50 50 50 50 50 50 50 50 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 50 50 50 50 50 50 50 50 50 50 50 50 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 50 50 50 50 50 50 50 50 50 50 50 50 1 2 2 3 3 4 4 5 5 6 6...
output:
0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 000...
result:
ok 100 tokens
Test #7:
score: 0
Accepted
time: 4ms
memory: 5008kb
input:
100 10 9 1793281831312430 2579712950976669 883262428445148 926941407766037 874610589009581 918671242302849 917202064660727 848094660280817 810513162735522 862049976415823 844577745576407 873085228984439 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 1890762965379103 2701769025604615 804306683243252 81402...
output:
0001000000 0001000000 0000100000 0000110000 0001111000 0000100000 0001111111 0000111100 0000111110 0000110000 0001111111 0000111000 0001100000 0001000000 0001100000 0001000000 0000111000 0001111100 0001000000 0001111110 0000110000 0000111100 0001000000 0001111111 0001100000 0001000000 0001000000 000...
result:
ok 100 tokens
Test #8:
score: 0
Accepted
time: 5ms
memory: 5128kb
input:
100 10 9 930392660078775 2806634959843587 930392660078775 905044994636391 985788965763349 912985101122684 987674992837788 921047708030944 933871032635272 924074917003015 906465081663363 976094961177209 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 1883664986961563 2834193280785472 958998107162380 924666...
output:
0000110000 0001000000 0000110000 0001110000 0001000000 0000111100 0001000000 0001000000 0001000000 0001000000 0001000000 0001100000 0001000000 0000111000 0001111000 0001000000 0001000000 0001111110 0001111110 0001000000 0001100000 0001110000 0001000000 0001110000 0000110000 0001110000 0001000000 000...
result:
ok 100 tokens
Test #9:
score: 0
Accepted
time: 1ms
memory: 5032kb
input:
100 10 9 999994984493978 2999942395429624 999994984493978 999939388770002 999967949978069 999931885129608 999990661850258 999984525481315 999963292059809 999975054238715 999981969673638 999985371517271 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 999995366940426 2999765738847089 999995366940426 9999556...
output:
0001100000 0000100000 0001000000 0000110000 0001111110 0000110000 0000111100 0001100000 0001111100 0000110000 0001100000 0000111110 0001100000 0001110000 0001111110 0000111000 0001110000 0001100000 0001100000 0000100000 0001110000 0001000000 0001000000 0001111110 0001111110 0000111110 0000100000 000...
result:
ok 100 tokens
Test #10:
score: 0
Accepted
time: 4ms
memory: 5180kb
input:
100 10 9 999999979118283 2999999819537067 999999979118283 999999975440440 999999958461371 999999979080922 999999991176682 999999985652594 999999984182267 999999928654853 999999990678448 999999900203766 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 999999951922360 2999999720940184 999999951922360 9999999...
output:
0000110000 0000111000 0001000000 0000100000 0001100000 0001100000 0001111000 0001110000 0001000000 0001000000 0000111000 0001110000 0001000000 0001111100 0001000000 0000110000 0000100000 0000110000 0001000000 0000110000 0001111111 0001111100 0001111100 0001000000 0001111100 0001110000 0000100000 000...
result:
ok 100 tokens
Test #11:
score: 0
Accepted
time: 1ms
memory: 5008kb
input:
100 10 9 999999999999480 2999999999998668 999999999999480 999999999999623 999999999999311 999999999999062 999999999999032 999999999999420 999999999999039 999999999999706 999999999999079 999999999999883 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 999999999999062 2999999999997761 999999999999062 9999999...
output:
0001110000 0000111110 0000111000 0000111100 0001110000 0000110000 0001100000 0001000000 0000111100 0000100000 0001111000 0001110000 0001111100 0001000000 0000111000 0000110000 0001000000 0001000000 0000110000 0000110000 0001110000 0001111110 0001000000 0001100000 0000111000 0001111100 0001000000 000...
result:
ok 100 tokens
Test #12:
score: 0
Accepted
time: 0ms
memory: 4912kb
input:
100 10 9 809217843509205176 1000000000000000000 819047520089857618 993247146028854493 979024090970900146 946916558454439857 809217843509205176 908857838415646655 809854521131167579 931917514552091282 890253286257158425 872828244740194237 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 810517126615250421 1...
output:
0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 000...
result:
ok 100 tokens
Test #13:
score: 0
Accepted
time: 0ms
memory: 5180kb
input:
100 10 9 990469099227929497 1000000000000000000 997087653799379867 998602320157374700 997500855340614575 998172426490578932 998173419961973183 997315871904813866 990469099227929497 991331794758268536 996329227071528815 994942302495919962 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 990138767121283623 1...
output:
0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 000...
result:
ok 100 tokens
Test #14:
score: 0
Accepted
time: 1ms
memory: 5032kb
input:
100 10 9 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 9 100000000...
output:
0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 0000000001 000...
result:
ok 100 tokens
Test #15:
score: -100
Wrong Answer
time: 4ms
memory: 5184kb
input:
1 1000 50 3 50 0 0 1 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 1 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 1 0 1 0 1 1 0 1 1 1 1 0 0 0 1...
output:
000000000000000000000000000000000000000000000000000
result:
wrong answer 1st words differ - expected: '000000000011111111111111111111111111111111111111111', found: '000000000000000000000000000000000000000000000000000'