Submission #925701

# Submission time Handle Problem Language Result Execution time Memory
925701 2024-02-12T07:37:45 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
19 / 100
18 ms 25268 KB
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
#define lld long long double
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=5e5+100;
const int mod=1e9+7;
const int K=500;
const ll inf=1e18+1337;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, -1, 1, 0};
vector<ll>h[N];
vector< pair<ll,ll> >v;

int main()
{
	IShowSpeed
	ll n,m,d,k,ans=0;
	cin>>n>>m>>d>>k;

	for(int i=1;i<=n;++i)
	{
		ll sum=0;
		h[i].pb(0);
		for(int j=1;j<=m;++j)
		{
			char c;
			cin>>c;
			if(c=='S') sum++;
			if(c=='M') v.pb({i,j});
			h[i].pb(sum);
		}
	}

	if(h[n][m]<k)
	{
		cout<<0;
		return 0;
	}

	for(auto p: v)
	{
		ll x=p.F,y=p.S,sum=0;
		ll x1=max(1ll,x-d),x2=min(n,x+d);
		ll y1=min(m,y+d),y2=max(0ll,y-d-1);
		for(int i=x1;i<=x2;i++)
		{
			sum+=h[i][y1]-h[i][y2];
			if(sum>=k)
			{
				ans++;
				break;
			}
		}
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12124 KB Output is correct
2 Correct 3 ms 12124 KB Output is correct
3 Incorrect 4 ms 12124 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12124 KB Output is correct
2 Correct 3 ms 12124 KB Output is correct
3 Incorrect 4 ms 12124 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12124 KB Output is correct
2 Correct 3 ms 12124 KB Output is correct
3 Correct 3 ms 12380 KB Output is correct
4 Correct 3 ms 12124 KB Output is correct
5 Incorrect 3 ms 12380 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 13916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 20924 KB Output is correct
2 Correct 18 ms 25016 KB Output is correct
3 Correct 17 ms 23736 KB Output is correct
4 Correct 15 ms 22128 KB Output is correct
5 Correct 18 ms 25268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12124 KB Output is correct
2 Correct 3 ms 12124 KB Output is correct
3 Incorrect 4 ms 12124 KB Output isn't correct
4 Halted 0 ms 0 KB -