QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707230#8835. Goodmansenak#WA 2ms3840kbC++20894b2024-11-03 15:12:262024-11-03 15:12:26

Judging History

This is the latest submission verdict.

  • [2024-11-03 15:12:26]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3840kb
  • [2024-11-03 15:12:26]
  • Submitted

answer

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int N = 2e5 + 7;
int arr[1000005];
void solve() {
    int n; cin >> n;
    map<int, int>mp;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        mp[arr[i]] = i;
    }
    int l = 1,flag=0,r=1;
    for (int i = 1; i <= n; i++)
    {
        if (flag)
        {
            if (mp[arr[l - 1]] == arr[l - 1])
                i--;
            else cout << arr[l - 1] << " ";
            flag = 0;
        }
        else
        {
            cout << l << " ";
            flag = 1;
            l++;
        }
    }
    cout << endl;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t; cin >> t;while(t--) solve();
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 2ms
memory: 3840kb

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

result:

wrong answer Participant didn't find permutation (test case 1)