이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <iostream>
#include <set>
#define MAXN 100000
using namespace std;
int valid(int n, int inputSeq[]) {
for (int i = 1; i < n; i++) {
if (inputSeq[i] < n) {
if (inputSeq[i] != inputSeq[i-1] + 1) {
return 0;
}
}
else {
inputSeq[i] = inputSeq[i - 1] + 1;
inputSeq[i] %= n;
}
}
return 1;
}
int og[MAXN + 1]; // original order
set<pair<int, int>> Q; // Q gondolas above n least to greatest
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int start = 0; // pos of 1 in the sequence
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
start = i + (n - gondolaSeq[i] + 1); // pos of 1
start %= n; // keep in bounds of array
break;
}
}
for (int i = 0; i < n; i++) {
og[i] = n + 1 + (i - start);
og[i] %= n;
if (gondolaSeq[i] > n) {
Q.insert(make_pair(gondolaSeq[i], i));
}
}
int curr = n;
set<pair<int, int>>::iterator it;
for (it = Q.begin(); it != Q.end(); it++) {
pair<int, int> a = *it;
while (curr < a.first) {
replacementSeq[curr - n] = og[a.second];
cout << replacementSeq[curr - n] << endl;
curr++;
og[a.second] = curr;
}
}
return curr-n;
}
int countReplacement(int n, int inputSeq[]) {
return 0;
}
# | 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... |