Submission #8577941


Source Code Expand

Copy
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int H, W;
int K;
char map[400][400];
int res[400][400];

template<typename T>void imos2d(int32_t x, int32_t y, int32_t x2, int32_t y2, T& arr)
{
	++arr[x][y];
	--arr[x][y2];
	--arr[x2][y];
	++arr[x2][y2];
}


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H >> W >> K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}

	int count = 1;
	int lasth = -1;
	for (int i = 0; i < H; i++)
	{
		int lastw = -1;
		bool updated = false;
		for (int j = 0; j < W; j++)
		{
			if (map[i][j] == '#') {
				
				updated = true;

				res[lasth + 1][lastw + 1] += count;
				res[lasth + 1][j+1] -= count;
				res[i + 1][lastw + 1] -= count;
				res[i + 1][j + 1] += count;

				lastw = j;
				++count;
			}
		}
		if (updated) {
			res[lasth + 1][lastw + 1] += count-1;
			res[lasth + 1][W] -= count - 1;
			res[i + 1][lastw + 1] -= count - 1;
			res[i + 1][W] += count - 1;

			lasth = i;
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			res[i][j] += res[i][j - 1];
		}
	}
	for (int i = 1; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			res[i][j] += res[i - 1][j];
		}
	}

	for (int i = lasth+1; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			assert(res[i][j]==0);
			res[i][j] += res[i - 1][j];
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W-1; j++)
		{
			out << res[i][j] << ' ';
		}
		out << res[i][W - 1] << '\n';
	}




	return 0;
}
#endif

Submission Info

Submission Time
Task C - Strawberry Cakes
User eiya
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2198 Byte
Status AC
Exec Time 11 ms
Memory 1408 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 9 ms 1280 KB
in18.txt AC 9 ms 1280 KB
in19.txt AC 9 ms 1280 KB
in20.txt AC 9 ms 1408 KB
in21.txt AC 8 ms 1152 KB
in22.txt AC 8 ms 1152 KB
in23.txt AC 1 ms 256 KB
in24.txt AC 1 ms 256 KB
in25.txt AC 8 ms 1152 KB
in26.txt AC 8 ms 1152 KB
in27.txt AC 1 ms 256 KB
in28.txt AC 8 ms 1280 KB
in29.txt AC 9 ms 1408 KB
in30.txt AC 9 ms 1408 KB
in31.txt AC 9 ms 1408 KB
in32.txt AC 9 ms 1408 KB
in33.txt AC 9 ms 1408 KB
in34.txt AC 9 ms 1408 KB
in35.txt AC 8 ms 1152 KB
in36.txt AC 8 ms 1280 KB
in37.txt AC 8 ms 1280 KB
in38.txt AC 11 ms 1280 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