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"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
int m,k,flag,t,vis[li],visit[li];
int cev;
string s;
vector<int> v;
int valid(int n, int a[]){
int con=-1;
for(int i=0;i<n;i++){
if(a[i]<=n && con==-1){
if(i>=a[i]-1)con=i-(a[i]-1);
else con=i+1+(n-a[i]);
}
else if(a[i]<=n){
int con1=0;
if(i>=a[i]-1)con1=i-(a[i]-1);
else con1=i+1+(n-a[i]);
if(con1!=con)flag=1;
}
}
sort(a,a+n);
for(int i=1;i<n;i++){
if(a[i]==a[i-1])flag=1;
}
if(flag)return 0;
return 1;
}
//----------------------
int replacement(int n, int a[], int replacementSequence[]){
for(int i=0;i<n;i++){
if(a[i]<=n){visit[i]=1;continue;}
vis[a[i]]=i+1;
}
FOR v.pb(i);
int maxi=n;
int len=0;
for(int i=0;i<(int)v.size();i++){
if(visit[i]==1)continue;
if(vis[maxi+1]==0){
replacementSequence[len++]=v[i];
v[i]=++maxi;
i--;
}
else{
replacementSequence[len++]=v[vis[maxi+1]-1];
visit[vis[maxi+1]-1]=1;
v[vis[maxi+1]-1]=maxi+1;
maxi++;
i--;
}
}
return len;
}
//----------------------
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... |