제출 #857340

#제출 시각아이디문제언어결과실행 시간메모리
857340teeslaBosses (BOI16_bosses)C++14
0 / 100
1 ms436 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<int> vis; int res = 0; void bfs(int x){ queue<pair<int,int>> q; q.push({x,1}); vis[x] = 1; while(!q.empty()){ auto [a,b] = q.front();q.pop(); if(vis[a]< b) continue; res += b; for(auto i: adj[a]){ if(vis[i] != -1) continue; vis[i] = b + 1; q.push({i, vis[i]}); } } } int main(){ int n; cin >> n; adj.resize(n); for(int i=0; i<n; i++){ int k; cin >> k; for(int j =0; j<k; j++){ int a; cin >> a; a--; adj[a].push_back(i); } } int menor = 0; for(int i=0; i<n; i++){ vis.assign(n,-1); res = 0; bfs(i); if(i ==0) menor =res; else menor = min(menor, res); } cout << menor << endl; }

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

bosses.cpp: In function 'void bfs(int)':
bosses.cpp:17:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   17 |         auto [a,b] = q.front();q.pop();
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...