Submission #980134

# Submission time Handle Problem Language Result Execution time Memory
980134 2024-05-12T00:08:19 Z vjudge1 Longest Trip (IOI23_longesttrip) C++17
Compilation error
0 ms 0 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second

using namespace std;

vector<int> longest_trip(int N, int D){
	deque<vector<int>> ans;
	rep(i,0,N){
		ans.pb({i});
	}
	while(ans.size()>1){
		if(are_connected(ans[0].back(),ans[1].back())){
			repa(e,ans[1]) ans[0].pb(e);
			ans.erase(ans.begin()+1);
		}else{
			repa(e,ans[2]) ans[0].pb(e);
			ans.erase(ans.begin()+2);
		}
	}
	if(ans[0].size()>ans[1].size()) return ans[0];
	else return ans[1];
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:20:31: error: could not convert '(& ans.std::deque<std::vector<int> >::operator[](0))->std::vector<int>::back()' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>'
   20 |   if(are_connected(ans[0].back(),ans[1].back())){
      |                    ~~~~~~~~~~~^~
      |                               |
      |                               __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}