QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#559432#8835. Goodmansnow#WA 1ms3816kbC++23896b2024-09-11 22:01:072024-09-11 22:01:08

Judging History

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

  • [2024-09-11 22:01:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2024-09-11 22:01:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll a[n + 1] = {0},b[n+1]={0},c[n+1]={0};
        map<ll, ll> mp;
        map<ll, ll> p;
        for (ll i = 1; i <= n; i++)
        {
            cin >> a[i];
            b[a[i]]=i;
        }
        for(ll i=1;i<=n;i++)
        {
            if(a[i]==i)
                cout<<i<<' ';
        }
        for(ll i=1;i<=n;i++)
        {
            if(a[i]!=i&&c[i]==0)
            {
                cout<<i<<' ';
                c[i]=1;
                if(c[b[i]]==0)
                {
                    cout<<b[i]<<' ';
                    c[b[i]]=1;
                }
            }
        }
        cout<<'\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

input:

2
4
1 2 3 4
6
6 5 4 3 2 1

output:

1 2 3 4 
1 6 2 5 3 4 

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3816kb

input:

873
6
1 5 2 4 6 3
6
5 1 6 4 3 2
4
1 4 3 2
6
2 1 6 5 4 3
6
4 5 1 3 6 2
6
6 2 1 5 4 3
5
1 5 4 3 2
6
1 2 6 3 5 4
4
2 1 3 4
6
1 6 4 2 3 5
6
6 1 3 5 2 4
6
2 1 4 5 3 6
6
3 4 1 5 2 6
6
4 1 5 2 6 3
6
5 2 1 4 6 3
6
4 1 6 2 3 5
6
5 1 3 4 6 2
6
6 2 5 4 1 3
6
6 2 5 1 4 3
6
5 2 3 6 4 1
6
6 1 2 5 4 3
6
2 3 4 6 1 ...

output:

1 4 2 3 5 6 
4 1 2 3 5 6 
1 3 2 4 
1 2 3 6 4 5 
1 3 2 6 4 5 
2 1 3 4 5 6 
1 2 5 3 4 
1 2 5 3 4 6 
3 4 1 2 
1 2 4 3 5 6 
3 1 2 4 6 5 
6 1 2 3 5 4 
6 1 3 2 5 4 
1 2 3 6 4 5 
2 4 1 3 5 6 
1 2 3 5 4 6 
3 4 1 2 5 6 
2 4 1 5 3 6 
2 1 4 3 6 5 
2 3 1 6 4 5 
1 2 3 6 4 5 
1 5 2 3 4 6 
4 1 5 2 3 6 
2 1 4 3 5 6...

result:

wrong answer Jury found better answer than participant (test case 1)