# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216516 | dantoh000 | Stray Cat (JOI20_stray) | C++14 | 0 ms | 0 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 "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;
}
}
}