Submission #169758


Source Code Expand

Copy
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cstdarg>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
#include <bitset>
#include <set>
#include <stdio.h>

using namespace std;  
typedef vector<string>          vs;
typedef vector<int>             vi;
typedef long long               ll;
typedef pair<int, int>			pi;
#define sz(a)					int((a).size())
#define in(a)					atoi(a.c_str())
#define FOR(a,b,c)				for(int (a)=(b);(a)<(c);(a)++)
#define sor(a)					sort((a).begin(),(a).end())
#define all(i)					(i).begin(),(i).end()
#define pb						push_back
#define mp						make_pair
#define bug1(x)					cout<<#x<<" = "<<x<<endl
#define bug2(x,y)				cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z)				cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define INF INT_MAX/2
int dx[4] = { -1, 0, 0, 1 };
int dy[4] = { 0, -1, 1, 0 };
int cnt = 0;
int W;
int H;
void collect(int field[85][85], int x, int y, int direction) {
	if (x < 0 || y < 0 || x >= W || y >= H) return;
	if (field[y][x] == 0) {
		field[y][x] = 1;
		cnt++;
		int nx = x + dx[direction];
		int ny = y + dy[direction];
		collect(field, nx, ny, direction);
	}
}
int main(int argc, char* argv[]) 
{
	cin >> W >> H;
	int N;
	cin >> N;
	vector<pi> cranes;
	FOR(i, 0, N) {
		int x, y;
		cin >> x >> y;
		cranes.push_back(pair<int, int>(x - 1, y - 1));
	}
	int ret = 0;
	sor(cranes);
	do {
		int field[85][85] = {};
		cnt = 0;
		FOR(i, 0, sz(cranes)) {
			int x = cranes[i].first;
			int y = cranes[i].second;
			cnt += 1;
			FOR(k, 0, 4) {
				int nx = x + dx[k];
				int ny = y + dy[k];
				collect(field, nx, ny, k);
			}
		}
		ret = max(ret, cnt);

	} while (next_permutation(all(cranes)));

	cout << ret << endl;
    return 0;
}

Submission Info

Submission Time
Task D - 金塊ゲーム
User papepi
Language C++ (GCC 4.4.7)
Score 80
Code Size 2016 Byte
Status TLE
Exec Time 4032 ms
Memory 944 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
TLE × 25
AC × 25
TLE × 25
RE × 25
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 19 ms 916 KB
sample_02.txt AC 21 ms 924 KB
sample_03.txt AC 85 ms 916 KB
subtask1_01.txt AC 21 ms 924 KB
subtask1_02.txt AC 19 ms 912 KB
subtask1_03.txt AC 77 ms 920 KB
subtask1_04.txt AC 98 ms 916 KB
subtask1_05.txt AC 22 ms 808 KB
subtask1_06.txt AC 22 ms 920 KB
subtask1_07.txt AC 22 ms 924 KB
subtask1_08.txt AC 21 ms 848 KB
subtask1_09.txt AC 22 ms 920 KB
subtask1_10.txt AC 21 ms 924 KB
subtask1_11.txt AC 21 ms 916 KB
subtask1_12.txt AC 22 ms 808 KB
subtask1_13.txt AC 25 ms 800 KB
subtask1_14.txt AC 24 ms 804 KB
subtask1_15.txt AC 173 ms 920 KB
subtask1_16.txt AC 111 ms 804 KB
subtask1_17.txt AC 116 ms 824 KB
subtask1_18.txt AC 88 ms 920 KB
subtask1_19.txt AC 73 ms 908 KB
subtask1_20.txt AC 73 ms 848 KB
subtask1_21.txt AC 118 ms 912 KB
subtask1_22.txt AC 138 ms 916 KB
subtask1_23.txt AC 100 ms 812 KB
subtask1_24.txt AC 170 ms 924 KB
subtask1_25.txt AC 166 ms 876 KB
subtask2_01.txt TLE 4030 ms 912 KB
subtask2_02.txt TLE 4031 ms 932 KB
subtask2_03.txt TLE 4031 ms 796 KB
subtask2_04.txt TLE 4031 ms 796 KB
subtask2_05.txt TLE 4029 ms 920 KB
subtask2_06.txt TLE 4029 ms 936 KB
subtask2_07.txt TLE 4031 ms 788 KB
subtask2_08.txt TLE 4028 ms 928 KB
subtask2_09.txt TLE 4030 ms 920 KB
subtask2_10.txt TLE 4029 ms 920 KB
subtask2_11.txt TLE 4028 ms 932 KB
subtask2_12.txt TLE 4030 ms 932 KB
subtask2_13.txt TLE 4030 ms 920 KB
subtask2_14.txt TLE 4029 ms 920 KB
subtask2_15.txt TLE 4030 ms 944 KB
subtask2_16.txt TLE 4029 ms 936 KB
subtask2_17.txt TLE 4029 ms 920 KB
subtask2_18.txt TLE 4030 ms 920 KB
subtask2_19.txt TLE 4030 ms 936 KB
subtask2_20.txt TLE 4030 ms 936 KB
subtask2_21.txt TLE 4030 ms 924 KB
subtask2_22.txt TLE 4029 ms 924 KB
subtask2_23.txt TLE 4032 ms 792 KB
subtask2_24.txt TLE 4030 ms 828 KB
subtask2_25.txt TLE 4029 ms 924 KB
subtask3_01.txt RE 231 ms 920 KB
subtask3_02.txt RE 250 ms 916 KB
subtask3_03.txt RE 233 ms 924 KB
subtask3_04.txt RE 233 ms 916 KB
subtask3_05.txt RE 232 ms 812 KB
subtask3_06.txt RE 232 ms 796 KB
subtask3_07.txt RE 232 ms 796 KB
subtask3_08.txt RE 230 ms 920 KB
subtask3_09.txt RE 231 ms 916 KB
subtask3_10.txt RE 233 ms 920 KB
subtask3_11.txt RE 235 ms 920 KB
subtask3_12.txt RE 229 ms 920 KB
subtask3_13.txt RE 233 ms 792 KB
subtask3_14.txt RE 235 ms 924 KB
subtask3_15.txt RE 234 ms 916 KB
subtask3_16.txt RE 231 ms 916 KB
subtask3_17.txt RE 248 ms 812 KB
subtask3_18.txt RE 234 ms 808 KB
subtask3_19.txt RE 232 ms 920 KB
subtask3_20.txt RE 232 ms 796 KB
subtask3_21.txt RE 230 ms 848 KB
subtask3_22.txt RE 241 ms 924 KB
subtask3_23.txt RE 230 ms 864 KB
subtask3_24.txt RE 230 ms 924 KB
subtask3_25.txt RE 230 ms 924 KB