제출 #316002

#제출 시각아이디문제언어결과실행 시간메모리
316002gurkot슈퍼트리 잇기 (IOI20_supertrees)C++14
46 / 100
248 ms22264 KiB
#include <iostream>
#include "supertrees.h"
#include <vector>
using namespace std;
int tree[1501],comp[1501],mas[1501];
int n,ntree,ncomp;

int construct(std::vector<std::vector<int>> p) {
	n = p.size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	
	//cout<<"ok1: let find trees"<<endl;
	for (int i=0; i<n;i++)	 
	 if (tree[i]==0){	  
	 ++ntree;
	 for (int j=0;j<n;j++) {
	  if (p[i][j]==3) return 0;
	  if (i!=j && p[i][j]==1){
	   if (tree[j]>0) return 0;
	   tree[j]=ntree;	 
	   answer[i][j]=answer[j][i]=1;
      }	
     }//J
	}//i
	
	//cout<<"ok2: let find connected components"<<endl;
	for (int i=0; i<n;i++)	 
	 if (comp[i]==0){	  	  
	  ncomp++;	  
	  int s=i,a=i,k=1,cnt=0;  
	  for (int j=0;j<n;j++)
	   if (i!=j && p[i][j]>0){	   	
	    mas[++cnt]=j;
	    for (int ic=1;ic<cnt;ic++)
	     if (p[mas[ic]] [j]==0 || p[j] [mas[ic]]==0) return 0;
	     
	   	if (comp[j]>0) return 0;
	    comp[j]=ncomp;
	    if (tree[j]==0) {
	      k++;
		  answer[a][j]=answer[j][a]=1;	      
	      a=j;
		}
	   }//j
	   if (k==2) return 0;
	   if (k>2) answer[a][s]=answer[s][a]=1;
	   
	   
	   
	 }//i
	
	
	build(answer);
	return 1;
}

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:36:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   36 |    for (int j=0;j<n;j++)
      |    ^~~
supertrees.cpp:50:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |     if (k==2) return 0;
      |     ^~
#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...