이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define MOD1 1000000009
const int N = 100005;
map<int,int> mp;
map<int,int> :: iterator it;
int valid(int n, int inputSeq[]) {
return -1;
}
//----------------------
vector<pair<int,int> > v;
int a[N], ans;
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int pos = -1;
for(int i = 0; i < n; i ++) {
if(gondolaSeq[i] > n) {
v.pb({gondolaSeq[i], i});
}
else {
pos = i;
}
}
if(pos != -1) {
int cur_pos = pos + 1;
int cur_val = gondolaSeq[pos];
if(cur_pos == n) cur_pos = 0;
while(cur_pos != pos) {
cur_val ++;
if(cur_val == n + 1) cur_val = 1;
a[cur_pos] = cur_val;
cur_pos ++;
if(cur_pos == n) cur_pos = 0;
}
//
}
else {
for(int i = 0; i < n; i ++) {
a[i] = i + 1;
}
}
sort(v.begin(), v.end());
for(int i = v.size() - 1; i >= 0; i --) {
if(i == 0) {
for(int j = v[i].ff - 1; j > n; j --) {
replacementSeq[ans] = j;
ans ++;
}
}
else {
for(int j = v[i].ff - 1; j > v[i - 1].ff ; j --) {
replacementSeq[ans] = j;
ans ++;
}
}
replacementSeq[ans] = a[v[i].ss];
ans ++;
}
ans --;
for(int i = 0; i < ans / 2; i ++) {
swap(replacementSeq[i], replacementSeq[ans - i]);
}
ans ++;
return ans;
}
//----------------------
int countReplacement(int n, int inputSeq[]) {
return -3;
}
# | 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... |