QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#382810#6506. Chase Game 3paoxiaomo#WA 0ms3652kbC++201.0kb2024-04-08 19:20:232024-04-08 19:20:23

Judging History

你现在查看的是最新测评结果

  • [2024-04-08 19:20:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-04-08 19:20:23]
  • 提交

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]