Submission #60737151
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;#define int long long#define ll __int128vector<pair<int, int>> prop(int x, int y, int h, int w) {vector<pair<int, int>> ans;if (x > 0) ans.push_back({x-1, y});if (y > 0) ans.push_back({x, y-1});if (x < h-1) ans.push_back({x+1, y});if (y < w-1) ans.push_back({x, y+1});return ans;}signed main() {int h, w, x; cin >> h >> w >> x;ll x1 = x;int p, q; cin >> p >> q;int grid[h][w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> grid[i][j];ll power = grid[p-1][q-1];int visited[h][w];for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) visited[i][j] = -1;
#include <bits/stdc++.h> using namespace std; #define int long long #define ll __int128 vector<pair<int, int>> prop(int x, int y, int h, int w) { vector<pair<int, int>> ans; if (x > 0) ans.push_back({x-1, y}); if (y > 0) ans.push_back({x, y-1}); if (x < h-1) ans.push_back({x+1, y}); if (y < w-1) ans.push_back({x, y+1}); return ans; } signed main() { int h, w, x; cin >> h >> w >> x; ll x1 = x; int p, q; cin >> p >> q; int grid[h][w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> grid[i][j]; ll power = grid[p-1][q-1]; int visited[h][w]; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) visited[i][j] = -1; visited[p-1][q-1] = 0; priority_queue <pair<ll, pair<ll, ll>>, vector<pair<ll, pair<ll, ll>>>, greater<pair<ll, pair<ll, ll>>>> pq; for (auto i:prop(p-1, q-1, h, w)) { pq.push({grid[i.first][i.second], {i.first, i.second}}); visited[i.first][i.second] = 1; } while (pq.size() > 0 and pq.top().first*x1 < power) { auto cur = pq.top(); pq.pop(); power += cur.first; //now propogate for (auto i:prop(cur.second.first, cur.second.second, h, w)) { if (visited[i.first][i.second] == -1) { visited[i.first][i.second] = 1; pq.push({grid[i.first][i.second], {i.first, i.second}}); } } } cout << (int)power; }
Submission Info
Submission Time | |
---|---|
Task | E - Takahashi is Slime 2 |
User | YSH2020 |
Language | C++ 20 (gcc 12.2) |
Score | 450 |
Code Size | 1474 Byte |
Status | AC |
Exec Time | 138 ms |
Memory | 19528 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt, 01_random_56.txt, 01_random_57.txt, 01_random_58.txt, 01_random_59.txt, 01_random_60.txt, 01_random_61.txt, 01_random_62.txt, 01_random_63.txt, 01_random_64.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3484 KB |
00_sample_01.txt | AC | 1 ms | 3484 KB |
00_sample_02.txt | AC | 1 ms | 3484 KB |
01_random_03.txt | AC | 132 ms | 10136 KB |
01_random_04.txt | AC | 7 ms | 3844 KB |
01_random_05.txt | AC | 133 ms | 13372 KB |
01_random_06.txt | AC | 32 ms | 5748 KB |
01_random_07.txt | AC | 134 ms | 13512 KB |
01_random_08.txt | AC | 6 ms | 3784 KB |
01_random_09.txt | AC | 136 ms | 13332 KB |
01_random_10.txt | AC | 24 ms | 4860 KB |
01_random_11.txt | AC | 76 ms | 7404 KB |
01_random_12.txt | AC | 1 ms | 3408 KB |
01_random_13.txt | AC | 75 ms | 7388 KB |
01_random_14.txt | AC | 14 ms | 4620 KB |
01_random_15.txt | AC | 135 ms | 13372 KB |
01_random_16.txt | AC | 3 ms | 3580 KB |
01_random_17.txt | AC | 138 ms | 13256 KB |
01_random_18.txt | AC | 8 ms | 3924 KB |
01_random_19.txt | AC | 129 ms | 10148 KB |
01_random_20.txt | AC | 22 ms | 4696 KB |
01_random_21.txt | AC | 133 ms | 13340 KB |
01_random_22.txt | AC | 10 ms | 4048 KB |
01_random_23.txt | AC | 75 ms | 7388 KB |
01_random_24.txt | AC | 15 ms | 4224 KB |
01_random_25.txt | AC | 77 ms | 7436 KB |
01_random_26.txt | AC | 2 ms | 3568 KB |
01_random_27.txt | AC | 54 ms | 7440 KB |
01_random_28.txt | AC | 15 ms | 4344 KB |
01_random_29.txt | AC | 74 ms | 7516 KB |
01_random_30.txt | AC | 24 ms | 4800 KB |
01_random_31.txt | AC | 72 ms | 7392 KB |
01_random_32.txt | AC | 20 ms | 4496 KB |
01_random_33.txt | AC | 75 ms | 7372 KB |
01_random_34.txt | AC | 40 ms | 5596 KB |
01_random_35.txt | AC | 64 ms | 7392 KB |
01_random_36.txt | AC | 5 ms | 3952 KB |
01_random_37.txt | AC | 52 ms | 7392 KB |
01_random_38.txt | AC | 19 ms | 4716 KB |
01_random_39.txt | AC | 75 ms | 7460 KB |
01_random_40.txt | AC | 9 ms | 4116 KB |
01_random_41.txt | AC | 76 ms | 7500 KB |
01_random_42.txt | AC | 22 ms | 4604 KB |
01_random_43.txt | AC | 1 ms | 3468 KB |
01_random_44.txt | AC | 1 ms | 3468 KB |
01_random_45.txt | AC | 1 ms | 3480 KB |
01_random_46.txt | AC | 1 ms | 3492 KB |
01_random_47.txt | AC | 1 ms | 3528 KB |
01_random_48.txt | AC | 1 ms | 3552 KB |
01_random_49.txt | AC | 1 ms | 3532 KB |
01_random_50.txt | AC | 1 ms | 3488 KB |
01_random_51.txt | AC | 1 ms | 3496 KB |
01_random_52.txt | AC | 1 ms | 3492 KB |
01_random_53.txt | AC | 1 ms | 3532 KB |
01_random_54.txt | AC | 1 ms | 3528 KB |
01_random_55.txt | AC | 1 ms | 3680 KB |
01_random_56.txt | AC | 1 ms | 3556 KB |
01_random_57.txt | AC | 1 ms | 3492 KB |
01_random_58.txt | AC | 70 ms | 19528 KB |
01_random_59.txt | AC | 78 ms | 19436 KB |
01_random_60.txt | AC | 73 ms | 19360 KB |
01_random_61.txt | AC | 1 ms | 3464 KB |
01_random_62.txt | AC | 1 ms | 3528 KB |
01_random_63.txt | AC | 1 ms | 3468 KB |
01_random_64.txt | AC | 1 ms | 3488 KB |