Submission #533870

# Submission time Handle Problem Language Result Execution time Memory
533870 2022-03-07T13:56:41 Z gilbirb Collecting Mushrooms (NOI18_collectmushrooms) C++14
60 / 100
2000 ms 6496 KB
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
typedef long long ll;
using namespace std;

ll r, c, d, k, ans;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,-1,1};
ll grid[10000][10000];

bool inside(ll x, ll y){
	return (x >= 1 && y >= 1 && x <= r && y <= c);
}

void check(ll x, ll y){
	ll x1, x2, y1, y2;
	x1 = x-d; x2 = x+d; y1 = y-d; y2 = y+d;
//	cout << x1 << " " << x2 << " " << y1 << " " << y2 << "\n";
	for(int i = x1; i <= x2; i++){
		for(int j = y1; j <= y2; j++){
			if(!inside(i,j)) continue;
			if(grid[i][j] != -1){
				grid[i][j]++;
				if(grid[i][j] == k){
					ans++;
				}
			}
		}
	}
}

int main(){
	cin >> r >> c >> d >> k;
	vector<pair<ll,ll>>spr;
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			char f; cin >> f;
			if(f == '.') grid[i][j] = -1;
			else if(f == 'M') grid[i][j] = 0;
			else{
				spr.pb({i,j});
				grid[i][j] = -1;
			}
		}
	}
	for(pair<ll,ll> x : spr){
		check(x.fi, x.se);
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 245 ms 856 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 9 ms 460 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 245 ms 856 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 9 ms 460 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 17 ms 588 KB Output is correct
7 Correct 47 ms 392 KB Output is correct
8 Correct 424 ms 972 KB Output is correct
9 Correct 22 ms 588 KB Output is correct
10 Correct 4 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 560 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 816 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 3796 KB Output is correct
2 Correct 154 ms 4044 KB Output is correct
3 Correct 37 ms 4624 KB Output is correct
4 Correct 341 ms 3776 KB Output is correct
5 Correct 15 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 6496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 245 ms 856 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 9 ms 460 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 17 ms 588 KB Output is correct
7 Correct 47 ms 392 KB Output is correct
8 Correct 424 ms 972 KB Output is correct
9 Correct 22 ms 588 KB Output is correct
10 Correct 4 ms 432 KB Output is correct
11 Correct 1 ms 560 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 816 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 64 ms 3796 KB Output is correct
17 Correct 154 ms 4044 KB Output is correct
18 Correct 37 ms 4624 KB Output is correct
19 Correct 341 ms 3776 KB Output is correct
20 Correct 15 ms 4172 KB Output is correct
21 Execution timed out 2077 ms 6496 KB Time limit exceeded
22 Halted 0 ms 0 KB -