이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
int valid(int n, int a[]){
map<int,int> mp;
for(int i=0;i<n;i++){
if(mp[a[i]]!=0) return 0;
mp[a[i]]=1;
}
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
if(a[i]<=n){
v.push_back({a[i],i});
}
}
sort(v.begin(),v.end());
for(int i=1;i<(int)v.size();i++){
int k=(v[i].first-v[i-1].first);
int s=(v[i].second-v[i-1].second+n)%n;
if(k!=s) return 0;
}
return 1;
}
//----------------------
bool cmp(pair<int,int> a, pair<int,int> b){
return a.second<b.second;
}
int replacement(int n, int a[], int ans[]){
for(int i=0;i<n;i++) a[i]--;
bool ok=0;
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
if(a[i]<n){
ok=1;
for(int j=1;j<n;j++){
if(a[(j+i)%n]>=n){
v.push_back({(a[i]+j)%n,a[(i+j)%n]});
}
}
break;
}
}
if(!ok && v.empty()){
for(int i=0;i<n;i++)
v.push_back({i,a[i]});
}
sort(v.begin(),v.end(),cmp);
int cnt=0;
for(auto it: v){
int l=it.first,r=it.second;
while(l!=r){
ans[cnt]=l+1;
l=n+cnt;
cnt++;
}
}
return cnt;
}
//----------------------
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... |