이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"WAFFLES "<<i<<"<\n"
#define INF 1000000000000000000LL
#define EPS (0.00000000001L)
#define pi (3.141592653589793L)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
void ComputeAdvice(int *C, int n, int k, int M) {
ll bits = 0;
while((1<<bits) <= k)
++bits;
vector<ll> nxt_ocur(n);
vector<ll> tmp(n, n);
vector<vector<ll>> ocur(n);
for(ll i = n-1; i >= 0; --i){
nxt_ocur[i] = tmp[C[i]];
tmp[C[i]] = i;
}
for(ll i = 0; i < n; ++i){
ocur[C[i]].pb(i);
}
set<pair<ll,pair<ll, ll>>> sc;
set<ll> cnt;
for(ll i = 0; i < k; ++i){
if(ocur[i].size() != 0)
sc.insert({-ocur[i][0], {i, i}});
else
sc.insert({-n, {i, i}});
cnt.insert(i);
}
vector<ll> adv(n);
for(ll i = 0; i < n; ++i){
if(cnt.find(C[i]) != cnt.end()){
adv[i] = -1;
continue;
}
pair<ll, pair<ll, ll>> rem = *sc.begin();
sc.erase(sc.begin());
cnt.erase(rem.ss.ss);
adv[i] = rem.ss.ff;
sc.insert({-nxt_ocur[i], {rem.ss.ff, C[i]}});
cnt.insert(C[i]);
}
for(ll advi : adv){
if(advi == -1){
for(ll b = 0; b < bits; ++b)
WriteAdvice(0);
}else{
for(ll b = 0; b < bits; ++b)
WriteAdvice((advi+1) & (1<<b));
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"WAFFLES "<<i<<"<\n"
#define INF 1000000000000000000LL
#define EPS (0.00000000001L)
#define pi (3.141592653589793L)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
void Assist(unsigned char *A, int N, int K, int R) {
ll bits = 0;
while((1<<bits) <= K)
++bits;
vector<ll> sc(N);
for(ll i = 0; i < K; ++i)
sc[i] = i;
for (ll i = 0; i < N; i++) {
int req = GetRequest();
ll adv = 0;
for(ll b = 0; b < bits; ++b){
adv = adv | (A[bits*i + b]<<b);
}
if(adv == 0){
continue;
}else{
adv--;
PutBack(sc[adv]);
sc[adv] = req;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |