답안 #79411

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79411 2018-10-13T09:34:46 Z szawinis 보물 찾기 (CEOI13_treasure2) C++17
100 / 100
7 ms 1228 KB
#include "treasure.h"
#include <bits/stdc++.h>
using namespace std;

int a[101][101];
map<tuple<int,int,int,int>, int> mp;
int query(int x1, int y1, int x2, int y2) {
    if(mp.count(make_tuple(x1, y1, x2, y2))) return mp[make_tuple(x1, y1, x2, y2)];
    return mp[make_tuple(x1, y1, x2, y2)] = countTreasure(x1, y1, x2, y2);
}
void findTreasure (int N) {
    for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
        if(i > N/2 && j > N/2) {
            a[i][j] = query(1, 1, i, j);
        } else if(i > N/2 && j <= N/2) {
            a[i][j] = query(1, 1, i, N) - query(1, j+1, i, N);
        } else if(i <= N/2 && j > N/2) {
            a[i][j] = query(1, 1, N, j) - query(i+1, 1, N, j);
        } else {
            a[i][j] = query(1, 1, N, N) - query(i+1, 1, N, N) - query(1, j+1, N, N) + query(i+1, j+1, N, N);
        }
    }
    for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) if(a[i][j] - a[i-1][j] - a[i][j-1] + a[i-1][j-1]) Report(i, j);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 3 ms 564 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 3 ms 564 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 2 ms 564 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 3 ms 788 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 4 ms 804 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 5 ms 936 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 6 ms 1100 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 7 ms 1228 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 7 ms 1228 KB Output is correct - N = 100, K = 43760000, score = 10