QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234088#2264. Secrets of Legendary TreasureNYCU_CartesianTree#WA 0ms3808kbC++202.1kb2023-11-01 13:50:222023-11-01 13:50:23

Judging History

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

  • [2023-11-01 13:50:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2023-11-01 13:50:22]
  • 提交

answer

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

#define pb push_back
#define F first
#define S second


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;
    int vis[n+m+5]={0};
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]) vis[a[i]]=1,now.push({a[i],i});
    }
    for(int i=1;i<=m;i++) {
        cin>>b[i];
        if(b[i]) vis[b[i]]=1,now.push({b[i],n+i+1});
    }
    // now.push({n+m+1,n+1});now.push({n+m+1,n+m+2});
    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";
}

詳細信息

Test #1:

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

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

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: 0
Accepted
time: 0ms
memory: 3600kb

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 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #4:

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

input:

97 83
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 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 ...

output:

1 2 3 4 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 ...

result:

ok correct

Test #5:

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

input:

92 90
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 0 0 0
89 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:

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 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 90 91 92 93 
89 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #6:

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

input:

96 100
97 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 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:

97 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 1...

result:

ok correct

Test #7:

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

input:

87 98
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 87
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...

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 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 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #8:

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

input:

83 83
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 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 ...

output:

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ...

result:

ok correct

Test #9:

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

input:

94 89
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 0 0 0 0 0
95 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:

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 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 93 94 
95 96 97 98 99 100 101 102...

result:

ok correct

Test #10:

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

input:

95 99
100 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 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:

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 ...

result:

ok correct

Test #11:

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

input:

90 99
0 0 6 0 0 0 16 0 19 0 21 23 27 29 31 34 35 37 0 44 46 0 49 0 53 54 0 0 0 0 65 66 67 0 71 0 74 75 0 77 0 79 80 82 84 85 0 0 95 97 102 0 105 0 109 0 111 112 0 115 116 120 0 124 127 0 130 134 0 137 141 0 144 148 150 151 153 0 160 165 0 0 171 0 0 0 185 0 187 188
1 0 5 8 11 12 0 14 15 18 22 0 0 0 0...

output:

2 3 6 7 9 10 16 17 19 20 21 23 27 29 31 34 35 37 38 44 46 45 49 52 53 54 57 58 59 61 65 66 67 70 71 73 74 75 76 77 78 79 80 82 84 85 92 94 95 97 102 104 105 106 109 110 111 112 114 115 116 120 123 124 127 129 130 134 136 137 141 143 144 148 150 151 153 154 160 165 164 170 171 179 180 181 185 186 187...

result:

wrong answer A is not sorted.