# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
830384 | 2023-08-19T05:10:46 Z | ajay | Collecting Mushrooms (NOI18_collectmushrooms) | C++14 | 2000 ms | 17736 KB |
/* 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 316 KB | Output is correct |
2 | Correct | 23 ms | 724 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 316 KB | Output is correct |
2 | Correct | 23 ms | 724 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 14 ms | 724 KB | Output is correct |
9 | Correct | 3 ms | 468 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 8 ms | 588 KB | Output is correct |
3 | Correct | 12 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Correct | 2 ms | 1484 KB | Output is correct |
3 | Correct | 2 ms | 1828 KB | Output is correct |
4 | Correct | 2 ms | 1624 KB | Output is correct |
5 | Correct | 2 ms | 1620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2049 ms | 17736 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 316 KB | Output is correct |
2 | Correct | 23 ms | 724 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 14 ms | 724 KB | Output is correct |
9 | Correct | 3 ms | 468 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 8 ms | 588 KB | Output is correct |
13 | Correct | 12 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 1492 KB | Output is correct |
17 | Correct | 2 ms | 1484 KB | Output is correct |
18 | Correct | 2 ms | 1828 KB | Output is correct |
19 | Correct | 2 ms | 1624 KB | Output is correct |
20 | Correct | 2 ms | 1620 KB | Output is correct |
21 | Execution timed out | 2049 ms | 17736 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |