Submission #300233

# Submission time Handle Problem Language Result Execution time Memory
300233 2020-09-17T01:58:24 Z daniel920712 Connecting Supertrees (IOI20_supertrees) C++14
11 / 100
249 ms 22268 KB
#include "supertrees.h"
#include <vector>
#include <stdio.h>
using namespace std;
vector < int > how[1005];
int Father[1005];
int Find(int here)
{
    if(Father[here]==here) return here;
    Father[here]=Find(Father[here]);
    return Father[here];
}
int construct(vector < vector< int > > p)
{
	int n=p.size(),i,j,m;
	vector< vector<int> > answer;
	vector< int > row;
	//printf("%d\n",n);
	for(i=0;i<n;i++) row.push_back(0);
	for(i=0;i<n;i++)
    {
        answer.push_back(row);
        Father[i]=i;
    }
    //printf("%d\n",n);
	for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            //printf("%d %d\n",i,j);
            if(p[i][j]==0&&Find(i)==Find(j)) return 0;
            Father[Find(i)]=Find(j);
        }
    }
    //printf("%d\n",n);
    for(i=0;i<n;i++)
    {
        how[Find(i)].push_back(i);
        //printf("%d %d\n",i,Find(i));
    }
    for(i=0;i<n;i++)
    {
        m=how[i].size();
        if(m<=1) continue;
        for(j=1;j<m;j++)
        {
            answer[how[i][j-1]][how[i][j]]=1;
            answer[how[i][j]][how[i][j-1]]=1;
        }
        if(p[how[i][0]][how[i][1]]==2)
        {
            if(m==2) return 0;
            answer[how[i][m-1]][how[i][j]]=1;
            answer[how[i][j]][how[i][m-1]]=1;
        }
    }


	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 249 ms 22268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 249 ms 22268 KB Output is correct
8 Incorrect 0 ms 256 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 249 ms 22268 KB Output is correct
8 Incorrect 0 ms 256 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 249 ms 22268 KB Output is correct
8 Incorrect 0 ms 256 KB Answer gives possible 0 while actual possible 1
9 Halted 0 ms 0 KB -