Submission #915459

# Submission time Handle Problem Language Result Execution time Memory
915459 2024-01-24T02:24:53 Z guagua0407 Minerals (JOI19_minerals) C++17
0 / 100
1 ms 600 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second

vector<int> a;
vector<pair<int,int>> vec;

void go(int l,int r,vector<int> &b,int id){
    if(l==r){
        Query(a[l]);
        assert((int)b.size()==1);
        vec.push_back({a[l],b[0]});
        return;
    }
    int mid=(l+r)/2;
    int cur=0;
    if(id==0 or id==1){
        for(int i=l;i<=mid;i++){
            cur=Query(a[i]);
        }
    }
    else{
        for(int i=mid+1;i<=r;i++){
            cur=Query(a[i]);
        }
    }
    vector<int> ls,rs;
    for(auto v:b){
        int x=Query(v);
        if(x==cur){
            ls.push_back(v);
        }
        else{
            rs.push_back(v);
        }
        cur=x;
    }
    vector<int>().swap(b);
    if(id==0 or id==2){
        go(l,mid,ls,3);
        go(mid+1,r,rs,1);
    }
    else{
        go(l,mid,ls,2);
        go(mid+1,r,rs,0);
    }
}

void Solve(int n){
    vector<bool> ok(2*n+1);
    int prv=0;
    for(int i=1;i<=2*n;i++){
        int x=Query(i);
        if(x==prv+1){
            ok[i]=true;
        }
        prv=x;
    }
    vector<int> b;
    for(int i=1;i<=2*n;i++){
        if(ok[i]) a.push_back(i);
        else b.push_back(i);
    }
    go(0,n-1,b,1);
    for(auto v:vec){
        Answer(v.f,v.s);
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -