#include<stdio.h> #include<stdlib.h> int main() { int t,n; int left;int right; int len; int pos=0; int flag=1; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d %d",&left,&right); if(left>right) return -1; if(i==0) { len=right-left; pos=right; }else{ while(pos<right) { pos+=len; if(pos>left&&pos<right) { flag=0; break; } } } } if(flag) printf("YES\n"); else printf("NO\n"); } return 0; } |
Double click to view unformatted code.