QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658266#7757. Palm IslandXiaoMo247WA 1ms3660kbC++201.3kb2024-10-19 16:30:242024-10-19 16:30:27

Judging History

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

  • [2024-10-19 16:30:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2024-10-19 16:30:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
ll Tex, n, x;
string a, b;
void AC(){
    cin >> n;
    a.clear(); b.clear();
    a = " "; b = " ";
    for(int i = 1; i <= n; i ++){
        cin >> x;
        a.push_back(x + '0');
    }
    for(int i = 1; i <= n; i ++){
        cin >> x;
        b.push_back(x + '0');
    }
    for(int i = n; i >= 1; i --){
        if(b[i] == a[i]) continue;
        ll idx = a.find(b[i]);
        // cout << " " << i << "\n";
        string q1, q2, q3, q4;
        q4.push_back(b[i]);
        if(idx - 1 > 0) q1 = a.substr(1, idx - 1);
        if(i - idx > 0) q2 = a.substr(idx + 1, i - idx);
        if(n - i > 0) q3 = a.substr(i + 1, n - i);
        if(i == n){
            cout << string(idx, '1');
        }
        else{
            cout << string(idx - 1, '1');
            cout << string(i - idx, '2');
            cout << string(n - i + 1, '1');
        }
        a.clear(); a = " ";
        if(q1.size()) a += q1;
        if(q2.size()) a += q2;
        if(q4.size()) a += q4;
        if(q3.size()) a += q3;
    }
    cout << endl;
}
int main(){
    // freopen("L.in", "r", stdin);
    ios::sync_with_stdio(false);
    // cin.tie(0);cout.tie(0);
    cin >> Tex;
    while(Tex --) AC();
    return 0;
}

详细

Test #1:

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

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

1
2111

result:

ok Correct. (2 test cases)

Test #2:

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

input:

200
3
3 1 2
2 3 1
4
2 4 1 3
2 1 4 3
4
1 4 2 3
2 1 3 4
5
4 3 2 1 5
2 4 5 3 1
5
2 1 5 4 3
5 2 4 1 3
4
4 3 1 2
1 2 4 3
3
1 2 3
3 1 2
4
1 4 2 3
2 1 4 3
4
1 3 2 4
1 4 3 2
3
3 2 1
1 3 2
3
2 3 1
1 3 2
4
1 4 3 2
3 1 2 4
3
1 2 3
1 3 2
3
3 2 1
2 3 1
5
5 1 3 2 4
2 4 5 1 3
4
4 3 1 2
1 4 3 2
4
1 3 4 2
2 4 3 1
3
...

output:

11211
1211
112111
11111221121111
1221121111
112211
11211
12112111
1111211
11211
1211
112111
11
211
1111221122111
12112111
122112111
1

1112221121111
1122112111
22112111
11122112111
11211
222111211121111
1
1111211
1221122111
1122112111
11
11
122112111
211
1121111
1111222112211121111
2221121111
211
11...

result:

wrong answer On Case#1: After your operations, a[1] = 3 but a[1] = 2. (test case 1)