結果
| 問題 | No.2225 Treasure Searching Rod (Easy) |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-02-25 05:51:50 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 881 bytes |
| 記録 | |
| コンパイル時間 | 5,295 ms |
| コンパイル使用メモリ | 148,608 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-04 04:19:32 |
| 合計ジャッジ時間 | 4,326 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp:22:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
22 | int X[K];
| ^
main.cpp:22:9: note: read of non-const variable 'K' is not allowed in a constant expression
main.cpp:19:13: note: declared here
19 | int H, W, K;
| ^
main.cpp:23:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
23 | int Y[K];
| ^
main.cpp:23:9: note: read of non-const variable 'K' is not allowed in a constant expression
main.cpp:19:13: note: declared here
19 | int H, W, K;
| ^
main.cpp:24:8: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
24 | ll V[K];
| ^
main.cpp:24:8: note: read of non-const variable 'K' is not allowed in a constant expression
main.cpp:19:13: note: declared here
19 | int H, W, K;
| ^
main.cpp:25:16: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
25 | ll values[H][W];
| ^
main.cpp:25:16: note: read of non-const variable 'W' is not allowed in a constant expression
main.cpp:19:10: note: declared here
19 | int H, W, K;
| ^
main.cpp:25:13: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
25 | ll values[H][W];
| ^
main.cpp:25:13: note: read of non-const variable 'H' is not allowed in a constant expression
main.cpp:19:7: note: declared here
19 | int H, W, K;
| ^
5 warnings generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
int main() {
int H, W, K;
cin >> H >> W >> K;
int X[K];
int Y[K];
ll V[K];
ll values[H][W];
memset(values, 0, sizeof(values));
for (int i = 0; i < K; ++i) {
cin >> X[i] >> Y[i] >> V[i];
X[i]--;
Y[i]--;
values[X[i]][Y[i]] = V[i];
}
ll ans = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
for (int x = 0; x < H; ++x) {
for (int y = 0; y < W; ++y) {
if (x + y >= i + j && x - y >= i - j) {
ans += values[x][y];
ans %= MOD;
}
}
}
}
}
cout << ans << endl;
return 0;
}
siman