제출 #387842

#제출 시각아이디문제언어결과실행 시간메모리
387842Keshi최후의 만찬 (IOI12_supper)C++17
100 / 100
203 ms22624 KiB
//In the name of God #include "advisor.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const ll maxn = 2e5 + 100; const ll mod = 1e9 + 7; const ll inf = 1e18; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() ll a[maxn], ok[maxn], ptr[maxn], prio[maxn], ind[maxn], ls[maxn], msg[maxn]; vector<ll> vec[maxn]; set<pll> st; void ComputeAdvice(int *c, int n, int k, int m){ for(ll i = 0; i < k; i++){ a[i] = i; ls[i] = i; ind[i] = i; ok[i] = 1; } for(ll i = 0; i < n; i++){ vec[c[i]].pb(i); } for(ll i = 0; i < n; i++){ vec[i].pb(n); vec[i].pb(n); } for(ll i = 0; i < n; i++){ prio[i] = vec[i][ptr[i]++]; if(i < k) st.insert(Mp(-prio[i], i)); } for(ll i = 0; i < n; i++){ if(ok[c[i]]){ st.erase(Mp(-prio[c[i]], c[i])); prio[c[i]] = vec[c[i]][ptr[c[i]]++]; st.insert(Mp(-prio[c[i]], c[i])); ls[c[i]] = i + k; continue; } ll j = st.begin()->S; msg[ls[j]] = 1; st.erase(st.begin()); ok[j] = 0; ok[c[i]] = 1; ind[c[i]] = ind[j]; prio[c[i]] = vec[c[i]][ptr[c[i]]++]; st.insert(Mp(-prio[c[i]], c[i])); ls[c[i]] = i + k; } for(ll i = 0; i < n + k; i++){ WriteAdvice(msg[i]); } } /*int main(){ int c[100], n, k, m; cin >> n >> k >> m; for(ll i = 0; i < n; i++){ cin >> c[i]; } ComputeAdvice(c, n, k, m); }*/
//In the name of God #include <bits/stdc++.h> #include "assistant.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pll; const ll maxn = 2e5 + 100; const ll mod = 1e9 + 7; const ll inf = 1e18; #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout); #define pb push_back #define Mp make_pair #define F first #define S second #define Sz(x) ll((x).size()) #define all(x) (x).begin(), (x).end() ll _ok[maxn]; void Assist(unsigned char *A, int n, int k, int r) { vector<ll> vec; for(ll i = 0; i < k; i++){ if(A[i]) vec.pb(i); _ok[i] = 1; } for(ll i = 0; i < n; i++){ ll x = GetRequest(); if(_ok[x]){ if(A[i + k]) vec.pb(x); continue; } ll y = vec.back(); vec.pop_back(); if(A[i + k]) vec.pb(x); PutBack(y); _ok[y] = 0; _ok[x] = 1; } }
#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...