Submission #8575099


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int h, w, k;
    char s[500][500];
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) cin >> s[i];

    bool fh = false;
    int ans[500][500], cnt = 1;
    for (int i = 0; i < h; i++) {
        int ichigo = 0;
        for (int j = 0; j < w; j++) ichigo += (s[i][j] == '#');
        if (ichigo == 0) {
            if (fh) {
                for (int j = 0; j < w; j++) ans[i][j] = ans[i - 1][j];
            }
        }
        else {
            int j = 0;
            while (j < w) {
                int sub = 0;
                while (j + sub < w && s[i][j + sub] == '.') {
                    sub++;
                }
                if (s[i][j + sub] == '#') {
                    for (int p = 0; p <= sub; p++) ans[i][j + p] = cnt;
                    cnt++;
                }
                else {
                    for (int p = j; p < w; p++) ans[i][p] = cnt - 1;
                }
                j += sub + 1;

            }
            if (!fh) {
                for (int p = 0; p < i; p++) {
                    for (int q = 0; q < w; q++) ans[p][q] = ans[i][q];
                }
            }
            fh = true;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }

}

Submission Info

Submission Time
Task D - Digit Sum Replace
User ast210
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1619 Byte
Status RE
Exec Time 99 ms
Memory 1408 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
WA × 2
WA × 12
RE × 8
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-corner-01.txt, 01-corner-02.txt, 01-corner-03.txt, 02-random-01.txt, 02-random-02.txt, 02-random-03.txt, 02-random-04.txt, 02-random-05.txt, 02-random-06.txt, 02-random-07.txt, 02-random-08.txt, 02-random-09.txt, 02-random-10.txt, 02-random-11.txt, 03-max-01.txt, 03-max-02.txt, 04-min-01.txt, 04-min-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt WA 1 ms 256 KB
00-sample-02.txt WA 1 ms 256 KB
01-corner-01.txt WA 1 ms 256 KB
01-corner-02.txt WA 1 ms 256 KB
01-corner-03.txt WA 1 ms 256 KB
02-random-01.txt WA 1 ms 256 KB
02-random-02.txt WA 1 ms 256 KB
02-random-03.txt WA 1 ms 256 KB
02-random-04.txt WA 1 ms 256 KB
02-random-05.txt WA 1 ms 256 KB
02-random-06.txt RE 97 ms 1408 KB
02-random-07.txt RE 97 ms 1408 KB
02-random-08.txt RE 99 ms 256 KB
02-random-09.txt RE 99 ms 256 KB
02-random-10.txt RE 99 ms 256 KB
02-random-11.txt RE 99 ms 256 KB
03-max-01.txt RE 98 ms 256 KB
03-max-02.txt WA 1 ms 256 KB
04-min-01.txt RE 98 ms 1408 KB
04-min-02.txt WA 1 ms 256 KB