Submission #665144

# Submission time Handle Problem Language Result Execution time Memory
665144 2022-11-27T09:59:37 Z true22 Studentsko (COCI14_studentsko) C++14
0 / 100
1000 ms 844 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair<ll, ll> pl;
typedef vector<ll> vl;   
typedef vector<pl> vp;

#define nl "\n"
#define fr first
#define sc second
#define pb push_back

#define all(x) x.begin(), x.end()
#define fur(i, a, b) for(ll i = a; i <= b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= b; --i)
#define pv(x) for(auto k : x){cout << k << " ";} cout << nl
const ll inf = 1e17;

void solve(){
    ll n, k;
    cin >> n >> k;
    vl a(n);
    fur(i, 0, n-1) cin >> a[i];
    vl b = a;
    sort(all(b));
    ll ans = inf;

    fur(i, 0, (1<<n)-1){
        ll bm = i;
        set<ll> tof;
        vl seq;
        fur(j, 0, n-1){
        if ((1<<j) & i){
            tof.insert(j);
            }else{
                seq.pb(a[j]);
            }
        }
        for(auto u: tof)
            seq.pb(a[u]);

    //  seq = {2, 1, 7, 5, 10, 16};
    bool val = 1;
    vl tmp;
    ll t = 0;
    ruf(x, n-1, 0){
        t++;
        tmp.pb(seq[x]);
        if (t+1 > k){
            sort(all(tmp));
            //pv(tmp);
            fur(m, 0, k-1){
                if (tmp[m] != b[m+x]){
                    val = 0;
                    break;
                }
            }
            t = 0;
            tmp.clear();
        }
    }
    if (val){
        //pv(seq);
        //cout << tof.size() << nl;
        ans = min(ans, (ll)tof.size());
    }
    
    }
    cout << ans << nl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll t = 1;
    //cin >> t;
    while(t--){
        
        solve();
    }
    
    return 0;
}

Compilation message

studentsko.cpp: In function 'void solve()':
studentsko.cpp:32:12: warning: unused variable 'bm' [-Wunused-variable]
   32 |         ll bm = i;
      |            ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1033 ms 300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 176 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 692 KB Time limit exceeded
2 Halted 0 ms 0 KB -