# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238997 | ant101 | 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 "grader.h"
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;
//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007
typedef long long ll;
ll add(ll a, ll b) {
a += b;
if(a >= MOD) {
a -= MOD;
}
return a;
}
ll sub(ll a, ll b) {
a -= b;
if(a < 0) {
a += MOD;
}
return a;
}
ll mul(ll a, ll b) {
return (a * b)%MOD;
}
void add_self(ll& a, ll b) {
a = add(a, b);
}
void sub_self(ll& a, ll b) {
a = sub(a, b);
}
void mul_self(ll& a, ll b) {
a = mul(a, b);
}
const ll MAXN = 200010;
ll grid[MAXN][MAXN];
ll N;
ll save[MAXN][MAXN];
const int maxn = 110;
int pref[maxn][maxn];
void findTreasure(int N)
{
for (int i = N; i >= 1; i--)
{
for (int j = N; j >= 1; j--)
{
if (i > N/2 && j > N/2)
pref[i][j] = countTreasure(1, 1, i, j);
else if (i > N/2 && j <= N/2)
pref[i][j] = pref[i][N] - countTreasure(1, j+1, i, N);
else if (i <= N/2 && j <= N/2)
pref[i][j] = pref[i][N] + pref[N][j] + countTreasure(i+1, j+1, N, N) - pref[N][N];
else
pref[i][j] = pref[N][j] - countTreasure(i+1, 1, N, j);
}
}
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
if (pref[i][j]-pref[i-1][j]-pref[i][j-1]+pref[i-1][j-1] == 1)
Report(i, j);
}