답안 #1073841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073841 2024-08-24T23:26:50 Z ArthuroWich 고대 책들 (IOI17_books) C++17
0 / 100
0 ms 348 KB
#include "books.h"
#include<bits/stdc++.h>
using namespace std;
long long minimum_walk(vector<int> p, int s) {
	int ans = 0, n = p.size();
	int i = 0;
	while(i < n) {
		if (p[i] == i) {
			i++;
			if (i != n) {
				ans++;
			}
			continue;
		}
		int a = i;
		while(p[a] != a) {
			ans += abs(p[a]-a);
			int b = p[a];
			p[a] = a;
			a = b;
		}
		if (is_sorted(p.begin(), p.end())) {
			break;
		}
		i = a;
		i++;
		if (i != n) {
			ans++;
		}
	}
	if (i == n) {
		i--;
	}
	while(i >= 0) {
		if (p[i] == i) {
			i--;
			if (i < 0) {
				ans++;
			}
			continue;
		}
		int a = i;
		while(p[a] != a) {
			ans += abs(p[a]-a);
			int b = p[a];
			p[a] = a;
			a = b;
		}
		i = a;
		i--;
		if (i < 0) {
			ans++;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '9'
4 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 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '9'
4 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 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '9'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '3304', found: '3737'
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 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '8', found: '9'
4 Halted 0 ms 0 KB -