#include "beechtree.h"
#include<bits/stdc++.h>
using namespace std;
#define REP(a,b,c) for(int a=b;a<c;a++)
#define PB push_back
#define F first
#define S second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
std::vector<int> beechtree(int n, int m, std::vector<int> p, std::vector<int> c)
{
if(n<=8){
vi ans(n,0);
vii a(n);
REP(i,0,n)a[i].PB(i);
for(int i=n-1;i>=1;i--)for(auto u:a[i])a[p[i]].PB(u);
REP(i,0,n)a[i].erase(a[i].begin());
vii b=a;
REP(i,0,n){
int s=a[i].size();
if(s==0){
ans[i]=1;
continue;
}
map<int,int> mp;
bool flag=1;
REP(j,0,s){
if(mp[c[b[i][j]]]!=p[b[i][j]]){
flag=0;
break;
}
mp[c[b[i][j]]]++;
}
if(flag){
ans[i]=1;
continue;
}
next_permutation(b[i].begin(),b[i].end());
while(b[i]!=a[i]){
mp.clear();
flag=1;
REP(j,0,s){
if(mp[c[b[i][j]]]!=p[b[i][j]]){
flag=0;
break;
}
mp[c[b[i][j]]]++;
}
if(flag)break;
next_permutation(b[i].begin(),b[i].end());
}
if(flag)ans[i]=1;
}
return ans;
}
return {};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
2nd lines differ - expected: 18 tokens, found 0 tokens |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
2nd lines differ - expected: 115 tokens, found 0 tokens |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
2nd lines differ - expected: 18 tokens, found 0 tokens |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
2nd lines differ - expected: 18 tokens, found 0 tokens |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
2nd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
604 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
2nd lines differ - expected: 18 tokens, found 0 tokens |
3 |
Halted |
0 ms |
0 KB |
- |