QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#163266 | #7121. Beech Tree | bulijiojiodibuliduo# | 9 | 57ms | 33984kb | C++17 | 2.4kb | 2023-09-03 23:08:18 | 2024-04-28 06:58:28 |
Judging History
answer
#include "beechtree.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
std::vector<int> beechtree(int n, int M, std::vector<int> P, std::vector<int> C)
{
vector<vector<PII>> son(n);
vector<VI> tson(n);
vector<vector<VI>> ps(n);
vector<int> val(n,1);
VI sz(n);
for (int i=1;i<n;i++) {
son[P[i]].pb(mp(i,C[i]));
}
//puts("???");
function<void(int)> dfs=[&](int u) {
ps[u].pb(VI{});
tson[u].pb(u);
sz[u]=1;
VI cc;
for (auto [v,c]:son[u]) {
dfs(v);
tson[u].pb(v);
sz[u]+=sz[v];
//for (auto w:tson[v]) tson[u].pb(w);
cc.pb(c);
if (!val[v]) val[u]=0;
for (auto x:ps[v]) {
auto y=x; y.insert(y.begin(),c);
ps[u].pb(y);
}
}
//printf("?? %d %d\n",u,SZ(tson[u]));
sort(all(cc));
rep(i,0,SZ(cc)-1) if (cc[i]==cc[i+1]) val[u]=0;
auto cmp=[&](vector<VI> &a,vector<VI> &b) {
sort(all(a)); sort(all(b));
for (auto x:b) {
auto it=lower_bound(all(a),x);
//for (auto y:x) printf("%d ",y); puts("----");
if (it==a.end()||*it!=x) return false;
}
//puts("!!!");
return true;
};
if (val[u]) {
sort(all(tson[u]),[&](int &a,int b) {
return SZ(tson[a])>SZ(tson[b]);
});
rep(i,0,SZ(tson[u])-1) {
if (!cmp(ps[tson[u][i]],ps[tson[u][i+1]])) {
val[u]=0;
break;
}
}
}
};
dfs(0);
return val;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 9
Accepted
Test #1:
score: 9
Accepted
time: 0ms
memory: 3744kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 8 500 -1 0 1 2 3 4 5 6 0 281 281 281 281 281 281 281
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 1 1 1 1 1 1 1 1
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 8 500 -1 0 1 2 3 4 5 6 0 11 169 169 169 169 169 169
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1 1
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 4048kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 8 500 -1 0 1 2 3 4 5 6 0 324 324 492 324 324 324 324
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 0 0 1 1 1 1 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 8 500 -1 0 1 2 3 4 5 6 0 216 220 387 371 53 34 188
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 0 0 0 0 0 1 1
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 7 500 -1 0 0 0 1 1 2 0 357 147 147 20 147 20
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 4 500 -1 0 0 0 0 267 210 278
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 1 1 1 1
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 7 500 -1 0 0 0 1 2 3 0 250 140 214 250 250 140
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 8 500 -1 0 0 0 1 1 3 3 0 40 205 455 455 36 36 455
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1 1
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 7 500 -1 0 0 1 1 1 2 0 181 33 33 181 201 33
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 5 500 -1 0 0 1 2 0 162 281 162 162
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 1 1 1 1 1
result:
ok
Subtask #2:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 200000 200000 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86...
output:
result:
Subtask #3:
score: 0
Wrong Answer
Test #25:
score: 9
Accepted
time: 57ms
memory: 33984kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 103965 200000 -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 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 ...
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok
Test #26:
score: 0
Accepted
time: 55ms
memory: 32156kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 97675 200000 -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 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 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ory: 33512kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 102084 200000 -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 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 ...
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer 2nd lines differ - on the 1st token, expected: '1', found: '0'
Subtask #4:
score: 0
Time Limit Exceeded
Test #48:
score: 0
Time Limit Exceeded
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 199979 200000 -1 0 1 1 1 1 1 1 1 1 1 1 11 11 1 11 11 11 11 11 11 11 0 22 23 23 23 23 23 23 23 23 23 23 33 22 35 36 36 36 36 36 36 36 36 38 38 38 35 48 49 49 49 49 49 49 49 53 53 48 59 60 60 60 60 60 59 66 67 67 67 67 67 67 67 67 67 67 73 71 66 80 81 81 81 81 81 81 81...
output:
result:
Subtask #5:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #54:
score: 14
Accepted
time: 1ms
memory: 3940kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 200 500 -1 0 0 1 1 2 3 4 5 6 2 7 0 8 9 10 11 12 13 14 1 15 3 16 17 2 18 19 20 4 5 21 22 23 24 25 26 27 28 29 6 30 31 3 32 33 34 35 36 37 7 8 9 38 10 39 11 40 41 12 13 14 4 42 43 44 45 46 5 47 6 48 15 49 50 51 16 52 53 7 54 17 55 56 57 8 9 18 58 59 60 61 19 62 63 64 2...
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok
Test #55:
score: -14
Wrong Answer
time: 1ms
memory: 4180kb
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 195 500 -1 0 1 2 3 0 5 5 6 6 7 7 5 8 6 8 9 10 11 9 12 13 14 15 16 10 11 12 17 18 19 20 21 22 13 23 24 14 25 26 15 27 28 1 43 43 44 45 46 47 48 44 49 45 46 50 43 44 47 51 52 53 54 45 55 56 48 49 57 58 59 60 61 62 63 64 46 65 66 50 67 2 81 82 81 81 82 83 84 83 84 85 86...
output:
p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH OK 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 1 1 1 0 ...
result:
wrong answer 2nd lines differ - on the 82nd token, expected: '0', found: '1'
Subtask #6:
score: 0
Time Limit Exceeded
Test #65:
score: 0
Time Limit Exceeded
input:
j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi 2000 2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 ...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #6:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%