結果
問題 | No.2225 Treasure Searching Rod (Easy) |
ユーザー |
![]() |
提出日時 | 2023-02-24 22:55:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 1,608 ms |
コンパイル使用メモリ | 168,144 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 05:57:28 |
合計ジャッジ時間 | 2,507 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;int H, W;long long cnt=0;int a[55][55];void sea(int x, int y, int l, int r){if(x<0||y<0||x>=H||y>=W) return;for(int i=x;i<H;i++){cnt += a[i][y];}cnt %= 998244353;if(r) sea(x+1, y+1, 0, 1);if(l) sea(x+1, y-1, 1, 0);return;}int main() {int K, i, j, x, y, v;cin>>H>>W>>K;for(i=0;i<K;i++){cin>>x>>y>>v;x--;y--;a[x][y]=v;}for(i=0;i<H;i++){for(j=0;j<W;j++){sea(i, j, 1, 1);}}cout<<cnt<<endl;return 0;}