# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
761233 | 2023-06-19T11:32:06 Z | ksu2009en | Floppy (RMI20_floppy) | C++17 | 80 ms | 5728 KB |
#include <iostream> #include <vector> #include <string> #include <math.h> #include <cmath> #include <iomanip> #include <cstdio> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <stack> #include <deque> #include <bitset> #include <cstring> #include <unordered_map> using namespace std; typedef long long ll; #include "floppy.h" string convert(ll n){ string ans; ll mx = 0; for(int i = 17; i >= 0; i--) if((n >> i) % 2 != 0){ mx = i; break; } for(int i = 0; i <= mx; i++){ if((n >> i) % 2 != 0) ans += "1"; else ans += "0"; } reverse(ans.begin(), ans.end()); return ans; } ll get(string a){ ll ans = 0; ll p = 1; for(int i = a.size() - 1; i >= 0; i--){ ans += (a[i] - '0') * p; p *= 2; } return ans; } string fill0(string a, ll n){ reverse(a.begin(), a.end()); ll c = n - a.size(); for(int i = 0; i < c; i++) a += "0"; reverse(a.begin(), a.end()); return a; } void squize(vector<ll> &a){ vector<ll> b = a; sort(b.begin(), b.end()); map<ll, ll> mp; ll step = 0; for(auto i: b) if(!mp.count(i)) mp[i] = step++; for(auto &i: a) i = mp[i]; } void read_array(int subtask_id, const std::vector<int> &v) { vector<string>d; vector<ll>a; for(auto i: v) a.push_back(i); squize(a); for(auto i: a){ d.push_back(convert(i)); } for(auto &i: d) i = fill0(i, 14); string ans; for(auto i: d) ans += i; save_to_floppy(ans); } std::vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) { vector<ll> d; for(int i = 0; i < bits.size(); i += 14){ string c; for(int j = i; j < i + 14; j++) c += bits[j]; d.push_back(get(c)); } vector<int>ans; for(int i = 0; i < a.size(); i++){ ll mx = -1, pos = 0; for(int j = a[i]; j <= b[i]; j++){ if(d[j] > mx){ mx = d[j]; pos = j; } } ans.push_back(pos); } return ans; } /* 2 4 1 -2 -4 2 0 0 1 0 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 660 KB | Output is correct |
2 | Correct | 2 ms | 668 KB | Output is correct |
3 | Correct | 2 ms | 660 KB | Output is correct |
4 | Correct | 2 ms | 788 KB | Output is correct |
5 | Correct | 2 ms | 660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 4016 KB | Output is correct |
2 | Correct | 49 ms | 3992 KB | Output is correct |
3 | Correct | 80 ms | 3924 KB | Output is correct |
4 | Correct | 66 ms | 3960 KB | Output is correct |
5 | Correct | 49 ms | 3984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 50 ms | 5728 KB | L is too large |
2 | Halted | 0 ms | 0 KB | - |