# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
205670 | Kastanda | Rope (JOI17_rope) | C++11 | 1523 ms | 139492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In The Name Of The Queen
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N = 1000006;
int n, m, A[N], C[N], S[N * 2];
vector < int > V[N][2];
inline void Add(int i, int val)
{
S[i += m - 1] += val;
for (; i; i >>= 1)
S[i >> 1] = max(S[i], S[i ^ 1]);
}
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i ++)
scanf("%d", &A[i]);
for (int i = 1; i <= n; i ++)
{
C[A[i]] ++;
for (int j = 0; j <= 1; j ++)
{
int nxt = i + 1 - ((i + j) % 2) * 2;
if (A[nxt] && A[nxt] != A[i])
V[A[i]][j].push_back(A[nxt]);
}
Add(A[i], 1);
}
for (int c = 1; c <= m; c ++)
{
int Mn = n - C[c];
Add(c, -C[c]);
for (int j = 0; j <= 1; j ++)
{
for (int a : V[c][j])
Add(a, -1);
Mn = min(Mn, n - C[c] - S[1]);
for (int a : V[c][j])
Add(a, 1);
}
Add(c, C[c]);
printf("%d\n", Mn);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |