# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475261 | stefantaga | Floppy (RMI20_floppy) | C++14 | 1109 ms | 12712 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 <stdlib.h>
#include <string.h>
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
int v[40005],n;
stack <int> st;
void read_array(int subtask_id, const std::vector<int> &x) {
std::string bits;
n=x.size();
int i;
for (i=1;i<=n;i++)
{
v[i]=x[i-1];
}
for (i=1;i<=n;i++)
{
while (!st.empty()&&v[st.top()]<v[i])
{
st.pop();
bits+="1";
}
st.push(i);
bits+="0";
}
save_to_floppy(bits);
}
int stanga[50005];
vector <pair <int,int> > queryuri;
std::vector<int> solve_queries(int subtask_id, int N,
const std::string &bits,
const std::vector<int> &a, const std::vector<int> &b) {
n=N;
int i,poz;
while (!st.empty())st.pop();
poz=1;
for (i=0;i<bits.size();i++)
{
if (bits[i]=='0')
{
if (st.empty())
{
stanga[poz]=0;
}
else
{
stanga[poz]=st.top();
}
st.push(poz);
poz++;
}
else
{
st.pop();
}
}
for (i=0;i<a.size();i++)
{
queryuri.push_back({a[i]+1,b[i]+1});
}
vector <int> answers;
for (i=0;i<queryuri.size();i++)
{
int minim=1e9,pozitie=0;
for (int j=queryuri[i].first;j<=queryuri[i].second;j++)
{
if (stanga[j]<=minim)
{
minim=stanga[j];
pozitie=j-1;
}
}
answers.push_back(pozitie);
}
return answers;
}
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... |