#1020685

Solution for 0033: Ball by orisano

Source Code Status Test Cases
    Policy: public     Reviewed: 177    
00.00 sec    1192 KB    42 lines     1223 bytes    2014-07-15 22:32
#include <bits/stdc++.h>

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(vector<int> bs) : bs(bs) {}
  bool solve(int it=0, int a=0, int b=0){
    if (it == bs.size()) return true;
    if (a < bs[it] && solve(it + 1, bs[it], b)) return true;
    if (b < bs[it] && solve(it + 1, a, bs[it])) return true;
    return false;
  }
  vector<int> bs;
};

int main()
{
  int n = in();
  for (int i = 0; i < n; i++){
    vector<int> bs;
    for (int j = 0; j < 10; j++){
      bs.push_back(in());
    }
    Solver solver(bs);
    if (solver.solve()) puts("YES");
    else puts("NO");
  }
  return (0);
}


Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 1/1 C++ CPU: 00.00 sec Memory: 1192 KB Length: 1223 B 2014-07-15 22:32 2014-07-15 22:32
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 1192 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags