제출 #302503

#제출 시각아이디문제언어결과실행 시간메모리
302503REALITYNB슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms512 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>> pp ; bool check(int i , vector<int>& a){ a[i] =1 ; for(int j=0;j<mn.size();j++){ if(pp[i][j]==2&&mn[j]!=2) return 1 ; if(mn[j]==2&&pp[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){ pp = 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[i]==1&&p[i][j]==2) continue ; if(vis[i]==0&&p[i][j]==0) continue ; if(vis[i]==0&&p[i][j]==1) continue ; //cout << i << " " << j << endl ; return 0 ; } if(one.size()==1) continue ; if(one.size()==2) return 0 ; 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++){
      |              ~^~~~~~~~~~
#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...