# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
925584 | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 2100 ms | 4296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define emb emplace_back
#define pii pair<int,int>
#define F first
#define S second
signed main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, d, k;
cin >> n >> m >> d >> k;
char c[n+1][m+1];
vector<pii> msh;
vector<pii> spr;
for( int i = 1; i <= n; i++ ) {
for( int j = 1; j <= m; j++ ) {
cin >> c[i][j];
if( c[i][j] == 'M') msh.emb(i,j);
if( c[i][j] == 'S') spr.emb(i,j);
}
}
sort(spr.begin(), spr.end());
int ans = 0;
for( int i = 0; i < msh.size(); i++ ) {
int cnt = 0;
if( spr.size() > 0 ) {
int pos = lower_bound(spr.begin(), spr.end(), make_pair(msh[i].F-d, msh[i].S-d)) - spr.begin();
if( pos >= 0 && pos < spr.size() ) {
if( (spr[pos].F - msh[i].F) > d ) pos++;
for( int j = pos; j < spr.size(); j++ ) {
if( abs(msh[i].F - spr[j].F) > d ) break;
if( abs(msh[i].S - spr[j].S) <= d ) cnt++;
if( cnt >= k ) break;
}
if( cnt >= k ) {
ans++;
}
}
}
}
cout << ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |