Submission #829748

# Submission time Handle Problem Language Result Execution time Memory
829748 2023-08-18T14:46:02 Z Blagoj Stray Cat (JOI20_stray) C++17
Compilation error
0 ms 0 KB
#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;
}



    

Compilation message

Anthony.cpp: In function 'int Move(std::vector<int>)':
Anthony.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < y.size(); i++) {
      |                     ~~^~~~~~~~~~
Anthony.cpp:51:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for (int i = 0; i < y.size(); i++) {
      |                         ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cciDyjj1.o: in function `main':
grader_anthony.cpp:(.text.startup+0x191): undefined reference to `Mark(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccuoO87M.o: in function `main':
grader_catherine.cpp:(.text.startup+0x41c): undefined reference to `Init(int, int)'
/usr/bin/ld: grader_catherine.cpp:(.text.startup+0xcfa): undefined reference to `Move(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status