Submission #949995

#TimeUsernameProblemLanguageResultExecution timeMemory
949995irmuunConnecting Supertrees (IOI20_supertrees)C++17
21 / 100
174 ms24144 KiB
#include<bits/stdc++.h> #include "supertrees.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int construct(vector<vector<int>>p){ int n=p.size(); bool a[4]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j) continue; a[p[i][j]]=true; } } vector<vector<int>>b(n,vector<int>(n,0)); if(!a[2]&&!a[3]){ vector<bool>used(n,0); vector<int>ver; for(int i=0;i<n;i++){ if(!used[i]){ queue<int>q; q.push(i); used[i]=true; while(!q.empty()){ int x=q.front(); ver.pb(x); q.pop(); for(int j=0;j<n;j++){ if(p[x][j]==1&&!used[j]){ used[j]=true; q.push(j); } } } for(auto x:ver){ for(auto y:ver){ if(x!=y&&p[x][y]!=1){ return 0; } } } for(int j=1;j<ver.size();j++){ b[ver[j]][ver[j-1]]=1; b[ver[j-1]][ver[j]]=1; } ver.clear(); } } build(b); return 1; } if(!a[1]&&!a[3]){ vector<bool>used(n,0); vector<int>ver; for(int i=0;i<n;i++){ if(!used[i]){ queue<int>q; q.push(i); used[i]=true; while(!q.empty()){ int x=q.front(); ver.pb(x); q.pop(); for(int j=0;j<n;j++){ if(p[x][j]==2&&!used[j]){ used[j]=true; q.push(j); } } } for(auto x:ver){ for(auto y:ver){ if(x!=y&&p[x][y]!=2){ return 0; } } } for(int j=1;j<ver.size();j++){ b[ver[j]][ver[j-1]]=1; b[ver[j-1]][ver[j]]=1; } if(ver.size()>1){ b[ver[0]][ver.back()]=1; b[ver.back()][ver[0]]=1; } ver.clear(); } } build(b); return 1; } return 0; }

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:49:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |                 for(int j=1;j<ver.size();j++){
      |                             ~^~~~~~~~~~~
supertrees.cpp:85:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |                 for(int j=1;j<ver.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...