QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#234085#2264. Secrets of Legendary TreasureNYCU_CartesianTree#WA 0ms3876kbC++202.2kb2023-11-01 13:48:202023-11-01 13:48:21

Judging History

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

  • [2023-11-01 13:48:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2023-11-01 13:48:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define F first
#define S second
int const N = 105;
bool xy[N][N], yz[N][N], xz[N][N], ans[N][N][N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;

    int a[n+5],b[m+5];


    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]) now.push({a[i],i});
    }
    for(int i=1;i<=m;i++) {
        cin>>b[i];
        if(b[i]) now.push({b[i],n+i+1});
    }
    // now.push({n+m+1,n+1});now.push({n+m+1,n+m+2});
    int vis[n+m+5]={0};
    while(now.size()){
        auto t=now.top();
        now.pop();
        if(t.S<=n+1){
            int id=t.S-1,p=a[t.S]-1;
            while(id>=1&&a[id]==0){
                while(vis[p]) p--;
                a[id]=p;vis[p]=1;
                id--;
            }
        }
        else{
            t.S-=n+1;
            int id=t.S-1;int p=b[t.S]-1;
            while(id>=1&&b[id]==0){
                while(vis[p]) p--;
                b[id]=p;
                vis[p]=1;
                id--;
            }
        }
    }
    a[0]=0,b[0]=0;
    int x1=0,v1=0,x2=0,v2=0;   
    for(int i=n;i>=1;i--){
        if(a[i]){
            x1=i,v1=a[i];
            break;
        }
    }

    for(int i=m;i>=1;i--){
        if(b[i]){
            x2=i,v2=b[i];
            break;
        }
    }

    if(v1<v2){
        // cerr<<x1<<" "<<x2<<" "<<v1<<" "<<v2<<"\n";
        int p=a[x1]+1;
        for(int i=x1+1;i<=n;i++){
            while(vis[p]) p++;
            a[i]=p,vis[p]=1;
        }
        p=b[x2]+1;
        for(int i=x2+1;i<=m;i++){
            while(vis[p]) p++;
            b[i]=p,vis[p]=1;
        }
    }
    else{
        int p=b[x2]+1;
        for(int i=x2+1;i<=m;i++){
            while(vis[p]) p++;
            b[i]=p,vis[p]=1;
        }
        p=a[x1]+1;
        for(int i=x1+1;i<=n;i++){
            while(vis[p]) p++;
            a[i]=p,vis[p]=1;
        }
    }

    for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<"\n";
    for(int i=1;i<=m;i++) cout<<b[i]<<" ";cout<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

100 100
1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 ...

output:

1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 175 177 ...

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

99 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
37

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 
37 

result:

ok correct

Test #3:

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

input:

90 96
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 
1 2 92 93 94 95 96 97 98 99 100 101 ...

result:

wrong answer duplicated element 92