Submission #1005996

#TimeUsernameProblemLanguageResultExecution timeMemory
1005996christinelynnCollecting Mushrooms (NOI18_collectmushrooms)C++17
0 / 100
2057 ms15948 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d, s; map < pair < int, int >, int > mp; vector < int > freq ( n * m + 5, 0); cin >> n >> m >> d >> s; string grid[n + 1]; int cnt = 1; for ( int i = 0; i < n; i++) cin >> grid[i]; vector < pair < int, int > > tanaman, sprinkle; for ( int i = 0; i < n; i++){ for ( int j = 0; j < m; j++){ if ( grid[i][j] == 'M' ){ tanaman.push_back({i, j}); mp[{i, j}] = cnt; cnt++; } if ( grid[i][j] == 'S' ){ sprinkle.push_back({i, j}); } } } for ( int i = 0; i < tanaman.size(); i++){ for ( int j = 0; j < sprinkle.size(); j++){ int x1 = tanaman[i].first, y1 = tanaman[i].second; int x2 = sprinkle[j].first, y2 = sprinkle[j].second; if ( max ( abs ( x1 - x2), abs ( y1 - y2)) <= d ){ freq[mp[{x1, y1}]]++; } } } int ans = 0; for ( int i = 1; i < freq.size(); i++){ ans += ( freq[i] >= s ); } cout << ans << endl; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:40:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for ( int i = 0; i < tanaman.size(); i++){
      |                      ~~^~~~~~~~~~~~~~~~
mushrooms.cpp:41:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for ( int j = 0; j < sprinkle.size(); j++){
      |                          ~~^~~~~~~~~~~~~~~~~
mushrooms.cpp:53:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for ( int i = 1; i < freq.size(); i++){
      |                      ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...