Submission #315265

# Submission time Handle Problem Language Result Execution time Memory
315265 2020-10-22T07:38:40 Z Seanliu Mouse (info1cup19_mouse) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include "grader.h"
using namespace std;

const int maxN = 326;
int ans[maxN];
bool has[maxN];

void solve(int N){
	vector<int> q;	
	for(int i = 1; i <= N; i++){
		fill(has, has + N + 1, true);
		vector<int>().swap(q);
		q.push_back(0);
		for(int j = 0; j < i; j++){
			q[j].push_back(ans[j]); 
			has[ans[j]] = true;
		}
		for(int j = 1; j <= N; j++) if(!has[j]){
			q.push_back(j);
		}
		int baseline = query(q), asked = i;
		if(baseline == N) return;
		for(int j = i + 1; j <= N; j++){
			swap(q[j], q[i]);
			int res = query(q);
			if(res == N) return;
			if(res > baseline){
				asked = j;	
				baseline = res;
			}
			swap(q[j], q[i]);
		}
		ans[i] = q[asked];
	}
	vector<int>().swap(q);
	q.resize(N + 1);
	for(int i = 1; i <= N; i++) q[i] = ans[i];
	query(q);
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:17:9: error: request for member 'push_back' in 'q.std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   17 |    q[j].push_back(ans[j]);
      |         ^~~~~~~~~