제출 #1263633

#제출 시각아이디문제언어결과실행 시간메모리
1263633minggaBosses (BOI16_bosses)C++20
100 / 100
392 ms776 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int mod = 1e9 + 7; const int inf = 2e18; const int N = 5005; vector<int> g[N]; int d[N]; int n; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" 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; g[x].pb(i); } } int ans = inf; for(int i = 1; i <= n; i++) { queue<int> q; q.push(i); memset(d, 0, sizeof d); d[i] = 1; int cur = 0; int cnt = 0; // cerr << "TURN " << i << ln; while(sz(q)) { int u = q.front(); q.pop(); cur += d[u]; cnt++; for(int v : g[u]) { if(d[v] == 0) { // cerr << u << ' ' << v << ln; d[v] = d[u] + 1; q.push(v); } } } if(cnt < n) continue; ans = min(ans, cur); } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

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

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