Submission #672611

#TimeUsernameProblemLanguageResultExecution timeMemory
672611tbzardConnecting Supertrees (IOI20_supertrees)C++14
11 / 100
228 ms22032 KiB
#include <bits/stdc++.h> using namespace std; void build(vector<vector<int> > b); bool vis[1002]; int construct(vector<vector<int> > p) { int n = (int)p.size(); vector<vector<int> > ans(n); for(int i=0;i<n;i++) ans[i].resize(n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j] == 3) return 0; } } for(int i=0;i<n;i++){ if(vis[i]) continue; vis[i] = 1; vector<int> c; for(int j=i+1;j<n;j++){ if(p[i][j] == 0) continue; c.push_back(j); p[p[i][j]].push_back(j); vis[j] = 1; } vector<int> x; vector<vector<int> > y; queue<int> q; q.push(i); while(!q.empty()){ int u = q.front(); q.pop(); vis[u] = 1; bool use = 0; x.push_back(u); vector<int> z; for(int v=u+1;v<n;v++){ if(p[u][v] == 0) continue; if(p[u][v] == 1){ ans[u][v] = 1; ans[v][u] = 1; vis[v] = 1; z.push_back(v); } else if(!use){ use = 1; q.push(v); } } y.push_back(z); } for(int i=0;i<y.size();i++){ for(int j=0;j<y[i].size();j++){ for(int k=j+1;k<y[i].size();k++){ if(p[y[i][j]][y[i][k]] != 1) return 0; } } for(int j=0;j<x.size();j++){ if(i == j) continue; for(int k=0;k<y[i].size();k++){ if(p[x[j]][y[i][k]] != 2) return 0; } } for(int j=0;j<y.size();j++){ if(i == j) continue; for(int a=0;a<y[i].size();a++){ for(int b=0;b<y[j].size();b++){ if(p[y[i][a]][y[j][b]] != 2) return 0; } } } } for(int i=0;i<x.size();i++){ for(int j=i+1;j<x.size();j++){ if(p[x[i]][x[j]] != 2) return 0; } } for(int i=0;i<(int)x.size()-1;i++){ ans[x[i]][x[i+1]] = 1; ans[x[i+1]][x[i]] = 1; } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int i=0;i<y.size();i++){
      |                     ~^~~~~~~~~
supertrees.cpp:54:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for(int j=0;j<y[i].size();j++){
      |                         ~^~~~~~~~~~~~
supertrees.cpp:55:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                 for(int k=j+1;k<y[i].size();k++){
      |                               ~^~~~~~~~~~~~
supertrees.cpp:59:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for(int j=0;j<x.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:61:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                 for(int k=0;k<y[i].size();k++){
      |                             ~^~~~~~~~~~~~
supertrees.cpp:65:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             for(int j=0;j<y.size();j++){
      |                         ~^~~~~~~~~
supertrees.cpp:67:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |                 for(int a=0;a<y[i].size();a++){
      |                             ~^~~~~~~~~~~~
supertrees.cpp:68:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |                     for(int b=0;b<y[j].size();b++){
      |                                 ~^~~~~~~~~~~~
supertrees.cpp:74:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |         for(int i=0;i<x.size();i++){
      |                     ~^~~~~~~~~
supertrees.cpp:75:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |             for(int j=i+1;j<x.size();j++){
      |                           ~^~~~~~~~~
#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...