#include <iostream>
#include <vector>
#include <bitset>
int solve(int n, std::vector<int> &line) {
if (n == 2) return 0;
// std::bitset<(int)1e3> misplaced;
// for (int i = 0; i < n; i++) {
// misplaced[i] = true;
// }
for (int i = n-1; i >= 0; i--) {
if (line[i] == i+1) continue;
return line[i];
}
return 0;
}
int main() {
std::ios_base::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
int _; std::cin >> _; while (_--) {
int n; std::cin >> n; std::vector<int> line(n); for (int i = 0; i < n; i++) std::cin >> line[i];
std::cout << solve(n, line) << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |