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 "sequence.h"
#include <bits/stdc++.h>
using namespace std;
#define DEBUG if (1)
int sequence(int N, std::vector<int> A) {
vector<int> pos[N + 1];
for (int i = 0; i < N; i++) pos[A[i]].push_back(i);
for (int i = 1; i <= N; i++) {
if ((int) pos[i].size() <= 1) continue;
if (pos[i][1] - pos[i][0] == 1) return 2;
}
for (int i = 1; i <= N; i++) {
if ((int) pos[i].size() <= 1) continue;\
int dl = pos[i][0] - 1;
int dr = N - pos[i][1];
int d = pos[i][1] - pos[i][0];
if ((dl + 1) >= d) return 2;
if ((dr + 1) >= d) return 2;
}
return 1;
}
# | 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... |