Submission #503089

#TimeUsernameProblemLanguageResultExecution timeMemory
503089bang627Treasure (different grader from official contest) (CEOI13_treasure2)C++14
0 / 100
7 ms1056 KiB
#include "treasure.h" #include <iostream> #include <map> using namespace std; struct my_key { int x1, x2, y1, y2; my_key(int X1, int Y1, int X2, int Y2) : x1(X1), y1(Y1), x2(X2), y2(Y2) {} bool operator <(const my_key& b) const { if (x1 < b.x1) return true; else if (x1 > b.x1) return false; if (y1 < b.y1) return true; else if (y1 > b.y1) return false; if (x2 < b.x2) return true; else if (x2 > b.x2) return false; if (y2 < b.y2) return true; else return false; } }; map<my_key, int> dp; int arr[4]; int N2; void dp_set(int x1, int y1, int x2, int y2,int k) { if (x1<0 || x1>N2 - 1 || y1<0 || y1>N2 - 1 || x2<0 || x2>N2 - 1 || y2<0 || y2>N2 - 1) return; if (dp.find(my_key(x1, y1, x2, y2)) == dp.end()) dp.insert(pair<my_key, int>(my_key(x1, y1, x2, y2), arr[k] = countTreasure(x1 + 1, y1 + 1, x2 + 1, y2 + 1))); else arr[k] = dp[my_key(x1, y1, x2, y2)]; } void findTreasure (int N) { N2 = N; int** board = new int* [N]; for (int i = 0; i < N; i++) board[i] = new int [N]; int mx = (int)(N) / 2, my = (int)(N) / 2; for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) { arr[0] = 0, arr[1] = 0, arr[2] = 0, arr[3] = 0; if (i <= mx) { if (j <= my) { dp_set(i, j, N - 1, N - 1,0); dp_set(i+1, j, N - 1, N - 1,1); dp_set(i, j+1, N - 1, N - 1,2); dp_set(i+1, j+1, N - 1, N - 1,3); } else { dp_set(i, 0, N - 1, j,0); dp_set(i+1, 0, N-1, j,1); dp_set(i, 0 , N - 1, j - 1,2); dp_set(i + 1, 0, N - 1, j-1,3); } } else { if (j <= my) { dp_set(0, j, i, N - 1,0); dp_set(0, j, i - 1, N - 1,1); dp_set(0, j+1, i, N - 1,2); dp_set(0, j + 1, i-1, N - 1,3); } else { dp_set(0, 0, i, j,0); dp_set(0, 0, i-1, j,1); dp_set(0, 0, i, j-1,2); dp_set(0, 0, i - 1, j-1,3); } } board[i][j] =arr[0] - arr[1] - arr[2] + arr[3]; } //solution(1, 1, N, N, board); for (int i = 0; i<N; i++) { for (int j = 0; j < N; j++) { cout << board[i][j] << " "; if (board[i][j] == 1) Report(i + 1, j + 1); } cout << endl; } //if(cnt > 0) Report (1, 1); }

Compilation message (stderr)

treasure.cpp: In constructor 'my_key::my_key(int, int, int, int)':
treasure.cpp:7:17: warning: 'my_key::y1' will be initialized after [-Wreorder]
    7 |     int x1, x2, y1, y2;
      |                 ^~
treasure.cpp:7:13: warning:   'int my_key::x2' [-Wreorder]
    7 |     int x1, x2, y1, y2;
      |             ^~
treasure.cpp:8:5: warning:   when initialized here [-Wreorder]
    8 |     my_key(int X1, int Y1, int X2, int Y2) : x1(X1), y1(Y1), x2(X2), y2(Y2) {}
      |     ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...