#include <bits/stdc++.h>
using namespace std;
int main(){
int n, k, d, a;
cin >> n >> k;
vector<vector<int>> ady(n,vector<int>(n,0));
vector<vector<int>> last(n);
for(int i=0;i<n;i++){
last[i] = {i};
cin >> d;
for(int j=0;j<d;j++){
cin >> a;
ady[min(i,a)][max(i,a)] = 1;
}
}
int cur = 2;
bool optim = false;
while(cur<=k){
int s = last.size();
vector<vector<int>> nw;
for(int i=0;i<s;i++){
if(optim) break;
// last[i] --> completed graphs of cur-1 nodes
for(int x=0;x<n;x++){
if (optim) break;
bool found = true;
for(auto p:last[i]){
if(ady[min(x,p)][max(x,p)]==0){
found = false;
break;
}
}
if(found){
last[i].push_back(x);
nw.push_back(last[i]);
last[i].pop_back();
//for(int kk=0;kk<last[i].size();kk++) cout << last[i][kk] << " ";
//cout << x << endl;
if(cur==k) optim = true;
}
}
}
if(nw.size()==0) break;
else{
last = nw;
cur++;
}
}
cout << cur-1 << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
47 ms |
98736 KB |
Output is correct |
4 |
Correct |
41 ms |
98540 KB |
Output is correct |
5 |
Correct |
39 ms |
98652 KB |
Output is correct |
6 |
Correct |
39 ms |
98648 KB |
Output is correct |
7 |
Correct |
40 ms |
98640 KB |
Output is correct |
8 |
Correct |
180 ms |
98736 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
39 ms |
98648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
47 ms |
98736 KB |
Output is correct |
4 |
Correct |
41 ms |
98540 KB |
Output is correct |
5 |
Correct |
39 ms |
98652 KB |
Output is correct |
6 |
Correct |
39 ms |
98648 KB |
Output is correct |
7 |
Correct |
40 ms |
98640 KB |
Output is correct |
8 |
Correct |
180 ms |
98736 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
39 ms |
98648 KB |
Output is correct |
11 |
Correct |
39 ms |
98652 KB |
Output is correct |
12 |
Correct |
523 ms |
100212 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
602 ms |
99796 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
475 ms |
99744 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
452 ms |
99788 KB |
Output is correct |
19 |
Correct |
167 ms |
98640 KB |
Output is correct |
20 |
Correct |
218 ms |
99200 KB |
Output is correct |
21 |
Correct |
169 ms |
99104 KB |
Output is correct |
22 |
Correct |
168 ms |
98652 KB |
Output is correct |
23 |
Correct |
177 ms |
99980 KB |
Output is correct |
24 |
Correct |
169 ms |
98640 KB |
Output is correct |
25 |
Correct |
241 ms |
99980 KB |
Output is correct |
26 |
Correct |
479 ms |
99892 KB |
Output is correct |
27 |
Correct |
460 ms |
99844 KB |
Output is correct |
28 |
Correct |
468 ms |
99984 KB |
Output is correct |
29 |
Correct |
444 ms |
99824 KB |
Output is correct |
30 |
Correct |
576 ms |
100240 KB |
Output is correct |
31 |
Correct |
536 ms |
100236 KB |
Output is correct |
32 |
Correct |
545 ms |
100260 KB |
Output is correct |
33 |
Correct |
555 ms |
100240 KB |
Output is correct |
34 |
Correct |
528 ms |
100252 KB |
Output is correct |
35 |
Correct |
95 ms |
25684 KB |
Output is correct |
36 |
Correct |
95 ms |
25680 KB |
Output is correct |
37 |
Correct |
95 ms |
25840 KB |
Output is correct |
38 |
Correct |
25 ms |
7028 KB |
Output is correct |
39 |
Correct |
27 ms |
7052 KB |
Output is correct |
40 |
Correct |
181 ms |
100872 KB |
Output is correct |
41 |
Correct |
27 ms |
7140 KB |
Output is correct |
42 |
Correct |
195 ms |
100896 KB |
Output is correct |
43 |
Correct |
181 ms |
100872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
164 ms |
98736 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Runtime error |
248 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
47 ms |
98736 KB |
Output is correct |
4 |
Correct |
41 ms |
98540 KB |
Output is correct |
5 |
Correct |
39 ms |
98652 KB |
Output is correct |
6 |
Correct |
39 ms |
98648 KB |
Output is correct |
7 |
Correct |
40 ms |
98640 KB |
Output is correct |
8 |
Correct |
180 ms |
98736 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
39 ms |
98648 KB |
Output is correct |
11 |
Correct |
39 ms |
98652 KB |
Output is correct |
12 |
Correct |
523 ms |
100212 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
602 ms |
99796 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
475 ms |
99744 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
452 ms |
99788 KB |
Output is correct |
19 |
Correct |
167 ms |
98640 KB |
Output is correct |
20 |
Correct |
218 ms |
99200 KB |
Output is correct |
21 |
Correct |
169 ms |
99104 KB |
Output is correct |
22 |
Correct |
168 ms |
98652 KB |
Output is correct |
23 |
Correct |
177 ms |
99980 KB |
Output is correct |
24 |
Correct |
169 ms |
98640 KB |
Output is correct |
25 |
Correct |
241 ms |
99980 KB |
Output is correct |
26 |
Correct |
479 ms |
99892 KB |
Output is correct |
27 |
Correct |
460 ms |
99844 KB |
Output is correct |
28 |
Correct |
468 ms |
99984 KB |
Output is correct |
29 |
Correct |
444 ms |
99824 KB |
Output is correct |
30 |
Correct |
576 ms |
100240 KB |
Output is correct |
31 |
Correct |
536 ms |
100236 KB |
Output is correct |
32 |
Correct |
545 ms |
100260 KB |
Output is correct |
33 |
Correct |
555 ms |
100240 KB |
Output is correct |
34 |
Correct |
528 ms |
100252 KB |
Output is correct |
35 |
Correct |
95 ms |
25684 KB |
Output is correct |
36 |
Correct |
95 ms |
25680 KB |
Output is correct |
37 |
Correct |
95 ms |
25840 KB |
Output is correct |
38 |
Correct |
25 ms |
7028 KB |
Output is correct |
39 |
Correct |
27 ms |
7052 KB |
Output is correct |
40 |
Correct |
181 ms |
100872 KB |
Output is correct |
41 |
Correct |
27 ms |
7140 KB |
Output is correct |
42 |
Correct |
195 ms |
100896 KB |
Output is correct |
43 |
Correct |
181 ms |
100872 KB |
Output is correct |
44 |
Execution timed out |
3051 ms |
159416 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
47 ms |
98736 KB |
Output is correct |
4 |
Correct |
41 ms |
98540 KB |
Output is correct |
5 |
Correct |
39 ms |
98652 KB |
Output is correct |
6 |
Correct |
39 ms |
98648 KB |
Output is correct |
7 |
Correct |
40 ms |
98640 KB |
Output is correct |
8 |
Correct |
180 ms |
98736 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
39 ms |
98648 KB |
Output is correct |
11 |
Correct |
39 ms |
98652 KB |
Output is correct |
12 |
Correct |
523 ms |
100212 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
602 ms |
99796 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
475 ms |
99744 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
452 ms |
99788 KB |
Output is correct |
19 |
Correct |
167 ms |
98640 KB |
Output is correct |
20 |
Correct |
218 ms |
99200 KB |
Output is correct |
21 |
Correct |
169 ms |
99104 KB |
Output is correct |
22 |
Correct |
168 ms |
98652 KB |
Output is correct |
23 |
Correct |
177 ms |
99980 KB |
Output is correct |
24 |
Correct |
169 ms |
98640 KB |
Output is correct |
25 |
Correct |
241 ms |
99980 KB |
Output is correct |
26 |
Correct |
479 ms |
99892 KB |
Output is correct |
27 |
Correct |
460 ms |
99844 KB |
Output is correct |
28 |
Correct |
468 ms |
99984 KB |
Output is correct |
29 |
Correct |
444 ms |
99824 KB |
Output is correct |
30 |
Correct |
576 ms |
100240 KB |
Output is correct |
31 |
Correct |
536 ms |
100236 KB |
Output is correct |
32 |
Correct |
545 ms |
100260 KB |
Output is correct |
33 |
Correct |
555 ms |
100240 KB |
Output is correct |
34 |
Correct |
528 ms |
100252 KB |
Output is correct |
35 |
Correct |
95 ms |
25684 KB |
Output is correct |
36 |
Correct |
95 ms |
25680 KB |
Output is correct |
37 |
Correct |
95 ms |
25840 KB |
Output is correct |
38 |
Correct |
25 ms |
7028 KB |
Output is correct |
39 |
Correct |
27 ms |
7052 KB |
Output is correct |
40 |
Correct |
181 ms |
100872 KB |
Output is correct |
41 |
Correct |
27 ms |
7140 KB |
Output is correct |
42 |
Correct |
195 ms |
100896 KB |
Output is correct |
43 |
Correct |
181 ms |
100872 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Runtime error |
230 ms |
524288 KB |
Execution killed with signal 9 |
46 |
Halted |
0 ms |
0 KB |
- |