結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー lddlinan
提出日時 2023-03-02 13:26:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 85,212 KB
最終ジャッジ日時 2025-02-11 01:06:54
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#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; cc%=MOD; c-=cc; if (c<0) c+=MOD;
}
if (e>=w) {
d=e-w+1;
cc=(1+d); cc*=d; cc/=2; cc%=MOD; 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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0