Submission #733798

#TimeUsernameProblemLanguageResultExecution timeMemory
733798vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++17
0 / 100
2072 ms4940 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long vector <pair<ll,ll>> v; ll r, c, d, k; bool check(ll a, ll b) { if(a < r && b < c && a >= 0 && b >= 0) return 1; else return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> r >> c; cin >> d >> k; char ch[r][c]; for(ll i = 0; i < r; i++) { for(ll j = 0; j < c; j++) { cin >> ch[i][j]; if(ch[i][j] == 'M') { v.push_back({i, j}); } } } ll s, ans = 0, t = 0; for(ll i = 0; i < v.size(); i++) { ll f = v[i].first; ll s = v[i].second; for(ll k = f - d; k <= f + d; k++) { if(t == 1) { t = 0; break; } for(ll q = s - d; q <= s + d; q++) { s = 0; if(!check(k, q)) continue; if(ch[k][q] == 'S') s++; if(s >= k) { ans++; break; t = 1; } } } } cout << ans; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:25:21: 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]
   25 |     for(ll i = 0; i < v.size(); i++) {
      |                   ~~^~~~~~~~~~
mushrooms.cpp:24:8: warning: unused variable 's' [-Wunused-variable]
   24 |     ll s, ans = 0, t = 0;
      |        ^
#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...