이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;
const int N = 1001;
const int MOD = 1e9+7 ;
int n , m , d , k , ans;
ll G[N][N] ;
vector<pii> mushroom ;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m >> d >> k ;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char x ; cin >> x ;
if(x == 'S'){
G[i][j]++ ;
}
else if(x == 'M'){
mushroom.push_back({i , j});
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
G[i][j] += G[i-1][j] + G[i][j-1] - G[i-1][j-1] ;
}
}
for(int i=0;i<mushroom.size();i++){
int uy = mushroom[i].first , ux = mushroom[i].second ;
int x1 = max(1 , ux - d) , y1 = max(1 , uy - d) ;
int x2 = min(m , ux + d) , y2 = min(n , uy + d) ;
ll sum = G[y2][x2] - G[y1 - 1][x2] - G[y2][x1 - 1] + G[y1 - 1][x1 - 1] ;
if(sum >= k){
ans++;
}
}
cout << ans ;
}
컴파일 시 표준 에러 (stderr) 메시지
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i=0;i<mushroom.size();i++){
| ~^~~~~~~~~~~~~~~~
# | 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... |