檢查每個y1與y2差是否一致即可得解。
C++(0.008)
/*******************************************************/
/* UVa 10963 The Swallowing Ground */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/09/14 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n, W;
int y1, y2, dis;
bool ok;
while( scanf( "%d", &n ) != EOF ){
for( int i = 0 ; i < n ; i++ ){
if( i ) printf( "\n" );
scanf( "%d", &W );
ok = true;
if( W ){
scanf( "%d%d", &y1, &y2 );
dis = y1-y2;
for( int j = 1 ; j < W ; j++ ){
scanf( "%d%d", &y1, &y2 );
if( y1-y2 != dis ) ok = false;
}
}
if( ok ) printf( "yes\n" );
else printf( "no\n" );
}
}
return 0;
}