# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
412704 | 2021-05-27T11:16:33 Z | 송준혁(#7518) | Bread First Search (CCO21_day2problem2) | C++17 | 1 ms | 204 KB |
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define lb lower_bound #define MOD 1000000007 #define INF (1ll<<62) using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, M; int L[202020], R[202020]; int D[202020], A[202020]; int main(){ scanf("%d %d", &N, &M); for (int i=1; i<=N; i++) L[i] = R[i] = i; while (M--){ int u, v; scanf("%d %d", &u, &v); if (u > v) swap(u, v); R[u] = max(R[u], v); L[v] = min(L[v], u); } for (int i=2; i<=N; i++) A[L[i]]++, A[i]--; int s=0, r=0; if (R[1] > 1) D[R[1]] = 1; for (int i=1; i<=N; i++){ s += A[i], r = max(r, R[i]); if (i < R[1]) continue; D[i] = max(D[i-1], D[i]); D[r] = max(D[r], D[i-1] + s); } printf("%d\n", N-D[N]-1); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 204 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 204 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Incorrect | 1 ms | 204 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |