Submission #272184

#TimeUsernameProblemLanguageResultExecution timeMemory
272184gs18115Last supper (IOI12_supper)C++14
100 / 100
194 ms8952 KiB
#include"advisor.h" #include<iostream> #include<vector> #include<map> #include<algorithm> #define ep emplace #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const int inf=1e9+7; const ll INF=1e18; void ComputeAdvice(int*C,int N,int K,int M) { map<pi,int,greater<pi> >st; vector<int>v(N,N); vector<int>nx=v; for(int i=N;i-->0;) nx[i]=v[C[i]],v[C[i]]=i; for(int i=0;i<K;i++) st[pi(v[i],i)]=i; vector<int>adv(N+K,1); for(int i=0;i<N;i++) { auto it=st.find(pi(i,C[i])); if(it==st.end()) { it=st.begin(); adv[it->se]=0; } st.erase(it); st[pi(nx[i],C[i])]=K+i; } for(auto t:st) adv[t.se]=0; for(int&t:adv) WriteAdvice(t); return; }
#include"assistant.h" #include<iostream> #include<vector> #include<queue> #include<set> #include<algorithm> #define ep emplace #define eb emplace_back #define fi first #define se second #define all(x) (x).begin(),(x).end() using namespace std; typedef long long ll; typedef pair<int,int>pi; typedef pair<ll,ll>pl; const int inf=1e9+7; const ll INF=1e18; void Assist(unsigned char*A,int N,int K,int R) { set<int>v1; queue<int>v2; for(int i=0;i<K;i++) { if(A[i]==1) v1.ep(i); else v2.ep(i); } for(int i=0;i<N;i++) { int c=GetRequest(); auto it=v1.find(c); if(it==v1.end()) { PutBack(v2.front()); v2.pop(); } else v1.erase(it); if(A[i+K]==1) v1.ep(c); else v2.ep(c); } return; }
#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...