제출 #975561

#제출 시각아이디문제언어결과실행 시간메모리
975561moaiBosses (BOI16_bosses)C++17
100 / 100
490 ms852 KiB
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include <iostream> #include<vector> #include <queue> using namespace std; long long bfs(int v, vector<vector<int>> &g) { queue<int> q; q.push(v); int n = g.size(); vector<long long> deep(n, 1e10); deep[v] = 1; while (q.size() > 0) { int u = q.front(); q.pop(); for (int i = 0; i < g[u].size(); ++i) { if (deep[g[u][i]] > 1000000) { deep[g[u][i]] = deep[u] + 1; q.push(g[u][i]); } } } long long summ = 0; for(int i = 0; i < n; ++i) { summ += deep[i]; } return summ; } int main() { int n; cin >> n; vector<vector<int>> g(n); for (int i = 0; i < n; ++i) { int k; cin >> k; for (int j = 0; j < k; ++j) { int v; cin >> v; --v; g[v].push_back(i); } } long long total_cost = 1000000000000; for (int i = 0; i < n; ++i) { long long ans = bfs(i, g); if(ans < total_cost) { total_cost = ans; } } cout << total_cost; return 0; }

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

bosses.cpp: In function 'long long int bfs(int, std::vector<std::vector<int> >&)':
bosses.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int i = 0; i < g[u].size(); ++i) {
      |                         ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...