이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int r, c, d, k;
cin >> r >> c >> d >> k;
int ans = 0;
int prefix[r + 2][c + 2];
vector<pair<int, int>>v;
memset(prefix, 0, sizeof(prefix));
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
char x; cin >> x;
prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + (x == 'S');
if(x == 'M') v.emplace_back(i, j);
}
}
for(auto &[x, y]: v){
int TLX = max(1, (x - d));
int TLY = max(1, (y - d));
int BRX = min(r, (x + d));
int BRY = min(c, (y + d));
int tmp = prefix[BRX][BRY] - prefix[BRX][TLY - 1] - prefix[TLX - 1][BRY] + prefix[TLX - 1][TLY - 1];
ans += (tmp >= k);
}
cout << ans << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:24:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
24 | for(auto &[x, y]: v){
| ^
# | 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... |