제출 #366899

#제출 시각아이디문제언어결과실행 시간메모리
366899rumen_m슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
3 ms620 KiB
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int maxn = 1005; vector <vector <int> > g; vector <vector <int> > ones; short id[maxn], ids = 0; bool vis[maxn]; vector <vector <int> > groups; //short ans[maxn][maxn]; vector <vector <int> > ans; short newids[maxn]; void dfs(int v) { id[v]=ids; int i; for(i=0;i<g[v].size();i++) { if(id[g[v][i]]==0)dfs(g[v][i]); } } void solve(int v) { newids[v] = ids; vis[v] = 1; int i; for(i=0;i<ones[v].size();i++) { if(!vis[ones[v][i]]) { ans[v][ones[v][i]] = 1; solve(ones[v][i]); } } } int construct(std::vector<std::vector<int>> p) { int n = p.size(); ans.resize(n); g.resize(n); ones.resize(n); groups.resize(n); int i,j,t; for(i=0;i<n;i++) ans[i].resize(n); for(i=0;i<n;i++) for(j=0;j<n;j++) { if(i==j)continue; if(p[i][j]==3)return 0; if(p[i][j]>0) { /* for(t=0;t<n;t++) { if((p[i][t]>0)^(p[j][t]>0)==1)return 0; if(p[i][j]==1) if(p[i][t]==1^p[j][t]==1)return 0; }*/ } if(p[i][j]!=0) { g[i].push_back(j); g[j].push_back(i); } if(p[i][j]==1) { ones[i].push_back(j); ones[j].push_back(i); } } for(i=0;i<n;i++) { if(id[i]==0){ids++;dfs(i);} } for(i=0;i<n;i++) { if(!vis[i]) { groups[id[i]].push_back(i); ids++; solve(i); } } for(i=1;i<=ids;i++) { if(groups[i].size()==2)return 0; if(groups[i].size()<=2)continue; ans[groups[i][0]][groups[i][groups[i].size()-1]] = 1; for(j=1;j<groups[i].size();j++) { ans[groups[i][j-1]][groups[i][j]] = 1; } } ///std::vector<std::vector<int>> answer; for (int i = 0; i < n; i++) { //std::vector<int> row; //row.resize(n); for(j=0;j<n;j++) { // row[j] = ans[i][j]|ans[j][i]; ans[i][j] = ans[i][j]|ans[j][i]; if(i==j)continue; if(p[i][j]==0&&id[i]==id[j]){return 0;} if(p[i][j]==1&&newids[i]!=newids[j])return 0; } //answer.push_back(row); } build(ans); return 1; }

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

supertrees.cpp: In function 'void dfs(int)':
supertrees.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(i=0;i<g[v].size();i++)
      |             ~^~~~~~~~~~~~
supertrees.cpp: In function 'void solve(int)':
supertrees.cpp:28:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(i=0;i<ones[v].size();i++)
      |             ~^~~~~~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:90:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for(j=1;j<groups[i].size();j++)
      |                 ~^~~~~~~~~~~~~~~~~
supertrees.cpp:43:10: warning: unused variable 't' [-Wunused-variable]
   43 |  int i,j,t;
      |          ^
#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...