結果

問題 No.1584 Stones around Circle Pond
ユーザー 👑 potato167potato167
提出日時 2021-07-02 22:59:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,912 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 202,924 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-11 23:26:02
合計ジャッジ時間 13,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 1 ms
4,380 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 2 ms
4,376 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
4,380 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 AC 2 ms
4,376 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";}


//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll N,L;
	cin>>N>>L;
	ll d[N*2];
	vector<ll> B(N*2);
	ll P[N*2]={0};
	rep(i,N) cin>>d[i];
	rep(i,N*2) d[i+N]=d[i]+L;
	rep(i,N*2) cin>>B[i];
	rep(i,N-1){
		if((B[i]+B[i+N])!=(B[i+1]+B[i+N+1])){
			yneos(0);
			return 0;
		}
	}
	ll C=B[0]+B[N];
	if(C%L!=0){
		yneos(0);
		return 0;
	}
	C/=L;
	ll X[N+1];
	ll T[2*N]={0};
	rep(i,N+1){
		ll BB=B[(i+1)]-B[i];
		ll DD=d[(i+1)]-d[i];
		//cout<<BB<<endl;
		if(BB%DD!=0){
			yneos(0);
			return 0;
		}
		X[i]=BB/DD;
		if((C-X[i]+Q*2)%2!=0){
			yneos(0);
			return 0;
		}
	}
	//cout<<endl;
	rep(i,N+1){
		X[i]=(C-X[i])/2;
	}
	rep(i,N){
		ll A=X[i+1]-X[i];
		if(A<0) T[i+1]=A*-1;
		else T[(i+1+N)%(2*N)]=A;
	}
	rep(i,2*N) rep(j,2*N){
		ll dis=abs(d[i]-d[j]);
		B[i]-=T[j]*(min(dis,2*L-dis));
	}
	//rep(i,N*2) cout<<B[i]<<endl;
	yneos(B[0]>=0&&B[0]%L==0);
}
0