Submission #8575384


Source Code Expand

Copy
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s[334];
int cnt[334],ans[334][334];

int main(void){
	int h,w,k,i,j,p,n=0;
	bool flag;
	cin >> h >> w >> k;
	for(i=0; i<h; ++i){
		cin >> s[i];
		for(j=0; j<w; ++j){
			if(s[i][j]=='#'){
				++cnt[i];
			}
		}
	}
	for(i=0; i<h; ++i){
		if(cnt[i]){
			p = i;
			break;
		}
	}
	for(i=p; i<h; ++i){
		if(!cnt[i]){
			for(j=0; j<w; ++j){
				ans[i][j] = ans[i-1][j];
			}
			continue;
		}
		flag = false;
		++n;
		for(j=0; j<w; ++j){
			if(s[i][j]=='#'){
				if(flag){
					++n;
				}else{
					flag = true;
				}
			}
			ans[i][j] = n;
		}
	}
	for(i=0; i<p; ++i){
		for(j=0; j<w; ++j){
			ans[i][j] = ans[p][j];
		}
	}
	for(i=0; i<h; ++i){
		for(j=0; j<w; ++j){
			cout << ((j)?" ":"") << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task C - Strawberry Cakes
User ransewhale
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1148 Byte
Status AC
Exec Time 14 ms
Memory 1280 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 41
Set Name Test Cases
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
Case Name Status Exec Time Memory
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 1 ms 256 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 1280 KB
in18.txt AC 13 ms 1280 KB
in19.txt AC 13 ms 1280 KB
in20.txt AC 13 ms 1280 KB
in21.txt AC 13 ms 1152 KB
in22.txt AC 13 ms 1152 KB
in23.txt AC 1 ms 256 KB
in24.txt AC 1 ms 256 KB
in25.txt AC 12 ms 1024 KB
in26.txt AC 12 ms 1024 KB
in27.txt AC 1 ms 256 KB
in28.txt AC 13 ms 1280 KB
in29.txt AC 14 ms 1280 KB
in30.txt AC 13 ms 1280 KB
in31.txt AC 13 ms 1280 KB
in32.txt AC 13 ms 1280 KB
in33.txt AC 13 ms 1280 KB
in34.txt AC 13 ms 1280 KB
in35.txt AC 12 ms 1152 KB
in36.txt AC 13 ms 1152 KB
in37.txt AC 13 ms 1152 KB
in38.txt AC 13 ms 1152 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