제출 #405044

#제출 시각아이디문제언어결과실행 시간메모리
405044ly20슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
2 ms464 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int comp[MAXN]; vector <int> grafo[MAXN]; int marc[MAXN]; int cmp; //vector <int> grafo2[MAXN]; vector <int> cat; int dfs(int v) { marc[v] = 1; comp[v] = cmp; for(int i = 0; i < grafo[v].size(); i++) { int viz = grafo[v][i]; if(marc[viz] == 1) continue; dfs(viz); } } int resp[MAXN][MAXN]; int rep[MAXN]; vector <int> cic; vector <vector <int> > answer; int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer; for(int i = 0; i < n; i++) { comp[i] = i; } for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] == 1) { grafo[i].push_back(j); grafo[j].push_back(i); } } } for(int i = 0; i < n; i++) { if(marc[i] == 0) { dfs(i); cmp++; } } for(int i = 0; i < cmp; i++) { vector <int> ln; for(int j = 0; j < n; j++) if(comp[j] == i) ln.push_back(j); int m = ln.size(); for(int j = 0; j < m; j++) { int cur = ln[j]; for(int k = j + 1; k < m; k++) { int tst = ln[k]; if(p[cur][tst] != 1) { return 0; } } } for(int j = 0; j < m - 1; j++) { int pr = j + 1; resp[ln[j]][ln[pr]] = 1; resp[ln[pr]][ln[j]] = 1; } } for (int i = 0; i < n; i++) { vector<int> row; for(int j = 0; j < n; j++) { row.push_back(resp[i][j]); } answer.push_back(row); } build(answer); return 1; }

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

supertrees.cpp: In function 'int dfs(int)':
supertrees.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
supertrees.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
#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...