This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <gondola.h>
using namespace std;
int pos[100001];
int valid(int n, int inputSeq[]) {
set<int> done;
fill(pos, pos + n + 1, -1);
vector<int> a;
int check = 1;
for (int i = 0; i < n; i++) {
if (done.count(inputSeq[i]))
check = 0;
done.insert(inputSeq[i]);
if (inputSeq[i] <= n)
a.push_back(inputSeq[i]), pos[inputSeq[i]] = i;
}
int ind = -1, val = n + 1;
for (int i = 0; i < a.size(); i++) {
if (a[i] < val)
val = a[i], ind = i;
}
if (ind == -1)
return check;
for (int i = 0, j = ind + 1; i < a.size() - 1; i++, j++) {
if (j == a.size())
j = 0;
assert(j < a.size());
if (a[j] <= val)
check = 0;
val = a[j];
}
int last = 1;
while (last <= n && pos[last] == -1)
last++;
for (int i = last + 1; i <= n; i++) {
assert(i <= n && last <= n);
if (pos[i] == -1)
continue;
if (i - last != pos[i] - pos[last] && i - last != pos[i] + n - pos[last])
check = 0;
last = i;
}
return check;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
return 1;
}
int countReplacement(int n, int inputSeq[]) {
return 1;
}
/*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;
}*/
Compilation message (stderr)
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:22:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.size(); i++) {
~~^~~~~~~~~~
gondola.cpp:30:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0, j = ind + 1; i < a.size() - 1; i++, j++) {
~~^~~~~~~~~~~~~~
gondola.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (j == a.size())
~~^~~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
from gondola.cpp:1:
gondola.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
assert(j < a.size());
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |