# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924448 | 2024-02-09T04:06:42 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; } } if (f.size()==k) { ans=max(ans,k); 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1624 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 2 ms | 1884 KB | Output is correct |
4 | Correct | 29 ms | 2072 KB | Output is correct |
5 | Correct | 29 ms | 2076 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 2 ms | 1884 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 | 1624 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1624 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 2 ms | 1884 KB | Output is correct |
4 | Correct | 29 ms | 2072 KB | Output is correct |
5 | Correct | 29 ms | 2076 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 2 ms | 1884 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 | 1624 KB | Output is correct |
11 | Correct | 29 ms | 1880 KB | Output is correct |
12 | Correct | 256 ms | 2052 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 272 ms | 2072 KB | Output is correct |
15 | Correct | 2 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1880 KB | Output is correct |
17 | Correct | 1 ms | 1624 KB | Output is correct |
18 | Correct | 6 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1628 KB | Output is correct |
20 | Correct | 3 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 | 1628 KB | Output is correct |
25 | Correct | 4 ms | 1884 KB | Output is correct |
26 | Correct | 3 ms | 1892 KB | Output is correct |
27 | Correct | 2 ms | 1880 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1884 KB | Output is correct |
30 | Correct | 87 ms | 1880 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 86 ms | 1884 KB | Output is correct |
33 | Correct | 4 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 | 2 ms | 1884 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 2 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 2136 KB | Output is correct |
40 | Correct | 6 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 6 ms | 1884 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 1628 KB | Output is correct |
6 | Correct | 1 ms | 1628 KB | Output is correct |
7 | Correct | 1 ms | 1628 KB | Output is correct |
8 | Correct | 1 ms | 1624 KB | Output is correct |
9 | Correct | 1 ms | 1628 KB | Output is correct |
10 | Correct | 1 ms | 1628 KB | Output is correct |
11 | Correct | 212 ms | 6228 KB | Output is correct |
12 | Correct | 1 ms | 1624 KB | Output is correct |
13 | Correct | 255 ms | 6008 KB | Output is correct |
14 | Correct | 2 ms | 1624 KB | Output is correct |
15 | Correct | 219 ms | 6004 KB | Output is correct |
16 | Correct | 206 ms | 6008 KB | Output is correct |
17 | Correct | 256 ms | 5980 KB | Output is correct |
18 | Correct | 219 ms | 5968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1624 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 2 ms | 1884 KB | Output is correct |
4 | Correct | 29 ms | 2072 KB | Output is correct |
5 | Correct | 29 ms | 2076 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 2 ms | 1884 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 | 1624 KB | Output is correct |
11 | Correct | 29 ms | 1880 KB | Output is correct |
12 | Correct | 256 ms | 2052 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 272 ms | 2072 KB | Output is correct |
15 | Correct | 2 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1880 KB | Output is correct |
17 | Correct | 1 ms | 1624 KB | Output is correct |
18 | Correct | 6 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1628 KB | Output is correct |
20 | Correct | 3 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 | 1628 KB | Output is correct |
25 | Correct | 4 ms | 1884 KB | Output is correct |
26 | Correct | 3 ms | 1892 KB | Output is correct |
27 | Correct | 2 ms | 1880 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1884 KB | Output is correct |
30 | Correct | 87 ms | 1880 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 86 ms | 1884 KB | Output is correct |
33 | Correct | 4 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 | 2 ms | 1884 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 2 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 2136 KB | Output is correct |
40 | Correct | 6 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 6 ms | 1884 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
44 | Execution timed out | 3032 ms | 1884 KB | Time limit exceeded |
45 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1624 KB | Output is correct |
2 | Correct | 1 ms | 1628 KB | Output is correct |
3 | Correct | 2 ms | 1884 KB | Output is correct |
4 | Correct | 29 ms | 2072 KB | Output is correct |
5 | Correct | 29 ms | 2076 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 2 ms | 1884 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 | 1624 KB | Output is correct |
11 | Correct | 29 ms | 1880 KB | Output is correct |
12 | Correct | 256 ms | 2052 KB | Output is correct |
13 | Correct | 1 ms | 1628 KB | Output is correct |
14 | Correct | 272 ms | 2072 KB | Output is correct |
15 | Correct | 2 ms | 1628 KB | Output is correct |
16 | Correct | 7 ms | 1880 KB | Output is correct |
17 | Correct | 1 ms | 1624 KB | Output is correct |
18 | Correct | 6 ms | 1884 KB | Output is correct |
19 | Correct | 1 ms | 1628 KB | Output is correct |
20 | Correct | 3 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 | 1628 KB | Output is correct |
25 | Correct | 4 ms | 1884 KB | Output is correct |
26 | Correct | 3 ms | 1892 KB | Output is correct |
27 | Correct | 2 ms | 1880 KB | Output is correct |
28 | Correct | 3 ms | 1884 KB | Output is correct |
29 | Correct | 2 ms | 1884 KB | Output is correct |
30 | Correct | 87 ms | 1880 KB | Output is correct |
31 | Correct | 4 ms | 1880 KB | Output is correct |
32 | Correct | 86 ms | 1884 KB | Output is correct |
33 | Correct | 4 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 | 2 ms | 1884 KB | Output is correct |
37 | Correct | 2 ms | 1884 KB | Output is correct |
38 | Correct | 2 ms | 1884 KB | Output is correct |
39 | Correct | 3 ms | 2136 KB | Output is correct |
40 | Correct | 6 ms | 1884 KB | Output is correct |
41 | Correct | 3 ms | 1884 KB | Output is correct |
42 | Correct | 6 ms | 1884 KB | Output is correct |
43 | Correct | 7 ms | 1884 KB | Output is correct |
44 | Correct | 1 ms | 1628 KB | Output is correct |
45 | Correct | 138 ms | 4444 KB | Output is correct |
46 | Execution timed out | 3023 ms | 3672 KB | Time limit exceeded |
47 | Halted | 0 ms | 0 KB | - |