#include "advisor.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// No communication/shared data between two namespaces
#define X first
#define Y second
#define PB push_back
#define PPB pop_back
#define all(x) (x).begin(), (x).end()
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll, ll> pll;
const int inf = 1e9 + 7;
const int MAXN = 2e5 + 7;
const int logo = 17;
const int off = 1 << logo;
const int trsz = off << 1;
const int mod = 1e9;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
int ans[MAXN], akt[MAXN], nx[MAXN], lst[MAXN];
void ComputeAdvice(int *c, int n, int k, int m){
set<ii> s;
for(int i=0; i<n; i++) lst[i] = n, akt[i] = -1;
for(int i=n-1; i>=0; i--){
nx[i] = lst[c[i]];
lst[c[i]] = i;
}
for(int i=0; i<k; i++){
s.insert({lst[i], i});
akt[i] = i;
}
for(int i=0; i<n; i++){
if(akt[c[i]] != -1) ans[akt[c[i]]] = 1;
else{
int x = (--s.end()) -> Y;
s.erase(--s.end());
akt[x] = -1;
}
akt[c[i]] = k + i;
s.insert({nx[i], c[i]});
}
for(int i=0; i<n+k; i++) WriteAdvice(ans[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
// No communication/shared data between two namespaces
#define X first
#define Y second
#define PB push_back
#define PPB pop_back
#define all(x) (x).begin(), (x).end()
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll, ll> pll;
const int inf = 1e9 + 7;
const int MAXN = 2e5 + 7;
const int logo = 17;
const int off = 1 << logo;
const int trsz = off << 1;
const int mod = 1e9;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
void Assist(unsigned char *A, int n, int k, int r){
set<int> pas, akt;
for(int i=0; i<k; i++){
if(A[i] == 0) pas.insert(i);
else akt.insert(i);
}
for(int i=k; i<n+k; i++){
int c = GetRequest();
if(akt.find(c) != akt.end()){
akt.erase(c);
}else{
PutBack(*pas.begin());
pas.erase(pas.begin());
}
if(A[i] == 0) pas.insert(c);
else akt.insert(c);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2836 KB |
Output is correct |
2 |
Correct |
2 ms |
2848 KB |
Output is correct |
3 |
Correct |
2 ms |
2844 KB |
Output is correct |
4 |
Correct |
2 ms |
824 KB |
Output is correct |
5 |
Correct |
3 ms |
956 KB |
Output is correct |
6 |
Correct |
4 ms |
1356 KB |
Output is correct |
7 |
Correct |
5 ms |
1104 KB |
Output is correct |
8 |
Correct |
3 ms |
1112 KB |
Output is correct |
9 |
Correct |
4 ms |
1100 KB |
Output is correct |
10 |
Correct |
5 ms |
3144 KB |
Output is correct |
11 |
Correct |
5 ms |
3148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
3480 KB |
Output is correct |
2 |
Correct |
37 ms |
6760 KB |
Output is correct |
3 |
Correct |
109 ms |
12364 KB |
Output is correct |
4 |
Correct |
37 ms |
7260 KB |
Output is correct |
5 |
Correct |
44 ms |
7552 KB |
Output is correct |
6 |
Correct |
61 ms |
8984 KB |
Output is correct |
7 |
Correct |
94 ms |
11272 KB |
Output is correct |
8 |
Correct |
56 ms |
9604 KB |
Output is correct |
9 |
Correct |
54 ms |
7372 KB |
Output is correct |
10 |
Correct |
104 ms |
12872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
8996 KB |
Output is correct |
2 |
Correct |
106 ms |
11032 KB |
Output is correct |
3 |
Correct |
90 ms |
11064 KB |
Output is correct |
4 |
Correct |
110 ms |
12352 KB |
Output is correct |
5 |
Correct |
89 ms |
12372 KB |
Output is correct |
6 |
Correct |
93 ms |
12152 KB |
Output is correct |
7 |
Correct |
91 ms |
12304 KB |
Output is correct |
8 |
Correct |
65 ms |
10368 KB |
Output is correct |
9 |
Correct |
83 ms |
12952 KB |
Output is correct |
10 |
Correct |
93 ms |
12144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3144 KB |
Output is correct |
2 |
Correct |
3 ms |
3248 KB |
Output is correct |
3 |
Correct |
3 ms |
2900 KB |
Output is correct |
4 |
Correct |
3 ms |
2896 KB |
Output is correct |
5 |
Correct |
3 ms |
3156 KB |
Output is correct |
6 |
Correct |
4 ms |
3144 KB |
Output is correct |
7 |
Correct |
4 ms |
3156 KB |
Output is correct |
8 |
Correct |
4 ms |
3152 KB |
Output is correct |
9 |
Correct |
5 ms |
3148 KB |
Output is correct |
10 |
Correct |
6 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
11592 KB |
Output is correct - 120000 bits used |
2 |
Correct |
88 ms |
11680 KB |
Output is correct - 122000 bits used |
3 |
Correct |
90 ms |
12180 KB |
Output is correct - 125000 bits used |
4 |
Correct |
106 ms |
12088 KB |
Output is correct - 125000 bits used |
5 |
Correct |
91 ms |
12292 KB |
Output is correct - 125000 bits used |
6 |
Correct |
107 ms |
12164 KB |
Output is correct - 125000 bits used |
7 |
Correct |
87 ms |
12088 KB |
Output is correct - 124828 bits used |
8 |
Correct |
91 ms |
12112 KB |
Output is correct - 124910 bits used |
9 |
Correct |
90 ms |
12372 KB |
Output is correct - 125000 bits used |
10 |
Correct |
76 ms |
10580 KB |
Output is correct - 125000 bits used |