이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "september.h"
using namespace std;
int xorhash[10];
vector <set <int> > ShitPar;
set <int> TSet;
int RemChild[10][500003];
int solve(int n, int m, vector<int> Par, vector <vector<int> > Record){
int ans;
ans=0;
for(int i=0;i<n;i++){
for(int k=0;k<m;k++){
RemChild[k][i]=0;
}
}
for(int i=0;i<n-1;i++){
for(int k=0;k<m;k++){
RemChild[k][Par[Record[k][i]]]++;
}
}
ShitPar.clear();
TSet.clear();
for(int i=0;i<m;i++){
xorhash[i]=123456789;
ShitPar.push_back(TSet);
}
for(int k=0;k<m;k++){
for(int i=0;i<n;i++){
// cout<<RemChild[k][i]<<" ";
}
// cout<<"\n";
}
int check1,check2;
ans=0;
for(int i=0;i<n-1;i++){
for(int k=0;k<m;k++){
xorhash[k]^=Record[k][i];
RemChild[k][Par[Record[k][i]]]--;
if(!RemChild[k][Par[Record[k][i]]]){
ShitPar[k].erase(Par[Record[k][i]]);
}
if(RemChild[k][Record[k][i]]){
ShitPar[k].insert(Record[k][i]);
}
}
xorhash[m]=xorhash[m-1];
check1=0;
check2=0;
for(int k=0;k<m;k++){
check1|=(!ShitPar[k].empty());
check2|=(xorhash[k]!=xorhash[k+1]);
//cout<<check1<<" "<<check2<<"\n";
}
if(!check1&&!check2){
ans++;
}
}
Record.clear();
Par.clear();
return ans;
}
/*
int main(){
for(int i=1;i<=5;i++){
cout<<solve(7, 1, {-1, 0, 0, 2, 3,3,5}, {{1,6,4,3,5,2}});
//cout<<solve(7, 2, {-1,0,1,2,3,4,5}, {{1,2,3,4,5,6},{1,2,6,5,4,3}});
//cout<<solve(3, 5, {-1, 0, 0}, {{1, 2},{1,2},{1,2},{1,2},{1,2}});
//cout<<solve(5, 2, {-1, 0, 0, 1, 1}, {{1, 2, 3, 4}, {2,1,3,4}});
//cout<<solve(7, 1, {-1,0,1,2,3,4,5}, {{2,4,3,5,1,6}});
cout<<"\n";
}
}
*/
/*
4
7 1
0 0 2 3 3 5
1 6 4 3 5 2
10 1
0 1 2 0 3 0 5 4 8
9 7 6 8 4 5 3 2 1
7 1
0 0 0 1 3 0
2 4 1 6 5 3
6 1
0 0 1 1 3
4 5 2 3 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |