제출 #306446

#제출 시각아이디문제언어결과실행 시간메모리
306446giorgikob슈퍼트리 잇기 (IOI20_supertrees)C++14
56 / 100
257 ms22264 KiB
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; const int N = 1e3+5; vector<int>c[N]; int cnt = 0, n; int fix[N]; vector<int>chain; void dfs(int x,vector<vector<int>>&p){ fix[x] = 1; //cout << x << endl; c[cnt].pb(x); for(int i = 0; i < n; i++){ if(fix[i]) continue; if(p[x][i]){ dfs(i,p); } } } void dfs1(int x,vector<vector<int>>&p){ fix[x] = 1; //c[cnt].pb(x); chain.pb(x); //cout << x << endl; for(int i = 0; i < n; i++){ //cout << fix[i] << " "; if(fix[i]) continue; if(p[x][i] == 1){ dfs1(i,p); } } //cout << endl; } bool check(vector<int>&v, vector<vector<int>>&p){ for(int i = 0; i < (int)v.size(); i++){ for(int j = 0; j < (int)v.size(); j++){ if(p[v[i]][v[j]] == 2){ return 0; } } } return 1; } void cr(int x,int y,vector<vector<int>>&v){ v[x][y] = 1; v[y][x] = 1; } int construct(std::vector<std::vector<int>> p) { n = p.size(); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j] == 3){ return 0; } } } for(int i = 0; i < n; i++){ if(fix[i]) continue; cnt++;//cout << i << endl; dfs(i,p); } for(int i = 0; i < n; i++) fix[i] = 0; for(int i = 1; i <= cnt; i++){ for(int j = 0; j < c[i].size(); j++){ for(int t = 0; t < c[i].size(); t++){ if(p[c[i][j]][c[i][t]] == 0){ return 0; } } } } vector<vector<int>>answer(n,vector<int>(n,0)); vector<int>cyc; for(int i = 1; i <= cnt; i++){ for(int j = 0; j < c[i].size(); j++){ int x = c[i][j]; if(fix[x]) continue; chain.clear(); dfs1(x,p); if(check(chain,p) == 0){ return 0; } for(int t = 0; t+1 < chain.size(); t++){ int x = chain[t]; int y = chain[t+1]; cr(x,y,answer); } cyc.pb(chain[0]); } if(cyc.size() > 1) for(int i = 0; i < cyc.size(); i++){ int x = cyc[i]; int y = cyc[(i+1)%(int)cyc.size()]; cr(x,y,answer); } cyc.clear(); } build(answer); return 1; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:81:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         for(int j = 0; j < c[i].size(); j++){
      |                        ~~^~~~~~~~~~~~~
supertrees.cpp:82:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |             for(int t = 0; t < c[i].size(); t++){
      |                            ~~^~~~~~~~~~~~~
supertrees.cpp:93:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |         for(int j = 0; j < c[i].size(); j++){
      |                        ~~^~~~~~~~~~~~~
supertrees.cpp:101:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |             for(int t = 0; t+1 < chain.size(); t++){
      |                            ~~~~^~~~~~~~~~~~~~
supertrees.cpp:109:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |         for(int i = 0; i < cyc.size(); i++){
      |                        ~~^~~~~~~~~~~~
#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...