# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733028 | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 2076 ms | 3804 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sts stable_sort
#define B begin()
#define rB rbegin()
#define E end()
#define rE rend()
#define F first
#define S second
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define eb emplace_back
#define ll long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
const int MAXN = 1e9 + 48;
const int MOD = 1e9 + 7;
const ll INF = 9223372036854775807LL;
const ll inf = 2147483647;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int x, y, d, k; cin >> x >> y >> d >> k;
vector<pair<int, int> > m, s;
for(int i = 1; i <= x; i++){
for(int j = 1; j <= y; j++){
char c; cin >> c;
if(c == 'M'){
m.pb({i, j});
}else if(c == 'S'){
s.pb({i, j});
}
}
}
map<pair<int, int>, int> ma;
int ans = 0;
for(int i = 0; i < m.size(); i++){
for(int j = 0; j < s.size(); j++){
int a = abs(m[i].F - s[j].F), b = abs(m[i].S - s[j].S);
if(a <= d && b <= d){
ma[m[i]]++;
}
if(ma[m[i]] >= k){
ans++;
break;
}
}
}
cout << ans << "\n";
return 0;
}
/**
**/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |