QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607864#3873. Towerspanyifan2021Compile Error//C++141.3kb2024-10-03 16:47:402024-10-03 16:47:41

Judging History

This is the latest submission verdict.

  • [2024-10-03 16:47:41]
  • Judged
  • [2024-10-03 16:47:40]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
int n;
int ex[1000005],ey[1000005];
vector<int> col[1000005],t;
int l[1000005],r[1000005];
set<int> row[1000005];
bool ans[1000005];
queue<int> q;
void add(int x){
	ans[x]=1;
	row[ex[x]].insert(ey[x]);
	if(row[ex[x]].size()>2) 
	q.push(ex[x]);
}
void del(int x){
	ans[x]=0;
	row[ex[x]].erase(ey[x]);
}
int main(){
	cin>>n;
	int mx=0;
	for(int i=1;i<=n;i++){
		cin>>ex[i]>>ey[i];
		col[ey[i]].push_back(i);
		mx=max(mx,ey[i])
	}
	for(int i=1;i<=mx;i++){
		if(!col[i].size()) continue;
		sort(col[i].begin(),col[i].end(),[](int i,int j){return ex[i]<ex[j];});
		l[i]=0;
		r[i]=col[i].size()-1;
		add(col[i][l[i]]);
		if(l[i]!=r[i])
		add(col[i][r[i]]);
	}
	while(q.size()){
		int x=q.front();
		q.pop();
		if(row[x].size()<=2) continue;
		int ly=*row[x].begin(),ry=*--row[x].end();
		t.clear();
		for(int y:row[x]) if(y!=ly&&y!=ry) t.push_back(y);
		for(int y:t){
			if(y==ly||y==ry) continue;
			if(l[y]>r[y]) continue;
			if(l[y]==r[y]) del(col[y][l[y]++]);
			else if(x==ex[col[y][l[y]]]){
				del(col[y][l[y]++]);
				if(l[y]<r[y]) add(col[y][l[y]]);
			}
			else{
				del(col[y][r[y]--]);
				if(l[y]<r[y]) add(col[y][r[y]]);
			}
		}
	}
	for(int i=1;i<=n;i++) 
	cout<<ans[i];
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:26:33: error: expected ‘;’ before ‘}’ token
   26 |                 mx=max(mx,ey[i])
      |                                 ^
      |                                 ;
   27 |         }
      |         ~