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 <bits/stdc++.h>
using namespace std;
#define pii pair <int,int>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
int valid(int n, int a[]) {
int c[n + 1];
for(int i = 0;i < n;i++) {
if(a[i] <= n) {
int tek = a[i];
for(int j = i + 1;j < n;j++) {
tek++;
if(tek == n + 1)tek = 1;
c[j] = tek;
}
for(int j = 0;j < i;j++) {
tek++;
if(tek == n + 1)tek = 1;
c[j] = tek;
}
break;
}
}
for(int i = 0;i < n;i++) {
if(a[i] <= n && c[i] != a[i])return 0;
}
return 1;
}
//----------------------
int replacement(int n, int a[], int b[]) {
int c[n + 1];
bool ch = 0;
for(int i = 0;i < n;i++) {
if(a[i] <= n) {
int tek = a[i];
for(int j = i + 1;j < n;j++) {
tek++;
if(tek == n + 1)tek = 1;
c[j] = tek;
}
for(int j = 0;j < i;j++) {
tek++;
if(tek == n + 1)tek = 1;
c[j] = tek;
}
ch = 1;
break;
}
}
if(!ch) {
for(int i = 0;i < n;i++) {
c[i] = i + 1;
}
}
set <pii> g;
for(int i = 0;i < n;i++) {
if(a[i] > n)g.insert(mp(a[i],i));
}
int k = 0;
int cnt = n + 1;
while(!g.empty()) {
pii vv = *(g.begin());
int val = vv.f,bilo = c[vv.s];
while(1) {
b[k++] = bilo;
if(cnt == val)break;
bilo = cnt++;
}
g.erase(vv);
}
return k;
}
/*
4
2
3 2
*/
//----------------------
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... |