답안 #427122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427122 2021-06-14T12:33:36 Z Hazem 고대 책들 (IOI17_books) C++14
12 / 100
103 ms 416 KB
#include "books.h"
#include <bits/stdc++.h>
#define LL long long 
 
using namespace std;
 
const LL LINF  = 1e18;
 
int a[10],n;
vector<int>vec;
 
bool check(){
 
	bool q = 1;
	for(int i=0;i<n;i++)
		q &= (a[i]==vec[i]);
	
	return q;
}
 
LL bt(int pos,int cur,int cnt);
 
LL move(int pos,int cur,int cnt){
 
	LL ret = LINF;
	if(pos<n-1)
		ret = min(ret,bt(pos+1,cur,cnt+1));
	
	if(pos>0)
		ret = min(ret,bt(pos-1,cur,cnt+1));
 
	return ret;
}
 
LL bt(int pos,int cur,int cnt){
 
	if(!pos&&check())
		return cnt;
	
	if(cnt>10)
		return LINF;
 
	LL ret = LINF;
	ret = min(ret,move(pos,cur,cnt));
	
	swap(cur,a[pos]);
	if(!pos&&check())
		return cnt;
		
	ret = min(ret,move(pos,cur,cnt));
	swap(cur,a[pos]);
 
	return ret;
}
 
long long minimum_walk(std::vector<int> P, int s) {	
	
	vec = P;
	n = P.size();
	for(int i=0;i<n;i++)
		a[i] = i;
 
	LL ans = bt(0,-1,0);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 4 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 4 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 4 ms 292 KB Output is correct
8 Correct 4 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 5 ms 296 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 4 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 4 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 4 ms 292 KB Output is correct
8 Correct 4 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 5 ms 296 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Runtime error 88 ms 324 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 4 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 4 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 4 ms 292 KB Output is correct
8 Correct 4 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 5 ms 296 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Runtime error 88 ms 324 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 416 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 204 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 4 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 4 ms 204 KB Output is correct
6 Correct 4 ms 204 KB Output is correct
7 Correct 4 ms 292 KB Output is correct
8 Correct 4 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 5 ms 296 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 4 ms 204 KB Output is correct
19 Runtime error 88 ms 324 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -