AOJ 0033 Ball
作者:互联网
#include<iostream>
#include<vector>
using namespace std;
int n;
int num[10];
vector<int> b;
vector<int> c;
bool check()
{
if(b.size() > 1)
for(int j = 0; j < b.size()-1; j++)
if(b[j] > b[j+1]) return false;
if(c.size() > 1)
for(int j = 0; j < c.size()-1; j++)
if(c[j] > c[j+1]) return false;
return true;
}
bool dfs(int i)
{
if(i >= 10) return true;
b.push_back(num[i]);
if(check()) if(dfs(i+1)) return true;
b.pop_back();
c.push_back(num[i]);
if(check()) if(dfs(i+1)) return true;
c.pop_back();
return false;
}
int main()
{
cin >> n;
while(n--)
{
b.clear(), c.clear();
for(int i = 0; i < 10; i++) cin >> num[i];
b.clear(), c.clear();
if(dfs(0)) cout << "YES" << endl;
else cout << "NO" << endl;
}
system("pause");
return 0;
}
标签:Ball,return,int,AOJ,0033,back,num,dfs,size 来源: https://www.cnblogs.com/znk97/p/13944282.html