# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227701 | emil_physmath | 성질 급한 지학이 (IZhO13_crazy) | C++17 | 66 ms | 640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin >> a[i];
--a[i];
}
set<int> res;
for (int x = 0; x < n; ++x)
{
bool poss = true;
vector<int> q;
q.push_back(x);
for (int i = 0; i < n; ++i)
if (i != x)
q.push_back(i);
vector<bool> used(n);
used[a[0]] = true;
for (int i = 1; i < n; ++i)
{
if (!used[q[i]] && a[i] != q[i])
{
poss = false;
break;
}
used[a[i]] = true;
}
if (poss)
res.insert(x);
}
if (res.size() == 1)
cout << *res.begin() + 1 << '\n';
else
cout << 0 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |