답안 #362727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362727 2021-02-04T09:06:42 Z tndud2612 보물 찾기 (CEOI13_treasure2) C++17
0 / 100
66 ms 944 KB
#include "treasure.h"
#include <queue>
#include <utility>
#include <vector>
#include <iostream>

using namespace std;

void findTreasure (int N) {

	int dir = 0;
    int cnt = countTreasure(1, 1, N, N);
	if (cnt == 0) {
		return;
	}

	queue<vector<int>> q;
	q.push({ 1, 1, N, N });
	vector<pair<int, int>> result;

	while (cnt && !q.empty()) {
		
		int size = q.size();
		for (int i = 0; i < size; i++) {
			vector<int> tmp;
			tmp = q.front();
			cout << q.size() << endl;
			cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << " " << tmp[3] << endl;
			if (tmp[1] == tmp[3] && tmp[0] == tmp[2]) {
				cnt--;
				result.push_back(make_pair(tmp[0], tmp[1]));
			}
			q.pop();
			if (dir && tmp[1] != tmp[3]) {
				int mid = (tmp[1] + tmp[3]) / 2;
				if (countTreasure(tmp[0], mid + 1, tmp[2], tmp[3])) {
					q.push({ tmp[0], mid + 1, tmp[2], tmp[3] });
				}
				if (countTreasure(tmp[0], tmp[1], tmp[2], mid)) {
					q.push({ tmp[0], tmp[1], tmp[2], mid });
				}
			}
			else if (!dir && tmp[0] != tmp[2]) {
				int mid = (tmp[0] + tmp[2]) / 2;
				if (countTreasure(mid + 1, tmp[1], tmp[2], tmp[3])) {
					q.push({ mid + 1, tmp[1], tmp[2], tmp[3] });
				}
				if (countTreasure(mid + 1, tmp[1], tmp[2], tmp[3])) {
					q.push({ tmp[0], tmp[1], mid, tmp[3] });
				}
			}
		}
		dir = 1 - dir;
	}
	for (int i = 0; i < (int)result.size(); i++) {
		Report(result[i].first, result[i].second);
	}

}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Invalid Access
2 Incorrect 1 ms 364 KB Invalid Access
3 Incorrect 2 ms 364 KB Invalid Access
4 Incorrect 2 ms 364 KB Invalid Access
5 Incorrect 19 ms 492 KB Invalid Access
6 Incorrect 29 ms 620 KB Invalid Access
7 Incorrect 25 ms 620 KB Invalid Access
8 Incorrect 41 ms 748 KB Invalid Access
9 Incorrect 66 ms 944 KB Invalid Access
10 Incorrect 58 ms 748 KB Invalid Access