Submission #472274

# Submission time Handle Problem Language Result Execution time Memory
472274 2021-09-13T10:54:54 Z elgamalsalman Political Development (BOI17_politicaldevelopment) C++14
16 / 100
67 ms 4516 KB
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int n, k;
bool foundTriple = 0, foundDouble = 0;
vvi  adj;
bitset<5005> adjMatrix[5005];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> k;
  adj.assign(n + 20, vi());
  for (int i = 0; i < n; i++) {
    int d; cin >> d;
    while (d--) {
      foundDouble = 1;
      int v; cin >> v;
      adj[i].push_back(v);
      adj[v].push_back(i);
      adjMatrix[i][v] = 1;
      adjMatrix[v][i] = 1;
    }
  }

  for (int i = 0; !foundTriple && i < n; i++) {
    for (int j = 0; !foundTriple && j < adj[i].size(); j++) {
      for (int k = j + 1; !foundTriple && k < adj[i].size(); k++) {
	int jj = adj[i][j];
	int kk = adj[i][k];
	if (adjMatrix[jj][kk]) {
	  foundTriple = 1;
	  //cerr << "// " << i << ", " << jj << ", " << kk << "\n";
	}
      }
    }
  }

  if (foundTriple) cout << "3\n";
  else if (foundDouble) cout << "2\n";
  else cout << "1\n";
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:39:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int j = 0; !foundTriple && j < adj[i].size(); j++) {
      |                                     ~~^~~~~~~~~~~~~~~
politicaldevelopment.cpp:40:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       for (int k = j + 1; !foundTriple && k < adj[i].size(); k++) {
      |                                           ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 6 ms 3796 KB Output is correct
4 Correct 66 ms 3788 KB Output is correct
5 Correct 67 ms 3788 KB Output is correct
6 Correct 7 ms 3860 KB Output is correct
7 Correct 6 ms 3788 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 6 ms 3796 KB Output is correct
4 Correct 66 ms 3788 KB Output is correct
5 Correct 67 ms 3788 KB Output is correct
6 Correct 7 ms 3860 KB Output is correct
7 Correct 6 ms 3788 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 64 ms 3788 KB Output is correct
12 Correct 64 ms 3788 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 65 ms 3788 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 3916 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 6 ms 3916 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 4 ms 3660 KB Output is correct
21 Correct 4 ms 3660 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 6 ms 3912 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 6 ms 3916 KB Output is correct
26 Correct 6 ms 3788 KB Output is correct
27 Correct 6 ms 3788 KB Output is correct
28 Correct 6 ms 3788 KB Output is correct
29 Correct 6 ms 3788 KB Output is correct
30 Correct 21 ms 3952 KB Output is correct
31 Correct 8 ms 3916 KB Output is correct
32 Correct 19 ms 3968 KB Output is correct
33 Correct 6 ms 3916 KB Output is correct
34 Correct 6 ms 3916 KB Output is correct
35 Correct 3 ms 2124 KB Output is correct
36 Correct 3 ms 2120 KB Output is correct
37 Correct 3 ms 2124 KB Output is correct
38 Correct 2 ms 1228 KB Output is correct
39 Correct 3 ms 1228 KB Output is correct
40 Correct 7 ms 4044 KB Output is correct
41 Correct 3 ms 1228 KB Output is correct
42 Correct 8 ms 4044 KB Output is correct
43 Correct 6 ms 4044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 332 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 6 ms 3796 KB Output is correct
4 Correct 66 ms 3788 KB Output is correct
5 Correct 67 ms 3788 KB Output is correct
6 Correct 7 ms 3860 KB Output is correct
7 Correct 6 ms 3788 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 64 ms 3788 KB Output is correct
12 Correct 64 ms 3788 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 65 ms 3788 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 3916 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 6 ms 3916 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 4 ms 3660 KB Output is correct
21 Correct 4 ms 3660 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 6 ms 3912 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 6 ms 3916 KB Output is correct
26 Correct 6 ms 3788 KB Output is correct
27 Correct 6 ms 3788 KB Output is correct
28 Correct 6 ms 3788 KB Output is correct
29 Correct 6 ms 3788 KB Output is correct
30 Correct 21 ms 3952 KB Output is correct
31 Correct 8 ms 3916 KB Output is correct
32 Correct 19 ms 3968 KB Output is correct
33 Correct 6 ms 3916 KB Output is correct
34 Correct 6 ms 3916 KB Output is correct
35 Correct 3 ms 2124 KB Output is correct
36 Correct 3 ms 2120 KB Output is correct
37 Correct 3 ms 2124 KB Output is correct
38 Correct 2 ms 1228 KB Output is correct
39 Correct 3 ms 1228 KB Output is correct
40 Correct 7 ms 4044 KB Output is correct
41 Correct 3 ms 1228 KB Output is correct
42 Correct 8 ms 4044 KB Output is correct
43 Correct 6 ms 4044 KB Output is correct
44 Incorrect 10 ms 4516 KB Output isn't correct
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 6 ms 3796 KB Output is correct
4 Correct 66 ms 3788 KB Output is correct
5 Correct 67 ms 3788 KB Output is correct
6 Correct 7 ms 3860 KB Output is correct
7 Correct 6 ms 3788 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 64 ms 3788 KB Output is correct
12 Correct 64 ms 3788 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 65 ms 3788 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 3916 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 6 ms 3916 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 4 ms 3660 KB Output is correct
21 Correct 4 ms 3660 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 6 ms 3912 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 6 ms 3916 KB Output is correct
26 Correct 6 ms 3788 KB Output is correct
27 Correct 6 ms 3788 KB Output is correct
28 Correct 6 ms 3788 KB Output is correct
29 Correct 6 ms 3788 KB Output is correct
30 Correct 21 ms 3952 KB Output is correct
31 Correct 8 ms 3916 KB Output is correct
32 Correct 19 ms 3968 KB Output is correct
33 Correct 6 ms 3916 KB Output is correct
34 Correct 6 ms 3916 KB Output is correct
35 Correct 3 ms 2124 KB Output is correct
36 Correct 3 ms 2120 KB Output is correct
37 Correct 3 ms 2124 KB Output is correct
38 Correct 2 ms 1228 KB Output is correct
39 Correct 3 ms 1228 KB Output is correct
40 Correct 7 ms 4044 KB Output is correct
41 Correct 3 ms 1228 KB Output is correct
42 Correct 8 ms 4044 KB Output is correct
43 Correct 6 ms 4044 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Runtime error 4 ms 2868 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -