Submission #821288

# Submission time Handle Problem Language Result Execution time Memory
821288 2023-08-11T08:42:57 Z vjudge1 Ancient Books (IOI17_books) C++14
12 / 100
74 ms 284 KB
#include<bits/stdc++.h>
#include "books.h"
#define fi first
#define se second
#define ll long long
using namespace std ;
ll ans = 1e18 ;
int sz ;
vector<int> now ;
bool check()
{
    vector<int> gr = now ;
    sort(gr.begin(), gr.end()) ;
    return (now == gr) ;
}
void rec(int ind, int cnt, int sum, int with)
{
    if(with == -1 && check())
    {
        ans = min(ans, (ll)sum + ind) ;
        return ;
    }
    if(cnt == 16)
        return ;
    if(with != -1)
    {
        swap(now[ind], with) ;
        rec(ind, cnt + 1, sum, with) ;
        swap(now[ind], with) ;
    }
    else
    {
        if(now[ind] != -1)
        {
            swap(now[ind], with) ;
            rec(ind, cnt + 1, sum, with) ;
            swap(now[ind], with) ;
        }
    }
    if(ind < sz - 1)
        rec(ind + 1, cnt + 1, sum + 1, with) ;
    if(ind)
        rec(ind - 1, cnt + 1, sum + 1, with) ;
}
ll minimum_walk(vector<int> p, int s)
{
    sz = p.size() ;
    if(sz <= 4)
    {
        now = p ;
        rec(s, 0ll, 0ll, -1ll) ;
    }
    return ans ;
}
//signed main()
//{
//    int n, s ;
//    cin >> n >> s ;
//    vector<int> p(n) ;
//    for(int i = 0 ; i < n ; i++)
//        cin >> p[i] ;
//    cout << minimum_walk(p, s) ;
//    return 0 ;
//}
# Verdict Execution time Memory Grader output
1 Correct 74 ms 284 KB Output is correct
2 Correct 62 ms 284 KB Output is correct
3 Correct 68 ms 212 KB Output is correct
4 Correct 24 ms 212 KB Output is correct
5 Correct 65 ms 212 KB Output is correct
6 Correct 70 ms 280 KB Output is correct
7 Correct 66 ms 280 KB Output is correct
8 Correct 69 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 56 ms 276 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 74 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 62 ms 212 KB Output is correct
16 Correct 73 ms 284 KB Output is correct
17 Correct 68 ms 280 KB Output is correct
18 Correct 64 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 284 KB Output is correct
2 Correct 62 ms 284 KB Output is correct
3 Correct 68 ms 212 KB Output is correct
4 Correct 24 ms 212 KB Output is correct
5 Correct 65 ms 212 KB Output is correct
6 Correct 70 ms 280 KB Output is correct
7 Correct 66 ms 280 KB Output is correct
8 Correct 69 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 56 ms 276 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 74 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 62 ms 212 KB Output is correct
16 Correct 73 ms 284 KB Output is correct
17 Correct 68 ms 280 KB Output is correct
18 Correct 64 ms 276 KB Output is correct
19 Incorrect 1 ms 224 KB 3rd lines differ - on the 1st token, expected: '338572', found: '1000000000000000000'
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 284 KB Output is correct
2 Correct 62 ms 284 KB Output is correct
3 Correct 68 ms 212 KB Output is correct
4 Correct 24 ms 212 KB Output is correct
5 Correct 65 ms 212 KB Output is correct
6 Correct 70 ms 280 KB Output is correct
7 Correct 66 ms 280 KB Output is correct
8 Correct 69 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 56 ms 276 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 74 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 62 ms 212 KB Output is correct
16 Correct 73 ms 284 KB Output is correct
17 Correct 68 ms 280 KB Output is correct
18 Correct 64 ms 276 KB Output is correct
19 Incorrect 1 ms 224 KB 3rd lines differ - on the 1st token, expected: '338572', found: '1000000000000000000'
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '1000000000000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 74 ms 284 KB Output is correct
2 Correct 62 ms 284 KB Output is correct
3 Correct 68 ms 212 KB Output is correct
4 Correct 24 ms 212 KB Output is correct
5 Correct 65 ms 212 KB Output is correct
6 Correct 70 ms 280 KB Output is correct
7 Correct 66 ms 280 KB Output is correct
8 Correct 69 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 56 ms 276 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 74 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 62 ms 212 KB Output is correct
16 Correct 73 ms 284 KB Output is correct
17 Correct 68 ms 280 KB Output is correct
18 Correct 64 ms 276 KB Output is correct
19 Incorrect 1 ms 224 KB 3rd lines differ - on the 1st token, expected: '338572', found: '1000000000000000000'
20 Halted 0 ms 0 KB -