제출 #625300

#제출 시각아이디문제언어결과실행 시간메모리
625300Trunkty슈퍼트리 잇기 (IOI20_supertrees)C++14
19 / 100
230 ms24084 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; //#define int ll #include "supertrees.h" int root[1005]; vector<int> ans[1005]; int findroot(int x){ if(root[x]!=x){ root[x] = findroot(root[x]); } return root[x]; } void domerge(int a, int b){ a = findroot(a); b = findroot(b); root[a] = b; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> ret; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); ret.push_back(row); } for(int i=0;i<n;i++){ root[i] = i; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]){ domerge(i,j); } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(p[i][j]==0 and findroot(i)==findroot(j)){ return 0; } } } for(int i=0;i<n;i++){ ans[findroot(i)].push_back(i); } for(int i=0;i<n;i++){ for(int j=1;j<ans[i].size();j++){ ret[ans[i][j-1]][ans[i][j]] = 1; ret[ans[i][j]][ans[i][j-1]] = 1; } if(ans[i].size()<=1){ continue; } else if(ans[i].size()==2){ return 0; } else{ ret[ans[i][0]][ans[i].back()] = 1; ret[ans[i].back()][ans[i][0]] = 1; } } build(ret); return 1; }

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

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