제출 #30683

#제출 시각아이디문제언어결과실행 시간메모리
30683noobprogrammerBosses (BOI16_bosses)C++14
100 / 100
666 ms2352 KiB
#include <bits/stdc++.h> using namespace std ; typedef long long ll ; #define ii pair<int,int> #define fi first #define se second #define vi vector<int> #define vii vector<ii> int n , m , visited[5005] , h[5005] ; ll dp[5005] , res = 1e18 ; queue<int> q ; vi adj[5005] ; void bfs(int x){ memset(visited , 0 , sizeof visited) ; q.push(x); h[x] = 1 ; ll sum = 0 ; visited[x] = 1 ; int cur ,cnt = 0 ; while(!q.empty()){ cur = q.front() ; q.pop() ; cnt++ ; sum += (ll)h[cur] ; for(int v : adj[cur]){ if(visited[v]) continue ; visited[v] = 1 ; h[v] = h[cur] + 1 ; q.push(v) ; } } if(cnt == n) res = min(res , sum ); // printf("%d : %lld %lld\n" ,x , sum , res ); // for(int i = 1 ; i<=n;i++) printf("%d " , h[i]) ; // cout <<endl ; } int main(){ // freopen("in.txt" , "r" , stdin) ; scanf("%d" ,&n) ; int a ,b ; for(int i=1;i<=n;i++){ scanf("%d" , &a); for(int j=0;j<a;j++){ scanf("%d" , &b) ; adj[b].push_back(i) ; } } for(int i=1;i<=n;i++) bfs(i) ; printf("%lld\n" , res) ; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d" ,&n) ;
                  ^
bosses.cpp:44:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &a);
                   ^
bosses.cpp:46:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d" , &b) ;
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...