結果
| 問題 |
No.2229 Treasure Searching Rod (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-02 12:48:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,053 bytes |
| コンパイル時間 | 493 ms |
| コンパイル使用メモリ | 84,348 KB |
| 最終ジャッジ日時 | 2025-02-11 01:05:53 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d %d %d", &h, &w, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d %d %d", &x, &y, &v);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;
bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
#define MOD 998244353
int main() {
int n, i, s, e, x, y, v, d;
int h, w, k;
LL r=0, t, c, cc;
scanf("%d %d %d", &h, &w, &k);
for (i=0; i<k; i++) {
scanf("%d %d %d", &x, &y, &v);
// count
x--; y--;
s=y-x; e=x+y;
// 1+... 1+x
c=(1+1+x*2); c*=(x+1); c/=2; c%=MOD;
if (s<0) {
d=-s;
cc=(1+d); cc*=d; cc/=2; c-=cc; if (c<0) c+=MOD;
}
if (e>=w) {
d=e-w+1;
cc=(1+d); cc*=d; cc/=2; c-=cc; if (c<0) c+=MOD;
}
// printf("%d,%d(%d,%d) ==>%lld\n", x, y,s, e, c);
t=v; t*=c; t%=MOD;
r+=t; r%=MOD;
}
printf("%lld\n", r);
return 0;
}