제출 #1018990

#제출 시각아이디문제언어결과실행 시간메모리
1018990Mardonbekhazratov슈퍼트리 잇기 (IOI20_supertrees)C++17
21 / 100
129 ms22100 KiB
#include "supertrees.h" #include <vector> using namespace std; int n; bool ok; vector<int>in; vector<vector<int>>v,comp; vector<bool>vis; bool dfs(int x){ comp[in[x]].push_back(x); vis[x]=true; for(int i=x+1;i<n;i++){ if(v[x][i]){ if(vis[i] && in[i]!=in[x]){ return 0; } if(vis[i]) continue; in[i]=in[x]; if(!dfs(i)) return 0; } } return 1; } int construct(vector<vector<int>> p) { swap(p,v); n=v.size(); in.resize(n); vis.assign(n,false); ok=true; for(int i=0;i<n;i++){ if(!vis[i]){ in[i]=comp.size(); comp.push_back({}); if(!dfs(i)) return 0; } } if(!ok) return 0; vector<vector<int>>ans(n,vector<int>(n,0)); for(auto g:comp){ for(int i=1;i<g.size();i++){ ans[g[i]][g[i-1]]=ans[g[i-1]][g[i]]=1; for(int j=0;j<i;j++){ if(v[g[i]][g[j]]==0) return 0; } // if(v[g[i]][g[i-1]]==2 && i==g.size()-1) ans[g[i]][g[0]]=ans[g[0]][g[i]]=1; } } build(ans); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

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