Submission #830016

#TimeUsernameProblemLanguageResultExecution timeMemory
830016ajayCollecting Mushrooms (NOI18_collectmushrooms)C++14
18 / 100
474 ms262144 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}); } } queue<vi> que; rep(i, 0, sz(sprinkler)) { sprinkler[i].pb(d); que.push(sprinkler[i]); } while (!que.empty()) { vi cur = que.front(); que.pop(); mat[cur[0]][cur[1]]++; if (cur[2] > 0) { rep(i, 0, 8) { int newx = cur[0] + dx[i]; int newy = cur[1] + dy[i]; if (newx >= 0 and newx < r and newy >= 0 and newy < c) { que.push({newx, newy, cur[2] - 1}); } } } } int ans = 0; rep(i, 0, sz(mushrooms)) { if (mat[mushrooms[i][0]][mushrooms[i][1]] >= 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; }
#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...