题解 | #体操队形#
体操队形
https://ac.nowcoder.com/acm/contest/11217/I
I 体操队形:
题目很简单,代码很短,三行过
#include<bits/stdc++.h>
int a[12],p,i,n, ans,th[12] = { 0,1,2,3,4,5,6,7,8,9,10};
int main(){
for (scanf("%d",&n),i = 1; i <= n; scanf("%d",a+i),i++);
do for (i = 1,p=1; i <= n;th[i] > th[a[i]]?p = 0:1,i++);
while (p==1?ans++:1,std::next_permutation(th + 1, th + n + 1)?1:0*printf("%d",ans));
}