# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404501 | 2021-05-14T14:04:57 Z | danielcm585 | Floppy (RMI20_floppy) | C++14 | 126 ms | 15780 KB |
#include "floppy.h" #include <bits/stdc++.h> using namespace std; void read_array(int subtask_id, const vector<int> &v) { string bits; stack<int> s; for (auto i : v) { while (!s.empty() && s.top() < i) { bits += '0'; s.pop(); } bits += '1'; s.push(i); } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &l, const vector<int> &r) { stack<int> s; vector<vector<int>> ls(N,vector<int>(16)); for (int i = 0, j = 0; i < bits.length(); i++) { if (bits[i] == '1') { if (s.empty()) ls[j][0] = j; else ls[j][0] = s.top(); s.push(j++); } else s.pop(); } for (int i = 1; i < 16; i++) { for (int j = 0; j < N; j++) { ls[j][i] = ls[ls[j][i-1]][i-1]; } } vector<int> res; for (int i = 0; i < l.size(); i++) { int ans = r[i]; for (int j = 15; j >= 0; j--) { if (ls[ans][j] >= l[i]) ans = ls[ans][j]; } res.push_back(ans); } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 768 KB | Output is correct |
2 | Correct | 3 ms | 632 KB | Output is correct |
3 | Correct | 4 ms | 760 KB | Output is correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 4196 KB | Output is correct |
2 | Correct | 29 ms | 4228 KB | Output is correct |
3 | Correct | 30 ms | 4152 KB | Output is correct |
4 | Correct | 32 ms | 4160 KB | Output is correct |
5 | Correct | 43 ms | 4232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 15632 KB | Output is correct |
2 | Correct | 126 ms | 15456 KB | Output is correct |
3 | Correct | 126 ms | 15764 KB | Output is correct |
4 | Correct | 117 ms | 15780 KB | Output is correct |
5 | Correct | 115 ms | 15536 KB | Output is correct |