답안 #952226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952226 2024-03-23T10:10:42 Z stefanneagu Political Development (BOI17_politicaldevelopment) C++17
39 / 100
3000 ms 57064 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, useless;
  cin >> n >> useless;
  vector<vector<int>> adj(n + 1);
  set<pair<int, int>> pr;
  vector<pair<int, int>> vp;
  for(int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    vp.push_back({x, i});
    while(x--) {
      int a;
      cin >> a;
      a++;
      adj[i].push_back(a);
      pr.insert({min(a, i), max(a, i)});
    }
  }
  sort(vp.begin(), vp.end());
  vector<vector<vector<int>>> v(n + 1);
  for(int i = 1; i <= n; i++) {
    v[i].push_back({i});
  }
  int ans = 0;
  while(true) {
    vector<vector<vector<int>>> curr(n + 1);
    ans++;
    bool ok = 0;
    for(int ii = 1; ii <= n; ii++) {
      int i = vp[ii - 1].second;
      // cout << "la " << i << "\n";
      for(auto it : adj[i]) {
        // cout << "vecin " << it << ':';
        vector<int> cp;
        bool used = 0;
        for(auto s : v[it]) {
          bool nf = 0;
          for(auto j : s) {
            if(pr.find({min(i, j), max(i, j)}) == pr.end()) {
              nf = 1;
              break;
            }
          }
          if(!nf) {
            // cout << " merge, face: ";
            cp = s;
            used = 1;
            ok = 1;
            break;
          }
        }
        if(used) {
          cp.push_back(i);
          curr[i].push_back(cp);
        }
      }
    }
    if(!ok) {
      break;
    }
    swap(v, curr); // o(1) plsplspls
  }
  cout << ans;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 11 ms 2136 KB Output is correct
4 Correct 1058 ms 2180 KB Output is correct
5 Correct 1204 ms 2144 KB Output is correct
6 Correct 32 ms 2140 KB Output is correct
7 Correct 30 ms 2136 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 11 ms 2136 KB Output is correct
4 Correct 1058 ms 2180 KB Output is correct
5 Correct 1204 ms 2144 KB Output is correct
6 Correct 32 ms 2140 KB Output is correct
7 Correct 30 ms 2136 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 1112 KB Output is correct
11 Correct 991 ms 2156 KB Output is correct
12 Correct 1092 ms 2140 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1511 ms 2304 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 32 ms 2140 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 33 ms 2312 KB Output is correct
19 Correct 2 ms 920 KB Output is correct
20 Correct 5 ms 1728 KB Output is correct
21 Correct 5 ms 1624 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 13 ms 2456 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 13 ms 2408 KB Output is correct
26 Correct 12 ms 2140 KB Output is correct
27 Correct 11 ms 2140 KB Output is correct
28 Correct 12 ms 2348 KB Output is correct
29 Correct 9 ms 2140 KB Output is correct
30 Correct 378 ms 2524 KB Output is correct
31 Correct 14 ms 2396 KB Output is correct
32 Correct 368 ms 2512 KB Output is correct
33 Correct 14 ms 2392 KB Output is correct
34 Correct 13 ms 2464 KB Output is correct
35 Correct 7 ms 1372 KB Output is correct
36 Correct 7 ms 1272 KB Output is correct
37 Correct 7 ms 1372 KB Output is correct
38 Correct 8 ms 1104 KB Output is correct
39 Correct 12 ms 860 KB Output is correct
40 Correct 25 ms 3420 KB Output is correct
41 Correct 12 ms 860 KB Output is correct
42 Correct 28 ms 3164 KB Output is correct
43 Correct 24 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1116 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1307 ms 56952 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1589 ms 56960 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1448 ms 56904 KB Output is correct
16 Correct 1352 ms 56916 KB Output is correct
17 Correct 1455 ms 57036 KB Output is correct
18 Correct 1360 ms 57064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 11 ms 2136 KB Output is correct
4 Correct 1058 ms 2180 KB Output is correct
5 Correct 1204 ms 2144 KB Output is correct
6 Correct 32 ms 2140 KB Output is correct
7 Correct 30 ms 2136 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 1112 KB Output is correct
11 Correct 991 ms 2156 KB Output is correct
12 Correct 1092 ms 2140 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1511 ms 2304 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 32 ms 2140 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 33 ms 2312 KB Output is correct
19 Correct 2 ms 920 KB Output is correct
20 Correct 5 ms 1728 KB Output is correct
21 Correct 5 ms 1624 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 13 ms 2456 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 13 ms 2408 KB Output is correct
26 Correct 12 ms 2140 KB Output is correct
27 Correct 11 ms 2140 KB Output is correct
28 Correct 12 ms 2348 KB Output is correct
29 Correct 9 ms 2140 KB Output is correct
30 Correct 378 ms 2524 KB Output is correct
31 Correct 14 ms 2396 KB Output is correct
32 Correct 368 ms 2512 KB Output is correct
33 Correct 14 ms 2392 KB Output is correct
34 Correct 13 ms 2464 KB Output is correct
35 Correct 7 ms 1372 KB Output is correct
36 Correct 7 ms 1272 KB Output is correct
37 Correct 7 ms 1372 KB Output is correct
38 Correct 8 ms 1104 KB Output is correct
39 Correct 12 ms 860 KB Output is correct
40 Correct 25 ms 3420 KB Output is correct
41 Correct 12 ms 860 KB Output is correct
42 Correct 28 ms 3164 KB Output is correct
43 Correct 24 ms 3164 KB Output is correct
44 Correct 153 ms 6904 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 25 ms 3208 KB Output is correct
47 Correct 73 ms 4944 KB Output is correct
48 Correct 24 ms 3152 KB Output is correct
49 Correct 71 ms 4944 KB Output is correct
50 Correct 69 ms 4952 KB Output is correct
51 Correct 242 ms 9300 KB Output is correct
52 Correct 710 ms 2136 KB Output is correct
53 Execution timed out 3062 ms 10008 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 11 ms 2136 KB Output is correct
4 Correct 1058 ms 2180 KB Output is correct
5 Correct 1204 ms 2144 KB Output is correct
6 Correct 32 ms 2140 KB Output is correct
7 Correct 30 ms 2136 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 1112 KB Output is correct
11 Correct 991 ms 2156 KB Output is correct
12 Correct 1092 ms 2140 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1511 ms 2304 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 32 ms 2140 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 33 ms 2312 KB Output is correct
19 Correct 2 ms 920 KB Output is correct
20 Correct 5 ms 1728 KB Output is correct
21 Correct 5 ms 1624 KB Output is correct
22 Correct 2 ms 1116 KB Output is correct
23 Correct 13 ms 2456 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 13 ms 2408 KB Output is correct
26 Correct 12 ms 2140 KB Output is correct
27 Correct 11 ms 2140 KB Output is correct
28 Correct 12 ms 2348 KB Output is correct
29 Correct 9 ms 2140 KB Output is correct
30 Correct 378 ms 2524 KB Output is correct
31 Correct 14 ms 2396 KB Output is correct
32 Correct 368 ms 2512 KB Output is correct
33 Correct 14 ms 2392 KB Output is correct
34 Correct 13 ms 2464 KB Output is correct
35 Correct 7 ms 1372 KB Output is correct
36 Correct 7 ms 1272 KB Output is correct
37 Correct 7 ms 1372 KB Output is correct
38 Correct 8 ms 1104 KB Output is correct
39 Correct 12 ms 860 KB Output is correct
40 Correct 25 ms 3420 KB Output is correct
41 Correct 12 ms 860 KB Output is correct
42 Correct 28 ms 3164 KB Output is correct
43 Correct 24 ms 3164 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 906 ms 37688 KB Output is correct
46 Execution timed out 3069 ms 22912 KB Time limit exceeded
47 Halted 0 ms 0 KB -