結果

問題 No.1373 Directed Operations
ユーザー leaf_1415leaf_1415
提出日時 2020-10-08 01:49:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 65,684 KB
実行使用メモリ 4,912 KB
最終ジャッジ日時 2023-09-28 00:36:15
合計ジャッジ時間 5,190 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 17 ms
4,488 KB
testcase_04 AC 30 ms
4,504 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 36 ms
4,912 KB
testcase_10 AC 30 ms
4,660 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <vector>
#include <utility>
#include <algorithm>
#include <ctime>

using namespace std;
typedef pair<int, int> P;

int n;
int a[100005];
P p[100005];
int ans[100005];

int main()
{
	cin >> n;
	assert(n >= 2 && n <= 100000);
	for(int i = 1; i <= n-1; i++){
		cin >> a[i];
		assert(a[i] >= 1 && a[i] <= n-1);
	}
	
	for(int i = 1; i <= n-1; i++) p[i] = P(a[i], i);
	sort(p+1, p+n);
	
	for(int i = 1; i <= n-1; i++){
		if(p[i].first > i){
			cout << "NO" << endl;
			return 0;
		}
		ans[p[i].second] = (i+1) - a[p[i].second];
	}
	
	srand(time(NULL));
	int x = rand() % (n-1) + 1;
	ans[x] = rand() % (n-a[x]) + 1;
	
	cout << "YES" << endl;
	for(int i = 1; i <= n-1; i++) cout << ans[i] << endl;
	
	return 0;
}
0