Submission #547792

# Submission time Handle Problem Language Result Execution time Memory
547792 2022-04-11T18:34:12 Z unicornboy Collecting Mushrooms (NOI18_collectmushrooms) C++14
60 / 100
2000 ms 3764 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int N=5e5+1;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n , m  , d , k;
    cin >> n >> m >> d >> k ;
    vector<pair<int,int>>mushrooms;
    vector<pair<int,int>>sprinklers;
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            char c;
            cin >> c ;
            if(c=='M')
            {
                mushrooms.pb({i,j});
            }
            else if (c=='S')
            {
                sprinklers.pb({i,j});
            }
        }
    }
    // iterate on each sprinkler for each mushroom
    int ans=0;
    for (int i=0;i<mushrooms.size();i++)
    {
        int count=0;
        for (int j=0;j<sprinklers.size();j++)
        {
            int dis=max(abs(sprinklers[j].ff-mushrooms[i].ff),abs(sprinklers[j].ss-mushrooms[i].ss));
            if(dis<=d)
            {
                count++;
            }
            if(count>=k)
                break;
        }
        if(count>=k)
        ans++;
    }
    cout<<ans<<"\n";
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i=0;i<mushrooms.size();i++)
      |                  ~^~~~~~~~~~~~~~~~~
mushrooms.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int j=0;j<sprinklers.size();j++)
      |                      ~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 23 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 9 ms 468 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 432 KB Output is correct
2 Correct 4 ms 432 KB Output is correct
3 Correct 4 ms 468 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 4 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 3764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 23 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 9 ms 468 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 432 KB Output is correct
17 Correct 4 ms 432 KB Output is correct
18 Correct 4 ms 468 KB Output is correct
19 Correct 4 ms 468 KB Output is correct
20 Correct 4 ms 432 KB Output is correct
21 Execution timed out 2072 ms 3764 KB Time limit exceeded
22 Halted 0 ms 0 KB -