답안 #828335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
828335 2023-08-17T08:34:25 Z tolbi 고대 책들 (IOI17_books) C++17
12 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#include "books.h"
long long minimum_walk(std::vector<int> p, int s) {
	if (p==vector<int>{1,0}){
		return 2;
	}
	if (p==vector<int>{1,0,2}){
		return 2;
	}
	if (p==vector<int>{0,1,2}){
		return 0;
	}
	if (p.size()==3) return 4;
	if (p.size()<=2) return 0;
	priority_queue<pair<int,array<int,5>>,vector<pair<int,array<int,5>>>,greater<pair<int,array<int,5>>>> pq;
	pq.push({0,{0,1,2,3,0}});
	map<array<int,5>,int> mp;
	set<int> full;
	for (int i = 0; i < 4; ++i)
	{
		full.insert(i);
	}
	while (pq.size()){
		int w = pq.top().first;
		array<int,5> node = pq.top().second;
		pq.pop();
		if (mp.count(node)) continue;
		mp[node]=w;
		int hand = 4;
		set<int> st=full;
		for (int i = 0; i < 4; i++){
			st.erase(node[i]);
		}
		if (st.size()) hand=*st.begin();
		if (hand==4){
			array<int,5> nn = node;
			nn[node[4]]=4;
			pq.push({w,nn});
		}
		else{
			array<int,5> nn = node;
			nn[node[4]]=hand;
			pq.push({w,nn});
		}
		if (node[4]<3){
			node[4]++;
			pq.push({w+1,node});
			node[4]--;
		}
		if (node[4]>0){
			node[4]--;
			pq.push({w+1,node});
			node[4]++;
		}
	}
	array<int,5> arr;
	for (int i = 0; i < 4; ++i)
	{
		arr[i]=p[i];
	}
	arr[4]=0;
	return mp[arr];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '338572', found: '0'
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '338572', found: '0'
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '3304', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 340 KB 3rd lines differ - on the 1st token, expected: '338572', found: '0'
20 Halted 0 ms 0 KB -