# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594506 | 2022-07-12T15:02:16 Z | propransh | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 2 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(0); #define ll int #define pb push_back #define tc long long int t; cin >> t; while(t--) #define vpll vector<pair<ll,ll>> #define MOD 1000000007 int main(){ #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif boost; ll i; ll r,c,d,k; cin >> r >> c >> d >> k; char a[r][c]; ll diff[r][c]; ll j; for(i = 0; i < r; i++){ for(j = 0; j < c; j++){ cin >> a[i][j]; if(a[i][j] == 'S'){ diff[i][j] = 1; } else{ diff[i][j] = 0; } } } ll pre[r][c]; pre[0][0] = diff[0][0]; for(i = 1; i < r; i++){ pre[i][0] = pre[i-1][0] + diff[i][0]; } for(i = 1; i < c; i++){ pre[0][i] = pre[0][i-1] + diff[0][i]; } for(i = 1; i < r; i++){ for(j = 1; j < c; j++){ pre[i][j] = (diff[i][j] + pre[i-1][j] + pre[i][j-1]) - pre[i-1][j-1]; } } ll u,v,x,y, ans = 0;; /*for(i = 0; i < r; i++){ for(j = 0; j < c; j++){ cout << pre[i][j] << " "; } cout << endl; }*/ for(i = 0; i < r; i++){ for(j = 0; j < c; j++){ if(a[i][j] == 'M'){ u = max(0,i-d); v = max(0,j-d); x = min(r-1, i+d); y = min(c-1, j+d); ll temp = pre[x][y] - pre[u-1][y] - pre[x][v-1] + pre[u-1][v-1]; if(temp >= k){ ans++; //cout << "i " << i << " j " << j <<endl; } } } } cout << ans <<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |