QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#265885#2337. AzulejosInfinityNS#AC ✓437ms40428kbC++141.8kb2023-11-25 22:07:342024-01-17 03:19:25

Judging History

This is the latest submission verdict.

  • [2024-01-17 03:19:25]
  • 管理员手动重测该提交记录
  • Verdict: AC
  • Time: 437ms
  • Memory: 40428kb
  • [2023-11-25 22:07:34]
  • Submitted

answer

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

const int N=500050;
array<int,3> a[N],b[N];

void No(){
    printf("impossible\n");
    exit(0);
}
int main(){
    int n;
    scanf("%i",&n);
    for(int i=1;i<=n;i++){
        a[i][2]=i;
        scanf("%i",&a[i][0]);
    }
    for(int i=1;i<=n;i++){
        scanf("%i",&a[i][1]);
    }
    for(int i=1;i<=n;i++){
        b[i][2]=i;
        scanf("%i",&b[i][0]);
    }
    for(int i=1;i<=n;i++){
        scanf("%i",&b[i][1]);
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    int asz=1,bsz=1;
    set<pair<int,int>> A,B;
    vector<int> Pa,Pb;
    while(asz<=n || bsz<=n){
        if(A.empty()){
            int i;
            for(i=asz;i<=n&&a[asz][0]==a[i][0];i++){
                A.insert({a[i][1],a[i][2]});
            }
            asz=i;
        }
        if(B.empty()){
            int i;
            for(i=bsz;i<=n&&b[bsz][0]==b[i][0];i++){
                B.insert({b[i][1],b[i][2]});
            }
            bsz=i;
        }
        if(A.size()<B.size()){
            for(auto it:A){
                auto jt=B.lower_bound({it.first,0});
                if(jt==B.begin()){
                    No();
                }
                jt--;
                Pa.pb(it.second);
                Pb.pb(jt->second);
                B.erase(jt);
            }
            A.clear();
        }else{
            for(auto it:B){
                auto jt=A.upper_bound({it.first,n+5});
                if(jt==A.end()){
                    No();
                }
                Pa.pb(jt->second);
                Pb.pb(it.second);
                A.erase(jt);
            }
            B.clear();
        }
    }
    for(int x:Pa)printf("%i ",x);printf("\n");
    for(int x:Pb)printf("%i ",x);printf("\n");
    return 0;
}

详细

Test #1:

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

Test #2:

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

Test #3:

score: 0
Accepted
time: 1ms
memory: 5780kb

Test #4:

score: 0
Accepted
time: 1ms
memory: 5800kb

Test #5:

score: 0
Accepted
time: 1ms
memory: 5852kb

Test #6:

score: 0
Accepted
time: 1ms
memory: 5992kb

Test #7:

score: 0
Accepted
time: 1ms
memory: 5784kb

Test #8:

score: 0
Accepted
time: 1ms
memory: 5804kb

Test #9:

score: 0
Accepted
time: 1ms
memory: 5788kb

Test #10:

score: 0
Accepted
time: 1ms
memory: 5804kb

Test #11:

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

Test #12:

score: 0
Accepted
time: 283ms
memory: 38880kb

Test #13:

score: 0
Accepted
time: 1ms
memory: 5780kb

Test #14:

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

Test #15:

score: 0
Accepted
time: 5ms
memory: 6624kb

Test #16:

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

Test #17:

score: 0
Accepted
time: 1ms
memory: 5776kb

Test #18:

score: 0
Accepted
time: 1ms
memory: 5776kb

Test #19:

score: 0
Accepted
time: 1ms
memory: 6064kb

Test #20:

score: 0
Accepted
time: 1ms
memory: 5740kb

Test #21:

score: 0
Accepted
time: 1ms
memory: 5820kb

Test #22:

score: 0
Accepted
time: 57ms
memory: 7372kb

Test #23:

score: 0
Accepted
time: 57ms
memory: 11120kb

Test #24:

score: 0
Accepted
time: 68ms
memory: 12824kb

Test #25:

score: 0
Accepted
time: 43ms
memory: 10984kb

Test #26:

score: 0
Accepted
time: 242ms
memory: 38904kb

Test #27:

score: 0
Accepted
time: 53ms
memory: 14612kb

Test #28:

score: 0
Accepted
time: 59ms
memory: 14876kb

Test #29:

score: 0
Accepted
time: 43ms
memory: 11632kb

Test #30:

score: 0
Accepted
time: 39ms
memory: 11852kb

Test #31:

score: 0
Accepted
time: 437ms
memory: 40428kb

Test #32:

score: 0
Accepted
time: 71ms
memory: 11904kb

Test #33:

score: 0
Accepted
time: 346ms
memory: 39160kb