제출 #572161

#제출 시각아이디문제언어결과실행 시간메모리
572161fuad27슈퍼트리 잇기 (IOI20_supertrees)C++17
46 / 100
216 ms23996 KiB
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> using namespace std; int construct(std::vector<std::vector<int>> p) { int n = p.size(); for(int i = 0;i<n;i++) { long long cnt = 0; for(int j = 0;j<n;j++) { if(p[i][j] == 3 or p[i][j]!=p[j][i])return 0; if(p[i][j] == 2)cnt++; } if(cnt == 1)return 0; } vector<vector<int>> ans(n,vector<int> (n,0)); { vector<bool> vis(n); vector<int> t; for(int i = 0;i<n;i++) { if(vis[i])continue; vector<int> cur; for(int j = 0;j<n;j++) { if(p[i][j] == 1) { cur.push_back(j); vis[j]=1; } } for(int j = 0;j<(int)cur.size()-1;j++) { ans[cur[j]][cur[j+1]]=1; ans[cur[j+1]][cur[j]]=1; } t.push_back(i); } for(int i = 0;i<n;i++)vis[i]=0; vector<int> cur; vector<int> beg; for(int j:t) { bool flag = 0; for(int &i:cur) { if(p[j][i] == 2) { ans[i][j] = ans[j][i] = 1; i = j; flag=1; break; } } if(!flag){ cur.push_back(j); beg.push_back(j); } } for(int i = 0;i<cur.size();i++) { if(cur[i]!=beg[i] and p[cur[i]][beg[i]] == 1)return 0; if(cur[i]!=beg[i]) { ans[cur[i]][beg[i]] = ans[beg[i]][cur[i]] = 1; } } } build(ans); return 1; }

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

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