답안 #127832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127832 2019-07-10T06:58:06 Z StevenH 곤돌라 (IOI14_gondola) C++14
25 / 100
15 ms 1784 KB
#include "gondola.h"
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int tag[10000000];
int a[2*100000+5];
int valid(int n, int inputSeq[])
{
	for(int i=0;i<n;i++)
		a[i]=a[n+i]=inputSeq[i];
	for(int i=0;i<n;i++)
	{
		if(!tag[a[i]])tag[a[i]]=1;
		else return 0;
	}
	int t=0;
	for(int i=0;i<n;i++)
		if(a[i]<=n)t=1;
	if(t==0)return 1;
	
	int res;t=0;
	for(int i=0;i<2*n;i++)
		if(a[i]>=1 && a[i]<=n && i+1>=a[i])
			{res=i;t=1;break;}
	
	for(int i=res;i<=res+n-a[res];i++)
		if(a[i]>=1 && a[i]<=n)
			if(a[i]!=i-res+a[res])return 0;
	return 1;
}

//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	for(int i=0;i<n;i++)
		a[i]=a[n+i]=gondolaSeq[i];
	int res;
	for(int i=0;i<2*n;i++)
		if(a[i]>=1 && a[i]<=n && i+1>=a[i])
			{res=i;break;}
	int l=0;
	int mx=res-a[res]+1;
	for(int i=res-a[res]+1;i<=res+n-a[res];i++)
		if(a[i]>n)
			if(a[i]>a[mx])
				mx=i;
	//cout<<res-a[res]+1<<endl;
	for(int i=res-a[res]+1;i<=res+n-a[res];i++)
	{
		if(a[i]>n && i!=mx)
		{
			//cout<<"/";       **-1 0 n-1
			replacementSeq[a[i]-n-1]=i-res+a[res];
			//cout<<a[i]-n-1<<" "<<replacementSeq[a[i]-n-1]<<endl;
		}
	}
	int r=mx-res+a[res];
	int rr=a[mx]-n;
	for(int i=0;i<rr;i++)
		if(!replacementSeq[i])
    		replacementSeq[i]=r;
	//for(int i=0;i<rr;i++)cout<<i<<" "<<replacementSeq[i]<<endl;
	return rr;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
    return 1;
}

Compilation message

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:42:6: warning: unused variable 'l' [-Wunused-variable]
  int l=0;
      ^
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:22:6: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int res;t=0;
      ^~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:38:6: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int res;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 404 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 8 ms 888 KB Output is correct
7 Correct 14 ms 1656 KB Output is correct
8 Correct 12 ms 1528 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 15 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 312 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 7 ms 888 KB Output is correct
7 Correct 14 ms 1656 KB Output is correct
8 Correct 12 ms 1424 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 13 ms 1656 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 8 ms 1532 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 15 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Integer -66 violates the range [0, 350000]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 256 KB Integer -66 violates the range [0, 350000]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 256 KB Integer -66 violates the range [0, 350000]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 420 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -