제출 #431095

#제출 시각아이디문제언어결과실행 시간메모리
431095Hazem슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms332 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int N = 2e3+10; vector<int>adj[N],vec; vector<vector<int>>adjans; int n,vis[N]; void dfs(int i){ if(vis[i]) return ; vis[i] = 1; vec.push_back(i); for(auto x:adj[i]) dfs(x); } int construct(std::vector<std::vector<int>> p) { n = p.size(); adjans = vector<vector<int>>(n,vector<int>(n,0)); for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(p[i][j]){ adj[i].push_back(j); adj[j].push_back(i); } bool ans = 1; for(int i=0;i<n;i++){ dfs(i);bool q = 1; if(vec.size()<=1)continue; for(int j=0;j<vec.size();j++) for(int k=j+1;k<vec.size();k++) q &= p[vec[j]][vec[k]]==2; q &= !vec.size()||vec.size()>2; for(int j=0;j<(int)vec.size()-1;j++) adjans[vec[j]][vec[j+1]] = adjans[vec[j+1]][vec[j]] = 1; adjans[vec[0]][vec.back()] = adjans[vec.back()][vec[0]] = 1; vec.clear(); ans &= q; } if(!ans) return 0; build(adjans); return 1; }

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

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