Submission #362665

# Submission time Handle Problem Language Result Execution time Memory
362665 2021-02-04T02:09:06 Z tndud2612 Treasure (different grader from official contest) (CEOI13_treasure2) C++17
Compilation error
0 ms 0 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;
	}

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

	while (cnt) {
		vector<int> tmp;
		tmp = q.front();
		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 });
			}
			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;
		}
	}
	for (int i = 0; i < result.size(); i++) {
		Report(result[i].first, result[i].second);
	}

}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:23:3: error: 'cout' was not declared in this scope
   23 |   cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << " " << tmp[3] << endl;
      |   ^~~~
treasure.cpp:3:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    2 | #include <queue>
  +++ |+#include <iostream>
    3 | #include <utility>
treasure.cpp:23:72: error: 'endl' was not declared in this scope
   23 |   cout << tmp[0] << " " << tmp[1] << " " << tmp[2] << " " << tmp[3] << endl;
      |                                                                        ^~~~
treasure.cpp:3:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
    2 | #include <queue>
  +++ |+#include <ostream>
    3 | #include <utility>
treasure.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |  for (int i = 0; i < result.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~