#include <iostream> #include <sstream> #include <stdio.h> #include <string> #include <math.h> #include <algorithm> #include <stdlib.h> #include <stack> #include <map> #include <set> #include <queue> using namespace std; int main() { #ifdef ONLINE_JUDGE #else freopen("1.txt","r",stdin); #endif int k; cin>>k; while(k--) { int n; cin>>n; int temp1,temp2; n--; cin>>temp1>>temp2; if(temp1!=0||temp2-temp1!=1) {cout<<"NO";continue;} bool flag=1; while(n--) { int a,b; cin>>a>>b; if(a!=temp2) {flag=0;break;} if(b-a!=1) {flag=0;break;} temp1=a; temp2=b; } if(flag==1) {cout<<"YES";} else {cout<<"NO";} cout<<endl; } } |
Double click to view unformatted code.