제출 #411066

#제출 시각아이디문제언어결과실행 시간메모리
411066eagle30슈퍼트리 잇기 (IOI20_supertrees)C++17
컴파일 에러
0 ms0 KiB
#include "supertrees.h" #include<bits/stdc++.h> using namespace std; int visited[2000]; vector<vector<int> > adjlist; int coun=1; void dfs(int s){ visited[s]=coun; for(int i=0; i<adjlist[s].size(); i++){ int v=adjlist[s][i]; if(visited[v]==0) dfs(v); } } int construct(vector<vector<int> > p) { int n = p.size(); adjlist.assign(n+1, vector<int>()); for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(p[i][j]){ adjlist[i].push_back(j); adjlist[j].push_back(i); } } } for(int i=0; i<n; i++){ if(visited[i]==0){ dfs(i); coun++; } } for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(visited[i]==visited[j] && p[i][j]==0) return 0; } } vector<vector<int> > answer; answer.assign(n, vector<int>()); for(int i=0; i<n; i++) answer[i].assign(n, 0); map<int, vector<int> > mp; for(int i=0; i<n; i++) mp[visited[i]].push_back(i); for(auto x:mp){ for(int i=1; i<x.second.size(); i++){ answer[x.second[i-1]][x.second[i]]=1; answer[x.second[i]][x.second[i-1]]=1; } if(k==2 && x.size()>1){ answer[0][x.second[x.second.size()-1]]=1; answer[x.second[x.second.size()-1]][0]=1; } } build(answer); return 1; }

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

supertrees.cpp: In function 'void dfs(int)':
supertrees.cpp:9:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0; i<adjlist[s].size(); i++){
      |               ~^~~~~~~~~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for(int i=1; i<x.second.size(); i++){
      |                ~^~~~~~~~~~~~~~~~
supertrees.cpp:50:6: error: 'k' was not declared in this scope
   50 |   if(k==2 && x.size()>1){
      |      ^
supertrees.cpp:50:16: error: 'struct std::pair<const int, std::vector<int> >' has no member named 'size'
   50 |   if(k==2 && x.size()>1){
      |                ^~~~