This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define pb push_back
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define mod 9871
const int mxn=1e6,inf=1e7;
set<pii>x[mxn+10];
set<pii>y[mxn+10];
ppii mxx[mxn+10],mxy[mxn+10];
int32_t main(){
fastio
int n;cin>>n;
string a="";
for(int i=0;i<n;i++)a+='0';
for(int i=0;i<=mxn;i++)mxx[i].f.f=mxy[i].f.f=inf,mxx[i].s.f=mxy[i].s.f=-1;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
x[a].insert({b,i});
y[b].insert({a,i});
mxx[a].f=min(mxx[a].f,{b,i});
mxx[a].s=max(mxx[a].s,{b,i});
mxy[b].f=min(mxy[b].f,{a,i});
mxy[b].s=max(mxy[b].s,{a,i});
}
bool yes=false;
for(int i=1;i<=mxn;i++){
if(x[i].size()==0)continue;
auto it=x[i].begin(),it2=x[i].end();
it2--;
while(it!=it2){
yes=false;
if(i!=mxy[it->f].f.f&&i!=mxy[it->f].s.f&&mxy[it->f].f.f!=inf){
it++,yes=true;
a[mxy[it->f].f.s]='1';
a[mxy[it->f].s.s]='1';
}
if(it==it2)break;
if(i!=mxy[it2->f].f.f&&i!=mxy[it2->f].s.f&&mxy[it2->f].f.f!=inf){
it2--,yes=true;
a[mxy[it2->f].f.s]='1';
a[mxy[it2->f].s.s]='1';
}
if(!yes)break;
}
if(i==mxy[it->f].f.f||i==mxy[it->f].s.f||mxy[it->f].f.f==inf)a[it->s]='1';
if(i==mxy[it2->f].f.f||i==mxy[it2->f].s.f||mxy[it2->f].f.f==inf)a[it2->s]='1';
}
/*
for(int i=1;i<=mxn;i++){
if(y[i].size()==0)continue;
auto it=y[i].begin(),it2=y[i].end();
it2--;
while(it!=it2){
yes=false;
if(i!=mxx[it->f].f&&i!=mxx[it->f].s&&mxx[it->f].f!=inf)it++,yes=true;
if(it==it2)break;
if(i!=mxx[it2->f].f&&i!=mxx[it2->f].s&&mxx[it2->f].f!=inf)it2--,yes=true;
if(!yes)break;
}
if(i==mxx[it->f].f||i==mxx[it->f].s||mxx[it->f].f==inf)a[it->s]='1';
if(i==mxx[it2->f].f||i==mxx[it2->f].s||mxx[it2->f].f==inf)a[it2->s]='1';
}
*/
cout<<a;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |