#include<bits/stdc++.h>
using namespace std;
vector<int> pre;
void dfs(vector<int>&arr, int i) {
int n = arr.size();
pre.push_back(i+1);
for (int j = 0; j < n; j++) {
if (arr[j] == i+1) {
dfs(arr, j);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int num, n,key;
vector<int> ori;
cin >> n;
int start = 0;
unordered_map<int,int> mymap;
for (int i = 0; i < n; i++) {
cin >> num;
if(!mymap.count(num)){
mymap[num]=1;
}
else{
mymap[num]++;
}
if (num == 0) { start = i; }
ori.push_back(num);
}
int max=0;
int check_num=0;
int check=0;
for(const auto & pairs:mymap){
max=pairs.second>max ?pairs.second : max;
if(pairs.first!=0){
if(check_num==0)
check_num=pairs.second;
else{
if(check_num != pairs.second){
check=1;
}
}
}
}
cout<<max<<" ";
if(check==1){
cout<<"no"<<endl;
}
else{
cout<<"yes"<<endl;
}
dfs(ori, start);
for (int i = 0; i < n-1; i++) {
cout << pre[i] << " ";
}
cout<<pre[n-1]<<endl;
return 0;
}
超时问题已经可以解决,想知道答案错误的是哪个测试点。