Submission #148142

# Submission time Handle Problem Language Result Execution time Memory
148142 2019-08-31T14:16:46 Z abacaba Treasure (different grader from official contest) (CEOI13_treasure2) C++14
100 / 100
2 ms 380 KB
#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>

int dp[105][105], m, n;

inline pii part(int i, int j) {
	return mp(i > n, j > n);
}

void findTreasure(int N) {
	m = N, n = (N >> 1);
    for(int i = m; i; --i)
    	for(int j = m; j; --j) {
    		if(part(i, j) == mp(1, 1))
    			dp[i][j] = countTreasure(1, 1, i, j);
    		else if(part(i, j) == mp(1, 0))
    			dp[i][j] = dp[i][m] - (j < m ? countTreasure(1, j + 1, i, m) : 0);
    		else if(part(i, j) == mp(0, 1))
    			dp[i][j] = dp[m][j] - (i < m ? countTreasure(i + 1, 1, m, j) : 0);
    		else
    			dp[i][j] = -(dp[m][m] - dp[i][m] - dp[m][j] - (i < m && j < m ? countTreasure(i + 1, j + 1, m, m) : 0));
    	}
    for(int i = 1; i <= N; ++i)
    	for(int j = 1; j <= N; ++j)
    		if(dp[i][j] - dp[i-1][j] - dp[i][j-1] + dp[i-1][j-1])
	    		Report(i, j);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct - N = 5, K = 289, score = 10
2 Correct 2 ms 376 KB Output is correct - N = 10, K = 4475, score = 10
3 Correct 2 ms 376 KB Output is correct - N = 15, K = 22289, score = 10
4 Correct 2 ms 376 KB Output is correct - N = 16, K = 28928, score = 10
5 Correct 2 ms 376 KB Output is correct - N = 55, K = 4005289, score = 10
6 Correct 2 ms 376 KB Output is correct - N = 66, K = 8305803, score = 10
7 Correct 2 ms 380 KB Output is correct - N = 77, K = 15383161, score = 10
8 Correct 2 ms 376 KB Output is correct - N = 88, K = 26244416, score = 10
9 Correct 2 ms 376 KB Output is correct - N = 99, K = 42032201, score = 10
10 Correct 2 ms 376 KB Output is correct - N = 100, K = 43760000, score = 10