제출 #309047

#제출 시각아이디문제언어결과실행 시간메모리
309047tjdgus4384슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "supertrees.h" using namespace std; vector<int> graph[1001], trees[1001]; vector<vector<int> > b, P, newp; vector<int> v[1001]; vector<int> sametree; bool visited[1001]; void dfs(int x, int cnt){ graph[cnt].push_back(x); for(int i = 0;i < v[x].size();i++){ if(visited[v[x][i]]) continue; visited[v[x][i]] = true; dfs(v[x][i], cnt); } } void make_tree(int x){ for(int i = 0;i < v[x].size();i++){ if(visited[v[x][i]]) continue; if(P[x][v[x][i]] != 1) continue; visited[v[x][i]] = true; sametree.push_back(v[x][i]); make_tree(v[x][i]); b[x][v[x][i]] = 1; b[v[x][i]][x] = 1; } } void build(vector<vector<int> > b){ for(int i = 0;i < b.size();i++){ for(int j = 0;j < b.size();j++){ printf("%d ", b[i][j]); } printf("\n"); } } int construct(vector<vector<int> > p){ P = p; b.resize(p.size()); newp.resize(p.size()); for(int i = 0;i < p.size();i++){ b[i].resize(p.size()); newp[i].resize(p.size()); for(int j = 0;j < p.size();j++){ if(i == j) continue; if(p[i][j]) v[i].push_back(j); if(p[i][j] == 3) return 0; } } int cnt = 0; for(int i = 0;i < p.size();i++){ if(visited[i]) continue; visited[i] = true; dfs(i, cnt); cnt++; } for(int i = 0;i < p.size();i++) visited[i] = false; for(int i = 0;i < cnt;i++){ vector<int> nv; for(int j = 0;j < graph[i].size();j++){ if(visited[graph[i][j]]) continue; visited[graph[i][j]] = true; sametree.push_back(graph[i][j]); make_tree(graph[i][j]); for(int x1 = 0;x1 < sametree.size();x1++){ for(int x2 = 0;x2 < sametree.size();x2++){ if(x1 == x2) continue; newp[sametree[x1]][sametree[x2]] = newp[sametree[x2]][sametree[x1]] = 1; } } sametree.clear(); nv.push_back(graph[i][j]); } if(nv.size() <= 1) continue; if(nv.size() <= 2) return 0; for(int j = 0;j < nv.size() - 1;j++){ b[nv[j]][nv[j+1]] = 1; b[nv[j+1]][nv[j]] = 1; } for(int x1 = 0;x1 < nv.size();x1++){ for(int x2 = 0;x2 < graph[i].size();x2++){ if(nv[x1] == graph[i][x2]) continue; if(newp[nv[x1]][graph[i][x2]]) continue; newp[nv[x1]][graph[i][x2]] = newp[graph[i][x2]][nv[x1]] = 2; } } for(int x1 = 0;x1 < graph[i].size();x1++){ for(int x2 = 0;x2 < graph[i].size();x2++){ if(graph[i][x1] == graph[i][x2]) continue; if(newp[graph[i][x1]][graph[i][x2]]) continue; newp[graph[i][x1]][graph[i][x2]] = newp[graph[i][x2]][graph[i][x1]] = 2; } } b[nv[0]][nv.back()] = 1; b[nv.back()][nv[0]] = 1; } for(int i = 0;i < p.size();i++){ for(int j = 0;j < p.size();j++){ if(i == j) continue; if(p[i][j] != newp[i][j]) return 0; } } build(b); return 1; }

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

supertrees.cpp: In function 'void dfs(int, int)':
supertrees.cpp:12:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0;i < v[x].size();i++){
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp: In function 'void make_tree(int)':
supertrees.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0;i < v[x].size();i++){
      |                   ~~^~~~~~~~~~~~~
supertrees.cpp: In function 'void build(std::vector<std::vector<int> >)':
supertrees.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 0;i < b.size();i++){
      |                   ~~^~~~~~~~~~
supertrees.cpp:33:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j = 0;j < b.size();j++){
      |                       ~~^~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0;i < p.size();i++){
      |                   ~~^~~~~~~~~~
supertrees.cpp:47:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int j = 0;j < p.size();j++){
      |                       ~~^~~~~~~~~~
supertrees.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i = 0;i < p.size();i++){
      |                   ~~^~~~~~~~~~
supertrees.cpp:59:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i = 0;i < p.size();i++) visited[i] = false;
      |                   ~~^~~~~~~~~~
supertrees.cpp:62:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j = 0;j < graph[i].size();j++){
      |                       ~~^~~~~~~~~~~~~~~~~
supertrees.cpp:67:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             for(int x1 = 0;x1 < sametree.size();x1++){
      |                            ~~~^~~~~~~~~~~~~~~~~
supertrees.cpp:68:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |                 for(int x2 = 0;x2 < sametree.size();x2++){
      |                                ~~~^~~~~~~~~~~~~~~~~
supertrees.cpp:78:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         for(int j = 0;j < nv.size() - 1;j++){
      |                       ~~^~~~~~~~~~~~~~~
supertrees.cpp:82:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |         for(int x1 = 0;x1 < nv.size();x1++){
      |                        ~~~^~~~~~~~~~~
supertrees.cpp:83:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |             for(int x2 = 0;x2 < graph[i].size();x2++){
      |                            ~~~^~~~~~~~~~~~~~~~~
supertrees.cpp:89:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         for(int x1 = 0;x1 < graph[i].size();x1++){
      |                        ~~~^~~~~~~~~~~~~~~~~
supertrees.cpp:90:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for(int x2 = 0;x2 < graph[i].size();x2++){
      |                            ~~~^~~~~~~~~~~~~~~~~
supertrees.cpp:99:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |     for(int i = 0;i < p.size();i++){
      |                   ~~^~~~~~~~~~
supertrees.cpp:100:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |         for(int j = 0;j < p.size();j++){
      |                       ~~^~~~~~~~~~
/tmp/ccvDHd4O.o: In function `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
grader.cpp:(.text+0x1d0): multiple definition of `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/tmp/ccNSBFUO.o:supertrees.cpp:(.text+0x90): first defined here
collect2: error: ld returned 1 exit status