# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494367 | Sho10 | Floppy (RMI20_floppy) | C++17 | 104 ms | 13388 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#include "floppy.h"
#define ll long long int
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 998244353
#define PI 3.14159265359
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll dp[20][400005];
void read_array ( int subtask_id , const std :: vector <int > & v ){
string bits="";
stack<ll>s;
s.push(-1);
for(ll i=0;i<v.size();i++)
{
while(s.top()!=-1&&v[s.top()]<v[i]){
bits+='0';
s.pop();
}
s.push(i);
bits+='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){
stack<ll>s;
s.push(-1);
ll pos=0;
ll j=0;
while(pos<N){
while(bits[j]=='0'){
j++;
s.pop();
}
dp[0][pos+1]=s.top()+1;
s.push(pos);
pos++;
j++;
}
for(ll i=1;(1ll<<i)<=N;i++)
{
for(ll j=1;j<=N;j++)
{
dp[i][j]=dp[i-1][dp[i-1][j]];
}
}
vector<int>ans;
for(ll i=0;i<a.size();i++)
{
ll x=b[i]+1;
for(ll j=15;j>=0;j--)
{
if((1ll<<j)>N){
continue;
}
if(dp[j][x]>=a[i]+1){
x=dp[j][x];
}
}
ans.pb(x-1);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |