hdu 6620 数字华容道定理
作者:互联网
没玩过数字华容道,网上找的,判断两张图能不能相等,把1234行按顺序插到前一行结尾,计算除0外的逆序对数,判断两张图0所在的行差和逆序数的奇偶性,相同就能到,而且其他博客都说80步,4*4的图就可到
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn=1e5+100;
int a[100];
int main() {
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int t;
scanf("%d",&t);
while(t--){
int b=4,c=0;
for(int i=0;i< 16;i++){
scanf("%d",&a[ i]);
if(!a[i]){
b=4-i/4-1;
continue;
}
for(int j=0;j<i;j++)
if(a[i]<a[j])c++;
}
// cout<<b<<" "<<c<<endl;
if(c%2==b%2)printf("Yes\n");
else printf("No\n");
}
return 0;
}
标签:hdu,txt,int,华容道,long,freopen,100,include,6620 来源: https://blog.csdn.net/qq_41360176/article/details/98231337