結果

問題 No.930 数列圧縮
ユーザー sigma425sigma425
提出日時 2019-11-22 22:01:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,563 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 204,272 KB
実行使用メモリ 9,412 KB
最終ジャッジ日時 2024-04-19 11:24:55
合計ジャッジ時間 4,196 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 28 ms
7,552 KB
testcase_09 AC 55 ms
8,192 KB
testcase_10 AC 37 ms
7,168 KB
testcase_11 AC 35 ms
7,680 KB
testcase_12 AC 40 ms
8,320 KB
testcase_13 AC 28 ms
6,944 KB
testcase_14 AC 28 ms
6,944 KB
testcase_15 AC 44 ms
9,344 KB
testcase_16 AC 44 ms
8,832 KB
testcase_17 AC 60 ms
9,344 KB
testcase_18 AC 72 ms
9,216 KB
testcase_19 AC 56 ms
9,284 KB
testcase_20 AC 50 ms
9,412 KB
testcase_21 AC 46 ms
9,216 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 43 ms
9,412 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<int> p(N),where(N);
	set<int> st; rep(i,N) st.insert(i);
	rep(i,N){
		cin >> p[i], p[i]--;
		where[p[i]] = i;
	}
	V<int> ans;
	rep(i,N){
		int x = where[i];
		if(*st.begin() == x){
			for(int v: st) if(v != x){
				ans.pb(p[v]);
			}
			break;
		}
		if(*st.rbegin() == x){
			cout << "No" << endl;
			return 0;
		}
		ans.pb(i);
		st.erase(x);
	}
	cout << "Yes" << endl;
	for(int x: ans) cout << x+1 << " ";
	cout << endl;
}
0