# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
625892 |
2022-08-11T01:03:16 Z |
as111 |
Gondola (IOI14_gondola) |
C++14 |
|
0 ms |
0 KB |
#include "gondola.h"
#include <iostream>
#include <set>
#include <algorithm>
#define MAXN 100000
using namespace std;
int valid(int n, int inputSeq[]) {
int start = 0;
for (int i = 0; i < n; i++) {
if (inputSeq[i] <= n) {
start = i;
break;
}
}
if (start < n) {
for (int j = 0; j < n; j++) {
if (inputSeq[j] <= n && (inputSeq[j] + i) % n != (inputSeq[i] + j) % n) return 0;
}
}
sort(inputSeq, inputSeq + n);
for (int i = 1; i < n; i++) {
if (inputSeq[i - 1] == inputSeq[i]) {
return 0;
}
}
return 1;
}
int og[MAXN + 1]; // original order
set<pair<int, int>> Q; // Q gondolas above n least to greatest
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int start = 0; // pos of 1 in the sequence
for (int i = 0; i < n; i++) {
if (gondolaSeq[i] <= n) {
start = i + (n - gondolaSeq[i] + 1); // pos of 1
start %= n; // keep in bounds of array
break;
}
}
for (int i = 0; i < n; i++) {
og[i] = n + 1 + (i - start);
og[i] %= n;
if (gondolaSeq[i] > n) {
Q.insert(make_pair(gondolaSeq[i], i));
}
}
int curr = n;
set<pair<int, int>>::iterator it;
for (it = Q.begin(); it != Q.end(); it++) {
pair<int, int> a = *it;
while (curr < a.first) {
replacementSeq[curr - n] = og[a.second];
cout << replacementSeq[curr - n] << endl;
curr++;
og[a.second] = curr;
}
}
return curr-n;
}
int countReplacement(int n, int inputSeq[]) {
return 0;
}
Compilation message
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:43: error: 'i' was not declared in this scope
20 | if (inputSeq[j] <= n && (inputSeq[j] + i) % n != (inputSeq[i] + j) % n) return 0;
| ^