提出 #763571


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int h,w;
	char t[105][105]={},u[105][105]={},d[105][105]={};
	int dy[8]={1,1,1,0,0,-1,-1,-1},dx[8]={-1,0,1,-1,1,-1,0,1};
	string s;
	vector<pii>v;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		cin>>s;
		for(int j=1;j<=w;j++)t[i][j]=s[j-1];
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(t[i][j]=='#')
			{
				bool flag=true;
				for(int k=0;k<8;k++)
				{
					if(1<=i+dy[k]&&i+dy[k]<=h&&1<=j+dx[k]&&j+dx[k]<=w)
					{
						if(t[i+dy[k]][j+dx[k]]!='#')flag=false;
					}
				}
				if(flag)
				{
					u[i][j]='#';
					d[i][j]='#';
					v.pb(mp(i,j));
				}
			}
		}
	}
	for(int i=0;i<v.size();i++)
	{
		for(int k=0;k<8;k++)
		{
			u[v[i].fi+dy[k]][v[i].se+dx[k]]='#';
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(u[i][j]!='#')u[i][j]='.';
			if(d[i][j]!='#')d[i][j]='.';
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(t[i][j]!=u[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<<d[i][j];
		}
		cout<<endl;
	}
	return 0;
}

提出情報

提出日時
問題 D - 画像処理高橋君
ユーザ kkrtjnj3829
言語 C++14 (GCC 5.4.1)
得点 100
コード長 1376 Byte
結果 AC
実行時間 6 ms
メモリ 384 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 100 / 100
結果
AC × 3
AC × 25
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
example_0.txt AC 4 ms 256 KiB
example_1.txt AC 4 ms 256 KiB
example_2.txt AC 4 ms 256 KiB
handmade_0.txt AC 4 ms 256 KiB
handmade_1.txt AC 4 ms 256 KiB
possible_0.txt AC 4 ms 256 KiB
possible_1.txt AC 5 ms 384 KiB
possible_2.txt AC 5 ms 384 KiB
possible_3.txt AC 5 ms 384 KiB
possible_4.txt AC 5 ms 256 KiB
possible_5.txt AC 4 ms 256 KiB
possible_6.txt AC 5 ms 256 KiB
possible_7.txt AC 6 ms 384 KiB
possible_8.txt AC 5 ms 384 KiB
possible_9.txt AC 4 ms 256 KiB
random_0.txt AC 4 ms 256 KiB
random_1.txt AC 4 ms 256 KiB
random_2.txt AC 4 ms 256 KiB
random_3.txt AC 4 ms 256 KiB
random_4.txt AC 4 ms 256 KiB
random_5.txt AC 4 ms 256 KiB
random_6.txt AC 4 ms 256 KiB
random_7.txt AC 5 ms 256 KiB
random_8.txt AC 4 ms 256 KiB
random_9.txt AC 4 ms 256 KiB