제출 #397171

#제출 시각아이디문제언어결과실행 시간메모리
397171keta_tsimakuridzeBosses (BOI16_bosses)C++14
67 / 100
1584 ms10120 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; const int N=2e5+5,mod=1e9+7,Inf=1e16; int t,n,fix[N]; long long sum; queue<int> q; vector<int>V_[N],V[N]; string s; long long dfs(int u){ long long c = 0; for(int i=0;i<V_[u].size();i++){ c+=dfs(V_[u][i]); } sum+=c+1; return c+1; } main(){ // t=1; ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin >> n; for(int i=1;i<=n;i++){ int c,a; cin >> c; while(c--){ cin>>a; V[a].push_back(i); } } long long ans = Inf; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ V_[j].clear(); fix[j] = 0; } q.push(i); fix[i]=1; int cnt = 0; while(q.size()) { int u=q.front(); q.pop(); cnt++; for(int j=0;j<V[u].size();j++){ if(!fix[V[u][j]]) { fix[V[u][j]] = 1; V_[u].push_back(V[u][j]); q.push(V[u][j]); } } } sum = 0; dfs(i); if(cnt==n) ans=min(ans,sum); } cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp:5:33: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
    5 | const int N=2e5+5,mod=1e9+7,Inf=1e16;
      |                                 ^~~~
bosses.cpp: In function 'long long int dfs(int)':
bosses.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<V_[u].size();i++){
      |              ~^~~~~~~~~~~~~
bosses.cpp: At global scope:
bosses.cpp:19:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 |  main(){
      |       ^
bosses.cpp: In function 'int main()':
bosses.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |    for(int j=0;j<V[u].size();j++){
      |                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...