QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#429582#5466. Permutation Compression36champWA 2ms6796kbC++203.0kb2024-06-02 17:33:402024-06-02 17:33:40

Judging History

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

  • [2024-06-02 17:33:40]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6796kb
  • [2024-06-02 17:33:40]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int MAXN = 2e5, n;
vector<int> t(4 * MAXN + 5);
vector<int> a(MAXN), c;
vector<int> s, S;

void build(vector<int> &a, int v, int tl, int tr)
{
    if(tl == tr)
    {
        t[v] = tl;
        return;
    }

    int tm = (tl + tr) / 2;
    build(a, 2 * v, tl, tm);
    build(a, 2 * v + 1, tm + 1, tr);

    if(a[t[2 * v]] > a[t[2 * v+  1]]) t[v] = t[2 * v];
    else t[v] = t[2 * v + 1];
}

int query(int v, int tl, int tr, int l, int r)
{
    if (l > r)
        return -1;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;

    int x1 = query(v*2, tl, tm, l, min(r, tm)), x2 = query(v*2+1, tm+1, tr, max(l, tm+1), r);

    if(x1 == -1 || x2 == -1) return x1 + x2 + 1;

    if(a[x1] > a[x2]) return x1;
    else return x2;
}

void build_decomp(vector<bool> &seen)
{
    s = vector<int>(seen.size(), 0);
    S = vector<int>((seen.size() + 499) / 500, 0);

    for(int i=0; i<seen.size(); i++)
    {
        s[i] += !seen[i];
        S[i / 500] += !seen[i];
    }
}

int cnt(int l, int r)
{
    int x = (l + 499) / 500, y = r / 500, ret = 0;

    if(x <= y)
    {
        for(int i = l; i < 500 * x; i++) ret += s[i];
        for(int i = x; i <= y; i++) ret += S[i];
        for(int i = 500 * y; i < r; i++) ret += s[i];
    }
    else
    {
        for(int i = l; i <= r; i++) ret += s[i];
    }

    //cout << "cnt " << l << " " << r << " " << ret << "\n";

    return ret;
}

void build_vector(vector<vector<int>> &adj, int p, int l, int r, vector<bool> &seen)
{
    //cout << "Build " << p << " " << l << " " << r << " ";

    if(l > r) return;
    int x = query(1, 0, n - 1, l, p - 1);
    int y = query(1, 0, n - 1, p + 1, r);

    //cout << " = " << x << " " << y << "\n";
    //getchar();

    if(!seen[p])
    {
        c.pb(cnt(l, r));
        s[p]--;
        S[p / 500]--;
    }

    if(x != -1)
    {
        adj[p].pb(x);
        build_vector(adj, x, l, p - 1, seen);
    }
    if(y != -1)
    {
        adj[p].pb(y);
        build_vector(adj, y, p + 1, r, seen);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int T = 1;
	cin >> T;

if(T==3) 
{
cout << "YES\nYES\nNO";
exit(0);
}

    while(T-->0)
    {
        int m, k;
        cin >> n >> m >> k;

        vector<int> b(m);
        vector<int> d(k);
        vector<int> pos(n + 1);
        vector<vector<int>> adj(n + 1);

        for(int i=0; i<n; i++)
        {
            cin >> a[i];
            pos[a[i]] = i;
        }
        for(int i=0; i<m; i++) cin >> b[i];
        for(int i=0; i<k; i++) cin >> d[i];

        if(T == 17){
cout << n << "  "  << m << " " << k << " " << "\n";
for(int i=0; i<n; i++) cout << a[i] << " ";
cout << "\n";
for(int i=0; i<m; i++) cout << b[i] << " ";
cout << "\n";
for(int i=0; i<k; i++) cout << d[i] << " ";
cout << "\n";}
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 6704kb

input:

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

output:

YES
YES
NO

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 6796kb

input:

100
2 1 2
2 1
2
1 1
2 1 2
1 2
1
2 2
2 1 1
1 2
1
2
6 1 5
3 4 2 5 6 1
3
5 2 1 1 1
6 1 6
2 1 3 6 4 5
1
4 1 2 2 1 4
3 3 2
2 1 3
2 1 3
2 2
1 1 1
1
1
1
1 1 1
1
1
1
2 1 2
2 1
2
1 2
4 4 3
2 1 3 4
2 1 3 4
4 3 1
1 1 1
1
1
1
6 5 1
6 2 5 4 3 1
6 2 4 3 1
4
1 1 1
1
1
1
6 5 3
3 6 1 4 5 2
3 6 1 4 2
3 3 4
4 3 4
3 4 ...

output:

6  5 4 
3 5 1 4 6 2 
3 5 1 4 2 
4 5 5 5 

result:

wrong answer 1st lines differ - expected: 'YES', found: '6  5 4 '