Submission #157304

# Submission time Handle Problem Language Result Execution time Memory
157304 2019-10-10T14:04:50 Z dolphingarlic Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#include "advisor.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

set<pair<int, int>> scaffold;
queue<int> occurrences[100000];
int swap_sequence[100000];

void ComputeAdvice(int *C, int N, int K, int M) {
    FOR(i, 0, N) occurrences[C[i]].push(i);
    FOR(i, 0, N) occurrences[i].push(INT_MAX);

    FOR(i, 0, K) scaffold.insert({-occurrences[i].front(), i});

    FOR(i, 0, N) {
        if (scaffold.find({-occurrences[C[i]].front(), C[i]})) {
            swap_sequence[i] = C[i];
            scaffold.erase({-occurrences[C[i]].front(), C[i]});
        } else {
            swap_sequence[i] = *scaffold.begin().second;
            scaffold.erase(scaffold.begin());
        }
        occurrences[C[i]].pop();
        scaffold.insert({-occurrences[C[i]].front(), C[i]});
    }
}
#include "assistant.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

set<pair<int, int>> scaffold;
int on_scaffold[100000];

void Assist(unsigned char *A, int N, int K, int R) {
    FOR(i, 0, K) {
        scaffold.insert({A[i] - '0', i});
        on_scaffold[i] = A[i] - '0' + 1;
    }

    FOR(i, K, N + K) {
        int nxt = GetRequest();
        if (on_scaffold[nxt]) {
            scaffold.erase({on_scaffold[nxt] - 1, nxt});
            scaffold.insert({A[i] - '0', nxt});
        } else {
            putback(*scaffold.begin().second);
            on_scaffold[*scaffold.begin().second] = 0;
            scaffold.erase(scaffold.begin());
            scaffold.insert({A[i] - '0', nxt});
        }
        on_scaffold[nxt] = A[i] - '0' + 1;
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:17:26: error: could not convert 'scaffold.std::set<std::pair<int, int> >::find(std::pair<int, int>((- occurrences[(*(C + ((sizetype)(((long unsigned int)i) * 4))))].std::queue<int>::front()), (*(C + ((sizetype)(((long unsigned int)i) * 4))))))' from 'std::set<std::pair<int, int> >::iterator {aka std::_Rb_tree_const_iterator<std::pair<int, int> >}' to 'bool'
         if (scaffold.find({-occurrences[C[i]].front(), C[i]})) {
             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
advisor.cpp:21:50: error: 'std::set<std::pair<int, int> >::iterator {aka struct std::_Rb_tree_const_iterator<std::pair<int, int> >}' has no member named 'second'
             swap_sequence[i] = *scaffold.begin().second;
                                                  ^~~~~~

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:21:39: error: 'std::set<std::pair<int, int> >::iterator {aka struct std::_Rb_tree_const_iterator<std::pair<int, int> >}' has no member named 'second'
             putback(*scaffold.begin().second);
                                       ^~~~~~
assistant.cpp:21:13: error: 'putback' was not declared in this scope
             putback(*scaffold.begin().second);
             ^~~~~~~
assistant.cpp:21:13: note: suggested alternative: 'PutBack'
             putback(*scaffold.begin().second);
             ^~~~~~~
             PutBack
assistant.cpp:22:43: error: 'std::set<std::pair<int, int> >::iterator {aka struct std::_Rb_tree_const_iterator<std::pair<int, int> >}' has no member named 'second'
             on_scaffold[*scaffold.begin().second] = 0;
                                           ^~~~~~