# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
205668 | 2020-02-29T12:07:47 Z | Kastanda | Rope (JOI17_rope) | C++11 | 34 ms | 47352 KB |
// 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]); C[A[i]] ++; for (int j = 0; j <= 1; j ++) { int nxt = i + 1 - (i ^ j & 1) * 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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 47352 KB | Output is correct |
2 | Correct | 32 ms | 47352 KB | Output is correct |
3 | Incorrect | 34 ms | 47352 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 47352 KB | Output is correct |
2 | Correct | 32 ms | 47352 KB | Output is correct |
3 | Incorrect | 34 ms | 47352 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 47352 KB | Output is correct |
2 | Correct | 32 ms | 47352 KB | Output is correct |
3 | Incorrect | 34 ms | 47352 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 47352 KB | Output is correct |
2 | Correct | 32 ms | 47352 KB | Output is correct |
3 | Incorrect | 34 ms | 47352 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 47352 KB | Output is correct |
2 | Correct | 32 ms | 47352 KB | Output is correct |
3 | Incorrect | 34 ms | 47352 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |