제출 #79527

#제출 시각아이디문제언어결과실행 시간메모리
79527Flying_dragon_02Bosses (BOI16_bosses)C++14
100 / 100
716 ms1020 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; int n; long long ans = LLONG_MAX; bool vis[5005]; vector<int> graph[5005]; queue<ii> pq; long long lmao(int u) { memset(vis, 0, sizeof(vis)); pq.push({1, u}); long long sum = 0; vis[u] = 1; while(!pq.empty()) { ii frt = pq.front(); pq.pop(); //if(vis[frt.se]) continue; sum += frt.fi; for(int i = 0; i < graph[frt.se].size(); i++) { //cout << graph[u][i] << " " << u << "\n"; int v = graph[frt.se][i]; if(!vis[v]) { pq.push({frt.fi + 1, v}), vis[v] = 1; } } } for(int i = 1; i <= n; i++) { if(!vis[i]) return LLONG_MAX; } return sum; } int main() { cin.tie(0), ios::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++) { int k, u; cin >> k; while(k--) { cin >> u; graph[u].pb(i); } } for(int i = 1; i <= n; i++) ans = min(ans, lmao(i)); cout << ans; }

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

bosses.cpp: In function 'long long int lmao(int)':
bosses.cpp:30:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < graph[frt.se].size(); i++) {
                        ~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...