Submission #169426


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 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 pair<int, int> P;
typedef long long int ll;
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;
ll ans = 0;
bool gold[80][80];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> w >> h >> n;
	Vp mac(n);
	if(w > 80 || h > 80 || n > 8) return 0;
	rep(i,n) cin >> mac[i].fi >> mac[i].sec;
	rep(i,n){
		mac[i].fi--;
		mac[i].sec--;
	}
	SORT(mac);
	do{
		rep(i,w) rep(j,h) gold[i][j] = false;
		ll tmp = 0;
		rep(i,n){
			int x = mac[i].fi, y = mac[i].sec;
			if(gold[x][y] == false){
				gold[x][y] = true;
				tmp++;
			}
			for(int j = x+1; j < w; j++){
				if(gold[j][y] == false){
					gold[j][y] = true;
					tmp++;
				}
				else break;
			}
			for(int j = x-1; j >= 0; j--){
				if(gold[j][y] == false){
					gold[j][y] = true;
					tmp++;
				}
				else break;
			}
			for(int j = y+1; j < h; j++){
				if(gold[x][j] == false){
					gold[x][j] = true;
					tmp++;
				}
				else break;
			}
			for(int j = y-1; j >= 0; j--){
				if(gold[x][j] == false){
					gold[x][j] = true;
					tmp++;
				}
				else break;
			}
		}
		if(tmp > ans) ans = tmp;
	} while(next_permutation(mac.begin(), mac.end()));
	
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - 金塊ゲーム
User gasin
Language C++ (G++ 4.6.4)
Score 80
Code Size 2016 Byte
Status WA
Exec Time 374 ms
Memory 932 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 80 / 80 0 / 19 0 / 1
Status
AC × 3
AC × 25
AC × 25
WA × 25
AC × 25
WA × 50
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 22 ms 920 KB
sample_02.txt AC 20 ms 924 KB
sample_03.txt AC 41 ms 932 KB
subtask1_01.txt AC 19 ms 928 KB
subtask1_02.txt AC 19 ms 920 KB
subtask1_03.txt AC 34 ms 804 KB
subtask1_04.txt AC 60 ms 928 KB
subtask1_05.txt AC 19 ms 928 KB
subtask1_06.txt AC 21 ms 924 KB
subtask1_07.txt AC 21 ms 924 KB
subtask1_08.txt AC 21 ms 932 KB
subtask1_09.txt AC 22 ms 920 KB
subtask1_10.txt AC 21 ms 804 KB
subtask1_11.txt AC 21 ms 924 KB
subtask1_12.txt AC 21 ms 804 KB
subtask1_13.txt AC 22 ms 928 KB
subtask1_14.txt AC 27 ms 932 KB
subtask1_15.txt AC 367 ms 792 KB
subtask1_16.txt AC 82 ms 932 KB
subtask1_17.txt AC 105 ms 800 KB
subtask1_18.txt AC 43 ms 808 KB
subtask1_19.txt AC 33 ms 800 KB
subtask1_20.txt AC 32 ms 932 KB
subtask1_21.txt AC 123 ms 812 KB
subtask1_22.txt AC 152 ms 800 KB
subtask1_23.txt AC 52 ms 756 KB
subtask1_24.txt AC 324 ms 928 KB
subtask1_25.txt AC 374 ms 932 KB
subtask2_01.txt WA 20 ms 924 KB
subtask2_02.txt WA 21 ms 804 KB
subtask2_03.txt WA 21 ms 812 KB
subtask2_04.txt WA 21 ms 756 KB
subtask2_05.txt WA 21 ms 928 KB
subtask2_06.txt WA 20 ms 928 KB
subtask2_07.txt WA 20 ms 932 KB
subtask2_08.txt WA 20 ms 924 KB
subtask2_09.txt WA 20 ms 928 KB
subtask2_10.txt WA 22 ms 732 KB
subtask2_11.txt WA 21 ms 928 KB
subtask2_12.txt WA 20 ms 928 KB
subtask2_13.txt WA 21 ms 928 KB
subtask2_14.txt WA 20 ms 792 KB
subtask2_15.txt WA 21 ms 928 KB
subtask2_16.txt WA 25 ms 924 KB
subtask2_17.txt WA 21 ms 924 KB
subtask2_18.txt WA 21 ms 812 KB
subtask2_19.txt WA 21 ms 924 KB
subtask2_20.txt WA 21 ms 928 KB
subtask2_21.txt WA 21 ms 928 KB
subtask2_22.txt WA 21 ms 748 KB
subtask2_23.txt WA 23 ms 768 KB
subtask2_24.txt WA 20 ms 796 KB
subtask2_25.txt WA 20 ms 800 KB
subtask3_01.txt WA 21 ms 804 KB
subtask3_02.txt WA 21 ms 928 KB
subtask3_03.txt WA 21 ms 928 KB
subtask3_04.txt WA 21 ms 928 KB
subtask3_05.txt WA 19 ms 796 KB
subtask3_06.txt WA 21 ms 764 KB
subtask3_07.txt WA 21 ms 928 KB
subtask3_08.txt WA 21 ms 764 KB
subtask3_09.txt WA 21 ms 928 KB
subtask3_10.txt WA 20 ms 804 KB
subtask3_11.txt WA 20 ms 924 KB
subtask3_12.txt WA 21 ms 804 KB
subtask3_13.txt WA 21 ms 808 KB
subtask3_14.txt WA 22 ms 760 KB
subtask3_15.txt WA 21 ms 932 KB
subtask3_16.txt WA 20 ms 796 KB
subtask3_17.txt WA 20 ms 796 KB
subtask3_18.txt WA 20 ms 800 KB
subtask3_19.txt WA 21 ms 732 KB
subtask3_20.txt WA 20 ms 932 KB
subtask3_21.txt WA 21 ms 928 KB
subtask3_22.txt WA 21 ms 932 KB
subtask3_23.txt WA 21 ms 928 KB
subtask3_24.txt WA 21 ms 928 KB
subtask3_25.txt WA 21 ms 800 KB