# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
81141 | 2018-10-24T02:23:09 Z | FutymyClone | Baloni (COCI15_baloni) | C++14 | 146 ms | 26112 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; struct disj { int par[N]; void init (int n) { for (int i = 1; i <= n; i++) par[i] = i; } int Find (int x) { return par[x] == x ? x : par[x] = Find(par[x]); } void join (int x, int y) { x = Find(x); y = Find(y); if (x == y) return; par[y] = x; } } dsu; int n, a[N], last[N]; int main(){ scanf("%d", &n); dsu.init(n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) { if (last[a[i] + 1]) dsu.join(i, last[a[i] + 1]); last[a[i]] = i; } int ans = 0; for (int i = 1; i <= n; i++) ans += dsu.par[i] == i; printf("%d", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 504 KB | Output isn't correct |
2 | Incorrect | 2 ms | 668 KB | Output isn't correct |
3 | Incorrect | 2 ms | 824 KB | Output isn't correct |
4 | Incorrect | 3 ms | 824 KB | Output isn't correct |
5 | Incorrect | 146 ms | 10576 KB | Output isn't correct |
6 | Incorrect | 143 ms | 14824 KB | Output isn't correct |
7 | Incorrect | 113 ms | 16452 KB | Output isn't correct |
8 | Incorrect | 113 ms | 19240 KB | Output isn't correct |
9 | Incorrect | 121 ms | 22736 KB | Output isn't correct |
10 | Incorrect | 126 ms | 26112 KB | Output isn't correct |