제출 #58806

#제출 시각아이디문제언어결과실행 시간메모리
58806thiago4532최후의 만찬 (IOI12_supper)C++17
0 / 100
2569 ms263168 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; string to_binary(int x){ string str; int l = 31 - __builtin_clz(x); for(int i=l;i>=0;i--) str += (bool(x&(1<<i)) + '0'); return str; } void ComputeAdvice(int *C, int N, int K, int M) { int digits = (31 - __builtin_clz(N)) + 1; for(int i=0;i<N;i++){ string s = to_binary(C[i]); for(int i=0;i<digits-int(s.size());i++) WriteAdvice(0); for(auto& e : s) WriteAdvice(e-'0'); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; int to_int(string const& s){ int ans=0, ct=0; for(int i=s.size()-1;i>=0;i--) ans += ((s[i]-'0') * (1<<ct)), ++ct; return ans; } void Assist(unsigned char *A, int N, int K, int R) { int digits = (31 - __builtin_clz(N)) + 1; set<int> colors; multiset<int> C; vector<int> C2; for(int i=0;i<digits*N;i+=digits){ string s; for(int j=0;j<digits;j++) s += (A[j+i]+'0') ; C.insert(to_int(s)); C2.push_back(to_int(s)); } for(int i=0;i<K;i++) colors.insert(i); for(int i=0;i<N;i++){ int x = GetRequest(); auto it = C.find(x); if(it != C.end()) C.erase(it); if(colors.find(x) != colors.end()) continue; bool good = false; for(auto& e : colors){ if(C.find(e) == C.end()){ good = true; PutBack(e); colors.erase(e); break; } } if(!good) for(int j=N-1;j>=i;j--){ if(colors.find(C2[j]) != colors.end()){ colors.erase(C2[j]); PutBack(C2[j]); break; } } colors.insert(x); } }
#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...