結果

問題 No.3407 Birds-of-Paradise' Christmas Live
コンテスト
ユーザー 👑 tails
提出日時 2025-12-14 05:24:40
言語 cLay
(20250308-1 + boost 1.89.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,069 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,322 ms
コンパイル使用メモリ 195,328 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2025-12-14 05:24:45
合計ジャッジ時間 4,755 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:151:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  151 |           for(auto[x,y]:b){
      |                   ^
main.cpp:159:17: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  159 |         for(auto[x,y]:a){
      |                 ^
main.cpp:183:19: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  183 |           for(auto[x,y]:a){
      |                   ^
main.cpp:191:17: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  191 |         for(auto[x,y]:b){
      |                 ^
main.cpp:207:13: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  207 |     for(auto[x,y]:a){
      |             ^
main.cpp:210:13: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
  210 |     for(auto[x,y]:b){
      |             ^

ソースコード

diff #
raw source code

ll@n,@w[n],@m,@s[m];
rep(i,1,n)w[i]+=w[i-1];
rep(i,1,m)s[i]+=s[i-1];
unordered_map<ll,ll>a,b;
a[0]=0;
b[0]=0;
ll z=0;
ll c=0,d=0;
while(c<n&&d<m){
	if(!(d<m)||c<n&&w[c]<=s[d]){
		if(c&1){
			// 0 open
			if(d&1){
				a[w[c]]=0;
			}else{
				if(c+1<n&&(!(d<m)||w[c+1]<=s[d])){
					c+=2;
					continue;
				}
				ll t=0;
				for(auto[x,y]:b){
					t>?=y+(w[c]-x)**2;
				}
				a[w[c]]=t;
			}
		}else{
			// 0 close
			ll t=0;
			for(auto[x,y]:a){
				t>?=y+(w[c]-x)**2;
			}
			if(d&1){
				z+=t;
			}else{
				b[w[c]]>?=t;
			}
			a.clear();
		}
		c+=1;
	}else{
		if(d&1){
			// 1 open
			if(c&1){
				b[s[d]]=0;
			}else{
				if(d+1<m&&(!(c<n)||s[d+1]<=w[c])){
					d+=2;
					continue;
				}
				ll t=0;
				for(auto[x,y]:a){
					t>?=y+(s[d]-x)**2;
				}
				b[s[d]]=t;
			}
		}else{
			// 1 close
			ll t=0;
			for(auto[x,y]:b){
				t>?=y+(s[d]-x)**2;
			}
			if(c&1){
				z+=t;
			}else{
				a[s[d]]>?=t;
			}
			b.clear();
		}
		d+=1;
	}
}
if(1){
	ll t=0;
	for(auto[x,y]:a){
		t>?=y+(w[n-1]-x)**2;
	}
	for(auto[x,y]:b){
		t>?=y+(s[m-1]-x)**2;
	}
	z+=t;
}
wt(z);
0