QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#632187#7757. Palm IslandasaltfishWA 1ms5912kbC++231.9kb2024-10-12 12:50:562024-10-12 12:50:57

Judging History

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

  • [2024-10-12 12:50:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5912kb
  • [2024-10-12 12:50:56]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
ll t, n, a[200005], p, b[200005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n;
        deque<int>d;
        for (int i = 1; i <= n; i++)
        {
            cin >> p;
            d.push_back(p);
            b[i] = p;
        }
        for (int i = 1; i <= n; i++)
        {
            cin >> p;
            a[p] = i;
        }
        ll l, r, cur = 0;
        for (int i = 2; i <= n; i++)
        {
            if (a[b[i]] != a[b[i - 1]] + 1)
            {
                cur++;
            }
        }
        string ans = "";
        for (int i = 1; i <= n * n; i++)
        {
            l = d.front();
            d.pop_front();
            r = d.front();
            d.pop_front();
            if (cur == 1 && a[l] > a[r])
            {
                ans.push_back('1'); break;
            }
            if (a[l] != a[r] - 1)cur--;
            if (a[r] != a[d.front()] - 1)cur--;
            if (a[l] > a[r])
            {
                if (a[l] != a[d.front()] - 1)cur++;
                if (a[r] - 1 != a[d.back()])cur++;
                ans.push_back('2');
                d.push_front(l);
                d.push_back(r);
            }
            else
            {
                if (a[r] != a[d.front()] - 1)cur++;
                if (a[l] - 1 != a[d.back()])cur++;
                ans.push_back('1');
                d.push_front(r);
                d.push_back(l);
            }
            if (!cur)
            {
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5604kb

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

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:

11
1211
1222222222222222
1212222222222222222222222
1221222222222222222222222
11
11
1212222222222222
1122222222222222
11
21
1222222222222222
121
211
111
1212222222222222
2222222222222222
1
1111
2122222222222222222222222
1222222222222222
2212222222222222
211
2222222222222222
2221222222222222222222222
...

result:

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