답안 #154012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154012 2019-09-17T17:26:25 Z stefdasca 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;


deque<int>v[100002], v2[100002];
void ComputeAdvice(int *C, int N, int K, int M)
{
    for(int i = 0; i < N; ++i)
        v[C[i]].push_back(i), v2[C[i]].push_back(i);
    for(int i = 0; i < N; ++i)
        v[i].push_back((1<<20)), v2[i].push_back((1<<20));
    set<pair<int, int> >cb;
    set<int>nr;
    for(int i = 0; i < K; ++i)
        cb.insert({v[i][0], i}), nr.insert(i);
    int act[100002];
    memset(act, 0, sizeof(act));
    int st[100002];
    for(int i = 0; i < K; ++i)
        st[i] = 1;
    int saved[100002];
    memset(saved, 0, sizeof(saved));
    int prv[100002];
    memset(prv, -1, sizeof(prv));
    for(int i = 0; i < N; ++i)
    {
        if(nr.find(C[i]) != nr.end())
        {
            if(C[i] < K && !saved[C[i]])
                saved[C[i]] = 1;
            cb.erase({v[C[i]][0], C[i]});
            v[C[i]].pop_front();
            cb.insert({v[C[i]][0], C[i]});
            if(prv[C[i]] != -1)
                act[prv[C[i]] = 1;
            prv[C[i]] = i;
        }
        else
        {
            if((*cb.rbegin()).second < K)
            {
                int val = (*cb.rbegin()).second;
                if(val < K && !saved[val])
                    st[val] = 0, saved[val] = 1;
            }
            nr.erase((*cb.rbegin()).second);
            cb.erase(cb.rbegin());
            nr.insert(C[i]);
            v[C[i]].pop_front();
            cb.insert({v[C[i]][0], C[i]});
            prv[C[i]] = i;
        }
    }
    for(int i = 0; i < K; ++i)
        WriteAdvice(st[i]);
    for(int i = 0; i < N; ++i)
        WriteAdvice(act[i]);
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *A, int N, int K, int R)
{
    int frq[100002];
    memset(frq, 0, sizeof(frq));
    int poz = 0;
    for(int i = 0; i < R; ++i)
    {
        if(A[i] == '1')
            ++poz;
        else
            ++frq[poz];
    }
    set<int>good;
    set<int>bad;
    for(int i = 0; i < K; ++i)
        if(A[i] == '1')
            good.insert(i);
        else
            bad.insert(i);
    for(int i = 0; i < N; ++i)
    {
        int req = GetRequest();
        if(bad.find(req) == bad.end() && good.find(req) == good.end())
        {
            PutBack(*bad.begin());
            bad.erase(bad.begin());
            if(A[i + K] == '1')
                good.insert(req);
            else
                bad.insert(req);
        }
        else
            if(bad.find(req) == bad.end())
            {
                good.erase(req);
                if(A[i + K] == '1')
                    good.insert(req);
                else
                    bad.insert(req);
            }
            else
            {
                bad.erase(req);
                if(A[i + K] == '1')
                    good.insert(req);
                else
                    bad.insert(req);
            }
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:36:34: error: expected ']' before ';' token
                 act[prv[C[i]] = 1;
                                  ^
advisor.cpp:48:33: error: no matching function for call to 'std::set<std::pair<int, int> >::erase(std::set<std::pair<int, int> >::reverse_iterator)'
             cb.erase(cb.rbegin());
                                 ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from advisor.cpp:1:
/usr/include/c++/7/bits/stl_set.h:644: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<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >]
       erase(const_iterator __position)
       ^~~~~
/usr/include/c++/7/bits/stl_set.h:644:7: note:   no known conversion for argument 1 from 'std::set<std::pair<int, int> >::reverse_iterator {aka std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<int, int> > >}' to 'std::set<std::pair<int, int> >::const_iterator {aka std::_Rb_tree_const_iterator<std::pair<int, int> >}'
/usr/include/c++/7/bits/stl_set.h:674:7: note: candidate: std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       erase(const key_type& __x)
       ^~~~~
/usr/include/c++/7/bits/stl_set.h:674:7: note:   no known conversion for argument 1 from 'std::set<std::pair<int, int> >::reverse_iterator {aka std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<int, int> > >}' to 'const key_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_set.h:696: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<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >]
       erase(const_iterator __first, const_iterator __last)
       ^~~~~
/usr/include/c++/7/bits/stl_set.h:696:7: note:   candidate expects 2 arguments, 1 provided