#include "advisor.h"
#include <vector>
#include <queue>
#include <set>
#include <cstdio>
using namespace std;
const int maxn = 2e5+10;
bool sol[maxn];
vector< int > v;
queue< int > q[maxn];
int las[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i = 0; i < K; i++) v.push_back(i);
for (int i = 0; i < N; i++) v.push_back(C[i]);
for (int i = 0; i < v.size(); i++) {
q[v[i]].push(i);
}
for (int i = 0; i < N; i++) q[i].push(v.size() + 1);
set< pair<int, int> > s;
for (int i = 0; i < K; i++) s.insert({-q[i].front(), i});
for (int i = 0; i < v.size(); i++) sol[i] = false;
for (int i = 0; i < N; i++) las[i] = N + K;
for (int i = 0; i < v.size(); i++) {
int x = v[i];
if (!s.count({-q[x].front(), x})) {
int tr = s.begin()->second;
s.erase(s.begin());
q[x].pop();
s.insert({-q[x].front(), x});
} else {
//printf("inside %d\n", x); fflush(stdout);
sol[las[x]] = true;
s.erase({-q[x].front(), x});
q[x].pop();
s.insert({-q[x].front(), x});
}
las[x] = i;
}
for (auto iter : s) sol[las[iter.second]] = true;
for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
#define X first
#define Y second
using namespace std;
const int maxn = 1e5+10;
void Assist(unsigned char *A, int N, int K, int R) {
return ;
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
advisor.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i = 0; i < v.size(); i++) sol[i] = false;
| ~~^~~~~~~~~~
advisor.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
advisor.cpp:31:8: warning: unused variable 'tr' [-Wunused-variable]
31 | int tr = s.begin()->second;
| ^~
advisor.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for (int i = 0; i < v.size(); i++) WriteAdvice(sol[i]);
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
135052 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
78 ms |
135628 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
125 ms |
139064 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
135336 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
143 ms |
140028 KB |
Error - GetRequest() must be called N times |
2 |
Incorrect |
156 ms |
139936 KB |
Error - GetRequest() must be called N times |
3 |
Incorrect |
161 ms |
140116 KB |
Error - GetRequest() must be called N times |
4 |
Incorrect |
151 ms |
140140 KB |
Error - GetRequest() must be called N times |
5 |
Incorrect |
152 ms |
140188 KB |
Error - GetRequest() must be called N times |
6 |
Incorrect |
153 ms |
140304 KB |
Error - GetRequest() must be called N times |
7 |
Incorrect |
153 ms |
140088 KB |
Error - GetRequest() must be called N times |
8 |
Incorrect |
152 ms |
140152 KB |
Error - GetRequest() must be called N times |
9 |
Incorrect |
151 ms |
140144 KB |
Error - GetRequest() must be called N times |
10 |
Incorrect |
154 ms |
140232 KB |
Error - GetRequest() must be called N times |