Submission #1013188

#TimeUsernameProblemLanguageResultExecution timeMemory
1013188jcelinLast supper (IOI12_supper)C++14
100 / 100
110 ms12952 KiB
#include "advisor.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; // No communication/shared data between two namespaces #define X first #define Y second #define PB push_back #define PPB pop_back #define all(x) (x).begin(), (x).end() #define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef pair<ll, ll> pll; const int inf = 1e9 + 7; const int MAXN = 2e5 + 7; const int logo = 17; const int off = 1 << logo; const int trsz = off << 1; const int mod = 1e9; const int dx[] = {0, 0, -1, 1}; const int dy[] = {1, -1, 0, 0}; int ans[MAXN], akt[MAXN], nx[MAXN], lst[MAXN]; void ComputeAdvice(int *c, int n, int k, int m){ set<ii> s; for(int i=0; i<n; i++) lst[i] = n, akt[i] = -1; for(int i=n-1; i>=0; i--){ nx[i] = lst[c[i]]; lst[c[i]] = i; } for(int i=0; i<k; i++){ s.insert({lst[i], i}); akt[i] = i; } for(int i=0; i<n; i++){ if(akt[c[i]] != -1) ans[akt[c[i]]] = 1; else{ int x = (--s.end()) -> Y; s.erase(--s.end()); akt[x] = -1; } akt[c[i]] = k + i; s.insert({nx[i], c[i]}); } for(int i=0; i<n+k; i++) WriteAdvice(ans[i]); }
#include "assistant.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; // No communication/shared data between two namespaces #define X first #define Y second #define PB push_back #define PPB pop_back #define all(x) (x).begin(), (x).end() #define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef pair<ll, ll> pll; const int inf = 1e9 + 7; const int MAXN = 2e5 + 7; const int logo = 17; const int off = 1 << logo; const int trsz = off << 1; const int mod = 1e9; const int dx[] = {0, 0, -1, 1}; const int dy[] = {1, -1, 0, 0}; void Assist(unsigned char *A, int n, int k, int r){ set<int> pas, akt; for(int i=0; i<k; i++){ if(A[i] == 0) pas.insert(i); else akt.insert(i); } for(int i=k; i<n+k; i++){ int c = GetRequest(); if(akt.find(c) != akt.end()){ akt.erase(c); }else{ PutBack(*pas.begin()); pas.erase(pas.begin()); } if(A[i] == 0) pas.insert(c); else akt.insert(c); } }
#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...