uva meeting with aliens code example

Example: uva meeting with aliens

#include <cstdio>#include <cstring>#define MAXN 510int POS[MAXN], START[MAXN], END[MAXN], N;intExchange () {intCNT =0; for(inti =1; I <= N; i++) {if(End[i]! = i) {POS[End[i]] =POS[i]; end[POS[i]] = end[i];        cnt++; }    }returnCNT;} void Solve () {intMIN =0x3f3f3f3f; for(inti =1; I <= N; i++) { for(intj =1, k = i; J <= N; J + +, k++) {if(k > N) k =1; END[J] = start[k];POS[End[j]] = j; }intt = Exchange (); min = (T > MIN?)    MIN:T); } for(inti =1; I <= N; i++) { for(intj =1, k = i; J <= N; J + +, k--) {if(k <=0) k = n; END[J] = start[k];POS[End[j]] = j; }intt = Exchange (); min = (T > MIN?)    MIN:T); }printf("%d\ n", MIN);}intMain () { while(SCANF ("%d", &n) = =1&& N) { for(inti =1; I <= N; i++) scanf ("%d", &start[i]);    Solve (); }return 0;}