제출 #284157

#제출 시각아이디문제언어결과실행 시간메모리
284157FlashGamezzz보물 찾기 (CEOI13_treasure2)C++17
66 / 100
1 ms512 KiB
#include "treasure.h"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
int psums[101][101] = {}, ul[101][101] = {}, dr[101][101] = {};
 
void findTreasure (int N) {
	int h = N/2;
    if (N % 2 != 0){
    	h++;
    }
	for (int r = 1; r <= N; r++){
		for (int c = 1; c <= N; c++){
			bool a = (r > h), b = (c > h);
			if (a && b){
				psums[r][c] = countTreasure(1, 1, r, c);
			} else {
				if (a && c > 1){
					dr[r][c] = countTreasure(1, c, r, N);
				}
				if (b && r > 1){
					ul[r][c] = countTreasure(r, 1, N, c);
				}
			}
		}
	}
	for (int i = N; i > h; i--){
		ul[1][i] = psums[N][i];
		dr[i][1] = psums[i][N];
	}
	for (int r = N; r > h; r--){
		for (int c = 1; c < h; c++){
			psums[r][c] = psums[r][N]-dr[r][c+1];
		}
		psums[r][h] = countTreasure(1, 1, r, h);
	}
	for (int c = N; c > h; c--){
		for (int r = 1; r < h; r++){
			psums[r][c] = psums[N][c]-ul[r+1][c];
		}
		psums[h][c] = countTreasure(1, 1, h, c);
	}
	for (int r = h; r >= 1; r--){
		for (int c = h; c >= 1; c--){
        	if (r != 1 || c != 1){
				psums[r][c] = countTreasure(r+1, c+1, N, N)-psums[N][N]+psums[N][c]+psums[r][N];
            }
		}
	}
    if (!(psums[2][2] == psums[2][1]+psums[1][2] && psums[1][2] < 2 && psums[2][1] < 2)){
    	psums[1][1] = 1;
    }
	for (int r = 1; r <= N; r++){
		for (int c = 1; c <= N; c++){
			if (psums[r][c] == psums[r-1][c]+psums[r][c-1]-psums[r-1][c-1]+1){
				Report(r, c);
			}
		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...