Submission #34278


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <sstream>

using namespace std;

void erase(vector<vector<int> > &a, int i, int j) {
    int di[8] = {-1,0,1,-1,1,-1,0,1}, dj[8]={-1,-1,-1,0,0,1,1,1};
    if (i<0 || a.size() <= i || j<0 || a[0].size() <= j)return;
    if (a[i][j] == 0)return;
    a[i][j] = 0;
    for (int c=0; c<8; c++) {
        int ni = i+di[c];
        int nj = j+dj[c];
        if (ni<0 || a.size() <= ni || nj<0 || a[0].size() <= nj)continue;
        if (a[ni][nj] == 0)continue;
        erase(a, ni, nj);
    }
}

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> mat(h);
    vector<vector<int> > sumi(h+1, vector<int>(w+1)),sumj(h+1, vector<int>(w+1));
    for (int i=0; i<h; i++) {
        cin >> mat[i];
    }

    for (int i=1; i<h; i++) {
        for (int j=1; j<w; j++) {
            if (mat[i][j] == 'o') {
                sumi[i][j] = sumi[i-1][j] + 1;
                sumj[i][j] = sumj[i][j-1] + 1;
            } else {
                sumi[i][j] = 0;
                sumj[i][j] = 0;
            }
        }
    }    
    int a = 0,b = 0,c = 0;
    for (int k=142; k>0; k--) {
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (sumi[i][j] == k * 5 && sumj[i][j] == k * 2 && sumi[i+1][j] == 0 || sumi[i][j] == k * 2 && sumj[i][j] == k * 5 && sumj[i][j+1] == 0) {
                    a++;
                    erase(sumi, i, j);
                    erase(sumj, i, j);
                }
            }
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (sumi[i][j] == k * 4 && sumj[i][j] == k * 1 && sumi[i+1][j] == 0 || sumi[i][j] == k * 1 && sumj[i][j] == k * 4 && sumj[i][j+1] == 0){
                    b++;
                    erase(sumi, i, j);
                    erase(sumj, i, j);
                }
            }
        }
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if ((sumi[i][j] == k * 3 && sumj[i][j] == k * 1 || sumi[i][j] == k * 1 && sumj[i][j] == k * 3) && (sumi[i+1][j] == 0 && sumj[i][j+1] == 0)) {
                    c++;
                    erase(sumi, i, j);
                    erase(sumj, i, j);
                }
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
}

Submission Info

Submission Time
Task D - アルファベット探し
User y3eadgbe
Language C++ (G++ 4.6.4)
Score 0
Code Size 2422 Byte
Status WA
Exec Time 1006 ms
Memory 19724 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 33
WA × 21
RE × 4
Set Name Test Cases
All 00_min.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rndsmall_00.txt, 01_rndsmall_01.txt, 01_rndsmall_02.txt, 01_rndsmall_03.txt, 01_rndsmall_04.txt, 01_rndsmall_05.txt, 01_rndsmall_06.txt, 01_rndsmall_07.txt, 01_rndsmall_08.txt, 01_rndsmall_09.txt, 01_rndsmall_10.txt, 01_rndsmall_11.txt, 01_rndsmall_12.txt, 01_rndsmall_13.txt, 01_rndsmall_14.txt, 01_rndsmall_15.txt, 01_rndsmall_16.txt, 01_rndsmall_17.txt, 01_rndsmall_18.txt, 01_rndsmall_19.txt, 02_rndmax_00.txt, 02_rndmax_01.txt, 02_rndmax_02.txt, 02_rndmax_03.txt, 02_rndmax_04.txt, 02_rndmax_05.txt, 02_rndmax_06.txt, 02_rndmax_07.txt, 02_rndmax_08.txt, 02_rndmax_09.txt, 02_rndmax_10.txt, 02_rndmax_11.txt, 02_rndmax_12.txt, 02_rndmax_13.txt, 02_rndmax_14.txt, 02_rndmax_15.txt, 02_rndmax_16.txt, 02_rndmax_17.txt, 02_rndmax_18.txt, 02_rndmax_19.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt, 03_rnd_05.txt, 03_rnd_06.txt, 03_rnd_07.txt, 03_rnd_08.txt, 03_rnd_09.txt, 04_empty_00.txt, 05_maxret_00.txt
Case Name Status Exec Time Memory
00_min.txt AC 22 ms 780 KB
00_sample_01.txt AC 21 ms 792 KB
00_sample_02.txt AC 25 ms 788 KB
00_sample_03.txt AC 20 ms 784 KB
00_sample_04.txt AC 20 ms 784 KB
00_sample_05.txt AC 21 ms 788 KB
01_rndsmall_00.txt AC 31 ms 884 KB
01_rndsmall_01.txt AC 31 ms 1008 KB
01_rndsmall_02.txt AC 31 ms 916 KB
01_rndsmall_03.txt AC 31 ms 868 KB
01_rndsmall_04.txt AC 31 ms 896 KB
01_rndsmall_05.txt AC 31 ms 888 KB
01_rndsmall_06.txt AC 33 ms 920 KB
01_rndsmall_07.txt AC 31 ms 920 KB
01_rndsmall_08.txt AC 31 ms 916 KB
01_rndsmall_09.txt AC 31 ms 900 KB
01_rndsmall_10.txt AC 30 ms 912 KB
01_rndsmall_11.txt AC 30 ms 912 KB
01_rndsmall_12.txt AC 31 ms 884 KB
01_rndsmall_13.txt AC 31 ms 912 KB
01_rndsmall_14.txt AC 31 ms 912 KB
01_rndsmall_15.txt AC 31 ms 896 KB
01_rndsmall_16.txt AC 31 ms 892 KB
01_rndsmall_17.txt AC 31 ms 888 KB
01_rndsmall_18.txt AC 30 ms 916 KB
01_rndsmall_19.txt AC 32 ms 916 KB
02_rndmax_00.txt WA 973 ms 11012 KB
02_rndmax_01.txt WA 978 ms 10752 KB
02_rndmax_02.txt WA 994 ms 9844 KB
02_rndmax_03.txt WA 987 ms 10500 KB
02_rndmax_04.txt WA 978 ms 10104 KB
02_rndmax_05.txt WA 991 ms 11132 KB
02_rndmax_06.txt RE 331 ms 19712 KB
02_rndmax_07.txt RE 601 ms 19696 KB
02_rndmax_08.txt WA 986 ms 10868 KB
02_rndmax_09.txt WA 964 ms 10628 KB
02_rndmax_10.txt WA 958 ms 11000 KB
02_rndmax_11.txt WA 966 ms 12168 KB
02_rndmax_12.txt WA 958 ms 10740 KB
02_rndmax_13.txt RE 612 ms 19724 KB
02_rndmax_14.txt RE 330 ms 19708 KB
02_rndmax_15.txt WA 994 ms 10120 KB
02_rndmax_16.txt WA 988 ms 14076 KB
02_rndmax_17.txt WA 983 ms 13056 KB
02_rndmax_18.txt WA 980 ms 11644 KB
02_rndmax_19.txt WA 983 ms 10752 KB
03_rnd_00.txt AC 44 ms 1032 KB
03_rnd_01.txt WA 224 ms 3328 KB
03_rnd_02.txt AC 214 ms 2680 KB
03_rnd_03.txt WA 252 ms 3944 KB
03_rnd_04.txt WA 290 ms 4092 KB
03_rnd_05.txt AC 75 ms 1532 KB
03_rnd_06.txt AC 364 ms 4340 KB
03_rnd_07.txt AC 134 ms 2028 KB
03_rnd_08.txt WA 518 ms 11772 KB
03_rnd_09.txt WA 426 ms 5116 KB
04_empty_00.txt AC 954 ms 9680 KB
05_maxret_00.txt AC 1006 ms 9668 KB