Submission #302044

# Submission time Handle Problem Language Result Execution time Memory
302044 2020-09-18T11:39:17 Z TMJN Ancient Books (IOI17_books) C++17
12 / 100
2000 ms 688480 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

long long minimum_walk(vector<int>P,int S){
	assert(S==0);
	int N=P.size();
	map<pair<vector<int>,pair<int,int>>,int>mp;
	priority_queue<pair<int,pair<vector<int>,pair<int,int>>>,vector<pair<int,pair<vector<int>,pair<int,int>>>>,greater<pair<int,pair<vector<int>,pair<int,int>>>>>pq;
	pq.push({0,{P,{0,-1}}});
	while(!pq.empty()){
		vector<int>v=pq.top().second.first;
		int pos=pq.top().second.second.first;
		int hold=pq.top().second.second.second;
		int dis=pq.top().first;
		pq.pop();
		if(mp.find({v,{pos,hold}})==mp.end()){
			mp[{v,{pos,hold}}]=dis;
			swap(v[pos],hold);
			pq.push({dis,{v,{pos,hold}}});
			swap(v[pos],hold);
			if(pos){
				pq.push({dis+1,{v,{pos-1,hold}}});	
			}
			if(pos!=N-1){
				pq.push({dis+1,{v,{pos+1,hold}}});
			}
		}
	}
	vector<int>K;
	for(int i=0;i<N;i++){
		K.push_back(i);
	}
	return mp[{K,{0,-1}}];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Execution timed out 2096 ms 688480 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Execution timed out 2096 ms 688480 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 640 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Execution timed out 2096 ms 688480 KB Time limit exceeded
20 Halted 0 ms 0 KB -