답안 #1061396

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1061396 2024-08-16T08:39:04 Z Zicrus 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

typedef long long ll;

ll minimum_walk(vector<int> p, int s) {
    ll n = p.size();
	ll res = 0;
    ll ooo = 0;
    for (int i = 0; i < n; i++) ooo += (p[i] != i);

    vector<bool> vst(n);
    for (int i = 0; i < n && ooo > 0; i++) {
        if (vst[i]) continue;
        ll cur = i;
        do {
            if (p[cur] != cur) ooo--;
            res += abs(cur - p[cur]);
            cur = p[cur];
            vst[cur] = true;
        } while (cur != i);
        if (ooo > 0) res += 2;
    }

    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4182'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -