Submission #830384

#TimeUsernameProblemLanguageResultExecution timeMemory
830384ajayCollecting Mushrooms (NOI18_collectmushrooms)C++14
60 / 100
2049 ms17736 KiB
/* Ajay Jadhav */ #include <iostream> #include <cstdio> #include <algorithm> #include <deque> #include <vector> #include <cstdlib> #include <iomanip> #include <cmath> #include <queue> #include <map> #include <set> #include <stack> #include <ctime> #include <string.h> #include <climits> #include <cstring> using namespace std; #define ll long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vvi vector<vi> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(x) (int)x.size() #define hell 1000000007 #define rep(i, a, b) for (int i = a; i < b; i++) #define endl '\n' void solve() { int r, c, d, k; cin >> r >> c >> d >> k; int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1}; int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; vector<string> field(r); vvi mat(r, vi(c)); vvi mushrooms, sprinkler; rep(i, 0, r) { cin >> field[i]; rep(j, 0, c) { if (field[i][j] == 'M') mushrooms.pb({i, j}); else if (field[i][j] == 'S') sprinkler.pb({i, j}); } } int ans = 0; rep(i, 0, sz(mushrooms)) { int cnt = 0; rep(j, 0, sz(sprinkler)) { int dis = max(abs(mushrooms[i][0] - sprinkler[j][0]), abs(mushrooms[i][1] - sprinkler[j][1])); if (dis <= d) { cnt++; } } if (cnt >= k) ans++; } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; while (t--) { solve(); } return 0; }

Compilation message (stderr)

mushrooms.cpp: In function 'void solve()':
mushrooms.cpp:42:9: warning: unused variable 'dx' [-Wunused-variable]
   42 |     int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
      |         ^~
mushrooms.cpp:43:9: warning: unused variable 'dy' [-Wunused-variable]
   43 |     int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
      |         ^~
#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...