結果

問題 No.1373 Directed Operations
ユーザー ttkkggwwttkkggww
提出日時 2021-02-05 21:51:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 214,660 KB
実行使用メモリ 10,244 KB
最終ジャッジ日時 2023-09-15 08:02:23
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 192 ms
10,244 KB
testcase_03 AC 19 ms
4,380 KB
testcase_04 AC 31 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 261 ms
10,108 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 25 ms
4,380 KB
testcase_09 AC 37 ms
4,380 KB
testcase_10 AC 31 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 269 ms
10,156 KB
testcase_15 AC 234 ms
9,048 KB
testcase_16 AC 270 ms
10,244 KB
testcase_17 AC 156 ms
8,432 KB
testcase_18 AC 87 ms
6,228 KB
testcase_19 AC 97 ms
5,932 KB
testcase_20 AC 144 ms
7,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;

int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> vpii(n-1);

	for(int i = 0;i<n-1;i++)cin >> vpii[i].first ,vpii[i].second=i;
	sort(vpii.begin(),vpii.end());
	for(int i = 0;i<n-1;i++){
		if(vpii[i].first>i+1){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	map<pair<int,int>,int> ans;
	for(int i = 0;i<n-1;i++){
		ans[vpii[i]] = (i+2)-(vpii[i].first);
	}
	sort(vpii.begin(),vpii.end(),[](auto a,auto b){
			return a.second<b.second;
			});
	cout<<"YES"<<endl;
	for(int i = 0;i<n-1;i++){
		cout<<ans[vpii[i]]<<endl;
	}

}
0