#include <bits/stdc++.h>
//#include "september.h"
using namespace std;
long long xorhash[6];
vector <set <int> > ShitPar;
set <int> TSet;
long long 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<5;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<5;i++){
xorhash[i]=123456789;
ShitPar.push_back(TSet);
}
int check1,check2;
for(int i=n-2;i>=0;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++;
}
}
return ans;
}
/*
int main(){
for(int i=1;i<=10;i++){
cout<<solve(5, 2, {-1, 0, 0, 1, 1}, {{1, 2, 3, 4}, {4, 1, 2, 3}});
//cout<<solve(7, 2, {-1,0,1,2,3,4,5}, {{1,2,3,4,5,6},{2,1,4,3,6,5}});
cout<<"\n";
}
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |