結果
問題 | No.1373 Directed Operations |
ユーザー |
👑 ![]() |
提出日時 | 2021-02-05 22:08:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 2,717 ms |
コンパイル使用メモリ | 195,088 KB |
最終ジャッジ日時 | 2025-01-18 12:27:20 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:14:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | rep(i,N-1){ int a; scanf("%d",&a); A[i]={a,i}; } | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; pair<int,int> A[100000]; int ans[100000]; int main(){ scanf("%d",&N); rep(i,N-1){ int a; scanf("%d",&a); A[i]={a,i}; } sort(A,A+N-1); rep(i,N-1) if(A[i].first>i+1){ printf("NO\n"); return 0; } rep(i,N-1) ans[A[i].second]=i+2-A[i].first; printf("YES\n"); rep(i,N-1){ if(i) printf(" "); printf("%d",ans[i]); } printf("\n"); return 0; }