#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
//#include<bits/extc++.h>
//__gnu_pbds
const int N =1e5+5;
bool in[N];
int dir[N];
ll T[N];
pii pt[N];
bool isstrong[N];
priority_queue<pii,vector<pii>,greater<pii> > pq;
int n;
int get(){
while(pq.size()){
auto cur = pq.top();
pq.pop();
if(cur.first!=T[cur.second]) continue;
if(in[cur.second]) continue;
in[cur.second]=1;
// cout<<cur.second<<" "<<T[cur.second]<<" "<<dir[cur.second]<<"w\n";
int i = cur.second;
for(int j=1;j<=n;j++){
if(in[j]) continue;
ll t=1e18;
int d=-1;
bool strong = 0;
if(dir[i]==1){
if(pt[i].first>pt[j].first) continue;
if(pt[i].second==pt[j].second){
t = (pt[i].first+pt[j].first+1)/2;
d = 2;
}
if(abs(pt[i].first-pt[j].first)==abs(pt[i].second-pt[j].second)){
t = abs(pt[i].first-pt[j].first);
d = (pt[i].second>pt[j].second)?(3):(4);
strong =1;
}
}
if(dir[i]==2){
if(pt[i].first<pt[j].first) continue;
if(pt[i].second==pt[j].second){
t = (pt[i].first+pt[j].first+1)/2;
d = 1;
}
if(abs(pt[i].first-pt[j].first)==abs(pt[i].second-pt[j].second)){
t = abs(pt[i].first-pt[j].first);
d = (pt[i].second>pt[j].second)?(3):(4);
strong =1;
}
}
if(dir[i]==3){
if(pt[i].second>pt[j].second) continue;
if(pt[i].first==pt[j].first){
t = (pt[i].second+pt[j].second+1)/2;
d = 4;
}
if(abs(pt[i].first-pt[j].first)==abs(pt[i].second-pt[j].second)){
t = abs(pt[i].first-pt[j].first);
d = (pt[i].first>pt[j].first)?(1):(2);
strong =1;
}
}
if(dir[i]==4){
if(pt[i].second<pt[j].second) continue;
if(pt[i].first==pt[j].first){
t = (pt[i].second+pt[j].second+1)/2;
d = 3;
}
if(abs(pt[i].first-pt[j].first)==abs(pt[i].second-pt[j].second)){
t = abs(pt[i].first-pt[j].first);
d = (pt[i].first>pt[j].first)?(1):(2);
strong =1;
}
}
//if((t<T[j] || (strong&(isstrong[j]==0)) ) && t>=T[i]){
// if(isstrong[j] && !strong) continue;
T[j]=t;
// isstrong[j]=strong;
dir[j]=d;
pq.push({T[j],j});
//}
}
}
int cnt = 0;
for(int i=1;i<=n;i++) cnt+=in[i];
return cnt;
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>pt[i].first>>pt[i].second;
int dx = -pt[1].first;
int dy = -pt[1].second;
for(int i=1;i<=n;i++){
pt[i].first+=dx;
pt[i].second+=dy;
}
int maxn = 0;
for(int d=1;d<=4;d++){
for(int i=1;i<=n;i++) {in[i]=0;dir[i]=0;T[i]=1e18;}
dir[1]=d;
T[1]=0;
pq.push({0,1});
int g = get();
maxn = max(maxn,g);
while(pq.size()) pq.pop();
}
cout<<maxn<<"\n";
return 0;
}
Compilation message
fever.cpp: In function 'int get()':
fever.cpp:29:9: warning: variable 'strong' set but not used [-Wunused-but-set-variable]
29 | bool strong = 0;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |