QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291832#5702. ColorsMax_s_xaMCompile Error//C++202.8kb2023-12-27 09:19:302023-12-27 09:19:30

Judging History

你现在查看的是最新测评结果

  • [2023-12-27 09:19:30]
  • 评测
  • [2023-12-27 09:19:30]
  • 提交

answer

#include <iostream>

typedef long long ll;
typedef double lf;

#define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = 110;

ll n, a[MAXN];
int tot;

inline bool Ask(ll p)
{
    cout << "? " << p << endl;
    bool x; cin >> x;
    return x;
}

int main()
{
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif
    {
        cin >> n;
        ll l = 1, r = n - 1, mid, ans = n;
        int trn;
        tot = 0;
        while (l <= r) mid = l + r >> 1, a[++tot] = mid, l = mid + 1;
        ll p = 1;
        for (int i = tot; i >= 1; i--)
            if (p + a[i] <= n) p += a[i], trn = -1;
            else p -= a[i], trn = 1;
        Ask(p);
        l = 1, r = n - 1;
        bool ret;
        while (l <= r)
        {
            mid = l + r >> 1;
            if (trn > 0) ret = Ask(p + mid), p = p + mid;
            else ret = Ask(p - mid), p = p - mid;
            trn *= -1;
            if (ret) ans = mid, r = mid - 1;
            else l = mid + 1;
        }
        cout << "= " << ans << endl;
    }
    return 0;
}

詳細信息

answer.code: In member function ‘void IO::Read(char*)’:
answer.code:37:18: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   37 |         std::cin >> s;
      |         ~~~~~~~~ ^~ ~
      |              |      |
      |              |      char*
      |              std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’
   37 |         std::cin >> s;
      |                     ^
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]
   37 |         std::cin >> s;
      |                     ^
      |                     |
      |                     char*
answer.code:37:21: error: cannot bind rvalue ‘(short int)s’ to ‘short int&’
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]
   37 |         std::cin >> s;
      |                     ^
      |                     |
      |                     char*
answer.code:37:21: error: cannot bind rvalue ‘(short unsigned int)s’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]
   37 |         std::cin >> s;
      |                     ^
      |                     |
      |                     char*
answer.code:37:21: error: cannot bind rvalue ‘(int)s’ to ‘int&’
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:182:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  182 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:182:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]
   37 |         std::cin >> s;
      |                     ^
      |                     |
      |                     char*
answer.code:37:21: error: cannot bind rvalue ‘(unsigned int)s’ to ‘unsigned int&’
In file included from /usr/include/c++/11/iostream:40,
                 from answer.code:1:
/usr/include/c++/11/istream:186:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  186 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:186:7: note:   conversion of argument 1 would be ill-formed:
answer.code:37:21: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   37 |         std::cin >> s;
   ...