Submission #1329764

#TimeUsernameProblemLanguageResultExecution timeMemory
1329764secondaccountmaybeKamenčići (COCI21_kamencici)C++20
0 / 70
1 ms1352 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll r,c,n;
string g[30005];
stack<pair<ll,ll>>s[35];
void f(ll j,ll k)
{
	while(!s[k].empty())
	{
		ll y=s[k].top().first;
		ll x=s[k].top().second;
		if(g[y][x]=='.')
		{
			break;
		}
		s[k].pop();
	}
	ll y,x;
	if(s[k].empty())
	{
		y=0;
		x=j;
	}
	else
	{
		y=s[k].top().first;
		x=s[k].top().second;
	}
	while(y<r-1)
	{
		s[k].push({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...