# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428450 | markthitrin | Gondola (IOI14_gondola) | C++14 | 49 ms | 4624 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 "gondola.h"
#include <map>
#include <queue>
class name {
public:
int value;
int base;
bool operator<(const name& b) const{
return value > b.value;
}
void operator=(const name& b){
value = b.value;
base = b.base;
}
}put_in;
int valid(int n, int inputSeq[])
{
std::map<int,bool> g;
int max = 0;
int find_min = 2000000000;
int min_pos = 0;
for(int q = 0 ;q<n;q++){
if(g[inputSeq[q]])
return 0;
g[inputSeq[q]] = true;
if(find_min > inputSeq[q]){
find_min = inputSeq[q];
min_pos = q;
}
}
if(find_min > n)
return 1;
int last_pos = min_pos - find_min;
for(int q = min_pos;q < min_pos + n;q++){
if(max < inputSeq[q % n] && inputSeq[q % n] <= n){
if(inputSeq[q % n] - max != q - last_pos)
return 0;
max = inputSeq[q % n];
inputSeq[q % n] = 2000000000;
last_pos = q;
}
}
for(int q = 0 ;q<n;q++){
if(inputSeq[q] <= n)
return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
std::priority_queue<name> g;
int max = 0;
for(int q = 0 ;q<n;q++){
max = std::max(max,gondolaSeq[q]);
}
int find_min = 2000000000;
int min_pos;
for(int q = 0 ;q<n;q++){
if(find_min > gondolaSeq[q]){
find_min = gondolaSeq[q];
min_pos = q;
}
}
if(find_min > n)
min_pos = 0;
else {
min_pos -= find_min - 1;
if(min_pos < 0) min_pos += n;
}
for(int q = min_pos;q<min_pos + n;q++){
put_in.value = gondolaSeq[q % n];
put_in.base = q + 1 - min_pos;
g.push(put_in);
}
int cnt = 0;
int last_value = n;
while(!g.empty()){
put_in = g.top();
g.pop();
if(put_in.value <= n)
continue;
replacementSeq[cnt++] = put_in.base;
for(int q = last_value + 1;q<put_in.value;q++){
replacementSeq[cnt++] = q;
}
last_value = put_in.value;
}
return cnt;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |