#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];
bool on_scaffold[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 (on_scaffold[C[i]]) {
swap_sequence[i] = C[i];
scaffold.erase({-occurrences[C[i]].front(), C[i]});
} else {
swap_sequence[i] = *scaffold.begin().second;
on_scaffold[*scaffold.begin().second] = false;
scaffold.erase(scaffold.begin());
}
occurrences[C[i]].pop();
scaffold.insert({-occurrences[C[i]].front(), C[i]});
on_scaffold[C[i]] = true;
}
}
#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:22: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;
^~~~~~
advisor.cpp:23: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] = false;
^~~~~~
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;
^~~~~~