# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
216516 | dantoh000 | Stray Cat (JOI20_stray) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int A, B;
int sure = 0;
vector<int> sofar;
int prv = -2;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
//printf("new move\n");
//printf("wasted %d so far, sure ? %d\n",(int)sofar.size(),sure);
//for (int j = 0; j < A; ++j) printf("%d %d\n",j,y[j]);
if (A >= 3){
if (prv == -2){
if (y[0] == 0) return prv = y[1]?1:2;
else if (y[1] == 0) return prv = y[2]?2:0;
else if (y[2] == 0) return prv = y[0]?0:1;
}
else{
return prv = (prv+2)%3;
}
}
else{
if (!sure){
int total = y[0]+y[1];
if (total > 1){
if (sofar.empty()){
int choose;
if (y[0] + y[1] == 2) choose = y[0]?0:1;
else{
sure = true;
assert(y[0]==1||y[1]==1);
choose = y[0]==1?0:1;
}
sofar.push_back(choose);
return choose;
}
else{
sure = true;
if (y[0]==0||y[1]==0){
return -1;
}
else{
return y[0]==1?0:1;
}
}
}
else if (total == 0){
sure = true;
return -1;
}
else{
int cur = y[0] == 1?0:1;
if ((int)sofar.size() == 0){
sure = true;
return cur;
}
if ((int)sofar.size() == 3){
sure = true;
int CUR = 4*sofar[0] + 2*sofar[1] + sofar[2];
int need;
if (CUR == 0 || CUR == 2 || CUR == 5 || CUR == 3) need = 1;
else need = 0;
//printf("so far visited %d %d %d -> %d\n",sofar[0],sofar[1],sofar[2],need);
if (cur == need){
return -1;
}
else return cur;
}
else{
sofar.push_back(cur);
return cur;
}
}
}
else{
return y[0]==1?0:1;
}
}
}
#include "Catherine.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
int A, B;
int sure = 0;
vector<int> sofar;
int prv = -2;
} // namespace
void Init(int A, int B) {
::A = A;
::B = B;
}
int Move(std::vector<int> y) {
//printf("new move\n");
//printf("wasted %d so far, sure ? %d\n",(int)sofar.size(),sure);
//for (int j = 0; j < A; ++j) printf("%d %d\n",j,y[j]);
if (A >= 3){
if (prv == -2){
if (y[0] == 0) return prv = y[1]?1:2;
else if (y[1] == 0) return prv = y[2]?2:0;
else if (y[2] == 0) return prv = y[0]?0:1;
}
else{
return prv = (prv+2)%3;
}
}
else{
if (!sure){
int total = y[0]+y[1];
if (sofar.empty()){
if (total == 1){
sure = true;
return y[0]==1?0:1;
}
}
if (total > 1){
if (sofar.empty()){
int choose;
if (y[0] + y[1] == 2) choose = y[0]?0:1;
else{
sure = true;
assert(y[0]==1||y[1]==1);
choose = y[0]==1?0:1;
}
sofar.push_back(choose);
return choose;
}
else{
sure = true;
if (y[0]==0||y[1]==0){
return -1;
}
else{
return y[0]==1?0:1;
}
}
}
else if (total == 0){
sure = true;
return -1;
}
else{
int cur = y[0] == 1?0:1;
if ((int)sofar.size() == 3){
sure = true;
int CUR = 4*sofar[0] + 2*sofar[1] + sofar[2];
int need;
if (CUR == 0 || CUR == 2 || CUR == 5 || CUR == 3) need = 1;
else need = 0;
//printf("so far visited %d %d %d -> %d\n",sofar[0],sofar[1],sofar[2],need);
if (cur == need){
return -1;
}
else return cur;
}
else{
sofar.push_back(cur);
return cur;
}
}
}
else{
return y[0]==1?0:1;
}
}
}