Submission #925598

# Submission time Handle Problem Language Result Execution time Memory
925598 2024-02-12T05:58:42 Z vjudge1 Collecting Mushrooms (NOI18_collectmushrooms) C++11
0 / 100
2000 ms 8132 KB
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define nl '\n'
#define sz(a) a.size()

using namespace std;

const int N = 1e5 + 1;
const int INF = 1e9;

void solve(){	
	int n, m, d, k;
	cin >> n >> m >> d >> k;
	char a[n + 1][m + 1];
	vector<pair<int, int>> ma, sp;

	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			cin >> a[i][j];
			if(a[i][j] == 'M'){
				ma.pb({i, j});			
			}
			if(a[i][j] == 'S'){
				sp.pb({i, j});	
			}
		}
	}
	
	int ans = 0;

	for(auto to : ma){
		int cnt = 0;
		for(auto ot : sp){
			if(max(abs(to.first - ot.first), abs(to.second - ot.second)) <= d){
				cnt++;					
			}			
		}
		if(cnt == k){
			ans ++;
		}
	}
	cout << ans << nl;
}
      
                                                                                                    
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int tt = 1;
   	//cin >> tt;
    
    while(tt--){
        solve();
    }
}

//written by Akhmad Khaber
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2043 ms 8132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -