이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define bupol __builtin_popcount
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int r, c, d, s; cin >> r >> c >> d >> s;
char grid[r+5][c+5];
int tmp[r+5][c+5];
memset(tmp, 0, sizeof tmp);
int add[c+5];
memset(add,0,sizeof add);
vector<pair<int,int>>v;
for(int i = 1; i <= r; i++){
string s; cin >> s;
for(int j = 0; j < s.length(); j++){
grid[i][j+1] = s[j];
if(s[j] == 'S'){
tmp[max(1ll,i-d)][max(1ll,j+1ll-d)]++;
tmp[max(1ll,i-d)][min(c+1,j+2+d)]--;
tmp[min(r+1,i+d+1ll)][max(1ll,j+1ll-d)]--;
tmp[min(r+1,i+d+1ll)][min(c+1,j+2+d)]++;
}
}
}
int ans = 0;
for(int i = 1; i <= r; i++){
int cnt = 0;
for(int j = 1; j <= c; j++){
//cout << "here >> " << i << " " << j << " " << tmp[i][j] << endl;
add[j] += tmp[i][j];
cnt += add[j];
if(grid[i][j] == 'M' && cnt >= s){
ans++;
}
}
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:21:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int j = 0; j < s.length(); j++){
| ~~^~~~~~~~~~~~
# | 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... |