結果
問題 | No.2826 Earthwork |
ユーザー | achapi |
提出日時 | 2024-07-26 10:43:16 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,425 bytes |
コンパイル時間 | 2,955 ms |
コンパイル使用メモリ | 228,216 KB |
実行使用メモリ | 157,560 KB |
最終ジャッジ日時 | 2024-07-26 10:43:55 |
合計ジャッジ時間 | 34,840 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 43 ms
6,812 KB |
testcase_02 | AC | 1,377 ms
156,996 KB |
testcase_03 | AC | 149 ms
17,620 KB |
testcase_04 | AC | 1,159 ms
133,296 KB |
testcase_05 | WA | - |
testcase_06 | AC | 742 ms
85,568 KB |
testcase_07 | AC | 921 ms
107,320 KB |
testcase_08 | AC | 1,323 ms
157,144 KB |
testcase_09 | AC | 1,400 ms
157,520 KB |
testcase_10 | AC | 1,441 ms
157,060 KB |
testcase_11 | WA | - |
testcase_12 | AC | 44 ms
6,944 KB |
testcase_13 | AC | 470 ms
51,756 KB |
testcase_14 | AC | 1,470 ms
157,472 KB |
testcase_15 | AC | 369 ms
41,820 KB |
testcase_16 | AC | 617 ms
85,852 KB |
testcase_17 | AC | 219 ms
26,060 KB |
testcase_18 | WA | - |
testcase_19 | AC | 254 ms
36,224 KB |
testcase_20 | AC | 1,153 ms
129,344 KB |
testcase_21 | WA | - |
testcase_22 | AC | 961 ms
103,856 KB |
testcase_23 | AC | 866 ms
102,532 KB |
testcase_24 | AC | 1,438 ms
157,168 KB |
testcase_25 | WA | - |
testcase_26 | AC | 845 ms
104,832 KB |
testcase_27 | AC | 30 ms
6,940 KB |
testcase_28 | AC | 1,465 ms
157,560 KB |
testcase_29 | AC | 111 ms
15,720 KB |
testcase_30 | AC | 67 ms
8,608 KB |
testcase_31 | AC | 111 ms
14,068 KB |
testcase_32 | AC | 37 ms
6,940 KB |
testcase_33 | AC | 807 ms
86,616 KB |
testcase_34 | AC | 1,402 ms
157,068 KB |
testcase_35 | AC | 321 ms
39,988 KB |
testcase_36 | AC | 1,367 ms
157,480 KB |
testcase_37 | AC | 1,471 ms
157,464 KB |
testcase_38 | AC | 709 ms
79,896 KB |
testcase_39 | WA | - |
testcase_40 | AC | 55 ms
7,540 KB |
ソースコード
#include <bits/stdc++.h> using namespace std;template<class T> vector<T> Dijkstra(vector<vector<pair<int, T>>> &G, int s){ vector<T> D(G.size(), 1e18); D[s] = 0; priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q; q.push(make_pair(0, s)); while (!q.empty()){ auto [d, u] = q.top(); q.pop(); if (D[u] < d){ continue; } for (auto [v, c] : G[u]){ d = D[u] + c; if (d < D[v]){ D[v] = d; q.push(make_pair(d, v)); } } } return D; } int main(){ int N; cin >> N; vector<vector<int>> H(N, vector<int>(N)); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ cin >> H[i][j]; } } vector<string> S(N); for (int i = 0; i < N; i++){ cin >> S[i]; } vector<vector<long long>> A(N - 1, vector<long long>(N)); for (int i = 0; i < N - 1; i++){ for (int j = 0; j < N; j++){ cin >> A[i][j]; } } vector<vector<long long>> B(N, vector<long long>(N - 1)); for (int i = 0; i < N; i++){ for (int j = 0; j < N - 1; j++){ cin >> B[i][j]; } } vector<vector<vector<pair<int, long long>>>> G(2, vector<vector<pair<int, long long>>>(N * N + 1)); vector<vector<long long>> D(2); for (int k = 0; k < 2; k++){ for (int i = 0; i < N - 1; i++){ for (int j = 0; j < N; j++){ long long T = (H[i][j] + H[i + 1][j]) * (1 - (i + j + k) % 2 * 2); G[k][i * N + j].push_back(make_pair((i + 1) * N + j, abs(T) * A[i][j] + T)); G[k][(i + 1) * N + j].push_back(make_pair(i * N + j, abs(T) * A[i][j] - T)); } } for (int i = 0; i < N; i++){ for (int j = 0; j < N - 1; j++){ long long T = (H[i][j] + H[i][j + 1]) * (1 - (i + j + k) % 2 * 2); G[k][i * N + j].push_back(make_pair(i * N + j + 1, abs(T) * B[i][j] + T)); G[k][i * N + j + 1].push_back(make_pair(i * N + j, abs(T) * B[i][j] - T)); } } for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if (S[i][j] == '?'){ continue; } if (S[i][j] == '=' or ((S[i][j] == '-') ^ (i + j + k) % 2) == 0){ G[k][i * N + j].push_back(make_pair(N * N, 0)); } if (S[i][j] == '=' or ((S[i][j] == '-') ^ (i + j + k) % 2) == 1){ G[k][N * N].push_back(make_pair(i * N + j, 0)); } } } D[k] = Dijkstra(G[k], N * N); } int Q; cin >> Q; while (Q--){ int R, C; long long E; cin >> R >> C >> E; R--; C--; if (D[(R + C) % 2][R * N + C] + H[R][C] >= E){ cout << "Yes" << endl; } else { cout << "No" << endl; } } }