Submission #761128

#TimeUsernameProblemLanguageResultExecution timeMemory
761128fatemetmhrLast supper (IOI12_supper)C++17
100 / 100
94 ms15460 KiB
// ~ Be Name Khoda ~ // #include <bits/stdc++.h> #include "advisor.h" //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second static const int maxn5 = 2e5 + 10; static vector <int> av[maxn5]; static set <pair<int, int>> cur; static bool mark[maxn5], rem[maxn5]; static int addtime[maxn5]; void ComputeAdvice(int *C, int n, int k, int m){ for(int i = n - 1; i >= 0; i--) av[C[i]].pb(i); for(int i = 0; i < k; i++){ int last = n; addtime[i] = i; mark[i] = true; if(av[i].size()) last = av[i].back(); cur.insert({last, i}); } for(int i = 0; i < n; i++){ av[C[i]].pop_back(); int last = n; addtime[C[i]] = i + k; if(av[C[i]].size()) last = av[C[i]].back(); if(mark[C[i]]){ cur.erase({i, C[i]}); cur.insert({last, C[i]}); continue; } auto it = cur.end(); it--; int v = it->se; mark[v] = false; cur.erase(it); cur.insert({last, C[i]}); rem[addtime[v]] = true; mark[C[i]] = true; //cout << "for " << i << ' ' << C[i] << ' ' << last << ' ' << v << ' ' << addtime[v] << endl; } for(int i = 0; i < n + k; i++) WriteAdvice(rem[i]); }
// ~ Be Name Khoda ~ // #include "assistant.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second static const int maxn5 = 2e5 + 10; static vector <int> av; static bool mark[maxn5]; void Assist(unsigned char *A, int n, int k, int r){ int ind = 0; fill(mark, mark + k, true); for(int i = 0; i < k; i++) av.pb(i); for(int i = 0; i < n; i++){ int req = GetRequest(); av.pb(req); if(!mark[req]){ while(!A[ind]) ind++; //cout << av.size() << ' ' << ind << endl; int v = av[ind++]; PutBack(v); mark[v] = false; } mark[req] = true; } }
#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...