이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, d, s;
map < pair < int, int >, int > mp;
vector < int > freq ( n * m + 5, 0);
cin >> n >> m >> d >> s;
string grid[n + 1];
int cnt = 1;
for ( int i = 0; i < n; i++) cin >> grid[i];
vector < pair < int, int > > tanaman, sprinkle;
for ( int i = 0; i < n; i++){
for ( int j = 0; j < m; j++){
if ( grid[i][j] == 'M' ){
tanaman.push_back({i, j});
mp[{i, j}] = cnt;
cnt++;
}
if ( grid[i][j] == 'S' ){
sprinkle.push_back({i, j});
}
}
}
for ( int i = 0; i < tanaman.size(); i++){
for ( int j = 0; j < sprinkle.size(); j++){
int x1 = tanaman[i].first, y1 = tanaman[i].second;
int x2 = sprinkle[j].first, y2 = sprinkle[j].second;
if ( max ( abs ( x1 - x2), abs ( y1 - y2)) <= d ){
freq[mp[{x1, y1}]]++;
}
}
}
int ans = 0;
for ( int i = 1; i < freq.size(); i++){
ans += ( freq[i] >= s );
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:40:24: warning: comparison of integer expressions of different signedness: 'long long 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 < tanaman.size(); i++){
| ~~^~~~~~~~~~~~~~~~
mushrooms.cpp:41:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for ( int j = 0; j < sprinkle.size(); j++){
| ~~^~~~~~~~~~~~~~~~~
mushrooms.cpp:53:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for ( int i = 1; i < freq.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... |