Submission #399442

#TimeUsernameProblemLanguageResultExecution timeMemory
399442bipartite_matchingConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define forint(i, N) for (int i = 0; i < (N); i++) using namespace std; void build(vector< vector<int> > b); int construct(vector< vector<int> > p) { int n = p.size(); //vector<int> coor(n, -1); vector< vector<int> > ans(n, vector<int>(n, 0)); vector<int> visited(n, false); vector< vector<int> > p2(n, vector<int>(n, 0)); forint(i, n) { //cerr << i << endl; if (!visited[i]) { vector< vector<int> > tree; visited[i] = true; //if (coor[i] == -1) { //coor[i] == i; tree.push_back({i}); vector<int> tmp; //tmp.push_back(i); for (int j = i + 1; j < n; j++) { if (p[i][j] == 3) { return 0; } if (p[i][j] == 1) { //if (coor[j] != -1) { if (visited[j]) { return 0; } //coor[j] = i; ans[i][j] = 1; ans[j][i] = 1; visited[j] = true; tree[tree.size()-1].push_back(j); } if (p[i][j] == 2) { //cerr << "eh " << j << endl; tmp.push_back(j); } } if (tmp.size() == 1) { return 0; } int last_node = i; for (int k = 0; k < tmp.size(); k++) { if (!visited[tmp[k]]) { visited[tmp[k]] = true; tree.push_back({tmp[k]}); ans[last_node][tmp[k]] = 1; ans[tmp[k]][last_node] = 1; last_node = tmp[k]; for (int k2 = k+1; k2 < tmp.size(); k2++) { if (!visited[tmp[k2]] && p[tmp[k]][tmp[k2]] == 1) { visited[tmp[k2]] = true; ans[tmp[k]][tmp[k2]] = 1; ans[tmp[k2]][tmp[k]] = 1; tree[tree.size()-1].push_back(tmp[k2]); } } } } ans[last_node][i] = 1; ans[i][last_node] = 1; //tree.push_back(tmp); /* cerr << i << "-----" << endl; for (auto a : tree) { for (auto b: a) { cerr << b << " "; } cerr << endl; } cerr << "-----" << endl; */ for (int k = 0; k < tree.size(); k++) { for (auto a : tree[k]) { for (auto b : tree[k]) { p2[a][b] = 1; } } for (int k2 = k+1; k2 < tree.size(); k2++) { for (auto a : tree[k]) { for (auto b : tree[k2]) { p2[a][b] = 2; p2[b][a] = 2; } } } } } /* else { forint(j, n) { if (p[i][j] != p[coor[i]][j]) { return 0; } } } */ } forint(i, n) { forint(j, n) { if (p[i][j] != p2[i][j]) { //cerr << i << " " << j << "---" << p2[i][j] << endl; return 0; } } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for (int k = 0; k < tmp.size(); k++) {
      |                    ~~^~~~~~~~~~~~
supertrees.cpp:77:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |      for (int k2 = k+1; k2 < tmp.size(); k2++) {
      |                         ~~~^~~~~~~~~~~~
supertrees.cpp:104:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |    for (int k = 0; k < tree.size(); k++) {
      |                    ~~^~~~~~~~~~~~~
supertrees.cpp:112:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |     for (int k2 = k+1; k2 < tree.size(); k2++) {
      |                        ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...