Submission #121932

#TimeUsernameProblemLanguageResultExecution timeMemory
121932baluteshihLast supper (IOI12_supper)C++14
43 / 100
398 ms149208 KiB
#include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define MEM(i,j) memset(i,j,sizeof i) #define F first #define S second #define MP make_pair #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #include "advisor.h" deque<int> pl[100005]; vector<int> seq; set<pii> pq; bitset<100005> inq; int nw[100005]; void ComputeAdvice(int *C, int N, int K, int M) { int L=__lg(K),cnt=0; for(int i=0;i<N;++i) pl[C[i]].pb(i); for(int i=0;i<N;++i) pl[i].pb(N); for(int i=0;i<K;++i) inq[i]=1,pq.insert(MP(pl[i][0],i)),nw[i]=i; for(int i=0;i<N;++i) if(inq[C[i]]) pq.erase(MP(i,C[i])),pl[C[i]].pop_front(),pq.insert(MP(pl[C[i]][0],C[i])); else { auto tmp=--pq.end(); seq.pb(nw[tmp->S]),inq[tmp->S]=0,nw[C[i]]=nw[tmp->S],pq.erase(tmp),pl[C[i]].pop_front(); pq.insert(MP(pl[C[i]][0],C[i])),inq[C[i]]=1; } //for(int i:seq) // cout << i << " "; //ET; for(int i:seq) for(int j=1<<L;j;j>>=1) WriteAdvice((bool)(i&j)),++cnt; //cout << cnt << "\n"; //cout << "start!\n"; }
#include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define MEM(i,j) memset(i,j,sizeof i) #define F first #define S second #define MP make_pair #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #include "assistant.h" int nnw[100005],rrel[100005]; void Assist(unsigned char *A, int N, int K, int R) { int L=__lg(K)+1,tp=0; for(int i=0;i<K;++i) nnw[i]=i,rrel[i]=i; for(int i=0;i<N;++i) { int cur=GetRequest(); if(rrel[nnw[cur]]!=cur) { int tmp=0; for(int i=tp;i<tp+L;++i) tmp=tmp<<1|A[i]; tp+=L; PutBack(rrel[tmp]),rrel[tmp]=cur,nnw[cur]=tmp; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...