Submission #169745
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; #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<pair<int, int>> 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] = {}; vector<pair<int, int>> buf; 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++ (G++ 4.6.4) |
Score | 0 |
Code Size | 2029 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main(int, char**)’: ./Main.cpp:57:22: error: ‘>>’ should be ‘> >’ within a nested template argument list ./Main.cpp:67:23: error: ‘>>’ should be ‘> >’ within a nested template argument list