Submission #1106697

#TimeUsernameProblemLanguageResultExecution timeMemory
1106697vjudge1Collecting Mushrooms (NOI18_collectmushrooms)C++14
0 / 100
168 ms262144 KiB
#include <bits/stdc++.h> #define sts(v) svble_sort(v.BE, v.E) #define Rsts(v) svble_sort(v.rBE, v.rE) #define rev(v) reverse(v.BE, v.E) #define BE begin() #define rBE rbegin() #define E end() #define rE rend() #define pb push_back #define ppb pop_back() #define pf push_front #define ppf pop_front() #define F first #define S second using namespace std; using ll = long long; const int MAXN = 1e5 + 1; const int MOD = 1e9 + 7; int n, m, D, K; vector<vector<int>> v; int new_cord(int a, int b){ if(a < 1 or a > (int)v.size() or b < 1 or b > (int)v[1].size())return 0; return v[a][b]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> D >> K; vector<pair<int,int>> mushroom; v.resize(n + D + 10000); for(int i = 0; i < (int)v.size(); i++) v[i].resize(m + D + 10000); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++){ char c; cin >> c; if(c == 'S')v[i][j] = 1; else if(c == 'M')mushroom.pb({i, j}); } for(int i = 1; i <= n + D; i++) for(int j = 1; j <= m + D; j++) v[i][j] = v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1] + v[i][j]; int cnt = 0; for(int j = 0; j < mushroom.size(); j++){ pair<int, int> i = mushroom[j]; int cor1 = new_cord(i.F + D, i.S + D), cor2 = new_cord(i.F - D - 1, i.S - D - 1), cor3 = new_cord(i.F + D, i.S - D - 1), cor4 = new_cord(i.F - D - 1, i.S + D); if(K <= cor1 + cor2 - cor3 - cor4)cnt++; } cout << cnt << '\n'; return 0; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int j = 0; j < mushroom.size(); j++){
      |                    ~~^~~~~~~~~~~~~~~~~
#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...