QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518880#7757. Palm IslandQFshengxiu#WA 0ms5604kbC++202.2kb2024-08-14 13:38:482024-08-14 13:38:51

Judging History

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

  • [2024-08-14 13:38:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5604kb
  • [2024-08-14 13:38:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define lowbit(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define inf 0x3f3f3f3f3f3f3f3f
#define int long long
#define pai 3.14
#define QF ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
// #define width cout << ""
using ll = long long;
using PII = pair<int, int>;
using LD = long double;
mt19937_64 rnd(chrono::duration_cast<chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
constexpr int N = 3e5 + 10;
map<int, int> mp;
int a[N], b[N];
void printer(vector<int> v)
{
    for (auto x : v)
    {
        cout << x << " ";
    }
    cout << endl;
}

void solve(int caseT)
{
    int n;
    cin >> n;
    list<int> l;
    set<PII> vis;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        l.push_back(a[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
        mp[b[i]] = i;
    }
    int cnt = 0;
    while (true)
    {

        list<int>::iterator it = l.begin();
        list<int>::iterator it2 = ++l.begin();
        list<int>::iterator it3 = --l.end();
        if (cnt >= n)
            break;
        // if (mp[*(it3)] == mp[*(it)] - 1)
        // {
        //     cnt++;
        //     l.push_back(*it);
        //     l.erase(it);
        //     cout << 1;
        //     continue;
        // }
        // if (mp[*(it3)] == mp[*(it2)] - 1)
        // {
        //     cout << 2;
        //     cnt = 0;
        //     l.push_back(*it2);
        //     l.erase(it2);
        //     continue;
        // }
        if (mp[*(it2)] < mp[*(it)] && !vis.count({*(it2), *(it)}))
        {
            cout << 2;
            cnt = 0;
            vis.insert({*(it2), *(it)});
            l.push_back(*it2);
            l.erase(it2);
        }
        else
        {
            cnt++;
            l.push_back(*it);
            l.erase(it);
            cout << 1;
        }
    }
}
signed main()
{
    QF;
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve(i);
        cout << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5604kb

input:

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

output:

22111
2112221111

result:

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