Submission #1143641

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11436412025-02-01 08:42:47RufatGondola (IOI14_gondola)C++20
Compilation error
0 ms0 KiB
//Author Gpt O3-Mini
#include <bits/stdc++.h>
using namespace std;
/*
We implement three functions:
1. int valid(int n, int inputSeq[]);
Checks whether the array inputSeq[0..n-1] is a valid gondola sequence.
Under our (simplified) model the gondola system is as follows:
- Initially there are n gondolas numbered 1,2,…,n in order on a circular rail.
- When a gondola breaks down it is replaced immediately by the first available spare.
(Thus if n = 5 the first spare is 6, the second is 7, etc.)
- In our simplified model we assume that any gondola that broke down was replaced only once.
- Finally, the observer may “see” the gondolas in any cyclic shift of the circle.
Our check is as follows. Suppose that a rotation (shift) r (0 ≤ r < n) makes the circle “line up” so that
the expected original numbers (if no breakdown had occurred) are 1,2,…,n in that order.
Then for each position j (0-indexed) we have:
- If no breakdown occurred there then the observed number must equal j+1.
- If a breakdown occurred then (by our simplified rule) the spare number assigned is
n + (k) where k is the count (starting at 1) of replaced gondolas in the order encountered.
(Thus, for example, if n = 5 and gondola 1 breaks down then the spare is 6; if gondola 4 breaks down then its spare is 7.)
We try all rotations r and if one is consistent with the rule we return 1; otherwise we return 0.
2. int replacement(int n, int gondolaSeq[], int replacementSeq[]);
Given that gondolaSeq is a valid gondola sequence (by the above definition),
we “reconstruct” one possible replacement sequence.
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

/usr/bin/ld: /tmp/ccHat2n0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3DvcHl.o:gondola.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status