답안 #1006047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006047 2024-06-23T10:41:13 Z andecaandeci Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
19 ms 22480 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pii pair<int,int> 
#define vl vector<ll> 
#define nikah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll maxn = 5e5+7, modn1 = 1e9+7, modn2 = 998244353;
using namespace std;

// kalo kamu ngga emas nanti nadya merasa bersalah, ayo san demi nadya!!!
// Kalo emang soalnya susah, pindah soal dulu 
// Jangan sampe diem, pikirin sesuatu, pasti bisa!!!
// Cobain semua approach, jangan ngestuck di satu pemikiran
// Jangan overthinking, jangan panik, tenangin pikiranmu

ll t,r,c,d,s;
vector<pll>v;

void solve() {
  cin>>r>>c>>d>>s;
  ll a[r+2][c+2];
  memset(a,0,sizeof a);
  for (ll i=1; i<=r; i++) {
    for (ll j=1; j<=c; j++) {
      char x; cin>>x;
      if (x == 'M') {
        v.pb({i,j});
      } else if (x == 'S') {
        a[i][j]++;
      }
      a[i][j] += a[i-1][j] + a[i][j-1] - a[i-1][j-1];
    }
  }
  ll ans = 0;
  for (auto p : v) {
    ll x1 = max((ll)1, p.fi - d);
    ll y1 = max((ll)1, p.se - d);
    ll x2 = min(r, p.fi + d);
    ll y2 = min(c, p.se + d);
    ll o = a[x2][y2] - a[x2][y1-1] - a[x1-1][y2] + a[x1-1][y1-1];
  //  cout<<o<<endl;
    if (a[x2][y2] - a[x2][y1-1] - a[x1-1][y2] + a[x1-1][y1-1] >= s) ans++;
  }
  cout<<ans;
}


int main () {
  nikah
  t = 1;
//  cin>>t;
  while (t--) {
    solve();
  //  cout<<endl;
  }
}

Compilation message

mushrooms.cpp: In function 'void solve()':
mushrooms.cpp:47:8: warning: unused variable 'o' [-Wunused-variable]
   47 |     ll o = a[x2][y2] - a[x2][y1-1] - a[x1-1][y2] + a[x1-1][y1-1];
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1884 KB Output is correct
2 Correct 3 ms 1884 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 3 ms 1884 KB Output is correct
5 Correct 3 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 16596 KB Output is correct
2 Correct 19 ms 20432 KB Output is correct
3 Correct 19 ms 22480 KB Output is correct
4 Correct 17 ms 17040 KB Output is correct
5 Correct 18 ms 21196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 3 ms 1884 KB Output is correct
17 Correct 3 ms 1884 KB Output is correct
18 Correct 4 ms 2396 KB Output is correct
19 Correct 3 ms 1884 KB Output is correct
20 Correct 3 ms 2140 KB Output is correct
21 Correct 17 ms 16596 KB Output is correct
22 Correct 19 ms 20432 KB Output is correct
23 Correct 19 ms 22480 KB Output is correct
24 Correct 17 ms 17040 KB Output is correct
25 Correct 18 ms 21196 KB Output is correct
26 Correct 10 ms 6616 KB Output is correct
27 Correct 13 ms 10288 KB Output is correct
28 Correct 16 ms 6616 KB Output is correct
29 Correct 11 ms 6612 KB Output is correct
30 Correct 11 ms 9940 KB Output is correct