Submission #572420

#TimeUsernameProblemLanguageResultExecution timeMemory
572420MODDICollecting Mushrooms (NOI18_collectmushrooms)C++14
60 / 100
2082 ms4184 KiB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int r, c, d, k;
bool check(int x1, int y1, int x2, int y2){
	int dist = max(abs(x1 - x2), abs(y1 - y2));
	if(d >= dist)
		return 1;
	return 0;
}
int main(){
	cin>>r>>c>>d>>k;
	char mat[r][c];
	vector<pii> s,m;
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++)
		{
			cin>>mat[i][j];
			if(mat[i][j]=='S')
				s.pb(mp(i,j));
			if(mat[i][j]=='M')
				m.pb(mp(i,j));
		}
	}
	ll rez=  0;
	for(int i = 0; i < m.size(); i++){
		int cnt = 0;
		for(int j = 0; j < s.size(); j++){
			if(cnt >= k)
				break;
			cnt += check(m[i].first, m[i].second, s[j].first, s[j].second);
		}
		if(cnt >= k)
			rez++;
	}
	cout<<rez<<endl;
}

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 0; i < m.size(); i++){
      |                 ~~^~~~~~~~~~
mushrooms.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int j = 0; j < s.size(); j++){
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...