Submission #472296

#TimeUsernameProblemLanguageResultExecution timeMemory
472296morasha3Political Development (BOI17_politicaldevelopment)C++17
4 / 100
3084 ms277008 KiB
#include<bits/stdc++.h> typedef long long ll; const ll mod = (ll) 1e9 + 7; const ll mx = (ll) 1e5 +7; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,k,ans=0; cin>>n>>k; vector<vector<ll>>v(n); map<pair<ll,ll>,ll>m; bool r=0; for(int i=0; i<n; i++) { ll a; cin>>a; for(int j=0; j<a; j++) { ll b; cin>>b; v[i].push_back(b); m[ {i,b}]=1; m[ {b,i}]=1; ans=2; r=1; } } for(int i=0; i<n; i++) { vector<ll>e; for(int j=0; j<v[i].size(); j++) { ll cnt=1; bool f=1; for(int h=0; h<e.size(); h++) { if(m[ {v[i][j],e[h]}]==1||m[ {e[h],v[i][j]}]==1) { if(f) { cnt++; f=0; } cnt++; if(cnt>=k)break; } } e.push_back(v[i][j]); ans=max(ans,cnt); if(cnt>=k)break; } if(ans>=k)break; } if(ans>k)ans=k; if(k==1)ans=1; if(k==2&&r==1)ans=2; else if(r==0&&k==2)ans=1; if(ans==0)ans=1; cout<<ans; }

Compilation message (stderr)

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j=0; j<v[i].size(); j++)
      |                      ~^~~~~~~~~~~~
politicaldevelopment.cpp:37:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(int h=0; h<e.size(); h++)
      |                          ~^~~~~~~~~
#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...