# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227701 | emil_physmath | Crazy old lady (IZhO13_crazy) | C++17 | 66 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |