제출 #246369

#제출 시각아이디문제언어결과실행 시간메모리
246369thecodingwizard보물 찾기 (CEOI13_treasure2)C++11
0 / 100
5 ms512 KiB
#include <bits/stdc++.h>
#include "treasure.h"

void findTreasure (int n) {
    int ps[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i>n/2&&j>n/2) ps[i][j] = countTreasure(1, 1, i+1, j+1);
            else if (i<=n/2&&j<=n/2) ps[i][j] = countTreasure(i+1, j+1, n, n);
            else if (i<=n/2&&j>n/2) ps[i][j] = countTreasure(i+1,1,n,j+1);
            else if (i>n/2&&j<=n/2) ps[i][j] = countTreasure(1,j+1,i+1,n);
            else assert(false);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i>n/2&&j>n/2) {
                if (ps[i][j]-(i-1>n/2?ps[i-1][j]:0)-(j-1>n/2?ps[i][j-1]:0)+(i-1>n/2&&j-1>n/2?ps[i-1][j-1]:0) == 1) Report(i+1,j+1);
            } else if (i<=n/2&&j<=n/2) {
                if (ps[i][j] - (i+1<=n/2?ps[i+1][j]:0) - (j+1<=n/2?ps[i][j+1]:0) + (i+1<=n/2&&j+1<=n/2?ps[i+1][j+1]:0) == 1) Report(i+1, j+1);
            } else if (i<=n/2&&j>n/2) {
                if (ps[i][j] - (i+1<=n/2?ps[i+1][j]:0) - (j-1>n/2?ps[i][j-1]:0) + (i+1<=n/2&&j-1>n/2?ps[i+1][j-1]:0) == 1) Report(i+1,j+1);
            } else if (i>n/2&&j<=n/2) {
                if (ps[i][j] - (i-1>n/2?ps[i-1][j]:0) - (j+1<=n/2?ps[i][j+1]:0) + (i-1>n/2&&j+1<=n/2?ps[i-1][j+1]:0) == 1) Report(i+1,j+1);
            } else assert(false);
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...