結果

問題 No.3597 Queen Score Attack 2
コンテスト
ユーザー askr58
提出日時 2026-07-24 21:42:44
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 724 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,128 ms
コンパイル使用メモリ 182,580 KB
実行使用メモリ 38,528 KB
最終ジャッジ日時 2026-07-24 21:42:50
合計ジャッジ時間 4,751 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <ranges>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w,sx,sy,n;
	cin>>h>>w>>sx>>sy>>n;
	sx--;sy--;
	vector<array<ll,3>> xyc(n);
	for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>xyc[i][j];
	ll inf=1e18;
	vector<ll> a(h,-inf),b(w,-inf),c(h+w,-inf),d(h+w,-inf);
	ll dp=0;
	a[0]=0;b[0]=0;c[0]=0;d[0]=0;
	ll pres=-inf;
	for(int i=0;i<n;i++){
		int x=xyc[i][0]-1,y=xyc[i][1]-1;
		ll res=max({dp,a[x],b[y],c[x+y],d[x-y+w]})+xyc[i][2];	
		dp=max(dp,pres);
		pres=res;
		a[x]=max(a[x],res);
		b[y]=max(b[y],res);
		c[x+y]=max(c[x+y],res);
		d[x-y+w]=max(d[x-y+w],res);
	}
	cout<<max(dp,pres)<<endl;
}


0