Submission #734997

# Submission time Handle Problem Language Result Execution time Memory
734997 2023-05-03T10:57:41 Z MODDI Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 376 KB
#include "supertrees.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> G[1001];
map<set<int>, bool> paths[1001];
int cnt[1001];
void dfs(int at, set<int> vis){
	if(!paths[at][vis]){
		paths[at][vis] = true;
		cnt[at]++;
	}
	for(auto next : G[at]){
		if(vis.find(next) == vis.end()){
			vis.insert(next);
			dfs(next, vis);
		}
	}
}
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vector<vector<int> > answer;
	for(int i = 0; i < n; i++){
		vector<int> now = p[i];
		for(int j = i + 1; j < n; j++){
			if(now[j] == 1){
				G[i].pb(j);
				G[j].pb(i);
			}
		}
	}
	bool ima = true;
	for(int i = 0; i < n; i++){
		memset(cnt, 0, sizeof cnt);
		for(int j = 0; j < n; j++)	paths[j].clear();
		dfs(i, {i});
		
		vector<int> now = p[i];
		for(int j = i + 1; j < n; j++){
			if(now[j] == cnt[j])	continue;
			else{
				ima = false;
				break;
			}
		}
	}
	if(ima){
		for(int i = 0; i < n; i++){
			vector<int> row(n, 0);
			for(auto next : G[i]){
				row[next] = 1;
			}
			answer.pb(row);
		}
	}
	else{
		for(int i = 0; i < n; i++){
			vector<int> row(n,0);
			answer.pb(row);
		}
	}
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 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 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 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 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 0 ms 340 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 376 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 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 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -