結果

問題 No.1055 牛歩
ユーザー nxterunxteru
提出日時 2020-05-15 22:19:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,589 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 173,756 KB
実行使用メモリ 13,724 KB
最終ジャッジ日時 2023-10-19 14:57:08
合計ジャッジ時間 5,164 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
12,196 KB
testcase_02 AC 21 ms
10,688 KB
testcase_03 AC 21 ms
10,688 KB
testcase_04 AC 21 ms
10,688 KB
testcase_05 WA -
testcase_06 AC 23 ms
10,952 KB
testcase_07 AC 22 ms
10,952 KB
testcase_08 AC 23 ms
11,116 KB
testcase_09 AC 19 ms
10,424 KB
testcase_10 AC 19 ms
10,424 KB
testcase_11 AC 19 ms
10,424 KB
testcase_12 AC 23 ms
10,628 KB
testcase_13 AC 24 ms
10,628 KB
testcase_14 AC 19 ms
10,600 KB
testcase_15 AC 19 ms
10,596 KB
testcase_16 AC 17 ms
10,312 KB
testcase_17 WA -
testcase_18 AC 17 ms
10,336 KB
testcase_19 WA -
testcase_20 AC 22 ms
10,952 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 23 ms
11,216 KB
testcase_24 AC 22 ms
11,268 KB
testcase_25 AC 19 ms
10,728 KB
testcase_26 AC 19 ms
10,868 KB
testcase_27 AC 21 ms
10,868 KB
testcase_28 AC 20 ms
11,012 KB
testcase_29 AC 22 ms
10,732 KB
testcase_30 AC 21 ms
10,496 KB
testcase_31 AC 7 ms
8,824 KB
testcase_32 AC 8 ms
8,844 KB
testcase_33 AC 8 ms
8,844 KB
testcase_34 AC 8 ms
8,844 KB
testcase_35 AC 8 ms
8,840 KB
testcase_36 AC 8 ms
8,844 KB
testcase_37 AC 8 ms
8,844 KB
testcase_38 AC 8 ms
8,840 KB
testcase_39 AC 5 ms
8,420 KB
testcase_40 AC 5 ms
8,416 KB
testcase_41 AC 4 ms
8,416 KB
testcase_42 AC 5 ms
8,416 KB
testcase_43 AC 5 ms
8,416 KB
testcase_44 AC 5 ms
8,416 KB
testcase_45 AC 4 ms
8,416 KB
testcase_46 AC 5 ms
8,416 KB
testcase_47 AC 5 ms
8,420 KB
testcase_48 AC 4 ms
8,360 KB
testcase_49 AC 4 ms
8,360 KB
testcase_50 AC 4 ms
8,360 KB
testcase_51 AC 4 ms
8,360 KB
testcase_52 AC 5 ms
8,364 KB
testcase_53 AC 4 ms
8,372 KB
testcase_54 AC 4 ms
8,372 KB
testcase_55 AC 4 ms
8,372 KB
testcase_56 AC 4 ms
8,372 KB
testcase_57 AC 4 ms
8,372 KB
testcase_58 AC 4 ms
8,372 KB
testcase_59 AC 4 ms
8,372 KB
testcase_60 AC 4 ms
8,376 KB
testcase_61 AC 4 ms
8,376 KB
testcase_62 AC 4 ms
8,376 KB
testcase_63 AC 4 ms
8,376 KB
testcase_64 AC 4 ms
8,376 KB
testcase_65 AC 4 ms
8,376 KB
testcase_66 AC 4 ms
8,360 KB
testcase_67 AC 4 ms
8,360 KB
testcase_68 AC 4 ms
8,360 KB
testcase_69 AC 4 ms
8,360 KB
testcase_70 AC 4 ms
8,360 KB
testcase_71 AC 4 ms
8,360 KB
testcase_72 WA -
testcase_73 AC 4 ms
8,364 KB
testcase_74 AC 4 ms
8,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
#define rng(i,l,r) for(int i=int(l);i<int(r);i++)
#define rep(i,r) rng(i,0,r)
#define rrng(i,l,r) for(int i=int(r)-1;i>=int(l);i--)
#define rrep(i,r) rrng(i,0,r)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#define inf INT_MAX/2-100
#define infl LLONG_MAX/3
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<' '<<#x<<' '<<x<<endl
#else
#define dmp(x) void(0)
#endif
 
template<class t,class u>bool chmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool chmin(t&a,u b){if(b<a)a=b;return b<a;}
 
template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;
 
using pi=pair<int,int>;
using pl=pair<ll,ll>;
using vi=vc<int>;
using vl=vc<ll>;
 
 
ll readl(void){
	ll x;
	cin>>x;
	return x;
}
int readi(void){
	int x;
	cin>>x;
	return x;
}
 
string readstr(){
	string s;
	cin>>s;
	return s;
}
vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=readi(),v[i]+=off;
	return v;
}
 
vl readvl(int n,int off=0){
	vl v(n);
	rep(i,n)v[i]=readl(),v[i]+=off;
	return v;
}
 
template<class t>
void print(t x,int suc=1){
	cout<<x;
	if(suc==1)cout<<"\n";
	if(suc==2)cout<<" ";
}
 
template<class t>
void print(const vc<t>&v,int suc=1){
	rep(i,si(v))print(v[i],i==int(si(v))-1?1:suc);
}
 
template<class t>
bool inc(t a,t b,t c){
	return !(c<b||b<a);
}
 
template<class t>
void compress(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}
 
template<class t>
int lwb(const vc<t>&v,const t&a){
	return lower_bound(all(v),a)-v.bg;
}
 
template<class t>
struct Compress{
	vc<t>v;
	Compress()=default;
	Compress(const vc<t>&x){
		add(x);
	}
	Compress(const initializer_list<vc<t> >&x){
		for(auto &p:x)add(p);
	}
	void add(const t&x){
		v.eb(x);
	}
	void add(const vc<t>&x){
		copy(all(x),back_inserter(v));
	}
	void build(){
		compress(v);
	}
	int get(const t&x)const{
		return lwb(v,x);
	}
	vc<t>get(const vc<t>&x)const{
		vc<t>res(x);
		for(auto &p:res)p=get(p);
		return res;
	}
	const t &operator[](int x)const{
		return v[x];
	}
	int size(){
		return v.size();
	}
};
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
}
void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
}
void orYes(bool x,bool ex=true){
	if(x)Yes(ex);
	else No(ex);
}
void orYES(bool x,bool ex=true){
	if(x)YES(ex);
	else NO(ex);
}
void Possible(bool ex=true){
	cout<<"Possible\n";
	if(ex)exit(0);
}
void POSSIBLE(bool ex=true){
	cout<<"POSSIBLE\n";
	if(ex)exit(0);
}
void Impossible(bool ex=true){
	cout<<"Impossible\n";
	if(ex)exit(0);
}
void IMPOSSIBLE(bool ex=true){
	cout<<"IMPOSSIBLE\n";
	if(ex)exit(0);
}
void orPossible(bool x,bool ex=true){
	if(x)Possible(ex);
	else Impossible(ex);
}
void orPOSSIBLE(bool x,bool ex=true){
	if(x)POSSIBLE(ex);
	else IMPOSSIBLE(ex);
}
 

int b[200005],p[200005];
vi nx[200005];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n,m,pr=0,q;
	cin>>n>>m;
	rep(i,m){
		int a;
		cin>>a;
		b[i]=a-1-pr;
		pr=a;
	}
	b[m]=n-pr;
	m++;
	cin>>q;
	rep(i,q){
		cin>>p[i];
	}
	rrep(i,q){
		nx[p[i]].pb(i);
		nx[p[i]-1].pb(i);
	}
	bool ok=true;
	rep(i,q){
		int x=p[i],y=p[i]-1;
		nx[x].pop_back();
		nx[y].pop_back();
		if(b[x]+b[y]==0)ok=false;
		if(b[x]>b[y])swap(x,y);
		if(b[x]==b[y]){
			if(nx[x].size()==0||(nx[y].size()!=0&&nx[x].size()<nx[y].size()))swap(x,y);
		}
		b[x]++;
		b[y]--;
	}
	orYES(ok);
}
0