Submission #624783

#TimeUsernameProblemLanguageResultExecution timeMemory
624783rm1729Collecting Mushrooms (NOI18_collectmushrooms)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void solve(){ int R, C; cin >>R>>C; int D, K; cin >>D >>K; vector <vector <int>> pref(R+1, vector <int> (C+1,0)); vector <pair<int,int>> loc; for(int i=1; i<=R; i++){ string a; cin >>a; for(int j=1; j<=C; j++){ char x = a[j-1]; pref[i][j]=pref[i][j-1]+pref[i-1][j]-pref[i-1][j-1]; if(x=='M') loc.push_back(make_pair(i,j)); if(x=='S'){ pref[i][j]++; } } } int ans = 0; for(auto x: loc){ pair maxpos =make_pair(min(R,x.first+D), min(C,x.second+D)); pair minpos =make_pair(max(1ll,x.first-D), max(1ll,x.second-D)); int n = pref[maxpos.first][maxpos.second]-pref[minpos.first-1][maxpos.second]-pref[maxpos.first][minpos.second-1]+pref[minpos.first-1][minpos.second-1]; if(K<=n) ans++; } cout <<ans<<endl; } signed main(){ int t; cin >>t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

mushrooms.cpp: In function 'void solve()':
mushrooms.cpp:26:14: error: missing template arguments before 'maxpos'
   26 |         pair maxpos =make_pair(min(R,x.first+D), min(C,x.second+D));
      |              ^~~~~~
mushrooms.cpp:27:14: error: missing template arguments before 'minpos'
   27 |         pair minpos =make_pair(max(1ll,x.first-D), max(1ll,x.second-D));
      |              ^~~~~~
mushrooms.cpp:28:22: error: 'maxpos' was not declared in this scope
   28 |         int n = pref[maxpos.first][maxpos.second]-pref[minpos.first-1][maxpos.second]-pref[maxpos.first][minpos.second-1]+pref[minpos.first-1][minpos.second-1];
      |                      ^~~~~~
mushrooms.cpp:28:56: error: 'minpos' was not declared in this scope; did you mean 'sincos'?
   28 |         int n = pref[maxpos.first][maxpos.second]-pref[minpos.first-1][maxpos.second]-pref[maxpos.first][minpos.second-1]+pref[minpos.first-1][minpos.second-1];
      |                                                        ^~~~~~
      |                                                        sincos