# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
871328 | 2023-11-10T15:01:55 Z | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 14 ms | 9264 KB |
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); #define int long long using namespace std; using lli = long long; using ld = long double; using pii = pair <int, int>; mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1e6 + 1000; const int maxm = 1e4 + 1000; const int mod = 1e9 + 7; lli n, m, k, d; void ReadInput() { } void Solve() { cin >> m >> n >> d >> k; lli a[m + 1][n + 1]; char s[m + 1][n + 1] ; for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { cin >> s[i][j]; a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1]; if (s[i][j] == 'S') { a[i][j] ++; } //cout << a[i][j] << endl; } } lli cnt = 0; for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { if (s[i][j] == 'M') { lli x = i - d - 1; if (x < 1) x = 0; lli y = j - d - 1; if (y < 1) y = 0; lli u = i + d; if (u > m) u = m; lli v = j + d; if (v > n) v = n; //return; lli sum = a[u][v] - a[u][y] - a[x][v] + a[x][y]; //cout << u << " " << v << " " << a[u][v] << " " << a[u][y] << " " << a[x][v] << " " << a[x][y] << " " << sum << endl; //return; if (sum >= k) { cnt ++; } } } } cout << cnt; } #define debug #define taskname "A" signed main(){ faster if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ ReadInput(); Solve(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000); timeout.close(); #ifndef debug cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n"; #endif // debug } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 500 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2136 KB | Output is correct |
2 | Correct | 5 ms | 2140 KB | Output is correct |
3 | Correct | 5 ms | 2648 KB | Output is correct |
4 | Correct | 5 ms | 2140 KB | Output is correct |
5 | Correct | 5 ms | 2140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 9052 KB | Output is correct |
2 | Correct | 10 ms | 9060 KB | Output is correct |
3 | Correct | 14 ms | 9048 KB | Output is correct |
4 | Correct | 11 ms | 9264 KB | Output is correct |
5 | Correct | 12 ms | 9052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 600 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 500 KB | Output is correct |
16 | Correct | 3 ms | 2136 KB | Output is correct |
17 | Correct | 5 ms | 2140 KB | Output is correct |
18 | Correct | 5 ms | 2648 KB | Output is correct |
19 | Correct | 5 ms | 2140 KB | Output is correct |
20 | Correct | 5 ms | 2140 KB | Output is correct |
21 | Correct | 11 ms | 9052 KB | Output is correct |
22 | Correct | 10 ms | 9060 KB | Output is correct |
23 | Correct | 14 ms | 9048 KB | Output is correct |
24 | Correct | 11 ms | 9264 KB | Output is correct |
25 | Correct | 12 ms | 9052 KB | Output is correct |
26 | Correct | 9 ms | 4956 KB | Output is correct |
27 | Correct | 10 ms | 5340 KB | Output is correct |
28 | Correct | 10 ms | 5212 KB | Output is correct |
29 | Correct | 9 ms | 5416 KB | Output is correct |
30 | Correct | 9 ms | 5212 KB | Output is correct |