Submission #157279

# Submission time Handle Problem Language Result Execution time Memory
157279 2019-10-10T10:47:58 Z AKaan37 Ancient Books (IOI17_books) C++17
0 / 100
33 ms 25208 KB
#include "books.h"
#include <cstdio>
#include <vector>
#include <cassert>
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[5][5][5][5][5][1002];
//~ int cev;
string s;
vector<int> v;

using namespace std;

inline int f(int sira,int bir,int iki,int uc,int dort,int cev){
	//~ cev++;
	int cevv=inf;
	if(cev>1000)return inf;
	//~ cout<<sira<<" : : "<<bir<<" : : "<<iki<<" : : "<<uc<<" : : "<<dort<<endl;
	if(sira==0 && bir==0 && iki==1 && uc==2 && dort==3)return 0;
	if(~dp[sira][bir][iki][uc][dort][cev])return dp[sira][bir][iki][uc][dort][cev];
	for(int i=0;i<4;i++){
		cevv=min(cevv,f(i,bir,iki,uc,dort,cev+1)+abs(i-sira));
	}
	cevv=min(cevv,f(1,iki,bir,uc,dort,cev+1)+abs(0-sira)+1);
	cevv=min(cevv,f(0,iki,bir,uc,dort,cev+1)+abs(1-sira)+1);
	cevv=min(cevv,f(2,uc,iki,bir,dort,cev+1)+abs(0-sira)+2);
	cevv=min(cevv,f(0,uc,iki,bir,dort,cev+1)+abs(2-sira)+2);
	cevv=min(cevv,f(3,dort,iki,uc,bir,cev+1)+abs(0-sira)+3);
	cevv=min(cevv,f(0,dort,iki,uc,bir,cev+1)+abs(3-sira)+3);
	cevv=min(cevv,f(2,bir,uc,iki,dort,cev+1)+abs(sira-1)+1);
	cevv=min(cevv,f(1,bir,uc,iki,dort,cev+1)+abs(sira-2)+1);
	cevv=min(cevv,f(3,bir,dort,uc,iki,cev+1)+abs(sira-1)+2);
	cevv=min(cevv,f(1,bir,dort,uc,iki,cev+1)+abs(sira-3)+2);
	cevv=min(cevv,f(3,bir,iki,dort,uc,cev+1)+abs(sira-2)+1);
	cevv=min(cevv,f(2,bir,iki,dort,uc,cev+1)+abs(sira-3)+1);
	return dp[sira][bir][iki][uc][dort][cev]=cevv;
}

long long minimum_walk(std::vector<int> p, int s) {
	memset(dp,-1,sizeof(dp));
	return f(s,p[0],p[1],p[2],p[3],0);
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12664 KB Output is correct
2 Correct 32 ms 12664 KB Output is correct
3 Incorrect 29 ms 12664 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12664 KB Output is correct
2 Correct 32 ms 12664 KB Output is correct
3 Incorrect 29 ms 12664 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12664 KB Output is correct
2 Correct 32 ms 12664 KB Output is correct
3 Incorrect 29 ms 12664 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 25208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 12664 KB Output is correct
2 Correct 32 ms 12664 KB Output is correct
3 Incorrect 29 ms 12664 KB 3rd lines differ - on the 1st token, expected: '8', found: '6'
4 Halted 0 ms 0 KB -