| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1339525 | luvqrose | Collecting Mushrooms (NOI18_collectmushrooms) | C++20 | 17 ms | 14496 KiB |
#include <bits/stdc++.h>
using namespace std;
const int nx=5e5+5;
int n, m, d, k, ans;
vector<pair<int,int>> s, mush;
char a;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>d>>k;
vector<vector<int>> sw1(n+2, vector<int> (m+2)), sw2(n+2, vector<int> (m+2));
vector<vector<char>> mp(n+2, vector<char> (m+2));
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
cin>>mp[i][j];
if (mp[i][j]=='S')
{
sw1[max(0, i-d)][max(0, j-d)]++;
sw1[min(n+1, i+d+1)][max(0, j-d)]--;
sw1[max(0, i-d)][min(m+1, j+d+1)]--;
sw1[min(n+1, i+d+1)][min(m+1, j+d+1)]++;
}
}
}
for (int i=1; i<=n; i++)
{
for (int j=0; j<=m; j++)
{
sw1[i][j]+=sw1[i-1][j];
}
}
for (int i=0; i<=n+1; i++)
{
for (int j=0; j<=m+1; j++)
{
sw2[i][j]=sw1[i][j];
}
}
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
sw2[i][j]+=sw2[i][j-1];
}
}
for (int i=1; i<=n; i++)
{
for (int j=1; j<=m; j++)
{
if (mp[i][j]=='M' && sw2[i][j]>=k) ans++;
}
}
cout<<ans;
}| # | 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... | ||||
