제출 #601195

#제출 시각아이디문제언어결과실행 시간메모리
601195yutabi슈퍼트리 잇기 (IOI20_supertrees)C++14
96 / 100
262 ms24184 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer(n,vector <int> (n,0)); vector <bool> v(n,0); vector <vector <int> > graphs; for(int i=0;i<n;i++) { if(v[i]==0) { graphs.pb({}); stack <int> st; st.push(i); while(st.size()) { int node=st.top(); st.pop(); v[node]=1; graphs.back().pb(node); for(int j=0;j<n;j++) { if(node!=j && p[node][j]>0 && v[j]==0) { st.push(j); v[j]=1; } } } } } for(int i=0;i<graphs.size();i++) { for(int j=0;j<graphs[i].size();j++) { for(int k=j+1;k<graphs[i].size();k++) { if(p[graphs[i][j]][graphs[i][k]]==0) { return 0; } } } vector <vector <int> > trees; v=vector <bool> (graphs[i].size(),0); for(int j=0;j<graphs[i].size();j++) { if(v[j]==0) { trees.pb({}); stack <int> st; st.push(j); while(st.size()) { int node=st.top(); st.pop(); v[node]=1; trees.back().pb(graphs[i][node]); for(int k=0;k<graphs[i].size();k++) { if(node!=k && p[graphs[i][node]][graphs[i][k]]==1 && v[k]==0) { st.push(k); v[k]=1; } } } } } if(trees.size()==2) { return 0; } for(int j=0;j<trees.size();j++) { for(int k=0;k<trees[j].size();k++) { for(int l=k+1;l<trees[j].size();l++) { if(p[trees[j][k]][trees[j][l]]!=1) { return 0; } } } } for(int j=0;j<trees.size();j++) { for(int k=0;k+1<trees[j].size();k++) { answer[trees[j][k]][trees[j][k+1]]=1; answer[trees[j][k+1]][trees[j][k]]=1; } answer[trees[(j)%trees.size()][0]][trees[(j+1)%trees.size()][0]]=1; answer[trees[(j+1)%trees.size()][0]][trees[(j)%trees.size()][0]]=1; } } for(int i=0;i<n;i++) { answer[i][i]=0; } build(answer); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:49:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i=0;i<graphs.size();i++)
      |              ~^~~~~~~~~~~~~~
supertrees.cpp:51:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int j=0;j<graphs[i].size();j++)
      |               ~^~~~~~~~~~~~~~~~~
supertrees.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |    for(int k=j+1;k<graphs[i].size();k++)
      |                  ~^~~~~~~~~~~~~~~~~
supertrees.cpp:66:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int j=0;j<graphs[i].size();j++)
      |               ~^~~~~~~~~~~~~~~~~
supertrees.cpp:84:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |      for(int k=0;k<graphs[i].size();k++)
      |                  ~^~~~~~~~~~~~~~~~~
supertrees.cpp:101:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |   for(int j=0;j<trees.size();j++)
      |               ~^~~~~~~~~~~~~
supertrees.cpp:103:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |    for(int k=0;k<trees[j].size();k++)
      |                ~^~~~~~~~~~~~~~~~
supertrees.cpp:105:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |     for(int l=k+1;l<trees[j].size();l++)
      |                   ~^~~~~~~~~~~~~~~~
supertrees.cpp:115:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |   for(int j=0;j<trees.size();j++)
      |               ~^~~~~~~~~~~~~
supertrees.cpp:117:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |    for(int k=0;k+1<trees[j].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...