Submission #575127

#TimeUsernameProblemLanguageResultExecution timeMemory
575127FatihSolakLast supper (IOI12_supper)C++17
0 / 100
109 ms17184 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; void ComputeAdvice(int *c, int n, int k, int m){ vector<int> occ[n]; int deltime[n]; bool ok[n]; for(int i = 0;i<n;i++){ deltime[i] = n; ok[i] = 0; occ[i].push_back(n); } for(int i = n-1;i>=0;i--){ occ[c[i]].push_back(i); } set<pair<int,int>> s; for(int i = 0;i<k;i++){ s.insert({occ[i].back(),i}); ok[i] = 1; } int del[n]; for(int i = 0;i<n;i++){ del[i] = -1; if(ok[c[i]]){ s.erase({occ[c[i]].back(),c[i]}); } occ[c[i]].pop_back(); if(!ok[c[i]]){ del[i] = s.rbegin()->second; ok[s.rbegin()->second] = 0; s.erase(*s.rbegin()); ok[c[i]] = 1; s.insert({occ[c[i]].back(),c[i]}); } } bool advice[k+n]; int pt = k + n - 1; for(int i = 0;i<n;i++){ occ[i].clear(); } for(int i = 0;i<n;i++){ occ[c[i]].push_back(i); } for(int i = 0;i<n;i++){ occ[i].push_back(n); } for(int i = n-1;i>=0;i--){ if(del[i] != -1){ deltime[del[i]] = i; } if(deltime[c[i]] < occ[c[i]].back()) advice[pt--] = 1; else advice[pt--] = 0; occ[c[i]].pop_back(); } for(int i = k-1;i>=0;i--){ if(deltime[i] < occ[i].back()) advice[pt--] = 1; else advice[pt--] = 0; } for(int i = 0;i<n+k;i++){ WriteAdvice(advice[i]); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; void Assist(unsigned char *a, int n, int k, int r) { set<int> s; bool ok[n]; int last = 0; for(int i = 0;i<n;i++){ ok[i] = 0; } for(int i = 0;i<k;i++){ if(a[last++] == 1){ s.insert(i); } ok[i] = 1; } for (int i = 0; i < n; i++) { int req = GetRequest(); if(ok[req] == 0){ int num = *s.begin(); s.erase(s.begin()); PutBack(num); ok[req] = 1; ok[num] = 0; } if(a[last++] == 1){ s.insert(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...