Submission #628579

# Submission time Handle Problem Language Result Execution time Memory
628579 2022-08-13T13:55:50 Z elesis Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
26 ms 21940 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define int long long 
#define pii pair<int,int> 
#define ff first
#define ss second
const int inf=1e11+7;
const int N=107;
const int mod =1000000007;
vector <int> adj[N];
void solve()
{
    int r,c,d,k;
    cin>>r>>c>>d>>k;
    char grid[r+1][c+1];
    vector <pii> cord;
    vector <vector <int>> pref(r+1,vector <int>(c+1,0));
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            cin>>grid[i][j];
            if(grid[i][j]=='M')
            {
                cord.push_back({i,j});
            }
        }
    }
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            pref[i][j]=pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
            if(grid[i][j]=='S')
            {
                pref[i][j]++;
            }
        }
    }
    int ans=0;
    int x1,x2,y1,y2;
    for(auto it:cord)
    {
        x1=max(1LL,it.ff-d);
        y1=max(1LL,it.ss-d);
        x2=min(r,it.ff+d);
        y2=min(c,it.ss+d);
        int spr=pref[x2][y2]-pref[x2][y1-1]-pref[x1-1][y2]+pref[x1-1][y1-1];
        if(spr>=k)
        {
            ans++;
        }
    }
    cout << ans << '\n';
}
signed main()
{
    fast
    clock_t start, end;
    start = clock();
    solve();
    end = clock();
    double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
    //cout << "time taken" << " " << time_taken << "\n";
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:64:12: warning: unused variable 'time_taken' [-Wunused-variable]
   64 |     double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
      |            ^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 4 ms 2260 KB Output is correct
3 Correct 6 ms 2768 KB Output is correct
4 Correct 4 ms 2364 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 16244 KB Output is correct
2 Correct 26 ms 21940 KB Output is correct
3 Correct 23 ms 21860 KB Output is correct
4 Correct 20 ms 16864 KB Output is correct
5 Correct 25 ms 21904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 5 ms 2260 KB Output is correct
17 Correct 4 ms 2260 KB Output is correct
18 Correct 6 ms 2768 KB Output is correct
19 Correct 4 ms 2364 KB Output is correct
20 Correct 5 ms 2388 KB Output is correct
21 Correct 24 ms 16244 KB Output is correct
22 Correct 26 ms 21940 KB Output is correct
23 Correct 23 ms 21860 KB Output is correct
24 Correct 20 ms 16864 KB Output is correct
25 Correct 25 ms 21904 KB Output is correct
26 Correct 14 ms 8036 KB Output is correct
27 Correct 15 ms 9300 KB Output is correct
28 Correct 12 ms 7380 KB Output is correct
29 Correct 12 ms 7560 KB Output is correct
30 Correct 17 ms 10052 KB Output is correct