답안 #74547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74547 2018-09-03T12:30:49 Z SpeedOfMagic 보물 찾기 (CEOI13_treasure2) C++17
100 / 100
3 ms 716 KB
#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
/*
20
00000000000000000001
00000000000000000001
00000001000000000001
00000001000000000001
00000001000001000001
00000000000000000001
00000000000000000001
00111000000000000001
00111000000000000001
00111000000000000001
00000000000000000001
00000000001100000001
00000000000000000001
00000100000000000001
00000000000000000001
00000000000111000001
00000000000000000001
11111111111111111111
00000000000000000001
00000000000000000001
*/

/**
01
23
**/
int n;
int quarter(int r, int c) { return (r > n / 2) * 2 + (c > n / 2); }
	
void findTreasure (int N) {
	n = N;
	int pref[n + 1][n + 1];
	memset(pref, 0, sizeof(pref));
	for (int i = n; i; i--)
		for (int j = n; j; j--)
			if (quarter(i, j) == 0)
				pref[i][j] = -(pref[n][n] - pref[n][j] - pref[i][n] - countTreasure(i + 1, j + 1, n, n));
			else if (quarter(i, j) == 1)
				pref[i][j] = pref[n][j] - countTreasure(i + 1, 1, n, j);
			else if (quarter(i, j) == 2)
				pref[i][j] = pref[i][n] - countTreasure(1, j + 1, i, n);
			else
				pref[i][j] = countTreasure(1, 1, i, j);
	
	rep(i, 1, n + 1)
        rep(j, 1, n + 1)
			if (pref[i][j] - pref[i - 1][j] - pref[i][j - 1] + pref[i - 1][j - 1])
				Report(i, j);
	/*
	ooxxoo
	ooxxoo
	xxxxxx
	xxxxxx
	ooxxoo
	ooxxoo
	
	ooxoo
	ooxoo
	xxxxx
	ooxoo
	ooxoo
	*/
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 2 ms 384 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 2 ms 464 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 2 ms 612 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 2 ms 612 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 2 ms 612 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 2 ms 612 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 2 ms 612 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 3 ms 612 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 2 ms 716 KB Output is correct - N = 100, K = 43760000, score = 10