結果

問題 No.1584 Stones around Circle Pond
ユーザー momoyuu
提出日時 2024-08-08 00:01:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,906 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 101,212 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-08 00:01:59
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 53 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n,l;
cin>>n>>l;
vector<ll> d(n);
for(int i = 0;i<n;i++) cin>>d[i];
vector<ll> b(2*n,0);
for(int i = 0;i<2*n;i++) cin>>b[i];
vector<ll> dif(2*n,0);
auto get = [&](int i){
if(i<n) return d[i];
return l + d[i-n];
};
auto clen = [&](int i,int j) {
ll now = abs(get(i) - get(j));
now = min(now,2*l-now);
return now;
};
for(int i = 0;i<2*n;i++){
int k = i - 1;
if(k<0) k = 2 * n - 1;
ll len = clen(k,i);
ll di = b[i] - b[k];
if(di%len!=0){
cout<<"No\n";
return 0;
}
di /= len;
int nk = i + 1;
nk %= 2 * n;
int nnk = i;
ll len2 = clen(nnk,nk);
ll di2 = b[nk] - b[nnk];
if(di2%len2!=0){
cout<<"No\n";
return 0;
}
di2 /= len2;
dif[i] = di2 - di;
if(dif[i]%2!=0){
cout<<"No\n";
return 0;
}
dif[i] /= 2;
}
vector<ll> now(2*n,0);
for(int i = 0;i<n;i++){
if(dif[i]+dif[i+n]!=0){
cout<<"No\n";
return 0;
}
}
auto go = [&](int i,ll use) {
for(int j = 0;j<2*n;j++){
ll len = clen(i,j);
now[j] += len * use;
}
};
for(int i = 0;i<n;i++){
if(dif[i]>0){
go(i,dif[i]);
}else{
go(i+n,-dif[i]);
}
}
for(int i = 0;i<2*n;i++){
now[i] = b[i] - now[i];
}
sort(now.begin(),now.end());
now.erase(unique(now.begin(),now.end()),now.end());
if(now.size()==1&&now[0]%l==0){
cout<<"Yes\n";
return 0;
}
cout<<"No\n";
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0