Submission #1012915

#TimeUsernameProblemLanguageResultExecution timeMemory
1012915TobLast supper (IOI12_supper)C++14
100 / 100
158 ms19284 KiB
#include <bits/stdc++.h> #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; #include "advisor.h" #include "assistant.h" void ComputeAdvice(int *c, int n, int k, int m) { vector <vector <int> > ne(n), del(n); for (int i = 0; i < n; i++) { ne[c[i]].pb(i); } for (int i = 0; i < n; i++) ne[i].pb(n); set <pii> s; for (int i = 0; i < k; i++) s.insert({*ne[i].begin(), i}); for (int i = 0; i < n; i++) { int x = c[i]; if (s.find({i, x}) != s.end()) s.erase({i, x}); else { int y = (--s.end()) -> S; s.erase(--s.end()); del[y].pb(i); } s.insert({*upper_bound(all(ne[x]), i), x}); } vector <int> res(n+k, 0); for (int i = 0; i < n; i++) del[i].pb(n+1); for (int i = 0; i < k; i++) { res[i] = (*del[i].begin() > *ne[i].begin()); } for (int i = 0; i < n; i++) { res[k+i] = (*upper_bound(all(del[c[i]]), i) > *upper_bound(all(ne[c[i]]), i)); } for (int i = 0; i < n+k; i++) { WriteAdvice(res[i]); } }
#include <bits/stdc++.h> #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; #include "advisor.h" #include "assistant.h" void Assist(unsigned char *a, int n, int k, int r) { set <int> s, t; for (int i = 0; i < k; i++) { s.insert(i); if (!a[i]) t.insert(i); } for (int i = 0; i < n; i++) { int x = GetRequest(); if (s.find(x) == s.end()) { int y = *t.begin(); s.erase(y); t.erase(y); s.insert(x); PutBack(y); } if (!a[k+i]) t.insert(x); } }
#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...