ソースコード 拡げる

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;
}

}
```

#### 提出情報

提出日時 2019-11-23 21:13:34+0900 C - Strawberry Cakes ast210 C++14 (GCC 5.4.1) 400 1619 Byte AC 14 ms 1536 KB

#### ジャッジ結果

セット名 Sample All

 AC × 3
 AC × 41
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
in01.txt AC 1 ms 256 KB
in02.txt AC 1 ms 256 KB
in03.txt AC 1 ms 256 KB
in04.txt AC 1 ms 256 KB
in05.txt AC 1 ms 256 KB
in06.txt AC 1 ms 256 KB
in07.txt AC 1 ms 256 KB
in08.txt AC 1 ms 256 KB
in09.txt AC 2 ms 384 KB
in10.txt AC 1 ms 256 KB
in11.txt AC 1 ms 256 KB
in12.txt AC 1 ms 256 KB
in13.txt AC 1 ms 256 KB
in14.txt AC 1 ms 256 KB
in15.txt AC 1 ms 256 KB
in16.txt AC 1 ms 256 KB
in17.txt AC 13 ms 1408 KB
in18.txt AC 13 ms 1408 KB
in19.txt AC 13 ms 1408 KB
in20.txt AC 13 ms 1408 KB
in21.txt AC 12 ms 1280 KB
in22.txt AC 12 ms 1280 KB
in23.txt AC 1 ms 256 KB
in24.txt AC 1 ms 256 KB
in25.txt AC 12 ms 1280 KB
in26.txt AC 12 ms 1280 KB
in27.txt AC 1 ms 256 KB
in28.txt AC 14 ms 1408 KB
in29.txt AC 13 ms 1536 KB
in30.txt AC 13 ms 1536 KB
in31.txt AC 13 ms 1536 KB
in32.txt AC 14 ms 1536 KB
in33.txt AC 13 ms 1536 KB
in34.txt AC 13 ms 1536 KB
in35.txt AC 12 ms 1280 KB
in36.txt AC 12 ms 1408 KB
in37.txt AC 12 ms 1408 KB
in38.txt AC 12 ms 1408 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB