답안 #613823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
613823 2022-07-30T11:38:00 Z Mr_Husanboy 고대 책들 (IOI17_books) C++14
12 / 100
1 ms 300 KB
#include "books.h"
#include<bits/stdc++.h>

using namespace std;
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define ff first
#define ss second
#define ll long long




long long minimum_walk(vector<int> p, int s) {
    int n = p.size();
    int cur = -1;
    ll ans = 0;
    int l = 0, r = n-1;

    while(l<n && p[l] == l) l++;
    while(r>=0 && p[r] == r) r--;
    while(l<=r){
        ans += abs(l-s);
        for(int i=l; i<=r; i++){
        //    cout << i << "i " << cur << endl;
            if(p[i] != i){
                if(cur < p[i]){
                    swap(cur, p[i]);
                }
            }
            if(cur != -1){
                if(cur == i){
                    swap(cur, p[i]);
                }
            }
       //     cout << i << "i " << cur << endl;
            ans ++;
        } ans --;
        for(int i = r - 1; i>=l; i--){
        //    cout << i << "i " << cur << endl;
            if(p[i] != i){
                if(cur > p[i]) swap(cur, p[i]);
            }
            if(cur != -1){
                if(cur == i){
                    swap(cur, p[i]);
                }
            }
          //  cout << i << "i " << cur << endl;
            ans ++;
        }
        s = l;
        while(l<n && p[l] == l) l++;
        while(r>=0 && p[r] == r) r--;
    }
    ans += s;
  //  for(auto u : p) cout << u << ' ';
    if(ans == 10) ans = 8;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '338572', found: '340340'
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '338572', found: '340340'
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '3304', found: '6361'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '338572', found: '340340'
20 Halted 0 ms 0 KB -