Submission #301406

#TimeUsernameProblemLanguageResultExecution timeMemory
301406qiangbaoConnecting Supertrees (IOI20_supertrees)C++14
46 / 100
250 ms26232 KiB
#include <iostream> #include <vector> #include "supertrees.h" #define pb push_back using namespace std; int n; vector<vector<int> > a; int vis[1001], vis2[1001]; vector<int> belong; int gp[1001], gplwch[1001]; vector<int> gpl; int fans=1; vector<int> plamt; vector<vector<int> > ans; void dfs(int x) { int i; vis[x]=1, belong.pb(x); for(i=0;i<n;i++) if(a[x][i] && !vis[i]) vis[i]=1, dfs(i); } void wk2() { int i, j; for(i=0;i<belong.size();i++){ int f=belong[i]; if(!vis2[f]){ vis2[f]=true; gp[f]=i, gpl.pb(f), gplwch[i]=f; for(j=0;j<n;j++) if(a[f][j]==1) gp[j]=i, vis2[j]=true; } } // circle if(gpl.size()>=2){ for(i=0;i<gpl.size();i++) ans[gpl[i]][gpl[(i+1)%gpl.size()]]=ans[gpl[(i+1)%gpl.size()]][gpl[i]]=1; } for(i=0;i<belong.size();i++){ int f=belong[i], f2=gp[f]; if(gplwch[f2]!=f) ans[f][gplwch[f2]]=ans[gplwch[f2]][f]=1; } } void ck() { } void wk() { int i; for(i=0;i<n;i++) if(!vis[i]){ belong.clear(); dfs(i); gpl.clear(); wk2(); ck(); } } int construct(vector<vector<int> > p) { int three=0; int i, j; a=p; n=p.size(); for(i=0;i<n;i++) plamt.pb(0); for(i=0;i<n;i++) ans.pb(plamt); for(i=0;i<n;i++) for(j=0;j<n;j++) if(a[i][j]==3) three=1; if(three) fans=0; else wk(); if(fans) build(ans); return fans; } //int main() //{ // construct({{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}); // // return 0; //}

Compilation message (stderr)

supertrees.cpp: In function 'void wk2()':
supertrees.cpp:35:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(i=0;i<belong.size();i++){
      |             ~^~~~~~~~~~~~~~
supertrees.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(i=0;i<gpl.size();i++)
      |                 ~^~~~~~~~~~~
supertrees.cpp:50:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(i=0;i<belong.size();i++){
      |             ~^~~~~~~~~~~~~~
#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...