답안 #759676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
759676 2023-06-16T14:43:01 Z doowey 보물 찾기 (CEOI13_treasure2) C++14
37 / 100
6 ms 980 KB
#include "treasure.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

int nn;

map<pair<pii, pii>, int> vl;
int go(int i1, int j1, int i2, int j2){
    if(i1 == 0 || j1 == 0 || i2 > nn || j2 > nn || i2 == 0 || j2 == 0 || i1 > nn || j2 > nn || i1 > i2 || j1 > j2)
        return 0;
    if(vl.count(mp(mp(i1,j1), mp(i2,j2))))
        return vl[mp(mp(i1,j1), mp(i2,j2))];
    return vl[mp(mp(i1,j1), mp(i2,j2))]=countTreasure(i1,j1,i2,j2);
}

void findTreasure (int n) {
    nn = n;
    int l1 = 0, l2 = 0, l3 = 0, l4 = 0;
    int lef, rig;
    int up, dow;
    int cnt;
    vector<pii> shit;
    for(int i = 1; i <= n; i ++ ){
        for(int j = 1; j <= n; j ++ ){
            lef = j;
            rig = n-j+1;
            up = i;
            dow = n-i+1;
            l1 = lef*up+(lef-1)*up+lef*(up-1)+(lef-1)*(up-1);
            l2 = rig*up+(rig-1)*up+rig*(up-1)+(rig-1)*(up-1);
            l3 = lef*dow+(lef-1)*dow+lef*(dow-1)+(lef-1)*(dow-1);
            l4 = rig*dow+(rig-1)*dow+rig*(dow-1)+(rig-1)*(dow-1);
            if(i > n/2 && j > n/2){
                cnt = go(1, 1, i, j) - go(1, 1, i - 1, j) - go(1, 1, i, j - 1) + go(1, 1, i - 1, j - 1);
                if(cnt)
                    shit.push_back(mp(i,j));
            }
            else if(j < n/2 && i > n/2){
                cnt = go(1, j, i, n) - go(1, j + 1, i, n) - go(1, j, i - 1, n) + go(1, j + 1, i - 1, n);
                if(cnt)
                    shit.push_back(mp(i,j));
            }
            else if(j > n/2 && i < n / 2){
                cnt = go(i, 1, n, j) - go(i + 1, 1, n, j) - go(i, 1, n, j - 1) + go(i + 1, 1, n, j - 1);
                if(cnt)
                    shit.push_back(mp(i, j));
            }
            else{
                cnt = go(i, j, n, n) - go(i + 1, j, n, n) - go(i, j + 1, n, n) + go(i + 1, j + 1, n, n);
                if(cnt)
                    shit.push_back(mp(i, j));
            }
        }
    }
    for(auto p : shit)
        Report(p.fi, p.se);
}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:26:9: warning: variable 'l1' set but not used [-Wunused-but-set-variable]
   26 |     int l1 = 0, l2 = 0, l3 = 0, l4 = 0;
      |         ^~
treasure.cpp:26:17: warning: variable 'l2' set but not used [-Wunused-but-set-variable]
   26 |     int l1 = 0, l2 = 0, l3 = 0, l4 = 0;
      |                 ^~
treasure.cpp:26:25: warning: variable 'l3' set but not used [-Wunused-but-set-variable]
   26 |     int l1 = 0, l2 = 0, l3 = 0, l4 = 0;
      |                         ^~
treasure.cpp:26:33: warning: variable 'l4' set but not used [-Wunused-but-set-variable]
   26 |     int l1 = 0, l2 = 0, l3 = 0, l4 = 0;
      |                                 ^~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 212 KB Output is partially correct - N = 5, K = 559, score = 1
2 Partially correct 0 ms 212 KB Output is partially correct - N = 10, K = 6557, score = 4
3 Partially correct 0 ms 212 KB Output is partially correct - N = 15, K = 29984, score = 4
4 Partially correct 1 ms 340 KB Output is partially correct - N = 16, K = 37877, score = 4
5 Partially correct 2 ms 468 KB Output is partially correct - N = 55, K = 4395684, score = 4
6 Partially correct 3 ms 596 KB Output is partially correct - N = 66, K = 8974677, score = 4
7 Partially correct 4 ms 724 KB Output is partially correct - N = 77, K = 16458031, score = 4
8 Partially correct 5 ms 852 KB Output is partially correct - N = 88, K = 27838049, score = 4
9 Partially correct 6 ms 980 KB Output is partially correct - N = 99, K = 44321042, score = 4
10 Partially correct 6 ms 980 KB Output is partially correct - N = 100, K = 46102847, score = 4