/**
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 3010;
struct point
{
int x, y;
}p[maxn];
int n, used[maxn], dir[maxn];
/**
directions:
0 - north
1 - east
2 - south
3 - west
*/
void simulate()
{
///cout << "simulate " << dir[1] << endl;
queue < int > q;
q.push(1);
while(!q.empty())
{
int cur = q.front();
q.pop();
///cout << cur << endl;
for (int i = 1; i <= n; i ++)
{
if (used[i] != -1)
continue;
if ((p[i].x + p[i].y != p[cur].x + p[cur].y) &&
(p[i].y - p[i].x != p[cur].y - p[cur].x))
continue;
///cout << cur << " : " << i << endl;
if (dir[cur] == 0)
{
if (p[i].y < p[cur].y)
continue;
int nec = p[i].y - p[cur].y;
if (nec > used[cur])
{
used[i] = nec;
q.push(i);
if (p[i].x < p[cur].x)
dir[i] = 1;
else
dir[i] = 3;
}
}
else if (dir[cur] == 2)
{
if (p[i].y > p[cur].y)
continue;
int nec = p[cur].y - p[i].y;
if (nec > used[cur])
{
used[i] = nec;
q.push(i);
if (p[i].x < p[cur].x)
dir[i] = 1;
else
dir[i] = 3;
}
}
else if (dir[cur] ==1)
{
if (p[i].x < p[cur].x)
continue;
int nec = p[i].x - p[cur].x;
if (nec > used[cur])
{
used[i] = nec;
q.push(i);
if (p[i].y > p[cur].y)
dir[i] = 2;
else
dir[i] = 0;
}
}
else
{
if (p[i].x > p[cur].x)
continue;
int nec = p[cur].x - p[i].x;
if (nec > used[cur])
{
used[i] = nec;
q.push(i);
if (p[i].y > p[cur].y)
dir[i] = 2;
else
dir[i] = 0;
}
}
}
}
}
void solve()
{
cin >> n;
int cnt = 0;
for (int i = 1; i <= n; i ++)
{
cin >> p[i].x >> p[i].y;
if (p[i].x == p[i].y)
cnt ++;
}
cout << cnt << endl;
return;
int ans = 0;
for (int d = 0; d < 4; d ++)
{
for (int i = 1; i <= n; i ++)
used[i] = -1, dir[i] = -1;
dir[1] = d;
used[1] = 0;
simulate();
int cur = 0;
for (int i = 1; i <= n; i ++)
if (used[i] != -1)
cur ++;
ans = max(ans, cur);
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
/**
7
64 52
68 56
65 53
62 62
44 44
60 60
59 59
*/
Compilation message
fever.cpp:2:1: warning: "/*" within comment [-Wcomment]
2 | /**
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |