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 <bits/stdc++.h>
#include "gondola.h"
using namespace std;
typedef long long ll;
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
const int MOD = 1'000'000'007;
const int MX = 100'005;
//long double PI = 3.14159265358979323846264338327950;
int valid(int n, int inputSeq[])
{
//return -1;
int a[250005];
memset(a,-1,sizeof(a));
for(int i=0; i<n; i++){
if(a[inputSeq[i]-1]!=-1){
return 0;
}
a[inputSeq[i]-1]=i;
}
int b[n];
memset(b,-1,sizeof(b));
for(int i=0; i<n; i++){
if(a[i]!=-1){
b[a[i]]=i;
//cout<<i<<'\n';
for(int j=a[i]+1; j<a[i]+n; j++){
b[j%n]=(b[(j-1)%n]+1)%n;
}
break;
}
}
//for(int i=0; i<n; i++) cout<<b[i]<<' ';
//cout<<'\n';
for(int i=0; i<n; i++){
if(a[i]!=-1&&b[i]!=-1){
if(a[i]!=b[i]) return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int a[250'005];
memset(a,-1,sizeof(a));
for(int i=0; i<n; i++){
a[gondolaSeq[i]-1]=i;
}
int b[n];
for(int i=0; i<n; i++){
b[i]=i;
}
//cout<<a[0]<<'\n';
for(int i=0; i<n; i++){
if(a[i]!=-1){
b[a[i]]=i;
//cout<<i<<'\n';
for(int j=a[i]+1; j<a[i]+n; j++){
b[j%n]=(b[(j-1)%n]+1)%n;
}
break;
}
}
//for(int i=0; i<n; i++) cout<<b[i]<<' ';
//cout<<'\n';
return 0;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
/*void caso_teste(){
}*/
/*
int main(){
cin.tie(0);ios_base::sync_with_stdio(0);
//freopen ("in.txt","r",stdin);
int n_casos=1; //cin>>n_casos;
//while(n_casos--) caso_teste();
int a[7]={2, 3, 4, 9, 6, 7, 1};
int b[2*MX];
int c=replacement(7, a, b);
cout<<c<<'\n';
}*/
# | 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... |