제출 #397179

#제출 시각아이디문제언어결과실행 시간메모리
397179keta_tsimakuridzeBosses (BOI16_bosses)C++14
100 / 100
840 ms672 KiB
#include<bits/stdc++.h> #define f first #define s second using namespace std; const int N=5005,mod=1e9+7,Inf=1e16; int t,n,fix[N],h[N]; long long sum; queue<int> q; vector<int>V[N]; string s; 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++){ fix[j] = 0; } q.push(i); fix[i]=1; h[i] = 1; int cnt = 0; sum = 0; while(q.size()) { int u=q.front(); q.pop(); cnt++; sum+=h[u]; for(int j=0;j<V[u].size();j++){ if(!fix[V[u][j]]) { fix[V[u][j]] = 1; h[V[u][j]] = h[u] + 1; q.push(V[u][j]); } } } if(cnt==n)ans=min(ans,sum); } cout<<ans; }

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

bosses.cpp:5:32: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
    5 | const int N=5005,mod=1e9+7,Inf=1e16;
      |                                ^~~~
bosses.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main(){
      |       ^
bosses.cpp: In function 'int main()':
bosses.cpp:37:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    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...