# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091062 | 2024-09-19T16:30:56 Z | Abito | Floppy (RMI20_floppy) | C++17 | 101 ms | 11956 KB |
#include <bits/stdc++.h> #include "floppy.h" #define pb push_back using namespace std; void read_array(int subtask_id, const std::vector<int> &v) { stack<int> s; int n=v.size(),b[n]; string ans=""; for (int i=n-1;i>=0;i--){ b[i]=0; while (!s.empty() && v[s.top()]<v[i]) s.pop(); if (!s.empty()) b[i]=s.top(); s.push(i); } for (int i=0;i<n;i++){ if (b[i]==0){ ans+="10"; continue; } if (b[i]>16){ ans+="11"; continue; } ans+='0'; int d=b[i]-i-1; for (int j=0;j<4;j++){ if (d&(1<<j)) ans+='1'; else ans+='0'; } } //for (int i=0;i<n;i++) cout<<b[i]<<' ';cout<<endl; save_to_floppy(ans); return; } std::vector<int> solve_queries(int subtask_id, int n, const std::string &bits, const std::vector<int> &L, const std::vector<int> &R) { vector<int> ans; int c[n]; int j=0; for (int i=0;i<n;i++){ if (bits[j]=='1'){ if (bits[j+1]=='0') c[i]=0; else c[i]=17; j+=2; continue; } c[i]=0; for (int k=j+1;k<=j+4;k++){ if (bits[k]=='1') c[i]|=(1<<(k-j-1)); } c[i]++; j+=5; } for (int i=0;i<L.size();i++){ int l=L[i],r=R[i],mx=l; while (true){ //cout<<l<<' '<<c[l]<<endl; if (c[l]==0){ mx=l; break; } if (c[l]==17){ if (l+17>r){ mx=l; break; } l+=17; continue; } if (l+c[l]>r){ mx=l; break; } l+=c[l]; } ans.pb(mx); }return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 828 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 3512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 101 ms | 11956 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |