답안 #162092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
162092 2019-11-06T10:35:58 Z Minnakhmetov 무지개나라 (APIO17_rainbow) C++14
11 / 100
15 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, INF = 1e9;
int a[N][N];
int r, c;
int mnx, mny, mxx, mxy;

void init(int R, int C, int sr, int sc, int M, char *S) {
	r = R;
	c = C;

	a[sr][sc] = 1;

	mnx = sr;
	mxx = sr;
	mny = sc;
	mxy = sc;

	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;

		mnx = min(mnx, x);
		mxx = max(mxx, x);
		mny = min(mny, y);
		mxy = max(mxy, y);
	}
}

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

	if (ar < mnx && mxx < br &&
		ac < mny && mxy < bc) {
		ans++;
	}

	// count of edges

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

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

	// count of vertices
	for (int i = ar; i < br; i++) {
		for (int j = ac; j < bc; j++) {
			if (a[i][j] || a[i + 1][j] 
				|| a[i][j + 1] || a[i + 1][j + 1])
				ans--;
		}
	}

	// count of useless
	for (int i = ar; i <= br; i++) {
		for (int j = ac; j <= bc; j++) {
			ans -= a[i][j];
		}
	}
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 15 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Runtime error 1 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 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 15 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 8 ms 376 KB Output is correct
14 Correct 15 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -