Submission #397699

#TimeUsernameProblemLanguageResultExecution timeMemory
397699priority_queueConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
// ioi 2020, day 1, supertrees #include <bits/stdc++.h> using namespace std; #define forint(i, N) for (int i = 0; i < (N); i++) using namespace std; void build(std::vector<std::vector<int> > b); int construct(const vector<std::vector<int> > & p) { int N = p.size(); vector< vector<int> > b(N, vector<int>(N, 0)); vector<int> visited(N, -1); forint(i, N) { if (visited[i] < 0) { // create new. All connected to i also not visited //visited[i] = i; vector<int> path2 = {}; //forint (j, N) { for (int j = i+1; j < N; j++) { /* if (j == i) { if (p[i][i]!=1) { return 0; } continue; } */ if (p[i][j] == 1) { if (visited[j] >=0) { return 0; } b[i][j] = 1; b[j][i] = 1; visited[j] = i; continue; } if (p[i][j] == 2) { if (visited[j] >=0) { return 0; } path2.push_back(j); //visited[j] = i; continue; } if (p[i][j] == 3) { return 0; } } if (!path2.empty()) { if (path2.size() < 2) { return 0; } int last = i; //b[i][path2[0]] = 1; //b[path2[0]][i] = 1; forint(j, path2.size()) { if (visited[j] < 0) { // make it root b[last][path2[j]] = 1; b[path2[j]][last] = 1; last = path2[j]; visited[path2[j]] = i; for (int j2 = j+1; j2 < path2.size(); j2++) { if (visited[path2[j2]] < 0 && p[path2[j]][path2[j2]] == 1) { b[path2[j]][path2[j2]] = 1; b[path2[j2]][path2[j]] = 1; visited[path2[j2]] = path2[j]; } } } } b[i][last] = 1; b[last][i] = 1; } } else { // check if it is OK for (int j = i+1; j< N; j++) { /* if (p[visited[i]][i] == p[visited[i]][j]) { if (p[i][j] != p[visited[i]][i]) { //cout << i << " ---- " << j << " : " << p[i][j] << " ? " << p[visited[i]][i] << " -- " << visited[i] << endl; return 0; } } else { */ if (p[i][j] != p[visited[i]][j] * p[visited[i]][i]) { //cout << i << " ----------------- " << j << endl; return 0; } //} //} } } } build(b); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(const std::vector<std::vector<int> >&)':
supertrees.cpp:7:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define forint(i, N) for (int i = 0; i < (N); i++)
      |                                        ^
supertrees.cpp:71:11: note: in expansion of macro 'forint'
   71 |           forint(j, path2.size()) {
      |           ^~~~~~
supertrees.cpp:79:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             for (int j2 = j+1; j2 < path2.size(); j2++) {
      |                                ~~~^~~~~~~~~~~~~~
/tmp/cccaw1ab.o: In function `main':
grader.cpp:(.text.startup+0x3d1): undefined reference to `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
collect2: error: ld returned 1 exit status