Submission #204663


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int w,h,n;
map<int,map<int,map<int,map<int,int> > > > dp;
int x[31], y[31];

int dfs(int sw, int sh, int ew, int eh){
	int res = dp[sw][sh][ew][eh];
	if(res != 0) return res;
	rep(i,n){
		if(sw<x[i]&&x[i]<=ew&&sh<y[i]&&y[i]<=eh){
			int tmp = 0;
			tmp += ew-sw+eh-sh-1;
			tmp += dfs(sw,sh,x[i]-1,y[i]-1);
			tmp += dfs(x[i],sh,ew,y[i]-1);
			tmp += dfs(sw,y[i],x[i]-1,eh);
			tmp += dfs(x[i],y[i],ew,eh);
			res = max(res,tmp);
		}
	}
	return dp[sw][sh][ew][eh] = res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> w >> h >> n;
	rep(i,n) cin >> x[i] >> y[i];
	cout << dfs(0,0,w,h) << endl;
}

Submission Info

Submission Time
Task D - 金塊ゲーム
User gasin
Language C++ (G++ 4.6.4)
Score 100
Code Size 1565 Byte
Status AC
Exec Time 111 ms
Memory 2160 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 80 / 80 19 / 19 1 / 1
Status
AC × 3
AC × 25
AC × 50
AC × 75
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt, subtask3_13.txt, subtask3_14.txt, subtask3_15.txt, subtask3_16.txt, subtask3_17.txt, subtask3_18.txt, subtask3_19.txt, subtask3_20.txt, subtask3_21.txt, subtask3_22.txt, subtask3_23.txt, subtask3_24.txt, subtask3_25.txt
Case Name Status Exec Time Memory
sample_01.txt AC 34 ms 860 KB
sample_02.txt AC 23 ms 928 KB
sample_03.txt AC 23 ms 932 KB
subtask1_01.txt AC 25 ms 928 KB
subtask1_02.txt AC 24 ms 932 KB
subtask1_03.txt AC 24 ms 940 KB
subtask1_04.txt AC 23 ms 928 KB
subtask1_05.txt AC 25 ms 928 KB
subtask1_06.txt AC 24 ms 924 KB
subtask1_07.txt AC 22 ms 928 KB
subtask1_08.txt AC 22 ms 932 KB
subtask1_09.txt AC 24 ms 928 KB
subtask1_10.txt AC 21 ms 928 KB
subtask1_11.txt AC 22 ms 928 KB
subtask1_12.txt AC 23 ms 932 KB
subtask1_13.txt AC 22 ms 864 KB
subtask1_14.txt AC 22 ms 928 KB
subtask1_15.txt AC 23 ms 924 KB
subtask1_16.txt AC 22 ms 932 KB
subtask1_17.txt AC 22 ms 920 KB
subtask1_18.txt AC 22 ms 984 KB
subtask1_19.txt AC 23 ms 924 KB
subtask1_20.txt AC 22 ms 932 KB
subtask1_21.txt AC 22 ms 924 KB
subtask1_22.txt AC 23 ms 924 KB
subtask1_23.txt AC 22 ms 932 KB
subtask1_24.txt AC 24 ms 928 KB
subtask1_25.txt AC 22 ms 936 KB
subtask2_01.txt AC 24 ms 1060 KB
subtask2_02.txt AC 24 ms 1056 KB
subtask2_03.txt AC 30 ms 1132 KB
subtask2_04.txt AC 28 ms 1188 KB
subtask2_05.txt AC 33 ms 1392 KB
subtask2_06.txt AC 38 ms 1508 KB
subtask2_07.txt AC 35 ms 1512 KB
subtask2_08.txt AC 35 ms 1512 KB
subtask2_09.txt AC 49 ms 1904 KB
subtask2_10.txt AC 49 ms 2160 KB
subtask2_11.txt AC 47 ms 2028 KB
subtask2_12.txt AC 48 ms 1900 KB
subtask2_13.txt AC 36 ms 1524 KB
subtask2_14.txt AC 35 ms 1520 KB
subtask2_15.txt AC 21 ms 924 KB
subtask2_16.txt AC 34 ms 1516 KB
subtask2_17.txt AC 49 ms 1956 KB
subtask2_18.txt AC 50 ms 1900 KB
subtask2_19.txt AC 49 ms 1908 KB
subtask2_20.txt AC 52 ms 1980 KB
subtask2_21.txt AC 49 ms 2032 KB
subtask2_22.txt AC 49 ms 1900 KB
subtask2_23.txt AC 49 ms 1904 KB
subtask2_24.txt AC 50 ms 1908 KB
subtask2_25.txt AC 52 ms 2032 KB
subtask3_01.txt AC 22 ms 924 KB
subtask3_02.txt AC 24 ms 1056 KB
subtask3_03.txt AC 27 ms 1004 KB
subtask3_04.txt AC 29 ms 1132 KB
subtask3_05.txt AC 31 ms 1388 KB
subtask3_06.txt AC 28 ms 1140 KB
subtask3_07.txt AC 28 ms 1140 KB
subtask3_08.txt AC 35 ms 1516 KB
subtask3_09.txt AC 36 ms 1512 KB
subtask3_10.txt AC 50 ms 1912 KB
subtask3_11.txt AC 50 ms 1912 KB
subtask3_12.txt AC 50 ms 1964 KB
subtask3_13.txt AC 50 ms 2028 KB
subtask3_14.txt AC 49 ms 1904 KB
subtask3_15.txt AC 49 ms 1960 KB
subtask3_16.txt AC 48 ms 1904 KB
subtask3_17.txt AC 49 ms 2024 KB
subtask3_18.txt AC 32 ms 1392 KB
subtask3_19.txt AC 49 ms 1904 KB
subtask3_20.txt AC 37 ms 1512 KB
subtask3_21.txt AC 51 ms 1884 KB
subtask3_22.txt AC 51 ms 1900 KB
subtask3_23.txt AC 51 ms 1908 KB
subtask3_24.txt AC 111 ms 1960 KB
subtask3_25.txt AC 50 ms 1900 KB