답안 #733826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733826 2023-05-01T10:47:07 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
43 ms 49276 KB
#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

#define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T, typename U>
ostream & operator << (ostream &out, const pair<T, U> &c) {
    out << c.first << ' ' << c.second;
    return out;
}

template<typename T>
ostream & operator << (ostream &out, vector<T> &v) {
    const int sz = v.size();
    for (int i = 0; i < sz; i++) {
        if (i) out << ' ';
        out << v[i];
    }
    return out;
}

template<typename T>
istream & operator >> (istream &in, vector<T> &v) {
    for (T &x : v) in >> x;
    return in;
}

template<typename T>
void mxx(T &a, T b){if(b > a) a = b;}
template<typename T>
void mnn(T &a, T b){if(b < a) a = b;}

void go() {
	int n, m, d, k;
	cin >> n >> m >> d >> k;
	vector<vector<int>> cnt(n + 10, vector<int>(m + 10, 0));
	vector<vector<char>> g(n + 10, vector<char>(m + 10));
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			cin >> g[i][j];
			if(g[i][j] == 'S') {
				int id = i - d;
				int l1 = j - d;
				int r1 = j + d + 1;
				mxx(l1, 1ll);
				mnn(r1, m + 1);
				mxx(id, 1ll);
				cnt[id][l1]++;
				cnt[id][r1]--;
				id = i + d + 1;
				mnn(id, n + 1);
				cnt[id][l1]--;
				cnt[id][r1]++;
			}
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			cnt[i][j] += cnt[i][j - 1];
		}
	}
	for(int i = 1; i <= m; i++) {
		for(int j = 1; j <= n; j++) {
			cnt[j][i] += cnt[j - 1][i];
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			if(cnt[i][j] >= k && g[i][j] == 'M') {
				ans++;
			}
		}
	}
	cout << ans << '\n';
}

signed main() {
    fast;
    int t = 1;
    // cin >> t;
    while(t--) {
        go();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2132 KB Output is correct
2 Correct 5 ms 2132 KB Output is correct
3 Correct 9 ms 2644 KB Output is correct
4 Correct 5 ms 2132 KB Output is correct
5 Correct 5 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 49276 KB Output is correct
2 Correct 34 ms 49244 KB Output is correct
3 Correct 39 ms 49236 KB Output is correct
4 Correct 43 ms 49152 KB Output is correct
5 Correct 35 ms 49168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 5 ms 2132 KB Output is correct
17 Correct 5 ms 2132 KB Output is correct
18 Correct 9 ms 2644 KB Output is correct
19 Correct 5 ms 2132 KB Output is correct
20 Correct 5 ms 2260 KB Output is correct
21 Correct 34 ms 49276 KB Output is correct
22 Correct 34 ms 49244 KB Output is correct
23 Correct 39 ms 49236 KB Output is correct
24 Correct 43 ms 49152 KB Output is correct
25 Correct 35 ms 49168 KB Output is correct
26 Correct 16 ms 8532 KB Output is correct
27 Correct 13 ms 4956 KB Output is correct
28 Correct 14 ms 5844 KB Output is correct
29 Correct 14 ms 5588 KB Output is correct
30 Correct 15 ms 7124 KB Output is correct