Submission #925696

# Submission time Handle Problem Language Result Execution time Memory
925696 2024-02-12T07:32:12 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
179 ms 262144 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define emb emplace_back
#define emc emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
template <class type_key, class type_val>
using um = unordered_map<type_key, type_val>;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

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;

	vector<array<int,4>> evs;
	for( int i = 1; i <= n; i++ ) {
		for( int j = 1; j <= m; j++ ) {
			char c;
			cin >> c;
			if( c == 'S') {
				int col1 = max(j - d, 1);
				bool k = (j + d + 1 > m);
				int col2 = min(j + d + 1, m);
				
				for( int row = max(1, i-d); row <= min(i+d,n); row++ ) {
					evs.pb({row,col1,0,+1});
					if( k ) evs.pb({row,col2,2,-1});
					else evs.pb({row,col2,0,-1});
				}
			}
			else if( c == 'M') {
				evs.pb({i,j,1,0});
			}
		}
	}
	sort(evs.begin(), evs.end()); 

	int spr = 0;
	int ans = 0;

	for( int i = 0; i < evs.size(); i++ ) {
		if( evs[i][2] == 1 ) {
			if( spr >= k ) ans++;
		} spr += evs[i][3];
	}
	cout << ans;

return 0;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for( int i = 0; i < evs.size(); i++ ) {
      |                  ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 54 ms 9680 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 736 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 54 ms 9680 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 736 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 9 ms 1500 KB Output is correct
7 Correct 4 ms 992 KB Output is correct
8 Correct 154 ms 35012 KB Output is correct
9 Correct 9 ms 2516 KB Output is correct
10 Correct 2 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 2 ms 736 KB Output is correct
3 Correct 1 ms 736 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1500 KB Output is correct
2 Correct 41 ms 10188 KB Output is correct
3 Correct 14 ms 2520 KB Output is correct
4 Correct 48 ms 9676 KB Output is correct
5 Correct 4 ms 992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 9168 KB Output is correct
2 Correct 48 ms 9936 KB Output is correct
3 Correct 46 ms 10192 KB Output is correct
4 Correct 87 ms 18632 KB Output is correct
5 Correct 69 ms 17100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 54 ms 9680 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 736 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 9 ms 1500 KB Output is correct
7 Correct 4 ms 992 KB Output is correct
8 Correct 154 ms 35012 KB Output is correct
9 Correct 9 ms 2516 KB Output is correct
10 Correct 2 ms 992 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 1 ms 736 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 7 ms 1500 KB Output is correct
17 Correct 41 ms 10188 KB Output is correct
18 Correct 14 ms 2520 KB Output is correct
19 Correct 48 ms 9676 KB Output is correct
20 Correct 4 ms 992 KB Output is correct
21 Correct 44 ms 9168 KB Output is correct
22 Correct 48 ms 9936 KB Output is correct
23 Correct 46 ms 10192 KB Output is correct
24 Correct 87 ms 18632 KB Output is correct
25 Correct 69 ms 17100 KB Output is correct
26 Runtime error 179 ms 262144 KB Execution killed with signal 9
27 Halted 0 ms 0 KB -