답안 #928956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
928956 2024-02-17T09:25:00 Z hmm789 무지개나라 (APIO17_rainbow) C++14
11 / 100
3000 ms 39860 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

int a[50][200000];
bool v[50][200000];

int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};

void init(int R, int C, int sr, int sc, int M, char *S) {
	sr--; sc--;
	a[sr][sc] = 1;
	for(int i = 0; i < M; i++) {
		if(S[i] == 'N') sr--;
		else if(S[i] == 'E') sc++;
		else if(S[i] == 'S') sr++;
		else if(S[i] == 'W') sc--;
		a[sr][sc] = 1;
	}
}

int colour(int ar, int ac, int br, int bc) {
    int ans = 0;
    ar--; ac--; br--; bc--;
    for(int i = ar; i <= br; i++) {
		for(int j = ac; j <= bc; j++) if(a[i][j] == 0 && v[i][j] == 0) {
			ans++;
			queue<pair<int, int>> q;
			q.push({i, j});
			v[i][j] = 1;
			while(!q.empty()) {
				pair<int, int> c = q.front();
				q.pop();
				for(int k = 0; k < 4; k++) {
					int nx = c.first+dx[k], ny = c.second+dy[k];
					if(nx < ar || nx > br || ny < ac || ny > bc) continue;
					if(a[nx][ny] == 1 || v[nx][ny] == 1) continue;
					v[nx][ny] = 1;
					q.push({nx, ny});
				}
			}
		}
	}
    for(int i = ar; i <= br; i++) for(int j = ac; j <= bc; j++) v[i][j] = 0;
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 17 ms 39512 KB Output is correct
3 Correct 20 ms 37640 KB Output is correct
4 Correct 20 ms 37468 KB Output is correct
5 Correct 9 ms 39768 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 16 ms 33488 KB Output is correct
12 Correct 13 ms 39516 KB Output is correct
13 Correct 14 ms 39660 KB Output is correct
14 Correct 12 ms 39860 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Execution timed out 3084 ms 5228 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 2 ms 860 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 17 ms 39512 KB Output is correct
3 Correct 20 ms 37640 KB Output is correct
4 Correct 20 ms 37468 KB Output is correct
5 Correct 9 ms 39768 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 16 ms 33488 KB Output is correct
12 Correct 13 ms 39516 KB Output is correct
13 Correct 14 ms 39660 KB Output is correct
14 Correct 12 ms 39860 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Runtime error 2 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 17 ms 39512 KB Output is correct
3 Correct 20 ms 37640 KB Output is correct
4 Correct 20 ms 37468 KB Output is correct
5 Correct 9 ms 39768 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 16 ms 33488 KB Output is correct
12 Correct 13 ms 39516 KB Output is correct
13 Correct 14 ms 39660 KB Output is correct
14 Correct 12 ms 39860 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Runtime error 2 ms 860 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -