| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 586363 | hibiki | Collecting Mushrooms (NOI18_collectmushrooms) | C++11 | 36 ms | 19700 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
int r, c, d, k;
vector<pair<int,int> > que;
vector<vector<int> > fen;
void up(int x, int y, int val)
{
x = max(x, 1);
y = max(y, 1);
while(x <= r)
{
int ty = y;
while(ty <= c)
{
fen[x][ty] += val;
ty += ty & -ty;
}
x += x & -x;
}
return ;
}
void up(int x, int y)
{
up(x - d, y - d, 1);
up(x + d + 1, y - d, -1);
up(x - d, y + d + 1, -1);
up(x + d + 1, y + d + 1, 1);
}
int query(int x, int y)
{
int ans = 0;
while(x > 0)
{
int ty = y;
while(ty > 0)
{
ans += fen[x][ty];
ty -= ty & -ty;
}
x -= x & -x;
}
return ans;
}
int main()
{
scanf("%d %d %d %d",&r,&c,&d,&k);
char pic[r + 5][c + 5];
fen.resize(r + 5);
for(int i = 0; i < r + 5; i++)
fen[i].resize(c + 5);
for(int i = 1; i <= r; i++)
{
scanf("%s",pic[i] + 1);
for(int j = 1; j <= c; j++)
{
if(pic[i][j] == 'M')
que.pb({i,j});
else if(pic[i][j] == 'S')
up(i, j);
}
}
int ans = 0;
for(auto val: que)
{
int ret = query(val.f, val.s);
if(ret >= k) ans++;
}
printf("%d\n",ans);
}
컴파일 시 표준 에러 (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... | ||||
