Submission #913835

#TimeUsernameProblemLanguageResultExecution timeMemory
913835Muhammad_AneeqLast supper (IOI12_supper)C++17
8 / 100
2599 ms28528 KiB
#include "advisor.h" #include <cmath> #include <map> #include <set> #include <iostream> using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { for (int i=0;i<N;i++) { for (int j=0;j<=log2(N);j++) { if ((1<<j)&C[i]) WriteAdvice(1); else WriteAdvice(0); } } }
#include "assistant.h" #include <cmath> #include <map> #include <set> #include <iostream> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { int re[N]={}; int z=log2(N); map<int,int>d; set<int>res[N]={}; for (int i=0;i<N;i++) { for (int j=0;j<=z;j++) re[i]+=(A[i*(z+1)+j]<<j); res[re[i]].insert(i); d[re[i]]++; } set<int>ind; for (int i=0;i<K;i++) ind.insert(i); for (int i=0;i<N;i++) { int z=GetRequest(); d[z]--; res[z].erase(i); if (ind.find(z)!=ind.end()) continue; int x=0; int f=-1; for (auto i:ind) { if (d[i]==0) { x=i; f=-1; break; } else { if (res[i].size()&&*begin(res[i])>f) { f=*begin(res[i]); x=i; } } } PutBack(x); ind.insert(z); ind.erase(x); res[i].erase(f); } }
#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...