답안 #302442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
302442 2020-09-18T16:57:13 Z arnold518 식물 비교 (IOI20_plants) C++14
0 / 100
4000 ms 18268 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 5000;

int N, K, R[MAXN+10];
int adj[MAXN+10][MAXN+10];

bool vis[MAXN+10];
void dfs(int now, int root)
{
	vis[now]=true;
	for(int i=0; i<N; i++)
	{
		if(adj[now][i]==0) continue;
		if(vis[i]) continue;
		adj[root][i]=1;
		dfs(i, root);
	}
}

void init(int _K, vector<int> _R)
{
	K=_K; N=_R.size();
	for(int i=0; i<N; i++) R[i]=_R[i];

	for(int i=0; i<N; i++)
	{
		if(R[i]==0)
		{
			for(int j=1; j<K; j++)
			{
				adj[(i+j)%N][i]=1;
			}
		}
		else
		{
			for(int j=1; j<K; j++)
			{
				adj[i][(i+j)%N]=1;
			}	
		}
	}
	for(int i=0; i<N; i++)
	{
		if(R[i]<R[(i+1)%N])
		{
			adj[(i+1)%N][i]=1;
		}
		if(R[i]>R[(i+1)%N])
		{
			adj[i][(i+1)%N]=1;
		}
	}
	for(int i=0; i<N; i++)
	{
		memset(vis, 0, sizeof(vis));
		dfs(i, i);
	}

	return;
}

int compare_plants(int x, int y)
{
	int ans=0;

	if(adj[x][y]==1) return -1;
	if(adj[y][x]==1) return 1;
	return 0;
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:71:6: warning: unused variable 'ans' [-Wunused-variable]
   71 |  int ans=0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 62 ms 3192 KB Output is correct
7 Runtime error 69 ms 5624 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Execution timed out 4051 ms 18268 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 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 Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 62 ms 3192 KB Output is correct
7 Runtime error 69 ms 5624 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -