Submission #8587526


Source Code Expand

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int H, W, K;
string S[303];
int cnt[303];
//---------------------------------------------------------------------------------------------------
int ans[303][303];
int idx = 1;
void go(int sx, int tx) {
	vector<int> vy;
	rep(y, 0, H) {
		int sm = 0;
		rep(x, sx, tx + 1) if (S[y][x] == '#') sm++;
		if (0 < sm) vy.push_back(y);
	}
	int pre = 0;
	int ny = vy.size();
	rep(i, 0, ny - 1) {
		rep(y, pre, vy[i] + 1) rep(x, sx, tx + 1) ans[y][x] = idx;
		idx++;
		pre = vy[i] + 1;
	}
	rep(y, pre, H) rep(x, sx, tx + 1) ans[y][x] = idx;
	idx++;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> W >> K;
	rep(y, 0, H) cin >> S[y];

	rep(y, 0, H) rep(x, 0, W) if (S[y][x] == '#') cnt[x]++;
	vector<int> vx;
	rep(x, 0, W) if (0 < cnt[x]) vx.push_back(x);

	int nx = vx.size();
	int pre = 0;
	rep(i, 0, nx - 1) {
		go(pre, vx[i]);
		pre = vx[i] + 1;
	}
	go(pre, W);

	rep(y, 0, H) {
		rep(x, 0, W) {
			if (x) printf(" ");
			printf("%d", ans[y][x]);
		}
		printf("\n");
	}
}





Submission Info

Submission Time
Task C - Strawberry Cakes
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2381 Byte
Status AC
Exec Time 11 ms
Memory 1280 KiB

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 KiB
in02.txt AC 1 ms 256 KiB
in03.txt AC 1 ms 256 KiB
in04.txt AC 1 ms 256 KiB
in05.txt AC 1 ms 256 KiB
in06.txt AC 1 ms 256 KiB
in07.txt AC 1 ms 256 KiB
in08.txt AC 1 ms 256 KiB
in09.txt AC 1 ms 256 KiB
in10.txt AC 1 ms 256 KiB
in11.txt AC 1 ms 256 KiB
in12.txt AC 1 ms 256 KiB
in13.txt AC 1 ms 256 KiB
in14.txt AC 1 ms 256 KiB
in15.txt AC 1 ms 256 KiB
in16.txt AC 1 ms 256 KiB
in17.txt AC 11 ms 1280 KiB
in18.txt AC 11 ms 1152 KiB
in19.txt AC 11 ms 1152 KiB
in20.txt AC 11 ms 1152 KiB
in21.txt AC 10 ms 1024 KiB
in22.txt AC 10 ms 1024 KiB
in23.txt AC 1 ms 256 KiB
in24.txt AC 1 ms 256 KiB
in25.txt AC 10 ms 1024 KiB
in26.txt AC 10 ms 1024 KiB
in27.txt AC 1 ms 256 KiB
in28.txt AC 10 ms 1152 KiB
in29.txt AC 11 ms 1280 KiB
in30.txt AC 11 ms 1280 KiB
in31.txt AC 11 ms 1280 KiB
in32.txt AC 11 ms 1280 KiB
in33.txt AC 11 ms 1280 KiB
in34.txt AC 11 ms 1280 KiB
in35.txt AC 10 ms 1024 KiB
in36.txt AC 10 ms 1152 KiB
in37.txt AC 10 ms 1152 KiB
in38.txt AC 10 ms 1152 KiB
sample_01.txt AC 1 ms 256 KiB
sample_02.txt AC 1 ms 256 KiB
sample_03.txt AC 1 ms 256 KiB