답안 #429002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
429002 2021-06-15T16:26:37 Z Dremix10 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 292 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define endl '\n'
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+1;
const ll INF = 2e18;
const int MOD = 1e9+7;


long long minimum_walk(vector<int> p, int s) {
    int i,n = p.size();

    ll ans = 0;
    bool ok[n] = {};

    i = 0;
    int cnt = 0;

    while(cnt < n){
        while(ok[i]){
            i++;
            ans++;
        }
        int fin = i;
        ans += abs(p[i] - i);
        i = p[i];
        ok[i] = true;
        cnt++;
        while(i != fin){
            ans += abs(p[i] - i);
            i = p[i];
            ok[i] = true;
            cnt++;
        }
    }
    ans += i;
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 268 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 268 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 268 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 292 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 268 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -