Submission #727238

# Submission time Handle Problem Language Result Execution time Memory
727238 2023-04-20T09:32:32 Z dxz05 Flight to the Ford (BOI22_communication) C++17
15 / 100
46 ms 1836 KB
#include"communication.h"
#include <bits/stdc++.h>

using namespace std;

bool can(string &s, string &t){
    if (s.size() != t.size()) return false;
    for (int i = 0; i + 1 < s.size(); i++){
        if (s[i] != t[i] && s[i + 1] != t[i + 1]) return false;
    }
    return true;
}

void encode(int N, int X) {
    if (X == 1) send(0), send(0), send(0), send(0);
    if (X == 2) send(0), send(1), send(1), send(0);
    if (X == 3) send(1), send(1), send(1), send(1);
}

pair<int, int> decode(int N) {
    string s(4, '0');
    s[0] += receive();
    s[1] += receive();
    s[2] += receive();
    s[3] += receive();

    vector<string> v = {"0000", "0110", "1111"};
    vector<int> ans;
    for (int i = 0; i < 3; i++){
        if (can(v[i], s)) ans.push_back(i + 1);
    }

    return make_pair(ans.front(), ans.back());
}

Compilation message

communication.cpp: In function 'bool can(std::string&, std::string&)':
communication.cpp:8:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i + 1 < s.size(); i++){
      |                     ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1728 KB Output is correct
2 Correct 11 ms 1712 KB Output is correct
3 Correct 12 ms 1792 KB Output is correct
4 Correct 10 ms 1744 KB Output is correct
5 Correct 13 ms 1752 KB Output is correct
6 Correct 31 ms 1836 KB Output is correct
7 Correct 46 ms 1676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 200 KB Not correct
2 Halted 0 ms 0 KB -