Submission #300594

# Submission time Handle Problem Language Result Execution time Memory
300594 2020-09-17T10:03:08 Z Dilshod_Imomov Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
1 ms 384 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int nn, comp, used[N], cc[N], cmp[N], ok, first[N];

int construct(std::vector<std::vector<int>> p) {
	nn = p.size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < nn; i++) {
		std::vector<int> row;
		row.resize(nn);
		answer.push_back(row);
	}
	for ( int i = 0; i < nn; i++ ) {
        if ( !cc[i] ) {
            cc[i] = ++comp;
            first[comp] = i;
        }
        cmp[ cc[i] ] = i;
        for ( int j = 0; j < nn; j++ ) {
            if ( p[i][j] && i != j ) {
                if ( cc[j] && cc[j] != cc[i] ) {
                    return 0;
                }
                if(  cc[j] ) {
                    continue;
                }
                cc[j] = cc[i];
                answer[ cmp[ cc[i] ] ][j] = 1;
                answer[ j ][ cmp[ cc[i] ] ] = 1;
                cmp[ cc[i] ] = j;
            }
        }
	}
	for ( int i = 1; i <= comp; i++ ) {
        if ( cmp[ i ] != first[i] ) {
            answer[cmp[i]][first[i]] = 1;
            answer[ first[i] ][cmp[i]] = 1;
        }
	}
    for ( int i = 0; i < nn; i++ ) {
        for ( int j = 0; j < nn; j++ ) {
            if ( cc[i] == cc[j] ) {
                if ( !p[i][j] || !p[j][i] ) {
                    return 0;
                }
            }
        }
    }
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 384 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -