답안 #942847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942847 2024-03-11T05:19:21 Z guagua0407 청소 (JOI20_sweeping) C++17
10 / 100
791 ms 88340 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

struct qry{
    int t,a,b;
};

const int mxn=2e6+5;
int x[mxn],y[mxn];
int prv[mxn];
vector<int> xs;
vector<int> segtree(mxn*4,-1);

void update(int pos,int val,int l=0,int r=xs.size()-1,int v=1){
    if(l==r){
        segtree[v]=max(segtree[v],val);
        return;
    }
    int mid=(l+r)/2;
    if(pos<=mid) update(pos,val,l,mid,v*2);
    else update(pos,val,mid+1,r,v*2+1);
    segtree[v]=max(segtree[v*2],segtree[v*2+1]);
}

int search(int tl,int tr,int val,int l=0,int r=xs.size()-1,int v=1){
    if(r<tl or tr<l){
        return -1;
    }
    if(segtree[v]<val){
        return -1;
    }
    if(l==r) return l;
    int mid=(l+r)/2;
    int res=search(tl,min(mid,tr),val,l,mid,v*2);
    if(res!=-1) return res;
    return search(max(mid+1,tl),tr,val,mid+1,r,v*2+1);
}

int main() {_
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++){
        cin>>x[i]>>y[i];
    }
    vector<qry> qs(q);
    for(int i=0;i<q;i++){
        cin>>qs[i].t>>qs[i].a;
        if(qs[i].t==4) cin>>qs[i].b;
        if(qs[i].t==2) xs.push_back(qs[i].a);
    }
    sort(all(xs));
    xs.resize(unique(all(xs))-xs.begin());
    int cur=m;
    for(int i=0;i<q;i++){
        int t=qs[i].t;
        int a=qs[i].a;
        int b=qs[i].b;
        if(t==1){
            int pos=lower_bound(all(xs),y[a])-xs.begin();
            int res=search(pos,xs.size()-1,prv[a]);
            if(res!=-1){
                x[a]=max(x[a],n-xs[res]);
            }
            //cout<<res<<'\n';
            cout<<x[a]<<' '<<y[a]<<'\n';
            prv[a]=i;
        }
        else if(t==2){
            int pos=lower_bound(all(xs),a)-xs.begin();
            update(pos,i);
        }
        else{
            prv[++m]=i;
            x[m]=a;
            y[m]=b;
        }
    }
    return 0;
}
//maybe its multiset not set
//yeeorz
//laborz

Compilation message

sweeping.cpp: In function 'int main()':
sweeping.cpp:68:9: warning: unused variable 'cur' [-Wunused-variable]
   68 |     int cur=m;
      |         ^~~
sweeping.cpp: In function 'void setIO(std::string)':
sweeping.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sweeping.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 35928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 661 ms 88008 KB Output is correct
2 Correct 743 ms 88340 KB Output is correct
3 Correct 791 ms 88188 KB Output is correct
4 Correct 515 ms 87164 KB Output is correct
5 Correct 536 ms 87756 KB Output is correct
6 Correct 605 ms 88016 KB Output is correct
7 Correct 677 ms 88332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 668 ms 87500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 668 ms 87500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 35928 KB Output isn't correct
2 Halted 0 ms 0 KB -