# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
924444 | 2024-02-09T04:02:28 Z | Muhammad_Aneeq | Political Development (BOI17_politicaldevelopment) | C++17 | 3000 ms | 6228 KB |
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #include <iostream> #include <vector> #include <set> using namespace std; int const N=6e4+10; vector<int>nei[N]={}; int res[N]={}; bool vis[N]={}; vector<int>f; int n,k,ans=0;; void dfs(int n) { if (f.size()==k) return; vis[n]=1; f.push_back(n); for (auto j:nei[n]) res[j]++; for (auto i:f) { if (res[i]!=f.size()-1) { for (auto j:nei[n]) res[j]--; f.pop_back(); vis[n]=0; return; } } for (auto j:nei[n]) { if (!vis[j]) dfs(j); } ans=max(ans,int(f.size())); for (auto j:nei[n]) res[j]--; f.pop_back(); vis[n]=0; } inline void solve() { cin>>n>>k; for (int i=0;i<n;i++) { int d; cin>>d; while (d--) { int x; cin>>x; if (i!=x) nei[i].push_back(x); } } for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++) vis[i]=0; dfs(i); } cout<<min(ans,k)<<endl; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 3 ms | 1928 KB | Output is correct |
4 | Correct | 105 ms | 2052 KB | Output is correct |
5 | Correct | 101 ms | 1880 KB | Output is correct |
6 | Correct | 5 ms | 1880 KB | Output is correct |
7 | Correct | 5 ms | 2040 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 3 ms | 1928 KB | Output is correct |
4 | Correct | 105 ms | 2052 KB | Output is correct |
5 | Correct | 101 ms | 1880 KB | Output is correct |
6 | Correct | 5 ms | 1880 KB | Output is correct |
7 | Correct | 5 ms | 2040 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 101 ms | 2080 KB | Output is correct |
12 | Correct | 293 ms | 2060 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 282 ms | 2056 KB | Output is correct |
15 | Correct | 1 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1884 KB | Output is correct |
17 | Correct | 1 ms | 1628 KB | Output is correct |
18 | Correct | 7 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1880 KB | Output is correct |
20 | Correct | 2 ms | 1884 KB | Output is correct |
21 | Correct | 2 ms | 1884 KB | Output is correct |
22 | Correct | 1 ms | 1884 KB | Output is correct |
23 | Correct | 4 ms | 1884 KB | Output is correct |
24 | Correct | 1 ms | 1884 KB | Output is correct |
25 | Correct | 5 ms | 1884 KB | Output is correct |
26 | Correct | 4 ms | 1880 KB | Output is correct |
27 | Correct | 2 ms | 1884 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1844 KB | Output is correct |
30 | Correct | 97 ms | 2052 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 91 ms | 2044 KB | Output is correct |
33 | Correct | 3 ms | 1884 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
35 | Correct | 2 ms | 1884 KB | Output is correct |
36 | Correct | 3 ms | 2140 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 3 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 1884 KB | Output is correct |
40 | Correct | 7 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 8 ms | 2088 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1628 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1628 KB | Output is correct |
5 | Correct | 1 ms | 1624 KB | Output is correct |
6 | Correct | 1 ms | 1844 KB | Output is correct |
7 | Correct | 1 ms | 1628 KB | Output is correct |
8 | Correct | 1 ms | 1712 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 2 ms | 1628 KB | Output is correct |
11 | Correct | 228 ms | 6012 KB | Output is correct |
12 | Correct | 1 ms | 1624 KB | Output is correct |
13 | Correct | 260 ms | 5932 KB | Output is correct |
14 | Correct | 1 ms | 1624 KB | Output is correct |
15 | Correct | 209 ms | 6008 KB | Output is correct |
16 | Correct | 220 ms | 5968 KB | Output is correct |
17 | Correct | 284 ms | 6228 KB | Output is correct |
18 | Correct | 216 ms | 5968 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 3 ms | 1928 KB | Output is correct |
4 | Correct | 105 ms | 2052 KB | Output is correct |
5 | Correct | 101 ms | 1880 KB | Output is correct |
6 | Correct | 5 ms | 1880 KB | Output is correct |
7 | Correct | 5 ms | 2040 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 101 ms | 2080 KB | Output is correct |
12 | Correct | 293 ms | 2060 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 282 ms | 2056 KB | Output is correct |
15 | Correct | 1 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1884 KB | Output is correct |
17 | Correct | 1 ms | 1628 KB | Output is correct |
18 | Correct | 7 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1880 KB | Output is correct |
20 | Correct | 2 ms | 1884 KB | Output is correct |
21 | Correct | 2 ms | 1884 KB | Output is correct |
22 | Correct | 1 ms | 1884 KB | Output is correct |
23 | Correct | 4 ms | 1884 KB | Output is correct |
24 | Correct | 1 ms | 1884 KB | Output is correct |
25 | Correct | 5 ms | 1884 KB | Output is correct |
26 | Correct | 4 ms | 1880 KB | Output is correct |
27 | Correct | 2 ms | 1884 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1844 KB | Output is correct |
30 | Correct | 97 ms | 2052 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 91 ms | 2044 KB | Output is correct |
33 | Correct | 3 ms | 1884 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
35 | Correct | 2 ms | 1884 KB | Output is correct |
36 | Correct | 3 ms | 2140 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 3 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 1884 KB | Output is correct |
40 | Correct | 7 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 8 ms | 2088 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
44 | Execution timed out | 3049 ms | 1884 KB | Time limit exceeded |
45 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1880 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 3 ms | 1928 KB | Output is correct |
4 | Correct | 105 ms | 2052 KB | Output is correct |
5 | Correct | 101 ms | 1880 KB | Output is correct |
6 | Correct | 5 ms | 1880 KB | Output is correct |
7 | Correct | 5 ms | 2040 KB | Output is correct |
8 | Correct | 1 ms | 1628 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 101 ms | 2080 KB | Output is correct |
12 | Correct | 293 ms | 2060 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 282 ms | 2056 KB | Output is correct |
15 | Correct | 1 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1884 KB | Output is correct |
17 | Correct | 1 ms | 1628 KB | Output is correct |
18 | Correct | 7 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1880 KB | Output is correct |
20 | Correct | 2 ms | 1884 KB | Output is correct |
21 | Correct | 2 ms | 1884 KB | Output is correct |
22 | Correct | 1 ms | 1884 KB | Output is correct |
23 | Correct | 4 ms | 1884 KB | Output is correct |
24 | Correct | 1 ms | 1884 KB | Output is correct |
25 | Correct | 5 ms | 1884 KB | Output is correct |
26 | Correct | 4 ms | 1880 KB | Output is correct |
27 | Correct | 2 ms | 1884 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1844 KB | Output is correct |
30 | Correct | 97 ms | 2052 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 91 ms | 2044 KB | Output is correct |
33 | Correct | 3 ms | 1884 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
35 | Correct | 2 ms | 1884 KB | Output is correct |
36 | Correct | 3 ms | 2140 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 3 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 1884 KB | Output is correct |
40 | Correct | 7 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 8 ms | 2088 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
44 | Correct | 1 ms | 1628 KB | Output is correct |
45 | Correct | 162 ms | 4436 KB | Output is correct |
46 | Execution timed out | 3053 ms | 3676 KB | Time limit exceeded |
47 | Halted | 0 ms | 0 KB | - |