Skip to content

[Week 5] FORTRESS self review - Yunhyunjo #176

@Yunhyunjo

Description

@Yunhyunjo

FORTRESS self review

1. 해결 시도 과정

스터디 자료를 보고 성벽 위치와 반지름을 담은 구조체를 만들었습니다.
그 다음 포함관계를 쉽게 구하기 위해 반지름을 기준으로 내림차순 정렬을 하였습니다.

2. 작성한 코드와 설명

struct Rampart {
	int x, y, r;
	Rampart(int x, int y, int r) {
		this->x = x;
		this->y = y;
		this->r = r;
	}

	bool operator> (const Rampart &a)const {
		return r > a.r;
	}
};

성벽의 위치와 반지름 정보를 담은 구조체입니다. 정렬은 반지름을 기준으로 내림차순 정렬을 해 주었습니다.

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int c;
	cin >> c;
	while (c--) {
		int n, a, b, c;
		cin >> n;
		vector <Rampart> v;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			v.push_back(Rampart(a,b,c));
		}
		sort(v.begin(), v.end());
	}
}

vector의 자료형을 Rampart로 해서 생성해주고 정렬을 해 주었습니다.

3. 막힌 점 및 개선 사항

정렬은 했는데 그 정보로 트리를 구현하는 과정에서 막혔습니다. 이 부분을 좀 더 고민해 봐야할 것 같습니다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2기스터디 2기WAWrong Answer

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions