제출 #39778

#제출 시각아이디문제언어결과실행 시간메모리
39778nonocutBosses (BOI16_bosses)C++14
22 / 100
0 ms2296 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; const int inf = 1e8; int n; int vis[maxn], val[maxn]; vector<int> way[maxn], p[maxn]; queue<int> q; void dfs(int u) { val[u] = 1; for(auto v : p[u]) dfs(v), val[u] += val[v]; } int bfs(int u) { int i; for(i=1;i<=n;i++) { p[i].clear(); vis[i] = 0; val[i] = inf; } vis[u] = 1; q.push(u); while(!q.empty()) { int x = q.front(); q.pop(); for(auto y : way[x]) { if(!vis[y]) { vis[y] = 1; p[x].push_back(y); q.push(y); } } } dfs(u); int ans = 0; for(i=1;i<=n;i++) ans += val[i]; return ans; } int main() { int i,x,k; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&k); while(k--) { scanf("%d",&x); way[x].push_back(i); } } int ans = inf; for(i=1;i<=n;i++) ans = min(ans, bfs(i)); printf("%d",ans); }

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

bosses.cpp: In function 'int main()':
bosses.cpp:47:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
bosses.cpp:49:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&k);
                 ^
bosses.cpp:51:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&x);
                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...