Submission #169492


Source Code Expand

Copy
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;
#define whole(xs) xs.begin(), xs.end()

struct P {
    int x, y;
    P(int x, int y) : x(x), y(y) {}
};
bool operator<(const P& a, const P& b) {
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}

int W, H;
int N;
vector<P> Ps;

/* bit :: 0 -> 東西, 1 -> 南北 */
int Calc() {
#define MW 80
#define MH 80
    static bool F[MW][MH];
    int Count = 0;
    for (int i = 0; i < W; i++) 
        for (int j = 0; j < H; j++)
            F[i][j] = true;
    for (int i = 0; i < N; i++) {
        int x = Ps[i].x;
        int y = Ps[i].y;
        for (int a = y + 1; a < H && F[x][a]; a++) {
            Count++;
            F[x][a] = false;
        }
        for (int a = y - 1; a >= 0 && F[x][a]; a--) {
            Count++;
            F[x][a] = false;
        }
        for (int a = x + 1; a < W && F[a][y]; a++) {
            Count++;
            F[a][y] = false;
        }
        for (int a = x - 1; a >= 0 && F[a][y]; a--) {
            Count++;
            F[a][y] = false;
        }
        Count++;
        F[x][y] = false;
    }
    /*
    for (int i = 0; i < W; i++) {
        for (int j = 0; j < H; j++) {
            cout << setw(1) << F[i][j];
        }
        cout << endl;
    }
    cout << endl;
    */
    return Count;
}

string to_b(int x) {
    string ret;
    while (x) {
        if (x % 2) {
            ret.push_back('1');
        } else {
            ret.push_back('0');
        }
        x /= 2;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    cin >> W >> H >> N;
    for (int i = 0; i < N; i++) {
        int X, Y;
        cin >> X >> Y;
        X--; Y--;
        Ps.push_back(P(X, Y));
    }
    vector<P> Pt = Ps;
    sort(whole(Ps));
    int ans = 0;
    do {
        ans = max(ans, Calc());
    } while (next_permutation(whole(Ps)));
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - 金塊ゲーム
User izuru
Language C++ (G++ 4.6.4)
Score 80
Code Size 2185 Byte
Status TLE
Exec Time 4036 ms
Memory 936 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 23 ms 928 KB
sample_02.txt AC 21 ms 800 KB
sample_03.txt AC 41 ms 800 KB
subtask1_01.txt AC 22 ms 928 KB
subtask1_02.txt AC 21 ms 932 KB
subtask1_03.txt AC 37 ms 796 KB
subtask1_04.txt AC 65 ms 928 KB
subtask1_05.txt AC 21 ms 928 KB
subtask1_06.txt AC 22 ms 800 KB
subtask1_07.txt AC 23 ms 808 KB
subtask1_08.txt AC 20 ms 788 KB
subtask1_09.txt AC 24 ms 920 KB
subtask1_10.txt AC 23 ms 812 KB
subtask1_11.txt AC 21 ms 924 KB
subtask1_12.txt AC 22 ms 924 KB
subtask1_13.txt AC 23 ms 792 KB
subtask1_14.txt AC 28 ms 916 KB
subtask1_15.txt AC 366 ms 812 KB
subtask1_16.txt AC 86 ms 804 KB
subtask1_17.txt AC 110 ms 808 KB
subtask1_18.txt AC 46 ms 796 KB
subtask1_19.txt AC 33 ms 716 KB
subtask1_20.txt AC 36 ms 804 KB
subtask1_21.txt AC 126 ms 920 KB
subtask1_22.txt AC 152 ms 812 KB
subtask1_23.txt AC 55 ms 920 KB
subtask1_24.txt AC 324 ms 928 KB
subtask1_25.txt AC 373 ms 924 KB
subtask2_01.txt TLE 4031 ms 808 KB
subtask2_02.txt TLE 4029 ms 928 KB
subtask2_03.txt TLE 4031 ms 812 KB
subtask2_04.txt TLE 4029 ms 812 KB
subtask2_05.txt TLE 4030 ms 876 KB
subtask2_06.txt TLE 4036 ms 928 KB
subtask2_07.txt TLE 4030 ms 804 KB
subtask2_08.txt TLE 4030 ms 808 KB
subtask2_09.txt TLE 4030 ms 808 KB
subtask2_10.txt TLE 4030 ms 816 KB
subtask2_11.txt TLE 4029 ms 932 KB
subtask2_12.txt TLE 4028 ms 932 KB
subtask2_13.txt TLE 4036 ms 920 KB
subtask2_14.txt TLE 4028 ms 924 KB
subtask2_15.txt TLE 4031 ms 868 KB
subtask2_16.txt TLE 4030 ms 800 KB
subtask2_17.txt TLE 4028 ms 804 KB
subtask2_18.txt TLE 4031 ms 808 KB
subtask2_19.txt TLE 4029 ms 928 KB
subtask2_20.txt TLE 4029 ms 928 KB
subtask2_21.txt TLE 4029 ms 936 KB
subtask2_22.txt TLE 4029 ms 920 KB
subtask2_23.txt TLE 4029 ms 928 KB
subtask2_24.txt TLE 4029 ms 924 KB
subtask2_25.txt TLE 4030 ms 924 KB
subtask3_01.txt RE 256 ms 796 KB
subtask3_02.txt RE 246 ms 716 KB
subtask3_03.txt RE 258 ms 788 KB
subtask3_04.txt RE 261 ms 800 KB
subtask3_05.txt RE 266 ms 804 KB
subtask3_06.txt RE 251 ms 928 KB
subtask3_07.txt RE 259 ms 672 KB
subtask3_08.txt RE 247 ms 796 KB
subtask3_09.txt RE 251 ms 740 KB
subtask3_10.txt RE 260 ms 800 KB
subtask3_11.txt RE 262 ms 800 KB
subtask3_12.txt RE 257 ms 804 KB
subtask3_13.txt RE 254 ms 748 KB
subtask3_14.txt RE 255 ms 800 KB
subtask3_15.txt RE 258 ms 796 KB
subtask3_16.txt RE 258 ms 696 KB
subtask3_17.txt RE 252 ms 672 KB
subtask3_18.txt RE 256 ms 796 KB
subtask3_19.txt RE 247 ms 800 KB
subtask3_20.txt RE 241 ms 928 KB
subtask3_21.txt RE 241 ms 920 KB
subtask3_22.txt RE 256 ms 800 KB
subtask3_23.txt RE 261 ms 676 KB
subtask3_24.txt RE 315 ms 800 KB
subtask3_25.txt RE 255 ms 800 KB