QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#712013#7757. Palm Islandtassei903#WA 1ms3816kbC++231.1kb2024-11-05 14:17:462024-11-05 14:17:47

Judging History

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

  • [2024-11-05 14:17:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2024-11-05 14:17:46]
  • 提交

answer


#include <bits/stdc++.h>
#include <bits/extc++.h> 
using namespace std;
#define sz(x) (int)(x).size()
#define rep(i, l, r) for (int i = l; i < (r); i++)
#define rrep(i, l, r) for(int i = (int)(r)-1; i >= (int)(l); i--)
#define all(x) begin(x), end(x)

using ll = long long;
using vi = vector<int>;

using pii = pair<int, int>;

void solve() {
    std::cin.tie(0)->sync_with_stdio(0);

    
    int n;cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n)cin >> a[i];
    rep(i, 0, n)cin >> b[i];
    rep(i, 0, n) {
        a[i]--;
        b[i]--;
        c[b[i]] = a[i];
    }
    // rep(i, 0, n) cout << c[i] << " ";cout << endl;
    string ans;
    rep(i, 0, n) {
        rep(j, 0, n-1) {
            if (c[j] > c[j+1]) {
                ans += "2";
                swap(c[j], c[j+1]);
            }
            else {
                ans += "1";
            }
        }
        ans += "1";
    }
    // rep(i, 0, n) cout << c[i] << " ";cout << endl;
    cout << ans << endl;
}

int main() {

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

详细

Test #1:

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

input:

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

output:

221111111
2111111111111111

result:

ok Correct. (2 test cases)

Test #2:

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

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:

121211111
2221121121111111
2221111111111111
2222122211121111111111111
2212111211121111111111111
2221221121111111
121211111
2221121111111111
1221111111111111
221111111
211111111
2221221111111111
121111111
121111111
1222112211211111111111111
2221211111111111
2121111111111111
121211111
1111111111111111...

result:

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