Submission #764286


Source Code Expand

Copy
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <queue>
#include <vector>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)


char map[105][105];//H,W
char result[105][105];//H,W
short map_count[105][105];//H,W
int H, W;

int main()
{
	cin >> H >> W;
	for (auto& i : result)
	{
		for (auto& j : i) {
			j = '.';
		}
	}


	for (int i = 1; i <= H; ++i)
	{
		cin >> map[i]+1;
		for (int j = 1; j <= W; ++j)
		{
			if (map[i][j] == '#') {
				for (int x = -1; x <= 1; ++x)
				{
					for (int y = -1; y <= 1; ++y)
					{
						++map_count[i + y][j + x];
					}
				}
			}
		}
	}
	for (int i = 1; i <= H; ++i)
	{
		map_count[i][1] += 3;
		map_count[i][W] += 3;
	}
	for (int i = 1; i <= W; ++i)
	{
		map_count[1][i] += 3;
		map_count[H][i] += 3;
	}
	--map_count[1][1];
	--map_count[1][W];
	--map_count[H][1];
	--map_count[H][W];


	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			if (map_count[i][j] >= 9) {
				result[i][j] = '#';
				map_count[i][j] = 0;
				for (int x = -1; x <= 1; ++x)
				{
					for (int y = -1; y <= 1; ++y)
					{
						if (map_count[i + y][j + x] < 9) {
							map_count[i + y][j + x] = 0;
						}
					}
				}
			}
		}
	}

	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			if (map_count[i][j] != 0) {
				if (map[i][j] == '#') {
					cout << "impossible" << endl;
					return 0;
				}
			}
		}
	}

	cout << "possible" << endl;
	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			cout << result[i][j];
		}
		cout << endl;
	}
}

Submission Info

Submission Time
Task D - 画像処理高橋君
User eiya
Language C++14 (Clang 3.8.0)
Score 100
Code Size 1963 Byte
Status AC
Exec Time 6 ms
Memory 256 KB

Compile Error

./Main.cpp:43:16: warning: operator '>>' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses]
                cin >> map[i]+1;
                    ~~ ~~~~~~^~
./Main.cpp:43:16: note: place parentheses around the '+' expression to silence this warning
                cin >> map[i]+1;
                             ^
                       (       )
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 25
Set Name Test Cases
Sample example_0.txt, example_1.txt, example_2.txt
All example_0.txt, example_1.txt, example_2.txt, handmade_0.txt, handmade_1.txt, possible_0.txt, possible_1.txt, possible_2.txt, possible_3.txt, possible_4.txt, possible_5.txt, possible_6.txt, possible_7.txt, possible_8.txt, possible_9.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt
Case Name Status Exec Time Memory
example_0.txt AC 4 ms 256 KB
example_1.txt AC 4 ms 256 KB
example_2.txt AC 4 ms 256 KB
handmade_0.txt AC 4 ms 256 KB
handmade_1.txt AC 4 ms 256 KB
possible_0.txt AC 5 ms 256 KB
possible_1.txt AC 5 ms 256 KB
possible_2.txt AC 5 ms 256 KB
possible_3.txt AC 6 ms 256 KB
possible_4.txt AC 4 ms 256 KB
possible_5.txt AC 5 ms 256 KB
possible_6.txt AC 5 ms 256 KB
possible_7.txt AC 6 ms 256 KB
possible_8.txt AC 5 ms 256 KB
possible_9.txt AC 5 ms 256 KB
random_0.txt AC 4 ms 256 KB
random_1.txt AC 5 ms 256 KB
random_2.txt AC 4 ms 256 KB
random_3.txt AC 4 ms 256 KB
random_4.txt AC 4 ms 256 KB
random_5.txt AC 4 ms 256 KB
random_6.txt AC 4 ms 256 KB
random_7.txt AC 5 ms 256 KB
random_8.txt AC 4 ms 256 KB
random_9.txt AC 4 ms 256 KB