[C++] O(n) Time, O(1) Space. 40ms
First count the total number of 1s. If it is not a multiple of 3, then it is not possible. Otherwise divide it by 3, we can get the number of 1s should be in ea
First count the total number of 1s. If it is not a multiple of 3, then it is not possible.
Otherwise divide it by 3, we can get the number of 1s should be in each partition. The only uncertain thing now is the number tailing zeros for each partition. However, this can be easily determined by the last partition.
Now, we konw the number of 1s for each partition and the number of tailing zeros for each partition, we can directly calculate the partition positions. 

C++ code here [wrote in the contest, maybe can be optimize further]:

```
class Solution {
public:
    vector<int> threeEqualParts(vector<int>& A) {
        
        int c = 0; // count the 1
        for (auto& x : A) {
            if (x == 1) {
                ++c;
            }
        }
        
        if (c % 3 != 0) {
            return {-1, -1};
        }
        if (c == 0) {
            return {0,2};
        }
        
        int n = c / 3;
        int nZero = 0;
        for (int i = A.size()-1; i >= 0; --i) {
            if (A[i] == 0) {
                ++nZero;
            }
            else {
                break;
            }
        }
        
        // a and b are the partitioning position
        int a, b;
        
        
        // calculate a
        a = 0;
        c = 0; // count the 1
        while(c < n) {
            if (A[a] == 0) {
                ++a;
            }
            else {
                ++a;
                ++c;
            }
        }
        c = 0; // count the 0
        while(c < nZero) {
            if (A[a] == 0) {
                ++c;
                ++a;
            }
            else {
                return {-1, -1};
            }
        }
        --a;
        
        // calculate b
        b = a + 1;       
        c = 0; // count 1
        while(c < n) {
            if (A[b] == 0) {
                ++b;
            }
            else {
                ++b;
                ++c;
            }
        }
        c = 0; // count 0
        while(c < nZero) {
            if (A[b] == 0) {
                ++c;
                ++b;
            }
            else {
                return {-1, -1};
            }
        }
        
        // verify a, b
        if (verify(A, 0, a, a+1, b-1) && verify(A, 0, a, b, A.size()-1)) {
            return {a, b};
        }
        else {
            return {-1, -1};
        }
    }
private:
    bool verify(vector<int>& A, int lo1, int hi1, int lo2, int hi2) {
        int p1 = lo1;
        int p2 = lo2;
        while(A[p1] == 0 && p1 <= hi1) ++p1;
        while(A[p2] == 0 && p2 <= hi2) ++p2;
        
        if (hi1 - p1 != hi2 - p2) {
            return false;
        }
        
        while(p1 < hi1) {
            if (A[p1] != A[p2]) {
                return false;
            }
            else {
                ++p1;
                ++p2;
            }
        }
        
        return true;
    }
};
```
[]