Submission #591390

#TimeUsernameProblemLanguageResultExecution timeMemory
591390cheissmartLast supper (IOI12_supper)C++14
26 / 100
376 ms17384 KiB
#include "advisor.h" #include <bits/stdc++.h> #include <bits/extc++.h> #define IO_OP ios::sync_with_stdio(0), cin.tie(0) #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int INF = 1e9 + 7; void ComputeAdvice(int *a, int n, int k, int m) { vi next_occ(n, INF), nxt(n); for(int i = n - 1; i >= 0; i--) { nxt[i] = next_occ[a[i]]; next_occ[a[i]] = i; } set<pi> s; ordered_set<int> tt; for(int i = 0; i < k; i++) { s.insert({next_occ[i], i}); tt.insert(i); } for(int i = 0; i < n; i++) { if(tt.find(a[i]) != tt.end()) { s.erase({i, a[i]}); s.insert({nxt[i], a[i]}); } else { auto[pos, val] = *s.rbegin(); s.erase({pos, val}); int rk = tt.order_of_key(val); for(int j = 0; j < 15; j++) WriteAdvice(rk >> j & 1); tt.erase(val); s.insert({nxt[i], a[i]}); tt.insert(a[i]); } } } // WriteAdvice
#include "assistant.h" #include <bits/stdc++.h> #include <bits/extc++.h> #define IO_OP ios::sync_with_stdio(0), cin.tie(0) #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(v) int((v).size()) #define ALL(v) (v).begin(), (v).end() using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int INF = 1e9 + 7; void Assist(unsigned char *a, int n, int k, int r) { ordered_set<int> tt; for(int i = 0; i < k; i++) { tt.insert(i); } int sz = 0; for(int i = 0; i < n; i++) { int req = GetRequest(); if(tt.find(req) != tt.end()) { } else { int rk = 0; for(int j = 0; j < 15; j++) rk += int(a[sz++]) << j; int val = *tt.find_by_order(rk); PutBack(val); tt.erase(val); tt.insert(req); } } }

Compilation message (stderr)

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:42:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |             auto[pos, val] = *s.rbegin();
      |                 ^
#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...