Submission #1041425

# Submission time Handle Problem Language Result Execution time Memory
1041425 2024-08-02T03:44:32 Z vjudge1 Izlet (COI19_izlet) C++17
18 / 100
687 ms 53584 KB
#include <iostream>
#include <vector>

using namespace std;
const int N = 3e3 + 10;
int a[N][N];
int par[N];
vector<int> vec[N];

int root(int v){
	if (par[v] == 0)
		return v;
	return par[v] = root(par[v]);
}

void solve1(int n){
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i != j and a[i][j] == 1 and root(i) != root(j))
				par[root(i)] = root(j);
	for (int i=1;i<=n;i++)
		cout<<1 + (root(i) != root(1))<<' ';
	cout<<'\n';

	for (int i=2;i<=n;i++)
		vec[root(i)].push_back(i);

	for (int i=1;i<=n;i++){
		int prv = 1;
		for (int j : vec[i])
			cout<<prv<<" "<<j<<'\n', prv = j;
	}

}

int main(){
	int t, n;
	cin>>t>>n;

	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			cin>>a[i][j];
	if (t == 1)
		solve1(n);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 601 ms 53584 KB Output is correct
3 Correct 599 ms 53584 KB Output is correct
4 Correct 650 ms 53448 KB Output is correct
5 Correct 629 ms 53200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 687 ms 53328 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 601 ms 53584 KB Output is correct
3 Correct 599 ms 53584 KB Output is correct
4 Correct 650 ms 53448 KB Output is correct
5 Correct 629 ms 53200 KB Output is correct
6 Incorrect 687 ms 53328 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -