Submission #672561

#TimeUsernameProblemLanguageResultExecution timeMemory
672561tbzardConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
1 ms212 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++){ if(vis[i]) continue; vector<int> c1, c2; for(int j=i+1;j<n;j++){ if(p[i][j] == 1){ c1.push_back(j); vis[j] = 1; } } for(int j=i+1;j<n;j++){ if(p[i][j] == 2){ c2.push_back(j); vis[j] = 1; } } if((int)c2.size() == 1) return 0; for(int k=0;k<n;k++){ if(vis[k]) continue; for(int j=0;j<(int)c1.size();j++){ if(p[c1[j]][k] != 0) return 0; } for(int j=0;j<(int)c2.size();j++){ if(p[c2[j]][k] != 0) return 0; } } for(int j=0;j<(int)c1.size();j++){ for(int k=0;k<(int)c1.size();k++){ if(j == k) continue; if(p[c1[j]][c1[k]] != 1) return 0; } } for(int j=0;j<c1.size();j++){ for(int k=0;k<(int)c2.size();k++){ if(p[c1[j]][c2[k]] != 2) return 0; } } for(int j=0;j<(int)c2.size();j++){ for(int k=0;k<(int)c2.size();k++){ if(j == k) continue; if(p[c2[j]][c2[k]] != 2) return 0; } } for(int j=0;j<(int)c1.size();j++){ ans[i][c1[j]] = 1; ans[c1[j]][i] = 1; } if((int)c2.size() > 1){ ans[i][c2[0]] = 1; ans[c2[0]][i] = 1; ans[i][c2[c2.size()-1]] = 1; ans[c2[c2.size()-1]][i] = 1; for(int j=0;j<(int)c2.size()-1;j++){ ans[c2[j]][c2[j+1]] = 1; ans[c2[j+1]][c2[j]] = 1; } } } build(ans); return 1; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int j=0;j<c1.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...