# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
512408 | 2022-01-16T10:39:58 Z | Stickfish | Floppy (RMI20_floppy) | C++17 | 99 ms | 15456 KB |
#include <stdlib.h> #include <iostream> #include <string.h> #include <vector> #include "floppy.h" using namespace std; void read_array(int subtask_id, const vector<int>& v) { int n = v.size(); string bits = ""; vector<int> st; for (int i = 0; i < n; ++i) { while (st.size() && v[i] >= v[st.back()]) { st.pop_back(); bits.push_back('0'); } st.push_back(i); bits.push_back('1'); } save_to_floppy(bits); } vector<int> get_v(int n, const string& bits) { vector<int> ans(n); int i = 0; int l = bits.size(); vector<int> st = {-1}; for (int j = 0; j < l; ++j) { if (bits[j] == '0') { st.pop_back(); } else { ans[i] = st.back(); st.push_back(i); ++i; } } return ans; } vector<int> solve_queries(int subtask_id, int N, const string& bits, const vector<int>& a, const vector<int>& b) { vector<int> v = get_v(N, bits); //for (int i = 0; i < N; ++i) //cout << v[i] << ' '; //cout << endl; vector<vector<int>> redg(N); for (int i = 0; i < N; ++i) { if (v[i] == -1) continue; redg[i].push_back(v[i]); for (int j = 1; j - 1 < redg[redg[i][j - 1]].size(); ++j) { redg[i].push_back(redg[redg[i][j - 1]][j - 1]); } } int m = a.size(); vector<int> answers(m); for (int i = 0; i < m; ++i) { int l = a[i]; int v = b[i]; int j = 20; while (j >= 0) { if (j < redg[v].size() && l <= redg[v][j]) v = redg[v][j]; else --j; } //cout << a[i] << ' ' << b[i] << ": " << v << endl; answers[i] = v; } return answers; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 616 KB | Output is correct |
2 | Correct | 3 ms | 596 KB | Output is correct |
3 | Correct | 2 ms | 772 KB | Output is correct |
4 | Correct | 2 ms | 748 KB | Output is correct |
5 | Correct | 2 ms | 788 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 3600 KB | Output is correct |
2 | Correct | 22 ms | 3708 KB | Output is correct |
3 | Correct | 24 ms | 4048 KB | Output is correct |
4 | Correct | 27 ms | 4000 KB | Output is correct |
5 | Correct | 25 ms | 3612 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 13572 KB | Output is correct |
2 | Correct | 89 ms | 13508 KB | Output is correct |
3 | Correct | 99 ms | 15416 KB | Output is correct |
4 | Correct | 98 ms | 15456 KB | Output is correct |
5 | Correct | 92 ms | 13416 KB | Output is correct |