QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#458838#8835. Goodmanucup-team3474#WA 1ms3536kbC++23912b2024-06-29 19:44:492024-06-29 19:44:50

Judging History

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

  • [2024-06-29 19:44:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2024-06-29 19:44:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std ;
void solve()
{
    int n ;
    cin >> n ;
    vector<int> id(n + 1) ;
    vector<int> p(n + 1) ;
    for(int i = 1 ; i <= n ; i ++)  cin >> p[i] , id[p[i]] = i ;
    int cnt = n ;
    vector<int> ans ;
    vector<int> vis(n + 1 , 0) ;
    for(int i = 1 ; i <= n ; i ++)
        if(p[i] == i)
        {
            ans.push_back(i) ;
            cnt -= 1 ;
            vis[i] = 1 ;
            break ;
        }
    for(int i = 1 ; i <= n ; i ++)
        if(vis[i] == 0)
        {
            vis[i] = 1 ;
            ans.push_back(i) ;
            if(vis[id[i]] == 0)  ans.push_back(id[i]) ;
            vis[id[i]] = 1 ;
        }
    for(auto u : ans)  cout << u << ' ' ; cout << '\n' ;
}
int main()
{
    std::ios::sync_with_stdio(false) , cin.tie(0) ;

    int T ;
    cin >> T ;
    while (T --)  solve() ;
    return 0 ;
}

詳細信息

Test #1:

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

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: 3536kb

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 2 3 4 5 6 
4 1 2 3 5 6 
1 2 4 3 
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 3 4 5 6 
3 1 2 4 
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 1 3 4 5 6 
1 2 3 5 4 6 
3 1 2 4 5 6 
2 1 5 3 6 4 
2 1 4 3 6 5 
2 1 6 3 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)