QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#382810 | #6506. Chase Game 3 | paoxiaomo# | WA | 0ms | 3652kb | C++20 | 1.0kb | 2024-04-08 19:20:23 | 2024-04-08 19:20:23 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
using vi = vector<int>;
#define endl '\n'
void solve()
{
int n;
cin >> n;
vector<int> v(n + 1);
bool is1 = 1, is2 = 1, is3 = 1;
for (int i = 1; i <= n; i++)
{
cin >> v[i];
}
for (int i = 1; i <= n; i++)
{
if (v[i] != i)
is1 = 0;
if (v[i] != n - i + 1)
is2 = 0;
}
for (int i = 1; i <= n; i++)
{
if (v[i] != i)
{
if (i != n && v[i + 1] == i)
swap(v[i + 1], v[i]);
else if (i != 1 && v[i - 1] == i)
swap(v[i - 1], v[i]);
else
is3 = 0;
}
}
if (n == 2 || n == 3 || is1 || is2 || is3)
{
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3652kb
input:
5 2 1 2 3 2 3 1 4 1 4 3 2 5 1 5 2 3 4 6 1 2 3 4 5 6
output:
Yes Yes No Yes Yes
result:
wrong answer expected NO, found YES [4th token]