# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
832605 |
2023-08-21T12:22:39 Z |
8pete8 |
Towers (NOI22_towers) |
C++17 |
|
388 ms |
123616 KB |
#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,int>
#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;
vector<pii>x[mxn+10];
vector<pii>y[mxn+10];
pii cx[mxn+10];
int cy[mxn+10];
string ans="";
void update(int xx,int di){
bool yes=true;
if(di){
while(cx[xx].f<=cx[xx].s){
yes=true;
if(cy[x[xx][cx[xx].f].f]==-1){
ans[x[xx][cx[xx].f].s]='1';
cy[x[xx][cx[xx].f].f]=0;
}
else{
if(cy[x[xx][cx[xx].f].f]==0)cy[x[xx][cx[xx].f].f]=xx,ans[x[xx][cx[xx].f].s]='1';
else if(cy[x[xx][cx[xx].f].f]<xx){
int nx=cy[x[xx][cx[xx].f].f];
if(x[nx][cx[nx].f].f==x[xx][cx[xx].f].f){
cy[x[xx][cx[xx].f].f]=xx;
ans[x[nx][cx[nx].f].s]='0';
ans[x[xx][cx[xx].f].s]='1';
update(nx,1);
}
else if(x[nx][cx[nx].s].f==x[xx][cx[xx].f].f){
cy[x[xx][cx[xx].f].f]=xx;
ans[x[nx][cx[nx].s].s]='0';
ans[x[xx][cx[xx].f].s]='1';
update(nx,0);
}
}
else cx[xx].f++,yes=false;;
}
if(yes)break;
}
return;
}
while(cx[xx].f<=cx[xx].s){
yes=true;
if(cy[x[xx][cx[xx].s].f]==-1){
ans[x[xx][cx[xx].s].s]='1';
cy[x[xx][cx[xx].s].f]=0;
}
else{
if(cy[x[xx][cx[xx].s].f]==0)cy[x[xx][cx[xx].s].f]=xx,ans[x[xx][cx[xx].s].s]='1';
else if(cy[x[xx][cx[xx].s].f]<xx){
int nx=cy[x[xx][cx[xx].s].f];
if(x[nx][cx[nx].f].f==x[xx][cx[xx].s].f){
cy[x[xx][cx[xx].s].f]=xx;
ans[x[nx][cx[nx].f].s]='0';
ans[x[xx][cx[xx].s].s]='1';
update(nx,1);
}
else if(x[nx][cx[nx].s].f==x[xx][cx[xx].s].f){
cy[x[xx][cx[xx].s].f]=xx;
ans[x[nx][cx[nx].s].s]='0';
ans[x[xx][cx[xx].s].s]='1';
update(nx,0);
}
}
else cx[xx].s--,yes=false;;
}
if(yes)break;
}
}
int32_t main(){
fastio
int n;cin>>n;
vector<ppii>v(n);
for(int i=0;i<n;i++)ans+='0';
for(int i=0;i<n;i++)cin>>v[i].f.f>>v[i].f.s,v[i].s=i;
sort(v.begin(),v.end());
for(auto i:v)x[i.f.f].pb({i.f.s,i.s});
for(int i=0;i<=mxn;i++)cx[i]={-1,-1},cy[i]=-1;
for(int i=1;i<=mxn;i++){
if(x[i].size()==0)continue;
cx[i].f=0;
cx[i].s=x[i].size()-1;
update(i,1);
update(i,0);
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
70740 KB |
Output is correct |
2 |
Correct |
33 ms |
70724 KB |
Output is correct |
3 |
Correct |
39 ms |
70656 KB |
Output is correct |
4 |
Correct |
38 ms |
70744 KB |
Output is correct |
5 |
Correct |
34 ms |
70732 KB |
Output is correct |
6 |
Correct |
35 ms |
70660 KB |
Output is correct |
7 |
Correct |
36 ms |
70736 KB |
Output is correct |
8 |
Incorrect |
34 ms |
70752 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
70740 KB |
Output is correct |
2 |
Correct |
33 ms |
70724 KB |
Output is correct |
3 |
Correct |
39 ms |
70656 KB |
Output is correct |
4 |
Correct |
38 ms |
70744 KB |
Output is correct |
5 |
Correct |
34 ms |
70732 KB |
Output is correct |
6 |
Correct |
35 ms |
70660 KB |
Output is correct |
7 |
Correct |
36 ms |
70736 KB |
Output is correct |
8 |
Incorrect |
34 ms |
70752 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
75340 KB |
Output is correct |
2 |
Correct |
50 ms |
76140 KB |
Output is correct |
3 |
Incorrect |
88 ms |
85868 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
388 ms |
123616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
70740 KB |
Output is correct |
2 |
Correct |
33 ms |
70724 KB |
Output is correct |
3 |
Correct |
39 ms |
70656 KB |
Output is correct |
4 |
Correct |
38 ms |
70744 KB |
Output is correct |
5 |
Correct |
34 ms |
70732 KB |
Output is correct |
6 |
Correct |
35 ms |
70660 KB |
Output is correct |
7 |
Correct |
36 ms |
70736 KB |
Output is correct |
8 |
Incorrect |
34 ms |
70752 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
70740 KB |
Output is correct |
2 |
Correct |
33 ms |
70724 KB |
Output is correct |
3 |
Correct |
39 ms |
70656 KB |
Output is correct |
4 |
Correct |
38 ms |
70744 KB |
Output is correct |
5 |
Correct |
34 ms |
70732 KB |
Output is correct |
6 |
Correct |
35 ms |
70660 KB |
Output is correct |
7 |
Correct |
36 ms |
70736 KB |
Output is correct |
8 |
Incorrect |
34 ms |
70752 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
70740 KB |
Output is correct |
2 |
Correct |
33 ms |
70724 KB |
Output is correct |
3 |
Correct |
39 ms |
70656 KB |
Output is correct |
4 |
Correct |
38 ms |
70744 KB |
Output is correct |
5 |
Correct |
34 ms |
70732 KB |
Output is correct |
6 |
Correct |
35 ms |
70660 KB |
Output is correct |
7 |
Correct |
36 ms |
70736 KB |
Output is correct |
8 |
Incorrect |
34 ms |
70752 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |