Submission #1065715

# Submission time Handle Problem Language Result Execution time Memory
1065715 2024-08-19T11:14:21 Z TheQuantiX Ancient Books (IOI17_books) C++17
12 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "books.h"

using namespace std;
using ll = long long;

constexpr ll INF = 1000000000000000000LL;

ll n, m, q, k, x, y, a, b, c;

map< pair< vector<int>, pair<int, int> >, ll > mp;
vector<int> perfect;

long long minimum_walk(vector<int> p, int s) {
    ll num = 0;
    bool fl = 1;
    for (int i = 0; i < p.size(); i++) {
        num += abs(i - p[i]);
        if (i != p[i]) {
            fl = 0;
        }
        if (fl) {
            num += 2;
        }
    }
    if (fl) {
        num = 0;
    }
    return num;
    // for (int i = 0; i < p.size(); i++) {
    //     perfect.push_back(i);
    // }
    // deque< pair< vector<int>, pair<int, int> > > q;
    // q.push_back({p, {s, -1}});
    // mp[{p, {s, -1}}] = 0;
    // while (!q.empty()) {
    //     auto [p, p2] = q[0];
    //     auto [s, carry] = p2;
    //     q.pop_front();
    //     // for (auto i : p) {
    //     //     cout << i << ' ';
    //     // }
    //     // cout << endl;
    //     // cout << s << ' ' << carry << endl;
    //     if (p == perfect && s == 0 && carry == -1) {
    //         return mp[{p, {s, carry}}];
    //     }
    //     ll d = mp[{p, {s, carry}}];
    //     swap(carry, p[s]);
    //     if (!mp.count({p, {s, carry}})) {
    //         q.push_front({p, {s, carry}});
    //         mp[{p, {s, carry}}] = d;
    //     }
    //     swap(carry, p[s]);
    //     if (s > 0 && !mp.count({p, {s - 1, carry}})) {
    //         q.push_back({p, {s - 1, carry}});
    //         mp[{p, {s - 1, carry}}] = d + 1;
    //     }
    //     if (s < p.size() - 1 && !mp.count({p, {s + 1, carry}})) {
    //         q.push_back({p, {s + 1, carry}});
    //         mp[{p, {s + 1, carry}}] = d + 1;
    //     }
    // }
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < p.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '2082', found: '788'
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '2082', found: '788'
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 440 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '2082', found: '788'
23 Halted 0 ms 0 KB -