제출 #927673

#제출 시각아이디문제언어결과실행 시간메모리
927673RifalConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
0 ms348 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define endl '\n' using namespace std; const int M = 1e3 + 4; int typ[M]; vector<int> v1[M], v2[M]; vector<vector<int>> gr; bool egd[M][M]; int cnt = 1; int construct(std::vector<std::vector<int>> p) { bool ok = true; int n = p.size(); for(int i = 0; i < n; i++) { if(typ[i] == 0) { typ[i] = cnt; v1[cnt].push_back(i); v2[cnt].push_back(i); cnt++; } for(int j = 0; j < n; j++) { if(j == i) continue; if(p[i][j] == 1) { if(typ[j] == 0) { v1[typ[i]].push_back(j); typ[j] = typ[i]; } else if(typ[j] != typ[i]){ ok = false; break; } } else if(p[i][j] == 2){ if(typ[j] == 0) { v2[typ[i]].push_back(j); typ[j] = typ[i]; } else if(typ[j] != typ[i]){ ok = false; break; } } else if(p[i][j] == 0 && typ[i] == typ[j]) { ok = false; break; } } if(!ok) break; } for(int i = 0; i < n; i++) cout << typ[i] << ' '; cout << endl; if(ok) { for(int i = 1; i < cnt; i++) { if(v1[i].size() > 1) { for(int j = 1; j < v1[i].size(); j++) { egd[v1[i][0]][v1[i][j]] = 1; egd[v1[i][j]][v1[i][0]] = 1; } } if(v2[i].size() > 1) { for(int j = 1; j < v2[i].size(); j++) { egd[v2[i][j]][v2[i][j-1]] = 1; egd[v2[i][j-1]][v2[i][j]] = 1; } int siz = v2[i].size(); egd[v2[i][0]][v2[i][siz-1]] = 1; egd[v2[i][siz-1]][v2[i][0]] = 1; } } for(int i = 0; i < n; i++) { // cout << 'i' << i << endl; vector<int> cur; for(int j = 0; j < n; j++) { //cout << 'j' << ' ' << j << ' ' << egd[i][j] << endl; cur.push_back(egd[i][j]); } gr.push_back(cur); } build(gr); return 1; } else { return 0; } }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int j = 1; j < v1[i].size(); j++) {
      |                    ~~^~~~~~~~~~~~~~
supertrees.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int j = 1; j < v2[i].size(); j++) {
      |                    ~~^~~~~~~~~~~~~~
#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...