# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148063 | abacaba | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <stdio.h>
#include "treasure.h"
#include <assert.h>
#include <string.h>
using namespace __gnu_pbds;
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <random>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
bool a[105][105], used[105][105][105][105];
int dp[105][105][105][105];
int rec(int x1, int y1, int x2, int y2) {
x1 = max(x1, 1);
y1 = max(y1, 1);
x2 = min(x2, N);
y2 = min(y2, N);
if(x1 > x2 || y1 > y2)
return 0;
if(used[x1][y1][x2][y2])
return dp[x1][y1][x2][y2];
used[x1][y1][x2][y2] = true;
dp[x1][y1][x2][y2] = countTreasure(x1, y1, x2, y2);
return dp[x1][y1][x2][y2];
}
void findTreasure(int N) {
int n = (N >> 1) + 1;
for(int i = 1; i <= N; ++i) {
for(int j = 1; j <= N; ++j) {
if(i > n && j > n)
a[i][j] = rec(i, j, N, N) - rec(i + 1, j, N, N) - rec(i, j + 1, N, N) + rec(i + 1, j + 1, N, N);
else if(i <= n && j <= n)
a[i][j] = rec(1, 1, i, j) - rec(1, 1, i - 1, j) - rec(1, 1, i, j - 1) + rec(1, 1, i - 1, j - 1);
else if(i <= n && j > n)
a[i][j] = rec(1, j, i, N) - rec(1, j + 1, i, N) - rec(1, j, i - 1, N) + rec(1, j + 1, i - 1, N);
else
a[i][j] = rec(i, 1, N, j) - rec(i + 1, 1, N, j) - rec(i, 1, N, j - 1) + rec(i + 1, 1, N, j - 1);
}
}
for(int i = 1; i <= N; ++i)
for(int j = 1; j <= N; ++j)
if(a[i][j])
Report(i, j);
}