제출 #804483

#제출 시각아이디문제언어결과실행 시간메모리
804483Dan4LifeLast supper (IOI12_supper)C++17
0 / 100
378 ms28352 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { if(K>25000){ int x = *max_element(C,C+N); for(int i = 0; i < N; i++) for(int j = 0; j < (x<5000?13:20); j++) WriteAdvice((C[i]>>j)&1); return; } set<int> S; set<pair<int,int>> SS; vector<int> v[N+1]; for(int i = 0; i < N; i++) v[C[i]].push_back(i); for(int i = 0; i < N; i++) v[i].push_back(N+1); for(int i = 0; i < K; i++){ int nx = *upper_bound(begin(v[i]),end(v[i]),-1); S.insert(i); SS.insert({nx,i}); } for(int i = 0; i < N; i++) { int req = C[i]; if(S.count(req)){ for(int j = 0; j < 15; j++) WriteAdvice(1); int nx = *upper_bound(begin(v[req]),end(v[req]),i); SS.erase({i,req}); SS.insert({nx,req}); continue; } int getCol = (--end(SS))->second; S.erase(getCol); S.insert(req); for(int j = 0; j < 15; j++) WriteAdvice((getCol>>j)&1); int nx = *upper_bound(begin(v[req]),end(v[req]),i); SS.erase(--end(SS)); SS.insert({nx,req}); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { if(R==K*15 and K<=25000){ for(int i = 0; i < R; i+=15){ int xd = 0; for(int j = 0; j < 15; j++) if(A[i+j]) xd |= (1<<j); if(xd!=(1<<16)-1) PutBack(xd); } return; } int C[N+1]; vector<int> v[N+1]; for(int i = 0; i < N; i++) C[i]=0; const int bit = R%20?13:20; for(int i = 0; i < R; i++) if(A[i]) C[i/bit] |= (1<<(i%bit)); set<int> S; set<pair<int,int>> SS; for(int i = 0; i < N; i++) v[C[i]].push_back(i); for(int i = 0; i < N; i++) v[i].push_back(N+1); for(int i = 0; i < K; i++){ int nx = *upper_bound(begin(v[i]),end(v[i]),-1); S.insert(i); SS.insert({nx,i}); } for(int i = 0; i < N; i++) { int req = GetRequest(); if(S.count(req)){ int nx = *upper_bound(begin(v[req]),end(v[req]),i); SS.erase({i,req}); SS.insert({nx,req}); continue; } int getCol = (--end(SS))->second; S.erase(getCol); S.insert(req); PutBack(getCol); int nx = *upper_bound(begin(v[req]),end(v[req]),i); SS.erase(--end(SS)); SS.insert({nx,req}); } }
#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...