제출 #107179

#제출 시각아이디문제언어결과실행 시간메모리
107179stefdascaBosses (BOI16_bosses)C++14
0 / 100
2 ms768 KiB
#include<bits/stdc++.h> using namespace std; int n, cost, ans = (1<<30); int sz[5002]; vector<int>v[5002]; vector<int>nt[5002]; bool viz[5002]; void bfs(int nod) { memset(viz, 0, sizeof(viz)); viz[nod] = 1; queue<int>q; q.push(nod); while(!q.empty()) { int t = q.front(); q.pop(); for(int j = 0; j < v[t].size(); ++j) { int vecin = v[t][j]; if(!viz[vecin]) { nt[t].push_back(vecin); viz[vecin] = 1; q.push(vecin); } } } } void dfs(int nod) { sz[nod] = 1; for(int i = 0; i < nt[nod].size(); ++i) { int vecin = nt[nod][i]; dfs(vecin); sz[nod] += sz[vecin]; } cost += sz[nod]; } int main() { cin >> n; for(int i = 1; i <= n; ++i) { int k; cin >> k; for(int j = 1; j <= k; ++j) { int nr; cin >> nr; v[nr].push_back(i); } } for(int i = 1; i <= n; ++i) { for(int j = 1; j <= n; ++j) nt[j].clear(); bfs(i); cost = 0; dfs(i); ans = min(ans, cost); } cout << ans; return 0; }

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

bosses.cpp: In function 'void bfs(int)':
bosses.cpp:18:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < v[t].size(); ++j)
                        ~~^~~~~~~~~~~~~
bosses.cpp: In function 'void dfs(int)':
bosses.cpp:33:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < nt[nod].size(); ++i)
                    ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...