#include "advisor.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 2e18;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
int bit[200005],nx[200005],on[200005];
priority_queue <pi> q;
vec v[100005];
void ComputeAdvice(int *C,int n,int k,int m) {
for(int i = 0;i < k;i++) v[i].pb(i);
for(int i = 0;i < n;i++) v[C[i]].pb(i+k);
for(int i = 0;i < n;i++) {
for(int j = 0;j < v[i].size()-1;j++) nx[v[i][j]] = v[i][j+1];
if(!v[i].empty()) nx[v[i].back()] = INF;
}
memset(on,-1,sizeof(on));
for(int i = 0;i < k;i++) q.push({nx[i],i}), on[i] = i;
for(int i = 0;i < n;i++) {
if(on[C[i]] != -1) bit[on[C[i]]] = 1;
else on[q.top().y] = -1, q.pop();
on[C[i]] = i+k;
q.push({nx[i+k],C[i]});
}
for(int i = 0;i < n+k;i++) WriteAdvice(bit[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const int INF = 1e9;
const int TMX = 1 << 18;
const long long llINF = 2e18;
const long long mod = 1e9+7;
const long long hashmod = 100003;
const int MAXN = 100000;
const int MAXM = 1000000;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
typedef vector <pi> vecpi;
typedef long long ll;
set <int> in,hubo;
void Assist(unsigned char *A,int n,int k,int r) {
for(int i = 0;i < k;i++) {
if(!A[i]) hubo.insert(i);
else in.insert(i);
}
for(int i = 0;i < n;i++) {
int now = GetRequest();
if(in.find(now) != in.end()) in.erase(now);
else PutBack(*hubo.begin()), hubo.erase(hubo.begin());
if(!A[i+k]) hubo.insert(now);
else in.insert(now);
}
}
Compilation message
advisor.cpp:7: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
7 | #pragma gcc optimize("O3")
|
advisor.cpp:8: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
8 | #pragma gcc optimize("Ofast")
|
advisor.cpp:9: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
9 | #pragma gcc optimize("unroll-loops")
|
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:33:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int j = 0;j < v[i].size()-1;j++) nx[v[i][j]] = v[i][j+1];
| ~~^~~~~~~~~~~~~~~
assistant.cpp:7: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
7 | #pragma gcc optimize("O3")
|
assistant.cpp:8: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
8 | #pragma gcc optimize("Ofast")
|
assistant.cpp:9: warning: ignoring #pragma gcc optimize [-Wunknown-pragmas]
9 | #pragma gcc optimize("unroll-loops")
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3988 KB |
Output is correct |
2 |
Runtime error |
6 ms |
5248 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
8 ms |
5868 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
10732 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
5484 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
12012 KB |
Execution killed with signal 11 |
2 |
Runtime error |
34 ms |
12140 KB |
Execution killed with signal 11 |
3 |
Runtime error |
38 ms |
12268 KB |
Execution killed with signal 11 |
4 |
Runtime error |
39 ms |
12268 KB |
Execution killed with signal 11 |
5 |
Runtime error |
33 ms |
12288 KB |
Execution killed with signal 11 |
6 |
Runtime error |
34 ms |
12140 KB |
Execution killed with signal 11 |
7 |
Runtime error |
34 ms |
12140 KB |
Execution killed with signal 11 |
8 |
Runtime error |
40 ms |
12140 KB |
Execution killed with signal 11 |
9 |
Runtime error |
36 ms |
12140 KB |
Execution killed with signal 11 |
10 |
Runtime error |
35 ms |
13804 KB |
Execution killed with signal 11 |