Ball
可以用dfs,不过发现用一个循环就可以搞定。
1 #include <iostream> 2 using namespace std; 3 int a[11], n; 4 int main(){ 5 cin >> n; 6 while(n--){ 7 for(int i = 0; i < 10; i ++) cin >> a[i]; 8 int c = 0, b = 0, flag = 1; 9 for(int i = 0; i < 10; i ++){ 10 if(c > b){ 11 if(a[i] > c){ 12 c = a[i]; 13 }else if(a[i] > b){ 14 b = a[i]; 15 }else{ 16 flag = 0; 17 } 18 }else{ 19 if(a[i] > b){ 20 b = a[i]; 21 }else if(a[i] > c){ 22 c = a[i]; 23 }else{ 24 flag = 0; 25 } 26 } 27 } 28 if(flag) cout << "YES" << endl; 29 else cout << "NO" << endl; 30 } 31 return 0; 32 }
时间: 2024-11-03 05:28:43