# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
857772 | 2023-10-06T22:12:52 Z | qrno | Bosses (BOI16_bosses) | C++11 | 411 ms | 848 KB |
#include <cstdio> #include <vector> #include <array> #include <queue> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") const int INF = 1e9; const int MAXN = 5e3; int best = INF; int N; array<vector<int>, MAXN> G; array<int, MAXN> val, last; signed main() { scanf("%d", &N); for (int i = 0; i < N; i++) { int K; scanf("%d", &K); while (K--) { int u; scanf("%d", &u); u--; G[u].push_back(i); } } for (int i = 0; i < N; i++) { queue<int> Q; Q.push(i); val[i] = 1; last[i] = i; int done = 0, sum = 0; while (!Q.empty()) { auto v = Q.front(); Q.pop(); sum += val[v]; done++; for (auto u : G[v]) { if (last[u] != i) { Q.push(u); val[u] = val[v]+1; last[u] = i; } } } if (done < N) continue; best = min(best, sum); } printf("%d", best); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 604 KB | Output is correct |
13 | Correct | 3 ms | 632 KB | Output is correct |
14 | Correct | 77 ms | 632 KB | Output is correct |
15 | Correct | 2 ms | 600 KB | Output is correct |
16 | Correct | 403 ms | 848 KB | Output is correct |
17 | Correct | 394 ms | 712 KB | Output is correct |
18 | Correct | 411 ms | 712 KB | Output is correct |