Submission #362589

# Submission time Handle Problem Language Result Execution time Memory
362589 2021-02-03T17:18:04 Z mosiashvililuka Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 620 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int a,c,d,e,i,j,ii,jj,zx,xc,msh[1009],ka[1009],msh2[1009],zm2[1009];
int bo[1009],k[1009][1009],cnt;
int B[1009][1009];
vector <int> v[1009],vv[1009];
vector <vector <int> > ans,b;
vector <vector <int> > A;
int fnd(int q){
	if(msh[q]==-1) return q; else msh[q]=fnd(msh[q]);
}
void mrg(int q, int w){
	q=fnd(q);w=fnd(w);
	if(q==w) return;
	if(ka[q]<ka[w]) swap(q,w);
	msh[w]=q;
	if(ka[q]==ka[w]) ka[q]++;
}
 
int fnd2(int q){
	if(msh2[q]==q) return q; else return msh2[q]=fnd2(msh2[q]);
}
void mrg2(int q, int w){
	q=fnd2(q);w=fnd2(w);
	if(q==w) return;
	if(zm2[q]<zm2[w]) swap(q,w);
	msh2[w]=q;
	if(zm2[q]==zm2[w]) zm2[q]++;
}
void dfs(int q){
	bo[q]=cnt;
	k[i][q]++;
	for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if(bo[(*it)]==cnt) continue;
		dfs((*it));
	}
	bo[q]=0;
}
int construct(vector <vector <int> > p) {
  	A=p;
	a = A.size();
	for(i=0; i<a; i++){
		for(j=0; j<a; j++){
			if(A[i][j]==3){
				return 0;
			}
		}
	}
	for(i=0; i<a; i++){
		msh[i]=-1;ka[i]=1;
	}
	for(i=0; i<a; i++){
		for(j=i+1; j<a; j++){
			if(A[i][j]==1){
				mrg(i,j);
			}
		}
	}
	/*for(i=0; i<a; i++){
		fnd(i);
		if(i!=msh[i]){
			B[i][msh[i]]=1;
			B[msh[i]][i]=1;
			v[i].push_back(msh[i]);
			v[msh[i]].push_back(i);
		}
	}/*
	/*for(i=0; i<a; i++){
		msh2[i]=i;zm2[i]=1;
	}
	for(i=0; i<a; i++){
		for(j=i+1; j<a; j++){
			if(A[i][j]==2){
				mrg2(msh[i],msh[j]);
			}
		}
	}
	for(i=0; i<a; i++){
		fnd2(i);
		vv[msh2[i]].push_back(i);
	}
	for(i=0; i<a; i++){
		if(vv[i].size()>1){
			for(j=0; j<vv[i].size(); j++){
				jj=j-1;if(jj<0) jj=vv[i].size()-1;
				B[vv[i][j]][vv[i][jj]]=1;
				B[vv[i][jj]][vv[i][j]]=1;
				v[vv[i][j]].push_back(vv[i][jj]);
				v[vv[i][jj]].push_back(vv[i][j]);
			}
		}
	}
	for(i=0; i<a; i++){
		cnt++;
		dfs(i);
		for(j=0; j<a; j++){
			if(k[i][j]!=A[i][j]){
				return 0;
			}
		}
	}*/
	for(i=0; i<a; i++){
		vector <int> va;
		for(j=0; j<a; j++){
          	if((i==0&&j!=0)||(i!=0&&j==0)){
              B[i][j]=1;
            }else{
              B[i][j]=0;
            }
			va.push_back(B[i][j]);
		}
		//ans.push_back(va);
      b.push_back(va);
	}
	build(b);
	return 1;
}

Compilation message

supertrees.cpp:68:3: warning: "/*" within comment [-Wcomment]
   68 |  }/*
      |    
supertrees.cpp:69:2: warning: "/*" within comment [-Wcomment]
   69 |  /*for(i=0; i<a; i++){
      |   
supertrees.cpp: In function 'int fnd(int)':
supertrees.cpp:11:38: warning: control reaches end of non-void function [-Wreturn-type]
   11 |  if(msh[q]==-1) return q; else msh[q]=fnd(msh[q]);
      |                                ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Runtime error 1 ms 620 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Runtime error 1 ms 620 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Too many ways to get from 0 to 1, should be 0 found no less than 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Runtime error 1 ms 620 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Runtime error 1 ms 620 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -