답안 #162000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
162000 2019-11-05T16:15:43 Z Minnakhmetov 무지개나라 (APIO17_rainbow) C++14
0 / 100
4 ms 888 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;

#define all(aaa) aaa.begin(), aaa.end()

string dir = "NSEW";
const int dx[4] = {-1, 1, 0, 0},
		  dy[4] = {0, 0, 1, -1};

const int N = 52;
int a[N][N];

void init(int R, int C, int sr, int sc, int M, char *S) {
	a[sr][sc] = 1;

	int x = sr, y = sc;
	for (int i = 0; i < M; i++) {
		int k = find(all(dir), S[i]) - dir.begin();
		x += dx[k];
		y += dy[k];
		a[x][y] = 1;
	}

	// for (int i = 1; i <= R; i++) {
	// 	for (int j = 1; j <= C; j++) {
	// 		cout << a[i][j];
	// 	}
	// 	cout << "\n";
	// }
}

int colour(int ar, int ac, int br, int bc) {
	int ans = 1;

	for (int i = ar; i <= br; i++) {
		for (int j = ac; j < bc; j++) {
			ans += (a[i][j] && a[i][j + 1]);
		}
	}

	for (int i = ar; i < br; i++) {
		for (int j = ac; j <= bc; j++) {
			ans += (a[i + 1][j] && a[i][j]);
		}
	}

	for (int i = ar; i <= br; i++) {
		for (int j = ac; j <= bc; j++) {
			ans -= a[i][j];
		}
	}

	for (int i = ar; i <= br; i++) {
		ans += a[i][ac] + a[i][bc];
	}

	for (int i = ac; i <= bc; i++) {
		ans += a[ar][i] + a[br][i];
	}

	for (int i = ar; i < br; i++) {
		ans -= (a[i][ac] && a[i + 1][ac]);
		ans -= (a[i][bc] && a[i + 1][bc]);
	}

	for (int i = ac; i < bc; i++) {
		ans -= (a[ar][i] && a[ar][i + 1]);
		ans -= (a[br][i] && a[br][i + 1]);
	}

	for (int i = ar; i < br; i++) {
		for (int j = ac; j < bc; j++) {
			ans -= (a[i][j] && a[i + 1][j] && 
				a[i][j + 1] && a[i + 1][j + 1]);
		}
	}

	ans -= a[ar][ac] + a[ar][bc] + a[br][ac] + a[br][bc];

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -