제출 #1329761

#제출 시각아이디문제언어결과실행 시간메모리
1329761secondaccountmaybeKamenčići (COCI21_kamencici)C++20
0 / 70
1 ms1348 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r,c,n;
string g[30005];
deque<pair<ll,ll>>d[35];
void f(ll j,ll k)
{
	while(!d[k].empty())
	{
		ll y=d[k].back().first;
		ll x=d[k].back().second;
		if(g[y][x]=='.')
		{
			break;
		}
		d[k].pop_back();
	}
	ll y,x;
	if(d[k].empty())
	{
		y=0;
		x=j;
	}
	else
	{
		y=d[k].back().first;
		x=d[k].back().second;
	}
	while(y<r-1)
	{
		d[k].push_back({y,x});
		if(g[y+1][x]=='.')
		{
			y++;
		}
		else if(x>0&&g[y][x-1]=='.'&&g[y+1][x-1]=='.')
		{
			y++;
			x--;
		}
		else if(x<c-1&&g[y][x+1]=='.'&&g[y+1][x+1]=='.')
		{
			y++;
			x++;
		}
		else
		{
			break;
		}
	}
	g[y][x]='O';
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>r>>c;
	for(ll i=0;i<r;i++)
	{
		cin>>g[i];
	}
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		f(a-1,a-1);
	}
	for(ll i=0;i<r;i++)
	{
		cout<<g[i]<<endl;
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...