제출 #337876

#제출 시각아이디문제언어결과실행 시간메모리
337876theshadow_04Bosses (BOI16_bosses)C++14
0 / 100
2 ms2668 KiB
#include <bits/stdc++.h> #define Task "BOSSES" #define pb push_back #define F first #define S second using namespace std; const int maxn = 50005; int n; vector<int> a[maxn], ke[maxn]; int dd[maxn]; long long ans = 1e1, f[maxn]; inline void BFS(int s) { queue<int> Q; Q.push(s); dd[s] = 1; while(Q.size()) { int u = Q.front(); Q.pop(); for(auto v : a[u]) { if(!dd[v]) { dd[v] = 1; ke[u].pb(v); Q.push(v); } } } } inline void DFS(int u) { int sum = 0; for(auto v : ke[u]) { if(!f[v]) { DFS(v); sum += f[v]; } } f[u] = sum + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n; for(int i = 1; i <= n; ++ i) { int k; cin >> k; while(k --) { int x; cin >> x; a[x].pb(i); } } for(int i = 1; i <= n; ++ i) { for(int j = 1; j <= n; ++ j) ke[j].clear(), f[j] = dd[j] = 0; BFS(i); DFS(i); long long total = 0; for(int j = 1; j <= n; ++ j) total += f[j]; ans = min(ans, total); } cout << ans; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         freopen(Task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         freopen(Task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...