제출 #302510

#제출 시각아이디문제언어결과실행 시간메모리
302510REALITYNB슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "supertrees.h" #define all(a) a.begin(),a.end() using namespace std; const int mxn= 1e3+1 ; vector<int> adj[mxn] , adjj[mxn] , one , mn ; void dfs(int i , vector<int>& a ){ a[i]=1 ; for(int& x : adj[i]){ if(a[x]) continue ; dfs(x,a) ; } } void dfss(int i , vector<int>& a){ a[i] = 1 ; if(adjj[i].size()==1) one.push_back(i) ; for(int& x : adjj[i]){ if(a[x]) continue ; dfss(x,a) ; } } vector<vector<int>> ppp; bool check(int i , vector<int>& a){ a[i] =1 ; for(int j=0;j<mn.size();j++){ if(ppp[pi][j]==2&&mn[j]!=2) return 1 ; if(mn[j]==2&&ppp[i][j]!=2) return 1 ; } bool b = 0 ; for(int& x : adj[i]){ if(a[x]) continue ; b|=check(x,a) ; } return b ; } int construct(vector<vector<int>> p){ ppp= p ; int n =p.size() ; vector<int> the(n) ; /*for(int i=0;i<n;i++){ bool flg = 0 ; vector<int> x=p[i] ; for(int j=0;j<i;j++){ if(x[j]==1){ adj[i].push_back(j) ; flg = 1 ; break ; } } if(flg) continue ; //cout <<i << endl ; the[i] =1 ; for(int j=i+1;j<n;j++) if(x[j]==1) adj[i].push_back(j) ; } for(int i=0;i<n;i++){ vector<int> vis(n) ; dfs(i,vis) ; for(int j=0;j<n;j++){ if(vis[j]==1&&p[i][j]==1) continue ; if(vis[j]==0&&p[i][j]==0) continue ; if(p[i][j]==2&&vis[j]==0) continue ; return 0 ; } }*/ for(int i=0;i<n;i++){ //if(the[i]==0) continue ; for(int j=i-1;j>-1;j--){ // if(the[j]==0) continue ; if(p[i][j]==2){ adjj[i].push_back(j) ; break ; } } for(int j=i+1;j<n;j++){ ///if(the[j]==0) continue ; if(p[i][j]==2){ adjj[i].push_back(j) ; break ; } } } map<vector<int>,int> pp ; for(int i=0;i<n;i++){ //if(the[i]==0) continue ; // if(vis[i]) continue ; vector<int> vis(n); one.erase(one.begin(),one.end()) ; dfss(i,vis) ; sort(all(one)) ; for(int j=0;j<n;j++){ if(i==j) continue ; ///if(the[j]==0) continue ; if(vis[j]==1&&p[i][j]==2) continue ; if(vis[j]==0&&p[i][j]==0) continue ; if(vis[j]==0&&p[i][j]==1) continue ; //cout << i << " " << j << endl ; return 0 ; } if(one.size()==1) continue ; if(one.size()>2) return 0 ; if(pp[one]) continue ; pp[one]=1 ; adjj[one.back()].push_back(one[0]) ; adjj[one[0]].push_back(one.back()) ; } /*vector<int> viss(n) ; for(int i=0;i<n;i++){ if(viss[i]==1) continue ; mn = p[i] ; bool f = check(i,viss) ; if(f) return 0 ; }*/ vector<vector<int>> ans ; for(int i=0;i<n;i++) for(int& x : adjj[i]) adj[i].push_back(x) ; for(int i=0;i<n;i++){ vector<int> row(n) ; for(int& x : adj[i]) row[x]= 1 ; ans.push_back(row) ; } build(ans) ; return 1 ; }

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

supertrees.cpp: In function 'bool check(int, std::vector<int>&)':
supertrees.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int j=0;j<mn.size();j++){
      |              ~^~~~~~~~~~
supertrees.cpp:26:10: error: 'pi' was not declared in this scope; did you mean 'i'?
   26 |   if(ppp[pi][j]==2&&mn[j]!=2) return 1 ;
      |          ^~
      |          i