| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 98498 | thiago4532 | Kronican (COCI16_kronican) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #define int int64_t
#define int uint_fast32_t
using namespace std;
const int maxn = 1010;
int v[maxn], i;
deque<int> dq;
int ct=0, n;
void backtracking(int i, deque<int> const& d){
if(i == n){
if(d == dq) ct++;
return;
}
deque<int> d1 = d, d2 = d;
d1.push_back(v[i]);
d2.push_front(v[i]);
backtracking(i+1, d1);
backtracking(i+1, d2);
}
int lis(){
vector<int> pilha;
for(int i=0; i<n; i++){
vector<int>::iterator it = lower_bound(pilha.begin(), pilha.end(), v[i]);
if(it==pilha.end()) pilha.push_back(v[i]);
else *it = v[i];
}
return pilha.size();
}
int32_t main(){
cin >> n;
int aux;
cin >> aux;
dq.push_back(aux);
for(int i=2;i<=n;i++){
int x;
cin >> x;
if(x <= dq[0]) dq.push_front(x);
else dq.push_back(x);
}
for(int i=0;i<n;i++)
v[i] = dq[i], cout << dq[i] << " \n"[i==n-1];
backtracking(1, deque<int>({v[0]}));
cout << lis
//cout << "Count: " << ct << "\n";
return 0;
}
