#include #include #include #include #include #include using namespace std; // Find existence of 213 relative permutation in n lg n time. bool solve(){ int n; cin >> n; deque> xy(n), yx(n); // map one coord to the other coord for(int x = 0; x < n; ++x){ int y; cin >> y; xy[x] = {x, y}; yx[x] = {y, x}; } sort(begin(xy), end(xy)); sort(begin(yx), end(yx)); // Repeatedly drop points: // - bottom left // - top left // - bottom right while(!xy.empty()){ if(xy.front().second == yx.front().first){ xy.pop_front(); yx.pop_front(); continue; } if(xy.front().second == yx.back().first){ xy.pop_front(); yx.pop_back(); continue; } if(xy.back().second == yx.front().first){ xy.pop_back(); yx.pop_front(); continue; } break; } // If there are >= 3 points left: success! assert(xy.size() == yx.size()); return xy.size() >= 3; } int main(){ int ts; cin >> ts; vector ans; for(int t = 1; t <= ts; ++t) if(solve()) ans.push_back(t); cout << ans.size() << endl; for(auto x : ans) cout << x << endl; }