Submission #169360

# Submission time Handle Problem Language Result Execution time Memory
169360 2019-12-20T05:34:41 Z gabrielpessoa Political Development (BOI17_politicaldevelopment) C++14
16 / 100
3000 ms 12280 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;

const int ms = 4e5+5;

vector<int> g[ms];
int cur[ms];
int z = 0;

main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  int maxS = 0;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    maxS = max(maxS, d);
    g[i].resize(d);
    for(int j = 0; j < d; j++) {
      cin >> g[i][j];
    }
  }
  int ans = 1;
  if(maxS <= 10) {
    for(int i = 0; i < n; i++) {
      int t = g[i].size();
      for(int j = 0; j < (1 << t); j++) {
        vector<int> v = {i};
        bool isGood = true;
        for(int k = 0; k < t; k++) {
          if(j & (1 << k)) {
            if(g[i][k] < i) {
              isGood = false;
              break;
            }
            v.push_back(g[i][k]);
          }
        }
        if(!isGood || v.size() <= ans) continue;
        ++z;
        for(int k : v) {
          cur[k] = z;
        }
        bool possible = true;
        for(int k : v) {
          int cnt = 0;
          for(int l : g[k]) if(cur[l] == z) cnt++;
          if(cnt != v.size() -1) possible = false;
        }
        if(possible) ans = max(ans, (int) v.size());
      }
    }
  } else if(n <= 5000 && k <= 3) {
    for(int i = 0; i < n; i++) {
      if(g[i].size() > 0) ans = max(ans, 2);
      set<int> s;
      for(int j : g[i]) {
        for(int k : g[j]) {
          if(s.count(k)) ans = max(ans, 3);
        }
        s.insert(j);
      }
    }
  } 
  cout << ans << '\n';
}

Compilation message

politicaldevelopment.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(!isGood || v.size() <= ans) continue;
                       ~~~~~~~~~^~~~~~
politicaldevelopment.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           if(cnt != v.size() -1) possible = false;
              ~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 13 ms 9852 KB Output is correct
4 Correct 36 ms 10080 KB Output is correct
5 Correct 36 ms 10104 KB Output is correct
6 Correct 13 ms 9976 KB Output is correct
7 Correct 13 ms 9848 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 13 ms 9852 KB Output is correct
4 Correct 36 ms 10080 KB Output is correct
5 Correct 36 ms 10104 KB Output is correct
6 Correct 13 ms 9976 KB Output is correct
7 Correct 13 ms 9848 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 37 ms 10232 KB Output is correct
12 Correct 38 ms 10212 KB Output is correct
13 Correct 10 ms 9720 KB Output is correct
14 Correct 36 ms 10104 KB Output is correct
15 Correct 10 ms 9720 KB Output is correct
16 Correct 13 ms 9976 KB Output is correct
17 Correct 10 ms 9720 KB Output is correct
18 Correct 14 ms 9976 KB Output is correct
19 Correct 10 ms 9692 KB Output is correct
20 Correct 12 ms 9976 KB Output is correct
21 Correct 12 ms 9976 KB Output is correct
22 Correct 10 ms 9720 KB Output is correct
23 Correct 16 ms 9848 KB Output is correct
24 Correct 10 ms 9720 KB Output is correct
25 Correct 17 ms 9848 KB Output is correct
26 Correct 16 ms 9848 KB Output is correct
27 Correct 13 ms 9976 KB Output is correct
28 Correct 16 ms 9976 KB Output is correct
29 Correct 13 ms 9848 KB Output is correct
30 Correct 19 ms 9976 KB Output is correct
31 Correct 16 ms 9976 KB Output is correct
32 Correct 20 ms 9976 KB Output is correct
33 Correct 17 ms 9976 KB Output is correct
34 Correct 17 ms 9976 KB Output is correct
35 Correct 13 ms 9848 KB Output is correct
36 Correct 13 ms 9820 KB Output is correct
37 Correct 13 ms 9848 KB Output is correct
38 Correct 12 ms 9720 KB Output is correct
39 Correct 12 ms 9720 KB Output is correct
40 Correct 16 ms 9976 KB Output is correct
41 Correct 11 ms 9720 KB Output is correct
42 Correct 16 ms 9948 KB Output is correct
43 Correct 16 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 10 ms 9720 KB Output is correct
4 Correct 10 ms 9720 KB Output is correct
5 Correct 10 ms 9692 KB Output is correct
6 Correct 10 ms 9720 KB Output is correct
7 Correct 10 ms 9720 KB Output is correct
8 Correct 10 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 10 ms 9720 KB Output is correct
11 Execution timed out 3034 ms 12280 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 13 ms 9852 KB Output is correct
4 Correct 36 ms 10080 KB Output is correct
5 Correct 36 ms 10104 KB Output is correct
6 Correct 13 ms 9976 KB Output is correct
7 Correct 13 ms 9848 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 37 ms 10232 KB Output is correct
12 Correct 38 ms 10212 KB Output is correct
13 Correct 10 ms 9720 KB Output is correct
14 Correct 36 ms 10104 KB Output is correct
15 Correct 10 ms 9720 KB Output is correct
16 Correct 13 ms 9976 KB Output is correct
17 Correct 10 ms 9720 KB Output is correct
18 Correct 14 ms 9976 KB Output is correct
19 Correct 10 ms 9692 KB Output is correct
20 Correct 12 ms 9976 KB Output is correct
21 Correct 12 ms 9976 KB Output is correct
22 Correct 10 ms 9720 KB Output is correct
23 Correct 16 ms 9848 KB Output is correct
24 Correct 10 ms 9720 KB Output is correct
25 Correct 17 ms 9848 KB Output is correct
26 Correct 16 ms 9848 KB Output is correct
27 Correct 13 ms 9976 KB Output is correct
28 Correct 16 ms 9976 KB Output is correct
29 Correct 13 ms 9848 KB Output is correct
30 Correct 19 ms 9976 KB Output is correct
31 Correct 16 ms 9976 KB Output is correct
32 Correct 20 ms 9976 KB Output is correct
33 Correct 17 ms 9976 KB Output is correct
34 Correct 17 ms 9976 KB Output is correct
35 Correct 13 ms 9848 KB Output is correct
36 Correct 13 ms 9820 KB Output is correct
37 Correct 13 ms 9848 KB Output is correct
38 Correct 12 ms 9720 KB Output is correct
39 Correct 12 ms 9720 KB Output is correct
40 Correct 16 ms 9976 KB Output is correct
41 Correct 11 ms 9720 KB Output is correct
42 Correct 16 ms 9948 KB Output is correct
43 Correct 16 ms 9848 KB Output is correct
44 Correct 132 ms 9976 KB Output is correct
45 Correct 10 ms 9720 KB Output is correct
46 Incorrect 13 ms 9976 KB Output isn't correct
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 9720 KB Output is correct
2 Correct 10 ms 9720 KB Output is correct
3 Correct 13 ms 9852 KB Output is correct
4 Correct 36 ms 10080 KB Output is correct
5 Correct 36 ms 10104 KB Output is correct
6 Correct 13 ms 9976 KB Output is correct
7 Correct 13 ms 9848 KB Output is correct
8 Correct 11 ms 9720 KB Output is correct
9 Correct 10 ms 9720 KB Output is correct
10 Correct 11 ms 9720 KB Output is correct
11 Correct 37 ms 10232 KB Output is correct
12 Correct 38 ms 10212 KB Output is correct
13 Correct 10 ms 9720 KB Output is correct
14 Correct 36 ms 10104 KB Output is correct
15 Correct 10 ms 9720 KB Output is correct
16 Correct 13 ms 9976 KB Output is correct
17 Correct 10 ms 9720 KB Output is correct
18 Correct 14 ms 9976 KB Output is correct
19 Correct 10 ms 9692 KB Output is correct
20 Correct 12 ms 9976 KB Output is correct
21 Correct 12 ms 9976 KB Output is correct
22 Correct 10 ms 9720 KB Output is correct
23 Correct 16 ms 9848 KB Output is correct
24 Correct 10 ms 9720 KB Output is correct
25 Correct 17 ms 9848 KB Output is correct
26 Correct 16 ms 9848 KB Output is correct
27 Correct 13 ms 9976 KB Output is correct
28 Correct 16 ms 9976 KB Output is correct
29 Correct 13 ms 9848 KB Output is correct
30 Correct 19 ms 9976 KB Output is correct
31 Correct 16 ms 9976 KB Output is correct
32 Correct 20 ms 9976 KB Output is correct
33 Correct 17 ms 9976 KB Output is correct
34 Correct 17 ms 9976 KB Output is correct
35 Correct 13 ms 9848 KB Output is correct
36 Correct 13 ms 9820 KB Output is correct
37 Correct 13 ms 9848 KB Output is correct
38 Correct 12 ms 9720 KB Output is correct
39 Correct 12 ms 9720 KB Output is correct
40 Correct 16 ms 9976 KB Output is correct
41 Correct 11 ms 9720 KB Output is correct
42 Correct 16 ms 9948 KB Output is correct
43 Correct 16 ms 9848 KB Output is correct
44 Correct 10 ms 9720 KB Output is correct
45 Incorrect 50 ms 11592 KB Output isn't correct
46 Halted 0 ms 0 KB -