답안 #1050317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050317 2024-08-09T08:43:09 Z aykhn 식물 비교 (IOI20_plants) C++17
11 / 100
4000 ms 125336 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

const int MXN = 5e3 + 5;

int n;
int a[MXN], cnt[MXN], f[MXN];
vector<int> adj[MXN];
int big[MXN][MXN], used[MXN];

void dfs(int a, int s)
{
	big[s][a] = 1;
	used[a] = 1;
	for (int &v : adj[a])
	{
		if (!used[v]) dfs(v, s);
	}
}

void init(int k, vector<int> r) 
{
	n = r.size();
	for (int i = 0; i < n; i++) cnt[i] = k - 1;
	int cur = -1;
	while (cur < n)
	{
		vector<int> idx;
		for (int i = 0; i < n; i++)
		{
			if (f[i]) continue;
			if (r[i] == cnt[i]) idx.push_back(i);
		}
		if (idx.empty()) break;
		int ind = -1;
		int sz = idx.size();
		if (sz == 1) ind = 0;
		else 
		{
			for (int i = 0; i < sz; i++)
			{
				if ((idx[(i + 1) % sz] - idx[i] + n) % n >= k) 
				{
					ind = (i + 1) % sz;
					break;
				}
			}
		}
		assert(!idx.empty());
		// for (int i = (idx[ind] - 1 + n) % n; i != idx[(ind - 1 + sz) % sz]; i = (i - 1 + n) % n)
		// {
		// 	if (!f[i]) adj[idx[ind]].push_back(i);
		// }
		for (int i = (idx[ind] + 1) % n; i != (idx[ind] + k) % n; i = (i + 1) % n)
		{
			if (!f[i]) adj[idx[ind]].push_back(i);
			else adj[i].push_back(idx[ind]);
		}
		for (int i = (idx[ind] - 1 + n) % n; i != (idx[ind] - k + n) % n; i = (i - 1 + n) % n)
		{
			// if (!f[i]) adj[idx[ind]].push_back(i);
			cnt[i]--;
		}
		f[idx[ind]] = 1;
	}
	for (int i = 0; i < n; i++)
	{
		fill(used, used + n, 0);
		dfs(i, i);
	}
}

int compare_plants(int x, int y) 
{
	if (big[x][y]) return -1;
	if (big[y][x]) return 1;
	return 0;
	// return (a[x] > a[y] ? 1 : -1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 32 ms 5228 KB Output is correct
7 Runtime error 22 ms 5824 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 115 ms 25844 KB Output is correct
7 Execution timed out 4018 ms 125336 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 115 ms 25844 KB Output is correct
7 Execution timed out 4018 ms 125336 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 47 ms 44628 KB Output is correct
4 Runtime error 65 ms 8784 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2652 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 7 ms 7412 KB Output is correct
8 Correct 9 ms 7496 KB Output is correct
9 Correct 7 ms 7260 KB Output is correct
10 Correct 9 ms 7512 KB Output is correct
11 Correct 9 ms 7256 KB Output is correct
12 Correct 14 ms 7260 KB Output is correct
13 Correct 12 ms 7836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 23 ms 21740 KB Output is correct
6 Runtime error 34 ms 8832 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 32 ms 5228 KB Output is correct
7 Runtime error 22 ms 5824 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -