이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"/**/
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define FOR(i,n) for (int i = 0; i < (n); i++)
const LL N = 100005, NR = 250005;
using namespace std;
LL i, j, k, l, r, t;
LL a[N], fox[NR];
bool fix[NR];
int valid(int n, int inputSeq[]){
t = NR;
for ( i = 1; i <= n; ++i ){
if ( fix[inputSeq[i-1]] ) return 0;
//cout << inputSeq[i-1] << " " << fix[inputSeq[i-1]] << endl;
fix[inputSeq[i-1]] = 1;
if ( inputSeq[i-1] <= n ){
t = inputSeq[i-1] - i;
}
}
if ( t == NR ) return 1;
for ( i = 1; i <= n; ++i ){
j = i + t;
while ( j < 1 ) j += n;
while ( j > n ) j -= n;
a[j] = inputSeq[i-1];
fox[a[j]] = j;
}
for ( i = 1; i <= n; ++i ){
if ( a[i] <= n && a[i] != i ) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
valid(n, gondolaSeq);
t = 0;
for ( i = 1; i <= n; ++i ){
if ( t < a[i] ){
t = a[i];
}
}
for ( i = n + 1; i <= t; ++i ){
if ( !fox[a[j]] ) replacementSeq[i - n - 1] = fox[t];
else replacementSeq[i - n - 1] = fox[i];
}
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
/*/
int gondolaSequence[100001];
int replacementSequence[250001];
int main()
{
int i, n, tag;
int nr;
assert(scanf("%d", &tag)==1);
assert(scanf("%d", &n)==1);
for(i=0;i< n;i++)
assert( scanf("%d", &gondolaSequence[i]) ==1);
switch (tag){
case 1: case 2: case 3:
printf("%d\n", valid(n, gondolaSequence));
break;
case 4: case 5: case 6:
nr = replacement(n, gondolaSequence, replacementSequence);
printf("%d ", nr);
if (nr > 0)
{
for (i=0; i<nr-1; i++)
printf("%d ", replacementSequence[i]);
printf("%d\n", replacementSequence[nr-1]);
}
else printf("\n");
break;
case 7: case 8: case 9: case 10:
printf("%d\n", countReplacement(n, gondolaSequence));
break;
}
return 0;
}
/**/
컴파일 시 표준 에러 (stderr) 메시지
gondola.cpp:103:1: warning: "/*" within comment [-Wcomment]
/**/
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:53:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# | 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... |