Submission #341533

# Submission time Handle Problem Language Result Execution time Memory
341533 2020-12-29T23:20:18 Z FlashGamezzz Ancient Books (IOI17_books) C++11
Compilation error
0 ms 0 KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <deque>
#include "books.h"

using namespace std;

bool valid(vector<int> v){
	for (int i = 1; i < v.size(); i++){
		if (v[i] < v[i-1]){
			return false;
		}
	}
	return true;
}

long long minimum_walk(vector<int> p, int s) {
	deque<pair<pair<int, int>, pair<int, vector<int> > > > bfs; bfs.push_back(make_pair(make_pair(0, 0), make_pair(-1, p)));
	while (bfs.size() > 0){
		int i = bfs.top().first.first, t = bfs.top().first.second, b = bfs.top().second.first; vector<int> v = bfs.top().second.second; bfs.pop();
		if (i == 0 && valid(v)) return t;
		if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(b, v)));
		if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(b, v)));
		if (v[i] == -1){
			vector<int> nv = v; nv[i] = b;
			if (i == 0 && valid(nv)) return t;
			if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(-1, nv)));
			if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(-1, nv)));
		} else {
			if (b == -1){
				vector<int> nv = v; int temp = nv[i]; nv[i] = -1;
				if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv)));
				if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
			} else {
				vector<int> nv = v; int temp = nv[i]; nv[i] = b;
				if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv)));
				if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
			}
		}
	}
}

Compilation message

books.cpp: In function 'bool valid(std::vector<int>)':
books.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 1; i < v.size(); i++){
      |                  ~~^~~~~~~~~~
books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:25:15: error: 'class std::deque<std::pair<std::pair<int, int>, std::pair<int, std::vector<int> > > >' has no member named 'top'
   25 |   int i = bfs.top().first.first, t = bfs.top().first.second, b = bfs.top().second.first; vector<int> v = bfs.top().second.second; bfs.pop();
      |               ^~~
books.cpp:25:110: error: 'class std::deque<std::pair<std::pair<int, int>, std::pair<int, std::vector<int> > > >' has no member named 'top'
   25 |   int i = bfs.top().first.first, t = bfs.top().first.second, b = bfs.top().second.first; vector<int> v = bfs.top().second.second; bfs.pop();
      |                                                                                                              ^~~
books.cpp:25:135: error: 'class std::deque<std::pair<std::pair<int, int>, std::pair<int, std::vector<int> > > >' has no member named 'pop'
   25 |   int i = bfs.top().first.first, t = bfs.top().first.second, b = bfs.top().second.first; vector<int> v = bfs.top().second.second; bfs.pop();
      |                                                                                                                                       ^~~
books.cpp:26:34: error: 't' was not declared in this scope
   26 |   if (i == 0 && valid(v)) return t;
      |                                  ^
books.cpp:27:53: error: 't' was not declared in this scope
   27 |   if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(b, v)));
      |                                                     ^
books.cpp:27:69: error: 'b' was not declared in this scope
   27 |   if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(b, v)));
      |                                                                     ^
books.cpp:28:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(b, v)));
      |       ~~^~~~~~~~~~~~
books.cpp:28:62: error: 't' was not declared in this scope
   28 |   if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(b, v)));
      |                                                              ^
books.cpp:28:78: error: 'b' was not declared in this scope
   28 |   if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(b, v)));
      |                                                                              ^
books.cpp:30:32: error: 'b' was not declared in this scope
   30 |    vector<int> nv = v; nv[i] = b;
      |                                ^
books.cpp:31:36: error: 't' was not declared in this scope
   31 |    if (i == 0 && valid(nv)) return t;
      |                                    ^
books.cpp:32:54: error: 't' was not declared in this scope
   32 |    if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(-1, nv)));
      |                                                      ^
books.cpp:33:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(-1, nv)));
      |        ~~^~~~~~~~~~~~
books.cpp:33:63: error: 't' was not declared in this scope
   33 |    if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(-1, nv)));
      |                                                               ^
books.cpp:35:8: error: 'b' was not declared in this scope
   35 |    if (b == -1){
      |        ^
books.cpp:37:55: error: 't' was not declared in this scope
   37 |     if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv)));
      |                                                       ^
books.cpp:38:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
      |         ~~^~~~~~~~~~~~
books.cpp:38:64: error: 't' was not declared in this scope
   38 |     if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
      |                                                                ^
books.cpp:41:55: error: 't' was not declared in this scope
   41 |     if (i > 0) bfs.push_back(make_pair(make_pair(i-1, t+1), make_pair(temp, nv)));
      |                                                       ^
books.cpp:42:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
      |         ~~^~~~~~~~~~~~
books.cpp:42:64: error: 't' was not declared in this scope
   42 |     if (i < v.size()-1) bfs.push_back(make_pair(make_pair(i+1, t+1), make_pair(temp, nv)));
      |                                                                ^