You are viewing a single comment's thread. Return to all comments →
Is this the right way to do it?
int main() { int n; cin>>n; n+=1; int f[n]; for(int i=1;i<n;i++) cin>>f[i]; for(int i=1;i<n;i++) { if(f[f[i]]!=i) { cout<<"NO"<<endl; goto x; } } cout<<"YES"; x: return 0; }
It passed all the test cases ^-^
Security Involution
You are viewing a single comment's thread. Return to all comments →
Is this the right way to do it?
It passed all the test cases ^-^