結果

問題 No.1373 Directed Operations
ユーザー 👑 kmjpkmjp
提出日時 2021-02-05 23:12:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 1,121 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 200,652 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2023-09-15 10:44:11
合計ジャッジ時間 5,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
15,392 KB
testcase_01 AC 8 ms
15,172 KB
testcase_02 AC 142 ms
16,180 KB
testcase_03 AC 13 ms
15,932 KB
testcase_04 AC 16 ms
15,980 KB
testcase_05 AC 6 ms
15,216 KB
testcase_06 AC 158 ms
19,068 KB
testcase_07 AC 10 ms
15,472 KB
testcase_08 AC 23 ms
15,624 KB
testcase_09 AC 31 ms
19,072 KB
testcase_10 AC 27 ms
18,716 KB
testcase_11 AC 11 ms
16,044 KB
testcase_12 AC 25 ms
17,216 KB
testcase_13 AC 8 ms
15,532 KB
testcase_14 AC 155 ms
17,600 KB
testcase_15 AC 138 ms
17,404 KB
testcase_16 AC 156 ms
17,632 KB
testcase_17 AC 113 ms
16,072 KB
testcase_18 AC 67 ms
15,596 KB
testcase_19 AC 68 ms
16,660 KB
testcase_20 AC 91 ms
17,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
int A[101010];
vector<int> C[505050];
int R[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>A[i];
		C[A[i]].push_back(i);
	}
	int ri=1;
	FOR(i,N) FORR(c,C[i]) {
		if(ri+1-i<1) return _P("NO\n");
		R[c]=ri+1-i;
		ri++;
	}
	cout<<"YES"<<endl;
	FOR(i,N-1) cout<<R[i]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0