Submission #924444

#TimeUsernameProblemLanguageResultExecution timeMemory
924444Muhammad_AneeqPolitical Development (BOI17_politicaldevelopment)C++17
39 / 100
3053 ms6228 KiB
/* بسم الله الرحمن الرحيم 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 (stderr)

politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:19:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (f.size()==k)
      |         ~~~~~~~~^~~
politicaldevelopment.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if (res[i]!=f.size()-1)
      |             ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...