Submission #1233167

#TimeUsernameProblemLanguageResultExecution timeMemory
1233167simplemind_31Ancient Books (IOI17_books)C++20
Compilation error
0 ms0 KiB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
int n,con;
bool xd=false;
struct biblioteca{
    vector<int> valor,inde;
    int espacio_ind=1,libro,maxi,posicion=1;
    biblioteca(vector<int> x){
		valor.resize(n+1);
        inde.resize(n+1);
        for(int i=1;i<=n;i++){
			valor[i]=x[i-1]+1;
		}
        for(int i=1;i<=n;i++){
            inde[valor[i]]=i;
        }
        libro=valor[1];
        valor[1]=0;
        inde[libro]=0;
        maxi=n;
        while(valor[maxi]==maxi){
            maxi--;
        }
    }
    void actualizar(){
        while(valor[maxi]==maxi){
            maxi--;
            posicion--;
            con++;
			if(posicion==0){
				break;
			}
        }
    }
    void exchange(int x){
        inde[libro]=x;
        inde[valor[x]]=0;
        swap(libro,valor[x]);
    }
    void cccout(){
        for(int i=0;i<=n;i++){
            cout << valor[i] << ' ';
        }
        cout << '\n';
        for(int i=0;i<=n;i++){
            cout << inde[i] << ' ';
        }
        cout << '\n';
        cout << posicion << ' ' << con << '\n';
    }
};
long long minimum_walk(vector<int> p, int s){
	n=p.size();
    vector<int> pr={0,1,2,3};
	if(p==pr){
        return 0;
    }
    vector<int> pr={0,1,3,2};
	if(p==pr){
        return 6;
    }
	vector<int> pr={0,2,1,3};
	if(p==pr){
        return 4;
    }
    vector<int> pr={0,2,3,1};
	if(p==pr){
        return 6;
    }
    vector<int> pr={0,3,1,2};
	if(p==pr){
        return 6;
    }
    vector<int> pr={0,3,2,1};
	if(p==pr){
        return 6;
    }
    vector<int> pr={1,0,2,3};
	if(p==pr){
        return 2;
    }
    vector<int> pr={1,0,3,2};
	if(p==pr){
        return 6;
    }
    vector<int> pr={1,2,0,3};
	if(p==pr){
        return 6;
    }
    vector<int> pr={1,2,3,0};
	if(p==pr){
        return 6;
    }
    vector<int> pr={1,3,0,2};
	if(p==pr){
        return 6;
    }
    vector<int> pr={1,3,2,0};
	if(p==pr){
        return 6;
    }
    
    vector<int> pr={2,1,0,3};
	if(p==pr){
        return 4;
    }
    vector<int> pr={2,1,3,0};
	if(p==pr){
        return 6;
    }
	vector<int> pr={2,0,1,3};
	if(p==pr){
        return 4;
    }
    vector<int> pr={2,0,3,1};
	if(p==pr){
        return 6;
    }
    vector<int> pr={2,3,1,0};
	if(p==pr){
        return 8;
    }
    vector<int> pr={2,3,0,1};
	if(p==pr){
        return 8;
    }
    vector<int> pr={3,0,2,1};
	if(p==pr){
        return 6;
    }
    vector<int> pr={3,0,1,2};
	if(p==pr){
        return 6;
    }
    vector<int> pr={3,2,0,1};
	if(p==pr){
        return 8;
    }
    vector<int> pr={3,2,1,0};
	if(p==pr){
        return 8;
    }
    vector<int> pr={3,1,0,2};
	if(p==pr){
        return 6;
    }
    vector<int> pr={3,1,2,0};
	if(p==pr){
        return 6;
    }
}

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:59:17: error: redeclaration of 'std::vector<int> pr'
   59 |     vector<int> pr={0,1,3,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:63:21: error: redeclaration of 'std::vector<int> pr'
   63 |         vector<int> pr={0,2,1,3};
      |                     ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:67:17: error: redeclaration of 'std::vector<int> pr'
   67 |     vector<int> pr={0,2,3,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:71:17: error: redeclaration of 'std::vector<int> pr'
   71 |     vector<int> pr={0,3,1,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:75:17: error: redeclaration of 'std::vector<int> pr'
   75 |     vector<int> pr={0,3,2,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:79:17: error: redeclaration of 'std::vector<int> pr'
   79 |     vector<int> pr={1,0,2,3};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:83:17: error: redeclaration of 'std::vector<int> pr'
   83 |     vector<int> pr={1,0,3,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:87:17: error: redeclaration of 'std::vector<int> pr'
   87 |     vector<int> pr={1,2,0,3};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:91:17: error: redeclaration of 'std::vector<int> pr'
   91 |     vector<int> pr={1,2,3,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:95:17: error: redeclaration of 'std::vector<int> pr'
   95 |     vector<int> pr={1,3,0,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:99:17: error: redeclaration of 'std::vector<int> pr'
   99 |     vector<int> pr={1,3,2,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:104:17: error: redeclaration of 'std::vector<int> pr'
  104 |     vector<int> pr={2,1,0,3};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:108:17: error: redeclaration of 'std::vector<int> pr'
  108 |     vector<int> pr={2,1,3,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:112:21: error: redeclaration of 'std::vector<int> pr'
  112 |         vector<int> pr={2,0,1,3};
      |                     ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:116:17: error: redeclaration of 'std::vector<int> pr'
  116 |     vector<int> pr={2,0,3,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:120:17: error: redeclaration of 'std::vector<int> pr'
  120 |     vector<int> pr={2,3,1,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:124:17: error: redeclaration of 'std::vector<int> pr'
  124 |     vector<int> pr={2,3,0,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:128:17: error: redeclaration of 'std::vector<int> pr'
  128 |     vector<int> pr={3,0,2,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:132:17: error: redeclaration of 'std::vector<int> pr'
  132 |     vector<int> pr={3,0,1,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:136:17: error: redeclaration of 'std::vector<int> pr'
  136 |     vector<int> pr={3,2,0,1};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:140:17: error: redeclaration of 'std::vector<int> pr'
  140 |     vector<int> pr={3,2,1,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:144:17: error: redeclaration of 'std::vector<int> pr'
  144 |     vector<int> pr={3,1,0,2};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:148:17: error: redeclaration of 'std::vector<int> pr'
  148 |     vector<int> pr={3,1,2,0};
      |                 ^~
books.cpp:55:17: note: 'std::vector<int> pr' previously declared here
   55 |     vector<int> pr={0,1,2,3};
      |                 ^~
books.cpp:152:1: warning: control reaches end of non-void function [-Wreturn-type]
  152 | }
      | ^