Submission #300934

# Submission time Handle Problem Language Result Execution time Memory
300934 2020-09-17T15:19:55 Z luciocf Comparing Plants (IOI20_plants) C++14
0 / 100
5 ms 5120 KB
#include <bits/stdc++.h>
#include "plants.h"

using namespace std;

const int maxn = 2e5+10;

int ord[maxn], tt;
bool mark[maxn];

vector<int> grafo[maxn];

void dfs(int u)
{
	mark[u] = 1;
	for (auto v: grafo[u])
		if (!mark[v])
			dfs(v);

	ord[u] = ++tt;
}

void init(int k, vector<int> r)
{
	int n = r.size();

	for (int i = 0; i < n-1; i++)
	{
		if (r[i] == 1) grafo[i+1].push_back(i);
		else grafo[i].push_back(i+1);
	}

	if (r[n-1] == 1) grafo[0].push_back(n-1);
	else grafo[n-1].push_back(0);

	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(i);
}

int compare_plants(int x, int y)
{
	return ord[x] > ord[y];
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Incorrect 3 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Incorrect 5 ms 5120 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Incorrect 5 ms 5120 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Incorrect 4 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Incorrect 4 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Incorrect 3 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -