답안 #362660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362660 2021-02-04T02:01:08 Z tndud2612 보물 찾기 (CEOI13_treasure2) C++17
0 / 100
1 ms 620 KB
#include "treasure.h"
#include <queue>
#include <utility>
#include <vector>

using namespace std;

void findTreasure (int N) {

	int dir = 0;
    int cnt = countTreasure(1, 1, N, N);
	if (cnt == 0) {
		return;
	}
	int r1 = 1;
	int c1 = 1;
	int r2 = N;
	int c2 = N;
	
	queue<vector<int>> q;
	q.push({ 1, 1, N, N });

	while (cnt) {
		vector<int> tmp;
		tmp = q.front();
		if (tmp[1] == tmp[3] && tmp[0] == tmp[2]) {
			cnt--;
		}
		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 });
			}
			dir = 0;
		}
		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;
		}
	}
}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:15:6: warning: unused variable 'r1' [-Wunused-variable]
   15 |  int r1 = 1;
      |      ^~
treasure.cpp:16:6: warning: unused variable 'c1' [-Wunused-variable]
   16 |  int c1 = 1;
      |      ^~
treasure.cpp:17:6: warning: unused variable 'r2' [-Wunused-variable]
   17 |  int r2 = N;
      |      ^~
treasure.cpp:18:6: warning: unused variable 'c2' [-Wunused-variable]
   18 |  int c2 = N;
      |      ^~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 11
2 Incorrect 1 ms 364 KB Error - check the range of the parameters of countTreasure() : r1 = 3725035, c1 = 0, r2 = 5, c2 = 5
3 Incorrect 1 ms 364 KB Error - check the range of the parameters of countTreasure() : r1 = 3724925, c1 = 0, r2 = 8, c2 = 11
4 Runtime error 1 ms 512 KB Execution killed with signal 6
5 Runtime error 1 ms 492 KB Execution killed with signal 6
6 Runtime error 1 ms 492 KB Execution killed with signal 11
7 Runtime error 1 ms 492 KB Execution killed with signal 11
8 Runtime error 1 ms 620 KB Execution killed with signal 6
9 Runtime error 1 ms 620 KB Execution killed with signal 6
10 Runtime error 1 ms 620 KB Execution killed with signal 6