제출 #329759

#제출 시각아이디문제언어결과실행 시간메모리
329759SuhaibSawalha1Bosses (BOI16_bosses)C++17
0 / 100
2 ms364 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; int vid = 1; vector<int> visited, dp; void dfs (int u){ visited[u] = vid; dp[u] = 1; for (int v : adj[u]){ if (visited[v] ^ vid){ dfs(v); dp[u] += dp[v]; } } } int main (){ #ifndef ONLINE_JUDGE freopen("SuhaibSawalha1","r",stdin); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; adj.resize(n); for (int u = 0; u < n; ++u){ int k, v; cin >> k; while (k--){ cin >> v; adj[--v].push_back(u); } } visited.resize(n); dp.resize(n); long long ans = 1e18; for (int i = 0; i < n; ++i, ++vid){ dfs(i); ans = min(ans, all_of(visited.begin(), visited.end(), [] (int x) {return x == vid;}) ? accumulate(dp.begin(), dp.end(), 0ll) : (long long) 1e18); } cout << ans; return 0; }

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

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