답안 #70315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70315 2018-08-22T15:09:28 Z Abelyan 곤돌라 (IOI14_gondola) C++17
25 / 100
17 ms 3468 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;

const int N=100006;
bool used[N];

struct Gondola{
	int endInd,startInd;
};

bool operator <(const Gondola a,const Gondola b){
	if (make_pair(a.endInd,a.startInd)<make_pair(b.startInd,b.endInd)) return true;
	return false;
}

int valid(int n, int inSeq[])
{
	int start=-1;
	for (int i=0;i<n;i++){
		if (used[inSeq[i]]){
			return 0;
		}
		used[inSeq[i]]=true;
		if (inSeq[i]<=n){
			if (start!=-1 && (n+i-inSeq[i]+1)%n!=start){
				return 0;
			}
			start=(n+i-inSeq[i]+1)%n;
		}
	}
	return 1;
}


int replacement(int n, int inSeq[], int finalAns[])
{
	if (n==0) return 0;
	int start=0;
	for (int i=0;i<n;i++){
		if (inSeq[i]<=n){
			start=(n+i-inSeq[i]+1)%n;
		}
	}
	vector<Gondola> v;
	for (int i=0;i<n;i++){
		v.push_back({inSeq[i],(n+i-start)%n+1});
	}
	sort(v.begin(),v.end());
	int ansLength=0;
	int curGondola=n+1;
	for (int i=0;i<n;i++){
		if (v[i].startInd==v[i].endInd)continue;
		finalAns[ansLength++]=v[i].startInd;
		curGondola++;
		while (curGondola!=v[i].endInd+1){
			finalAns[ansLength++]=curGondola-1;
			curGondola++;
		}
	}
	return ansLength;
}


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;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 516 KB Output is correct
2 Correct 1 ms 516 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 7 ms 700 KB Output is correct
7 Correct 17 ms 956 KB Output is correct
8 Correct 13 ms 956 KB Output is correct
9 Correct 6 ms 956 KB Output is correct
10 Correct 15 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 8 ms 1024 KB Output is correct
7 Correct 14 ms 1024 KB Output is correct
8 Correct 14 ms 1024 KB Output is correct
9 Correct 7 ms 1024 KB Output is correct
10 Correct 14 ms 1024 KB Output is correct
11 Correct 2 ms 1024 KB Output is correct
12 Correct 3 ms 1024 KB Output is correct
13 Correct 8 ms 1024 KB Output is correct
14 Correct 3 ms 1024 KB Output is correct
15 Correct 16 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Runtime error 7 ms 3452 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3452 KB Output is correct
2 Correct 3 ms 3452 KB Output is correct
3 Correct 2 ms 3452 KB Output is correct
4 Correct 2 ms 3452 KB Output is correct
5 Correct 2 ms 3452 KB Output is correct
6 Correct 2 ms 3452 KB Output is correct
7 Runtime error 7 ms 3468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3468 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3468 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3468 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 3468 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -