Submission #821249

# Submission time Handle Problem Language Result Execution time Memory
821249 2023-08-11T08:22:09 Z vjudge1 Ancient Books (IOI17_books) C++17
0 / 100
2000 ms 212 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

long long minimum_walk(vector<int> p, int s) {
    int c = 0, n = p.size();
    for(; n && p[n - 1] == n - 1; -- n);
    for(int cr = 0, take = -1; cr < n;) {
        if(cr == p[cr]) {
            cr += (take == -1 || take > cr ? +1 : -1);
            continue;
        }
        if(take == cr) {
            swap(take, p[cr]);
            if(cr == n - 1) {
                -- n;
            }
        } else if(take == -1) {
            take = p[cr];
            p[cr] = -1;
        } else if(take < p[cr]){
            swap(take, p[cr]);
        }
    }
    return c;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2055 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -