QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423005#8179. 2D ParenthesesheaksicnCompile Error//C++141.9kb2024-05-27 20:46:382024-05-27 20:46:39

Judging History

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

  • [2024-05-27 20:46:39]
  • 评测
  • [2024-05-27 20:46:38]
  • 提交

answer

//Man always remember love because of romance only!
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int n=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) n=(n<<3)+(n<<1)+(ch^48),ch=getchar();
    return w?-n:n;
}
inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int x[200001],y[200001],xx[200001],yy[200001];
int p[200001],q[200001]; 
bool cmp1(int a,int b){
	if(x[a]==x[b]) return yy[a]<yy[b];
	return x[a]<x[b];
}
bool cmp2(int a,int b){	
	if(xx[a]==xx[b]) return yy[a]<yy[b];
	return xx[a]<xx[b];
}
int c[200001];
int main(){
	int n=read();
	for(int i=1;i<=n;i++) x[i]=read(),y[i]=read();
	for(int i=1;i<=n;i++) xx[i]=read(),yy[i]=read();
	for(int i=1;i<=n;i++) q[i]=i,p[i]=i;
	sort(q+1,q+n+1,cmp2);
	sort(p+1,p+n+1,cmp1);
    int j=1;
    set<array<int,3>> s;
    for(int i=1;i<=n;i++){
    	while(j<=n&&x[p[j]]<xx[q[i]]){
    		s.insert({y[p[j]],x[p[j]],p[j]});
    		j++;
		}
		auto it=s.lower_bound({yy[q[i]],-1000000000,1});
		if(it==s.begin()){
			puts("No");
			return 0;
		}
		it--;
		s.erase(it);
		c[(*it)[2]]=q[i];
	}
    vector<array<int,4>> a;
    for(int i=1;i<=n;i++){
    	int j=c[i];
    	a.push_back({x[i],2,y[i]});
    	a.push_back({xx[j],0,yy[j]});
    	a.push_back({x[i],2,yy[j]});
    	a.push_back({xx[j],0,y[i]});
    	a.push_back({x[i],1,y[i],yy[j]});
    	a.push_back({xx[j],1,y[i],yy[j]});
	}
    sort(a.begin(),a.end());
    multiset<int> S;
    for(auto [x,op,y1,y2]:a){
        if(op==0) S.extract(y1);
        else if(op==2) S.insert(y1);
        else{
            auto it=S.upper_bound(y1);
            if(it!=S.end()&&(*it)<y2){
            	puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    for(int i=1;i<=n;i++) write(c[i]),putchar('\n');
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:61:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   61 |     for(auto [x,op,y1,y2]:a){
      |              ^
answer.code:62:21: error: ‘class std::multiset<int>’ has no member named ‘extract’
   62 |         if(op==0) S.extract(y1);
      |                     ^~~~~~~