# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
829748 | Blagoj | 길고양이 (JOI20_stray) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Catherine.h"
using namespace std;
namespace {
int A, B;
int went;
string path;
bool wrong;
set<string> valid, invalid;
vector<string> vl, ivl;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
vl = {"11010", "10100", "01001", "10011", "00110", "01101"};
ivl = {"00101", "10010", "11001", "01100", "10110", "01011"};
for (auto x : vl) valid.insert(x);
for (auto x : ivl) invalid.insert(x);
path = "";
went = 0;
wrong = 0;
}
int Move(vector<int> y) {
// cout << path << " " << went << endl;
if (went && wrong) {
went--;
path.pop_back();
return -1;
}
if (path.size() == 5) {
path = path.substr(1);
}
wrong = 0;
vector<pair<int, int>> total;
for (int i = 0; i < y.size(); i++) {
if (y[i]) total.push_back({y[i], i});
}
if (total.size() == 0) cout << "NIGA";
sort(total.begin(), total.end());
went++;
if (total.size() == 1 || total[0] < total[1]) {
path += to_string(total[0].second);
return total[0].second;
}
if (path.size() + 1 == 5) {
for (int i = 0; i < y.size(); i++) {
if (y[i]) {
string cur = path + to_string(i);
if (invalid.count(cur)) {
wrong = 1;
went -= 2;
return -1;
}
if (valid.count(cur)) {
path += to_string(i);
return i;
}
}
}
}
path += to_string(total[0].second);
return total[0].second;
}