제출 #1184180

#제출 시각아이디문제언어결과실행 시간메모리
1184180HasanV11010238Floppy (RMI20_floppy)C++20
100 / 100
66 ms7920 KiB
#include <stdlib.h> #include <string.h> #include <iostream> #include "floppy.h" using namespace std; void read_array(int subtask_id, const std::vector<int> &v) { int n = v.size(); string bits(2 * n, '0'); int no = 0; vector<int> st; for (int i = 0; i < n; i++){ while (!st.empty() && st.back() < v[i]) st.pop_back(), no++; st.push_back(v[i]); bits[no++] = '1'; } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b){ int m = a.size(), no = 0; vector<int> st, ans(m, 0); vector<vector<vector<int>>> qu(N); for (int i = 0; i < m; i++){ qu[b[i]].push_back({a[i], i}); } for (int i = 0; i < N; i++){ while (bits[no] == '0') st.pop_back(), no++; no++; st.push_back(i); for (auto el : qu[i]){ ans[el[1]] = *lower_bound(st.begin(), st.end(), el[0]); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...