Submission #1101838

#TimeUsernameProblemLanguageResultExecution timeMemory
1101838blackslexGlobal Warming (NOI13_gw)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using pii = pair<int, int>; int gw (int N, int *H) { int n = N; vector<int> h(n), par(n); iota(par.begin(), par.end(), 0); vector<bool> ck(n); for (int i = 0; i < n; i++) h[i] = H[i]; int cnt = 0, ans = 0; function<int(int)> fset = [&] (int x) {return (par[x] == x ? x : par[x] = fset(par[x]));}; auto mg = [&] (int x, int y) { if ((x = fset(x)) == (y = fset(y))) return; if (ck[x] || ck[y]) par[y] = x, ck[x] = ck[y] = 1; else { cnt++; par[y] = x; ck[x] = ck[y] = 1; } }; vector<int> c = h; sort(c.begin(), c.end()); c.resize(unique(c.begin(), c.end()) - c.begin()); vector<vector<int>> add(n, vector<int>()); auto get = [&] (int x) { return lower_bound(c.begin(), c.end(), x) - c.begin(); }; for (int i = 0; i < n; i++) add[get(h[i])].emplace_back(i); for (int i = n - 1; i >= 0; i--) { for (auto &e: add[i]) { if (e && h[e - 1] >= h[e]) mg(e - 1, e); if (e != n - 1 && h[e + 1] >= h[e]) mg(e, e + 1); } ans = max(ans, cnt); } return ans; }

Compilation message (stderr)

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status