#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
bool isvalid(vector<int>tre,vector<int>del){
int vis[tre.size()+5]={};
int canottake[tre.size()+5]={};
for(auto i:del) canottake[i]=1;
vector<ll>v[tre.size()+5];
for(int i=0;i<tre.size();i++){
if(tre[i]==-1) continue;
v[tre[i]].push_back(i);
}
queue<ll>proces;
proces.push(0);
while(proces.size()){
int num=proces.front();
proces.pop();
if(canottake[num]||vis[num]) continue;
vis[num]=1;
for(auto i:v[num]){
proces.push(i);
}
}
for(int i=0;i<tre.size();i++){
if(vis[i]==0&&canottake[i]==0) return 0;
}
return 1;
}
int solve(int N,int M,vector<int>F,vector<vector<int>>S){
ll ans=0;
map<ll,ll>mp[M+5];
vector<int>curr[M+5];
for(int i=0;i<N-1;i++){
int isgood=1;
for(int j=0;j<M;j++){
curr[j].push_back(S[j][i]);
mp[j][S[j][i]]=1;
if(!isvalid(F,curr[j])||mp[j]!=mp[0]) isgood=0;
}
ans+=isgood;
}
return ans;
}
Compilation message
september.cpp: In function 'bool isvalid(std::vector<int>, std::vector<int>)':
september.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | for(int i=0;i<tre.size();i++){
| ~^~~~~~~~~~~
september.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i=0;i<tre.size();i++){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
464 KB |
Output is correct |
2 |
Correct |
46 ms |
612 KB |
Output is correct |
3 |
Correct |
46 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
46 ms |
464 KB |
Output is correct |
9 |
Correct |
46 ms |
612 KB |
Output is correct |
10 |
Correct |
46 ms |
616 KB |
Output is correct |
11 |
Correct |
47 ms |
604 KB |
Output is correct |
12 |
Correct |
58 ms |
612 KB |
Output is correct |
13 |
Correct |
53 ms |
600 KB |
Output is correct |
14 |
Correct |
49 ms |
632 KB |
Output is correct |
15 |
Correct |
45 ms |
604 KB |
Output is correct |
16 |
Correct |
41 ms |
600 KB |
Output is correct |
17 |
Correct |
50 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
464 KB |
Output is correct |
2 |
Correct |
46 ms |
612 KB |
Output is correct |
3 |
Correct |
46 ms |
616 KB |
Output is correct |
4 |
Correct |
238 ms |
852 KB |
Output is correct |
5 |
Correct |
235 ms |
848 KB |
Output is correct |
6 |
Correct |
233 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
46 ms |
464 KB |
Output is correct |
16 |
Correct |
46 ms |
612 KB |
Output is correct |
17 |
Correct |
46 ms |
616 KB |
Output is correct |
18 |
Correct |
47 ms |
604 KB |
Output is correct |
19 |
Correct |
58 ms |
612 KB |
Output is correct |
20 |
Correct |
53 ms |
600 KB |
Output is correct |
21 |
Correct |
49 ms |
632 KB |
Output is correct |
22 |
Correct |
45 ms |
604 KB |
Output is correct |
23 |
Correct |
41 ms |
600 KB |
Output is correct |
24 |
Correct |
50 ms |
604 KB |
Output is correct |
25 |
Correct |
238 ms |
852 KB |
Output is correct |
26 |
Correct |
235 ms |
848 KB |
Output is correct |
27 |
Correct |
233 ms |
848 KB |
Output is correct |
28 |
Correct |
201 ms |
928 KB |
Output is correct |
29 |
Correct |
197 ms |
852 KB |
Output is correct |
30 |
Correct |
235 ms |
1104 KB |
Output is correct |
31 |
Correct |
229 ms |
900 KB |
Output is correct |
32 |
Correct |
213 ms |
1116 KB |
Output is correct |
33 |
Correct |
198 ms |
720 KB |
Output is correct |
34 |
Correct |
246 ms |
868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
464 KB |
Output is correct |
2 |
Correct |
46 ms |
612 KB |
Output is correct |
3 |
Correct |
46 ms |
616 KB |
Output is correct |
4 |
Execution timed out |
1057 ms |
1108 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
46 ms |
464 KB |
Output is correct |
9 |
Correct |
46 ms |
612 KB |
Output is correct |
10 |
Correct |
46 ms |
616 KB |
Output is correct |
11 |
Correct |
47 ms |
604 KB |
Output is correct |
12 |
Correct |
58 ms |
612 KB |
Output is correct |
13 |
Correct |
53 ms |
600 KB |
Output is correct |
14 |
Correct |
49 ms |
632 KB |
Output is correct |
15 |
Correct |
45 ms |
604 KB |
Output is correct |
16 |
Correct |
41 ms |
600 KB |
Output is correct |
17 |
Correct |
50 ms |
604 KB |
Output is correct |
18 |
Execution timed out |
1057 ms |
1108 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
464 KB |
Output is correct |
2 |
Correct |
46 ms |
612 KB |
Output is correct |
3 |
Correct |
46 ms |
616 KB |
Output is correct |
4 |
Correct |
238 ms |
852 KB |
Output is correct |
5 |
Correct |
235 ms |
848 KB |
Output is correct |
6 |
Correct |
233 ms |
848 KB |
Output is correct |
7 |
Execution timed out |
1057 ms |
1108 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
600 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
46 ms |
464 KB |
Output is correct |
16 |
Correct |
46 ms |
612 KB |
Output is correct |
17 |
Correct |
46 ms |
616 KB |
Output is correct |
18 |
Correct |
47 ms |
604 KB |
Output is correct |
19 |
Correct |
58 ms |
612 KB |
Output is correct |
20 |
Correct |
53 ms |
600 KB |
Output is correct |
21 |
Correct |
49 ms |
632 KB |
Output is correct |
22 |
Correct |
45 ms |
604 KB |
Output is correct |
23 |
Correct |
41 ms |
600 KB |
Output is correct |
24 |
Correct |
50 ms |
604 KB |
Output is correct |
25 |
Correct |
238 ms |
852 KB |
Output is correct |
26 |
Correct |
235 ms |
848 KB |
Output is correct |
27 |
Correct |
233 ms |
848 KB |
Output is correct |
28 |
Correct |
201 ms |
928 KB |
Output is correct |
29 |
Correct |
197 ms |
852 KB |
Output is correct |
30 |
Correct |
235 ms |
1104 KB |
Output is correct |
31 |
Correct |
229 ms |
900 KB |
Output is correct |
32 |
Correct |
213 ms |
1116 KB |
Output is correct |
33 |
Correct |
198 ms |
720 KB |
Output is correct |
34 |
Correct |
246 ms |
868 KB |
Output is correct |
35 |
Execution timed out |
1057 ms |
1108 KB |
Time limit exceeded |
36 |
Halted |
0 ms |
0 KB |
- |