답안 #596028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596028 2022-07-14T09:22:29 Z 장태환(#8443) IOI 바이러스 (JOI21_fever) C++17
6 / 100
1 ms 1108 KB
#include <bits/stdc++.h>
using namespace std;
map<int, set<pair<int,int>>>d1, d2;
int dir[100100];
int dist[100100];
int arr[100100][2];
queue<int>t;
int main()
{
	int N;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	int i;
	for (i = 0; i < N; i++)
	{
		cin >> arr[i][0] >> arr[i][1];
	}
	int ans = 0;
	for (i = 0; i <4; i++)
	{
		d1.clear();
		d2.clear();
		{
			int i;
			for (i = 0; i < N; i++)
			{
				d1[arr[i][0] + arr[i][1]].insert({ arr[i][0],i });
				d2[arr[i][0] - arr[i][1]].insert({ arr[i][0],i });
			}
		}
		
		memset(dir, -1, sizeof(dir));
		memset(dist, 0, sizeof(dist));
		dir[0] = i;
		t.push(0);

		int c = 0;
		while (t.size())
		{
			c++;
			auto x = t.front();
			t.pop();
			if (dir[x]==0||dir[x]==1)
			{
				auto v = d1[arr[x][0] + arr[x][1]].lower_bound({ arr[x][0] + dist[x] + 1,0 });
				while (v != d1[arr[x][0] + arr[x][1]].end())
				{
					if (dir[v->second] >= 0)
						v = d1[arr[x][0] + arr[x][1]].erase(v);
					if (v == d1[arr[x][0] + arr[x][1]].end())
						break;
					dir[v->second] = 3 - dir[x];
					dist[v->second] = v->first - arr[x][0];
					t.push(v->second);
					v = d1[arr[x][0] + arr[x][1]].erase(v);
				}
			}
			else
			{
				auto v = d1[arr[x][0] + arr[x][1]].lower_bound({ arr[x][0] - dist[x],0 });
				if (v != d1[arr[x][0] + arr[x][1]].begin())
					v--;
				else
					continue;
				while (1)
				{
					if (dir[v->second] >= 0)
					{
						v = d1[arr[x][0] + arr[x][1]].erase(v);
						v--;
					}	
					dir[v->second] = 3 - dir[x];
					dist[v->second] = arr[x][0]-v->first;
					t.push(v->second);
					if (v == d1[arr[x][0] + arr[x][1]].begin())
					{
						v = d1[arr[x][0] + arr[x][1]].erase(v);
						break;
					}
						
					v = d1[arr[x][0] + arr[x][1]].erase(v);
					v--;
				}
			}
			if (dir[x] == 3 || dir[x] == 0)
			{
				auto v = d2[arr[x][0] - arr[x][1]].lower_bound({ arr[x][0] + dist[x] + 1,0 });
				while (v != d2[arr[x][0] - arr[x][1]].end())
				{
					if (dir[v->second] >= 0)
					{
						v = d2[arr[x][0] - arr[x][1]].erase(v);
					}
					if (v == d2[arr[x][0] - arr[x][1]].end())
						break;
					dir[v->second] =dir[x]^1;
					dist[v->second] = v->first - arr[x][0];
					t.push(v->second);
					v = d2[arr[x][0] - arr[x][1]].erase(v);
				}
			}
			else
			{
				auto v = d2[arr[x][0] - arr[x][1]].lower_bound({ arr[x][0] - dist[x],0 });
				if (v != d2[arr[x][0] - arr[x][1]].begin())
					v--;
				else
					continue;
				while (1)
				{
					if (dir[v->second] >= 0)
					{
						v = d2[arr[x][0] - arr[x][1]].erase(v);
						v--;
					}
						
					dir[v->second] = dir[x] ^ 1;
					dist[v->second] = arr[x][0] - v->first;
					t.push(v->second);
					if (v == d2[arr[x][0] - arr[x][1]].begin())
					{
						v = d2[arr[x][0] - arr[x][1]].erase(v);
						break;
					}
					v = d2[arr[x][0] - arr[x][1]].erase(v);
					
					v--;
				}
			}
		}
		ans = max(ans, c);
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1096 KB Output is correct
6 Correct 1 ms 1092 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1096 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1096 KB Output is correct
8 Correct 1 ms 1088 KB Output is correct
9 Correct 1 ms 1088 KB Output is correct
10 Correct 1 ms 1096 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1100 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 1108 KB Output is correct
16 Correct 1 ms 1108 KB Output is correct
17 Correct 1 ms 1092 KB Output is correct
18 Correct 1 ms 1096 KB Output is correct
19 Correct 1 ms 1108 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 1108 KB Output is correct
23 Correct 1 ms 1108 KB Output is correct
24 Correct 1 ms 1108 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 1108 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Incorrect 1 ms 1100 KB Output isn't correct
30 Halted 0 ms 0 KB -