제출 #861310

#제출 시각아이디문제언어결과실행 시간메모리
861310nnhzzzBosses (BOI16_bosses)C++14
100 / 100
451 ms852 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(int i = (a); i<=(b); ++i) #define REPD(i,a,b) for(int i = (a); i>=(b); --i) #define REPDIS(i,a,b,c) for(int i = (a); i<=(b); i += c) #define task "test" #define task1 "nnhzzz" #define ALL(x) (x).begin(),(x).end() #define SZ(x) (int)(x).size() #define MASK(x) (1LL<<x) #define BIT(x,i) ((x>>i)&1LL) #define vi vector<int> #define vvi vector<vi> #define pii pair<int,int> #define vpii vector<pii> #define fi first #define se second #define ld long double #define ll long long //-------------------------------------------------------------------------------// template<typename T> bool mini(T &a, T b){if(a>b){a=b;return true;}return false;} template<typename T> bool maxi(T &a, T b){if(a<b){a=b;return true;}return false;} //-------------------------------------------------------------------------------// const int MAXN = 5e3+7,N = 1e5+7,inf = 1e9,LOG = 20; const int MOD = 1e9+7,MOD1 = 123456789; //-------------------------------------------------------------------------------// vi adj[MAXN]; void solve(){ int res = inf,n; cin >> n; REP(i,1,n){ int k; cin >> k; while(k--){ int j; cin >> j; adj[j].push_back(i); } } REP(s,1,n){ queue<int> q; q.push(s); vi dep(n+3,0); dep[s] = 1; int ma = 1; while(SZ(q)!=0){ int u = q.front(); q.pop(); REP(i,0,SZ(adj[u])-1){ int v = adj[u][i]; if(dep[v]!=0) continue; dep[v] = dep[u]+1; maxi(ma,dep[v]); q.push(v); } } int sum = 0; REP(i,1,n){ if(dep[i]==0) sum = inf; sum += dep[i]; } mini(res,sum); } cout << res; } signed main(){ ios::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); } if(fopen(task1".inp","r")){ freopen(task1".inp","r",stdin); freopen(task1".out","w",stdout); } solve(); return 0; }

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

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