# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
362728 | tndud2612 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++17 | 2 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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();
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);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |