Submission #299713

#TimeUsernameProblemLanguageResultExecution timeMemory
299713REALITYNBAncient Books (IOI17_books)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> 
using namespace std; 
//#define int long long 
map<vector<int>,int> mem ; 
int dp(vector<int> a , int i , int hand, int mv){
	if(mv==20) return 1e7 ; 
	bool flg = 1 ; 
	for(int k=0;k<a.size();k++) if(k!=a[k]) flg = 0 ; 
	if(flg) return 0 ; 
	vector<int> mm= a ; 
	mm.push_back(i) ; 
	mm.push_back(mv) ;
	mm.push_back(hand) ; 
	if(mem.count(mm)) return mem[mm] ; 
	int mn = 1e7 ; 
	//hand is empty 
    for(int j=0;j<a.size();j++){
        swap(a[j],hand) ; 
        mn = min(mn,abs(i-j)+dp(a,j,hand,mv+1)) ; 
        swap(a[j],hand) ; 
    }
	mem[mm]=mn ; 
	return mn ;
}
long long minimum_walk(vector<int> p , int s){
	int n = p.size() ; 
	return dp(p,0,-1,0) ; 
}
int main(){
	cout <<minimum_walk({0, 2, 3, 1},0) ; 
}

Compilation message (stderr)

books.cpp: In function 'int dp(std::vector<int>, int, int, int)':
books.cpp:8:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for(int k=0;k<a.size();k++) if(k!=a[k]) flg = 0 ;
      |              ~^~~~~~~~~
books.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int j=0;j<a.size();j++){
      |                 ~^~~~~~~~~
books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:26:6: warning: unused variable 'n' [-Wunused-variable]
   26 |  int n = p.size() ;
      |      ^
/tmp/cc245trA.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccp5IylY.o:books.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status