Submission #928401

#TimeUsernameProblemLanguageResultExecution timeMemory
928401Tuanlinh123Last supper (IOI12_supper)C++17
0 / 100
94 ms14788 KiB
#include "advisor.h" #include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double using namespace std; void ComputeAdvice(int *c, int n, int k, int m) { vector <ll> cnt(n+k, 0), a(k), p(n); iota(a.begin(), a.end(), n); for (ll i=0; i<n; i++) p[i]=i<k?i:-1; vector <vector <ll>> pos(n); for (ll i=n-1; i>=0; i--) pos[c[i]].pb(i); auto get=[&](ll i) {return pos[i].size()?pos[i].back():n+1;}; set <pll> s; for (ll i=0; i<k; i++) s.insert({get(i), i}); for (ll i=0; i<n; i++) { if (p[c[i]]!=-1) { cnt[a[p[c[i]]]]++; s.erase(s.find({get(c[i]), c[i]})); pos[c[i]].pop_back(); s.insert({get(c[i]), c[i]}); } else { ll id=(*prev(s.end())).se; s.erase(prev(s.end())); pos[c[i]].pop_back(); a[p[id]]=i, p[c[i]]=p[id], p[id]=-1; s.insert({get(c[i]), c[i]}); } } for (ll i=n; i<n+k; i++) { for (ll j=0; j<cnt[i]; j++) WriteAdvice(1); WriteAdvice(0); } for (ll i=0; i<n; i++) { for (ll j=0; j<cnt[i]; j++) WriteAdvice(1); WriteAdvice(0); } return; }
#include "assistant.h" #include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double using namespace std; void Assist(unsigned char *a, int n, int k, int r) { ll ptr=0; vector <ll> ok, cnt(k, 0), p(n, -1); auto get=[&]() { ll ans=0; while (a[ptr]==1) ans++, ptr++; ptr++; return ans; }; for (ll i=0; i<k; i++) { cnt[i]=get(), p[i]=i; if (!cnt[i]) ok.pb(i); } for (ll i=0; i<n; i++) { ll cr=GetRequest(); if (p[cr]!=-1) { cnt[cr]--; if (!cnt[cr]) ok.pb(cr); } else { ll id=ok.back(); ok.pop_back(); PutBack(id), p[cr]=id, cnt[cr]=get(); if (!cnt[cr]) ok.pb(cr); } } }
#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...