이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
#define MAX 200001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
for(int i=0;i<b;i++){\
cin >> a[i];\
}\
}
#define inputvec(a,b){\
for(int i=0;i<b;i++){\
ll num;\
cin >> num;\
a.pb(num);\
}\
}
#define outputar(a,b){\
for(int i=0;i<b;i++){\
cout << a[i] << " ";\
}\
cout << "\n";\
}
#define outputvec(a){\
for(auto x:a){\
cout << x << " ";\
}\
cout << "\n";\
}
#define reset(a,n,v){\
for(int i=0;i<n;i++){\
a[i]=v;\
}\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
freopen((filename+".in").c_str(),"r",stdin);
freopen((filename+".out").c_str(),"w",stdout);
}
int valid(int n, int inputSeq[])
{
map<int,int> b;
int x=-1;
for(int i=0;i<n;i++){
if(inputSeq[i]<=n){
x=i;
}
b[inputSeq[i]]++;
}
for(auto x:b){
if(x.second>1){
return 0;
}
}
if(x==-1){
return 1;
}
vector<int> a;
a.resize(n);
int h1=inputSeq[x]-1;
for(int i=0;i<n;i++){
a[x]=h1+1;
x++;
x%=n;
h1++;
h1%=n;
}
for(int i=0;i<n;i++){
if(inputSeq[i]<=n && inputSeq[i]!=a[i]){
return 0;
}
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int ind=0;
vector<pii> c;
c.pb(mp(n,-1));
int x=-1;
for(int i=0;i<n;i++){
if(gondolaSeq[i]>n){
c.pb(mp(gondolaSeq[i],i));
}
else{
x=i;
}
}
vector<int> a;
a.resize(n);
if(x!=-1){
int h1=gondolaSeq[x]-1;
for(int i=0;i<n;i++){
a[x]=h1+1;
x++;
x%=n;
h1++;
h1%=n;
}
}
else{
for(int i=0;i<n;i++){
a[i]=i+1;
}
}
sortv(c);
int sz=(int)c.size();
for(int i=1;i<sz;i++){
replacementSeq[ind]=a[c[i].ss];
ind++;
for(int j=c[i-1].ff+1;j<c[i].ff;j++){
replacementSeq[ind]=j;
ind++;
}
}
return ind;
}
//----------------------
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... |