Submission #737691

# Submission time Handle Problem Language Result Execution time Memory
737691 2023-05-07T14:46:54 Z shoryu386 Gondola (IOI14_gondola) C++17
Compilation error
0 ms 0 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[])
{
	int baseline = -1;
	int baselineIdx = -1;
	for (int x = 0; x < n; x++){
		if (inputSeq[x] <= n){
			baseline = inputSeq[x];
			baselineIdx = x;
		}
	}
	
	if (baseline == -1){
		return 1;
	}
	
	//baseline is supposed to be at x+1
	int shiftsRight = x+1 - baseline;
	int shifted[n];
	for (int x = 0; x < n; x++) {
		shifted[x] = inputSeq[(x + shiftsRight + n)%n];
	}
	
	for (int x = 0; x < n; x++){
		if (shifted[x] <= n && shifted[x] != x+1) return 0;
	}
	return 1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

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

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

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:20: error: 'x' was not declared in this scope
   20 |  int shiftsRight = x+1 - baseline;
      |                    ^