# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577156 | Ronin13 | Zoltan (COCI16_zoltan) | C++14 | 1080 ms | 4588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const ll mod = 1e9 + 7;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
int a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
deque <int> q;
q.push_front(a[1]);
for(int i = 2; i <= n; i++){
if(a[i] > q.front()) q.push_back(a[i]);
else q.push_front(a[i]);
}
int b[n + 1];
int ind = 0;
while(!q.empty()){
int v = q.front();
q.pop_front();
b[ind++] = v;
}
ll cnt = 0;
int mx = 0;
for(int i = 0; i < (1 << n); i++){
vector <int> vec;
for(int j = 0; j < n; j++) if((1 << j) & i) vec.pb(b[j]);
int ind = false;
for(int i = 1; i < vec.size(); i++){
if(vec[i] <= vec[i - 1]){
ind = true;
break;
}
}
if(!ind){
mx = max(mx, (int)vec.size());
}
}
for(int i = 0; i < (1 << n); i++){
if(__builtin_popcount(i) != mx) continue;
vector <int> vec;
for(int j = 0; j < n; j++) if((1 << j) & i) vec.pb(b[j]);
int ind = false;
for(int i = 1; i < vec.size(); i++){
if(vec[i] <= vec[i - 1]){
ind = true;
break;
}
}
if(!ind){
cnt++;
}
}
for(int i = 1; i <= n - mx; i++) cnt *= 2, cnt %= mod;
cout << mx << ' ' << cnt << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |