답안 #577174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577174 2022-06-14T08:29:58 Z Ronin13 Zoltan (COCI16_zoltan) C++14
21 / 140
1000 ms 4532 KB
#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 j = 1; j < vec.size(); j++){
            if(vec[j] <= vec[j - 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 j = 1; j < vec.size(); j++){
            if(vec[j] <= vec[j - 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

zoltan.cpp: In function 'int main()':
zoltan.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j = 1; j < vec.size(); j++){
      |                        ~~^~~~~~~~~~~~
zoltan.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int j = 1; j < vec.size(); j++){
      |                        ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 232 ms 300 KB Output isn't correct
2 Incorrect 234 ms 308 KB Output isn't correct
3 Incorrect 221 ms 212 KB Output isn't correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 204 ms 300 KB Output is correct
6 Correct 248 ms 332 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 1 ms 336 KB Output isn't correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Incorrect 18 ms 3340 KB Output isn't correct
12 Execution timed out 1084 ms 3248 KB Time limit exceeded
13 Incorrect 17 ms 2848 KB Output isn't correct
14 Incorrect 52 ms 3524 KB Output isn't correct
15 Execution timed out 1080 ms 3904 KB Time limit exceeded
16 Incorrect 48 ms 4532 KB Output isn't correct
17 Incorrect 23 ms 3888 KB Output isn't correct
18 Incorrect 19 ms 3892 KB Output isn't correct
19 Incorrect 18 ms 3916 KB Output isn't correct
20 Incorrect 20 ms 3916 KB Output isn't correct