# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1015988 | 2024-07-07T08:14:14 Z | qnicondavid23 | Bosses (BOI16_bosses) | C++14 | 472 ms | 860 KB |
#include <vector> #include <iostream> #include <queue> using namespace std; //ifstream cin("date.in"); //ofstream cout("date.out"); int n; int x, a; vector<vector<int>> A; vector<int> fr; int sum; void bfs(int nod) { queue<int> Q; Q.push(nod); fr[nod] = 1; sum = 1; while (!Q.empty()) { int cap = Q.front(); Q.pop(); for (int i = 0; i < A[cap].size(); i++) { int vecin = A[cap][i]; if (!fr[vecin]) { fr[vecin] = fr[cap]+1; sum = sum + fr[vecin]; Q.push(vecin); } } } } int main() { cin >> n; A.resize(n + 1); for (int i = 1; i <= n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> a; A[a].push_back(i); } } int mini = 0x3f3f3f3f; for (int i = 1; i <= n; i++) { fr.resize(0); fr.resize(n + 1); sum = 0; bfs(i); bool ok = 1; for (int j = 1; j <= n; j++) if (fr[j]==0) { ok = 0; break; } if (!ok) continue; mini = min(mini, sum); } cout << mini; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 432 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 432 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 432 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 5 ms | 348 KB | Output is correct |
13 | Correct | 4 ms | 348 KB | Output is correct |
14 | Correct | 70 ms | 860 KB | Output is correct |
15 | Correct | 6 ms | 600 KB | Output is correct |
16 | Correct | 440 ms | 604 KB | Output is correct |
17 | Correct | 437 ms | 760 KB | Output is correct |
18 | Correct | 472 ms | 760 KB | Output is correct |