제출 #91909

#제출 시각아이디문제언어결과실행 시간메모리
91909easrui보물 찾기 (CEOI13_treasure2)C++14
0 / 100
2 ms504 KiB
#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;

int S[101][101]; // S[a][b] a행 b열까지합
void findTreasure(int N){
    static int S[101][101]; // S[a][b] a행 b열까지합
    int L,R,U,D,tmp,res;
    L=1,R=N,U=1,D=N;
    tmp = countTreasure(1,L,N,R);
    for(U=2,D=N;U<N/2;U++){
        res = countTreasure(U,L,D,R);
        if(L==1) S[U-1][R] = tmp - res;
        else S[U-1][L-1] = S[U-1][N] - (tmp - res);
        tmp = res;
    }
    tmp = countTreasure(1,L,N,R);
    for(U=1,D=N-1;D>=N/2;D--){
        res = countTreasure(U,L,D,R);
        if(L==1) S[D+1][R] = tmp - res;
        else S[D+1][L-1] = S[D+1][N] - (tmp - res);
        tmp = res;
    }
    if(L==1) S[D+1][R] = tmp - S[D][R];
    else S[D+1][L-1] = S[D+1][N] - (tmp - S[D][R]);
    for(L=2,R=N;L<N/2;L++){
        tmp = countTreasure(1,L,N,R);
        for(U=2,D=N;U<N/2;U++){
            res = countTreasure(U,L,D,R);
            if(L==1) S[U-1][R] = tmp - res;
            else S[U-1][L-1] = S[U-1][N] - (tmp - res);
            tmp = res;
        }
        tmp = countTreasure(1,L,N,R);
        for(U=1,D=N-1;D>=N/2;D--){
            res = countTreasure(U,L,D,R);
            if(L==1) S[D+1][R] = tmp - res;
            else S[D+1][L-1] = S[D+1][N] - (tmp - res);
            tmp = res;
        }
        if(L==1) S[D+1][R] = tmp - S[D][R];
        else S[D+1][L-1] = S[D+1][N] - (tmp - S[D][R]);
    }
    for(L=1,R=N-1;R>=N/2;R--){
        tmp = countTreasure(1,L,N,R);
        for(U=2,D=N;U<N/2;U++){
            res = countTreasure(U,L,D,R);
            if(L==1) S[U-1][R] = tmp - res;
            else S[U-1][L-1] = S[U-1][N] - (tmp - res);
            tmp = res;
        }
        tmp = countTreasure(1,L,N,R);
        for(U=1,D=N-1;D>=N/2;D--){
            res = countTreasure(U,L,D,R);
            if(L==1) S[D+1][R] = tmp - res;
            else S[D+1][L-1] = S[D+1][N] - (tmp - res);
            tmp = res;
        }
        if(L==1) S[D+1][R] = tmp - S[D][R];
        else S[D+1][L-1] = S[D+1][N] - (tmp - S[D][R]);
    }
    for(int x=1; x<=N; x++)
        for(int y=1; y<=N; y++){
            if(S[y][x]!=S[y][x-1]){
                Report(y,x);
            }
        }
}
#Verdict Execution timeMemoryGrader output
Fetching results...