UVALive - 5963 ad-hoc
注意到合法条件是对称的,那很有可能与2有关,
小于2表示没有这一页,大于2表示冲突了
我也不知道这样做对不对的(输入范围很迷),试一下就A了...
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
const int maxn = 1e6+11;
const int MOD = 1e6;
typedef long long ll;
int a[maxn],b[maxn],book[maxn],tmp[maxn];
int main(){
ios::sync_with_stdio(0);
int T,kase=0; cin>>T;
while(T--){
int n;cin>>n;
rep(i,1,n) cin>>tmp[i];
rep(i,1,n) a[i]=n-tmp[i],b[i]=1+tmp[i];
memset(book,0,sizeof book);
rep(i,1,n) book[a[i]]++,book[b[i]]++;
bool flag=0;
rep(i,1,n) if(book[i]!=2) flag=1;
if(flag) cout<<"Case "<<++kase<<": "<<"no"<<endl;
else cout<<"Case "<<++kase<<": "<<"yes"<<endl;
}
return 0;
}