My Union find solution got AC with builtin array but not vector. In C++ vector is supposed to be the default container with little performance loss compared to builtin array.
I encountered similar issue with other problems. I think the OJ is a bit too strict about the timing.
Here is my UF solution: https://oj.leetcode.com/discuss/6285/solve-it-using-union-find?show=16793#c16793