제출 #761820

#제출 시각아이디문제언어결과실행 시간메모리
761820Sohsoh84Last supper (IOI12_supper)C++17
40 / 100
312 ms39256 KiB
#include "advisor.h" #include <bits/stdc++.h> // TODO: check k = 1 using namespace std; #define X first #define Y second #define all(x) (x).begin(), (x).end() const int MAXN = 1e6 + 10; typedef pair<int, int> pll; int n, k, m; vector<int> vec[MAXN]; inline int wtf(int k) { int ans = 1, res = 0; while (ans < k) ans *= 2, res++; return res; } inline void put(int x) { for (int i = m - 1; i >= 0; i--) WriteAdvice(x >> i & 1); } inline int get(int c, int i) { return *lower_bound(all(vec[c]), i); } void ComputeAdvice(int *C, int N, int K, int M) { n = N, k = K; m = wtf(n); for (int i = 0; i < n; i++) vec[C[i]].push_back(i); for (int i = 0; i < n; i++) vec[i].push_back(n); set<pll> st; for (int i = 0; i < k; i++) st.insert(pll(get(i, 0), i)); for (int i = 0; i < n; i++) { int c = C[i]; if (st.find(pll(get(c, i), c)) != st.end()) { st.erase(pll(get(c, i), c)); } else { put(st.rbegin() -> Y); st.erase(prev(st.end())); } st.insert(pll(get(c, i + 1), c)); } }
#include "assistant.h" #include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int, int> pll; inline int wtf(int k) { int ans = 1, res = 0; while (ans < k) ans *= 2, res++; return res; } void Assist(unsigned char *A, int N, int K, int R) { int n = N, k = K, m = wtf(n); set<int> st; for (int i = 0; i < k; i++) st.insert(i); int ind = 0; for (int i = 0; i < n; i++) { int c = GetRequest(); if (st.find(c) != st.end()) continue; int x = 0; for (int i = m - 1; i >= 0; i--) { x <<= 1; x |= A[ind]; ind++; } PutBack(x); st.erase(x); st.insert(c); } }
#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...