답안 #625077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625077 2022-08-09T10:00:34 Z QwertyPi 무지개나라 (APIO17_rainbow) C++14
0 / 100
5 ms 724 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;

bool a[51][51];

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

int dir[256];
void init(int R, int C, int sr, int sc, int M, char *S) {
	dir['E'] = 0;
	dir['W'] = 1;
	dir['S'] = 2;
	dir['N'] = 3;
	a[sr][sc] = true;
	for(int i = 0; i < M; i++){
		sr += dx[dir[S[i]]];
		sc += dy[dir[S[i]]];
		a[sr][sc] = true;
	}
}

int colour(int ar, int ac, int br, int bc) {
	int x1 = ar, x2 = br, y1 = ac, y2 = bc;
	int V = 0, E = 0, SQ = 0;
	for(int i = x1; i <= x2; i++){
		for(int j = y1; j <= y2; j++){
			V += !a[i][j];
		}
	}
	for(int i = x1; i <= x2; i++){
		for(int j = y1; j < y2; j++){
			E += !a[i][j] && !a[i][j + 1];
		}
	}
	for(int i = x1; i < x2; i++){
		for(int j = y1; j <= y2; j++){
			E += !a[i + 1][j] && !a[i][j];
		}
	}
	for(int i = x1; i < x2; i++){
		for(int j = y1; j < y2; j++){
			SQ += !a[i][j] && !a[i + 1][j] && !a[i][j + 1] && !a[i + 1][j + 1];
		}
	}
    return V - E + SQ;
}

Compilation message

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:19:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   19 |   sr += dx[dir[S[i]]];
      |                ~~~^
rainbow.cpp:20:19: warning: array subscript has type 'char' [-Wchar-subscripts]
   20 |   sc += dy[dir[S[i]]];
      |                ~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Incorrect 5 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 404 KB Output is correct
3 Runtime error 2 ms 724 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 1 ms 620 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Incorrect 5 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 324 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Incorrect 5 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -