# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924447 | 2024-02-09T04:04:26 Z | Muhammad_Aneeq | Political Development (BOI17_politicaldevelopment) | C++17 | 304 ms | 2072 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]++; if (f.size()==k) { ans=max(ans,k); for (auto j:nei[n]) res[j]--; f.pop_back(); vis[n]=0; return ; } 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
# | 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 | 2 ms | 1880 KB | Output is correct |
4 | Correct | 25 ms | 2072 KB | Output is correct |
5 | Correct | 25 ms | 1884 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 3 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 | 1880 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 | 2 ms | 1880 KB | Output is correct |
4 | Correct | 25 ms | 2072 KB | Output is correct |
5 | Correct | 25 ms | 1884 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 3 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 | 1880 KB | Output is correct |
11 | Correct | 32 ms | 2072 KB | Output is correct |
12 | Incorrect | 304 ms | 2052 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 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 | Incorrect | 1 ms | 1628 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 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 | 2 ms | 1880 KB | Output is correct |
4 | Correct | 25 ms | 2072 KB | Output is correct |
5 | Correct | 25 ms | 1884 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 3 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 | 1880 KB | Output is correct |
11 | Correct | 32 ms | 2072 KB | Output is correct |
12 | Incorrect | 304 ms | 2052 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 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 | 2 ms | 1880 KB | Output is correct |
4 | Correct | 25 ms | 2072 KB | Output is correct |
5 | Correct | 25 ms | 1884 KB | Output is correct |
6 | Correct | 3 ms | 1884 KB | Output is correct |
7 | Correct | 3 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 | 1880 KB | Output is correct |
11 | Correct | 32 ms | 2072 KB | Output is correct |
12 | Incorrect | 304 ms | 2052 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |