답안 #981208

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981208 2024-05-13T02:21:42 Z pcc 무지개나라 (APIO17_rainbow) C++17
11 / 100
10 ms 860 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 55;
pii dir[] = {{0,1},{0,-1},{1,0},{-1,0}};
int arr[mxn][mxn];

void init(int R, int C, int sr, int sc, int M, char *S) {
	memset(arr,0,sizeof(arr));
	pii now = pii(sr,sc);
	arr[now.fs][now.sc] = -1;
	for(int i = 0;i<M;i++){
		if(S[i] == 'N')now.fs--;
		else if(S[i] == 'S')now.fs++;
		else if(S[i] == 'E')now.sc++;
		else if(S[i] == 'W')now.sc--;
		arr[now.fs][now.sc] = -1;
	}
	return;
}

int brr[mxn][mxn];

void dfs(int r,int c,int ar,int ac,int br,int bc){
	if(brr[r][c])return;
	brr[r][c] = 1;
	for(auto &d:dir){
		int nr = r+d.fs,nc = c+d.sc;
		if(nr<ar||nc<ac||nr>br||nc>bc||brr[nr][nc])continue;
		dfs(nr,nc,ar,ac,br,bc);
	}
	return;
}

int colour(int ar, int ac, int br, int bc) {
	int ans = 0;
	for(int i = ar;i<=br;i++)for(int j = ac;j<=bc;j++)brr[i][j] = arr[i][j];
	for(int i = ar;i<=br;i++){
		for(int j = ac;j<=bc;j++){
			if(!brr[i][j])ans++,dfs(i,j,ar,ac,br,bc);
		}
	}
	return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 660 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 3 ms 508 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 860 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 856 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 660 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 3 ms 508 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
3 Correct 10 ms 660 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 444 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 8 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 3 ms 508 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -