제출 #384731

#제출 시각아이디문제언어결과실행 시간메모리
384731nicholask슈퍼트리 잇기 (IOI20_supertrees)C++14
21 / 100
285 ms22252 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; int construct(vector <vector <int> > p){ int n=p.size(); vector <vector <int> > ans(n,vector<int>(n,0)); vector <pair <int,vector <int> > > ones; bool d[n]; int cnt=0; int belong[n]; for (int i=0; i<n; i++) d[i]=0; for (int i=0; i<n; i++){ if (d[i]) continue; vector <int> v; for (int j=i; j<n; j++){ if (p[i][j]==1){ if (d[j]) return 0; d[j]=1; v.push_back(j); } } for (int j=0; j<v.size()-1; j++) ans[v[j]][v[j+1]]=1; ones.push_back({cnt,v}); for (auto&j:v) belong[j]=cnt; cnt++; } cnt=0; int bigbelong[n]; for (int i=0; i<n; i++) bigbelong[i]=0; int nway[n]; for (int i=0; i<n; i++) nway[i]=0; bool e[ones.size()]; for (int i=0; i<ones.size(); i++) e[i]=0; for (int i=0; i<ones.size(); i++){ if (e[i]) continue; vector <int> temp; temp.push_back(ones[i].y.front()); for (int j=i+1; j<ones.size(); j++){ if (!e[j]&&p[ones[i].y.front()][ones[j].y.front()]==2){ temp.push_back(ones[j].y.front()); e[j]=1; } } for (auto&j:ones[i].y) bigbelong[j]=cnt; int ss=temp.size(); if (ss<3){ nway[cnt]=1; cnt++; continue; } for (int j=0; j<temp.size(); j++) ans[temp[j]][temp[(j+1)%ss]]=1; nway[cnt]=2; cnt++; } for (int i=0; i<n; i++){ for (int j=i+1; j<n; j++){ if (p[i][j]==0){ if (bigbelong[i]==bigbelong[j]) return 0; } else if (p[i][j]==1){ if (belong[i]!=belong[j]&&(bigbelong[i]!=bigbelong[j]||nway[bigbelong[i]]!=1)) return 0; } else if (p[i][j]==2){ if (belong[i]==belong[j]||bigbelong[i]!=bigbelong[j]||nway[bigbelong[i]]!=2) return 0; } } } for (int i=0; i<n; i++){ for (int j=0; j<n; j++){ if (ans[j][i]) ans[i][j]=1; } } build(ans); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int j=0; j<v.size()-1; j++) ans[v[j]][v[j+1]]=1;
      |                 ~^~~~~~~~~~~
supertrees.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (int i=0; i<ones.size(); i++) e[i]=0;
      |                ~^~~~~~~~~~~~
supertrees.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i=0; i<ones.size(); i++){
      |                ~^~~~~~~~~~~~
supertrees.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for (int j=i+1; j<ones.size(); j++){
      |                   ~^~~~~~~~~~~~
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 j=0; j<temp.size(); j++) ans[temp[j]][temp[(j+1)%ss]]=1;
      |                 ~^~~~~~~~~~~~
#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...