답안 #753615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753615 2023-06-05T14:45:19 Z minhcool 최후의 만찬 (IOI12_supper) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}

//set<ii> se;

map<int, int> mp;

int nxt[N];

int c[N];

bool cook[N];
int in[N];

void ComputeAdvice(int *C, int N, int K, int M){
	for(int i = 0; i < k; i++) c[i] = i;
	for(int i = k; i < n + k; i++) c[i] = C[i - k];
	for(int i = n + k - 1; i >= 0; i--){
		if(mp.find(c[i]) == mp.end()) nxt[i] = oo;
		else nxt[i] = mp[c[i]];
		mp[c[i]] = i;
	}
	set<ii> se;
	for(int i = 0; i < n; i++) in[i] = -1;
	for(int i = 0; i < n + k; i++){
		if(in[c[i]] >= 0){
			se.erase({in[c[i]], c[i]});
			in[c[i]] = nxt[i];
			se.insert({in[c[i]], c[i]});
		}
		else{
			if(se.size() == k){
				int temp = (*se.rbegin()).se;
				cook[temp] = 1;
				in[temp] = -1;
				se.erase(se.rbegin());
			}
			in[c[i]] = nxt[i];
			se.insert({in[c[i]], c[i]});
		}
	}
	for(int i = 0; i < n + k; i++) WriteAdvice(cook[i]); 
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}


void Assist(unsigned char *A, int N, int K, int R){
	set<int> cooking;
	set<int> ins;
	for(int i = 0; i < n; i++) in[i] = -1;
	for(int i = 0; i < n + k; i++){
		int x = GetRequest();
		if(ins.find(x) != ins.end()){
			cooking.erase(x);
			if(A[i]) cooking.insert(x);
		}
		else{
			int temp = (*cooking.begin());
			cooking.erase(temp);
			PutBack(temp);
			if(A[i]) cooking.insert(x);
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(long long int*, long long int, long long int, long long int)':
advisor.cpp:39:21: error: 'k' was not declared in this scope
   39 |  for(int i = 0; i < k; i++) c[i] = i;
      |                     ^
advisor.cpp:40:14: error: 'k' was not declared in this scope
   40 |  for(int i = k; i < n + k; i++) c[i] = C[i - k];
      |              ^
advisor.cpp:40:21: error: 'n' was not declared in this scope
   40 |  for(int i = k; i < n + k; i++) c[i] = C[i - k];
      |                     ^
advisor.cpp:41:14: error: 'n' was not declared in this scope
   41 |  for(int i = n + k - 1; i >= 0; i--){
      |              ^
advisor.cpp:41:18: error: 'k' was not declared in this scope
   41 |  for(int i = n + k - 1; i >= 0; i--){
      |                  ^
advisor.cpp:10:12: error: reference to 'make_pair' is ambiguous
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:42:6: note: in expansion of macro 'mp'
   42 |   if(mp.find(c[i]) == mp.end()) nxt[i] = oo;
      |      ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: candidates are: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
advisor.cpp:10:12: note:                 'std::map<long long int, long long int> make_pair'
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:29:15: note: in expansion of macro 'mp'
   29 | map<int, int> mp;
      |               ^~
advisor.cpp:10:12: error: reference to 'make_pair' is ambiguous
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:42:23: note: in expansion of macro 'mp'
   42 |   if(mp.find(c[i]) == mp.end()) nxt[i] = oo;
      |                       ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: candidates are: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
advisor.cpp:10:12: note:                 'std::map<long long int, long long int> make_pair'
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:29:15: note: in expansion of macro 'mp'
   29 | map<int, int> mp;
      |               ^~
advisor.cpp:10:12: error: reference to 'make_pair' is ambiguous
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:43:17: note: in expansion of macro 'mp'
   43 |   else nxt[i] = mp[c[i]];
      |                 ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: candidates are: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
advisor.cpp:10:12: note:                 'std::map<long long int, long long int> make_pair'
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:29:15: note: in expansion of macro 'mp'
   29 | map<int, int> mp;
      |               ^~
advisor.cpp:10:12: error: reference to 'make_pair' is ambiguous
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:44:3: note: in expansion of macro 'mp'
   44 |   mp[c[i]] = i;
      |   ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: candidates are: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
advisor.cpp:10:12: note:                 'std::map<long long int, long long int> make_pair'
   10 | #define mp make_pair
      |            ^~~~~~~~~
advisor.cpp:29:15: note: in expansion of macro 'mp'
   29 | map<int, int> mp;
      |               ^~
advisor.cpp:47:21: error: 'n' was not declared in this scope
   47 |  for(int i = 0; i < n; i++) in[i] = -1;
      |                     ^
advisor.cpp:48:21: error: 'n' was not declared in this scope
   48 |  for(int i = 0; i < n + k; i++){
      |                     ^
advisor.cpp:48:25: error: 'k' was not declared in this scope
   48 |  for(int i = 0; i < n + k; i++){
      |                         ^
advisor.cpp:59:25: error: no matching function for call to 'std::set<std::pair<long long int, long long int> >::erase(std::set<std::pair<long long int, long long int> >::reverse_iterator)'
   59 |     se.erase(se.rbegin());
      |                         ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from advisor.cpp:1:
/usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator]'
  654 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:654:28: note:   no known conversion for argument 1 from 'std::set<std::pair<long long int, long long int> >::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<long long int, long long int> > >'} to 'std::set<std::pair<long long int, long long int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'}
  654 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<long long int, long long int>]'
  684 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:684:29: note:   no known conversion for argument 1 from 'std::set<std::pair<long long int, long long int> >::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<long long int, long long int> > >'} to 'const key_type&' {aka 'const std::pair<long long int, long long int>&'}
  684 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator]'
  706 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:706:7: note:   candidate expects 2 arguments, 1 provided
advisor.cpp:65:21: error: 'n' was not declared in this scope
   65 |  for(int i = 0; i < n + k; i++) WriteAdvice(cook[i]);
      |                     ^
advisor.cpp:65:25: error: 'k' was not declared in this scope
   65 |  for(int i = 0; i < n + k; i++) WriteAdvice(cook[i]);
      |                         ^
advisor.cpp:65:33: error: 'WriteAdvice' was not declared in this scope; did you mean 'ComputeAdvice'?
   65 |  for(int i = 0; i < n + k; i++) WriteAdvice(cook[i]);
      |                                 ^~~~~~~~~~~
      |                                 ComputeAdvice

assistant.cpp: In function 'void Assist(unsigned char*, long long int, long long int, long long int)':
assistant.cpp:31:21: error: 'n' was not declared in this scope
   31 |  for(int i = 0; i < n; i++) in[i] = -1;
      |                     ^
assistant.cpp:31:29: error: 'in' was not declared in this scope; did you mean 'i'?
   31 |  for(int i = 0; i < n; i++) in[i] = -1;
      |                             ^~
      |                             i
assistant.cpp:32:21: error: 'n' was not declared in this scope
   32 |  for(int i = 0; i < n + k; i++){
      |                     ^
assistant.cpp:32:25: error: 'k' was not declared in this scope
   32 |  for(int i = 0; i < n + k; i++){
      |                         ^
assistant.cpp:33:11: error: 'GetRequest' was not declared in this scope
   33 |   int x = GetRequest();
      |           ^~~~~~~~~~
assistant.cpp:41:4: error: 'PutBack' was not declared in this scope
   41 |    PutBack(temp);
      |    ^~~~~~~