QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140787#5156. Going in CirclesAnwar_Gehad_Maghraby#Compile Error//C++232.0kb2023-08-16 20:21:542023-08-16 20:21:57

Judging History

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

  • [2023-08-16 20:21:57]
  • 评测
  • [2023-08-16 20:21:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

vector<int> write, read;
int get(){
    int r1= rand() & 1;
    int r2= rand() & 1;
    int r3= rand() & 1;
    return (r1 + r2 + r3) & 1;
}
int Flip(){
    cout<<"? flip\n"; cout.flush();
    int x; cin>>x;
    return x;
}
int Right(){
    cout<<"? right\n"; cout.flush();
    int x; cin>>x;
    return x;
}
int Left(){
    cout<<"? left\n"; cout.flush();
    int x; cin>>x;
    return x;
}

void out(int n){
    cout<<"! "<<n; cout.flush();
    exit(0);
}
int main() {
    cin.tie(0);cin.sync_with_stdio(0);
    cout.tie(0);cout.sync_with_stdio(0);

    int cur;
    cin>>cur;

    int qs = 10;
    while(qs)
    {
        read.push_back(cur);
        int put= get();
        if(put != cur){
            assert(Flip() == put);
            qs--;
        }
        write.push_back(put);
        cur= Right();
        qs--;
    }
    int p = 0;
    for(int i = 3; i < read.size(); i++){
        int n = i;
        if(read.size() >= 2 * n){
            bool valid = 1;
            for(int j = 0, k = i; k < read.size(); k++, j++){
                if(read[k] != write[j]){
                    valid= 0;
                    break;
                }
            }
            if(valid)
            {
                out(n);
            }
            p= i + 1;
        }else break;
    }

    int ops = 3 * 5000 + 10;
    while(ops--)
    {
        read.push_back(cur);
        int put= get();
        if(put != cur){
            assert(Flip() == put);
            qs--;
        }
        write.push_back(put);
        cur= Right();

        while(read.size() >= 2 * p)
        {
            int n = p;
            bool valid = 1;
            for(int j = 0, k = p; k < read.size(); k++, j++){
                if(read[k] != write[j]){
                    valid= 0;
                    break;
                }
            }
            if(valid)
            {
                out(n);
            }
            p++;
        }
    }
}

详细

answer.code:4:13: error: ‘std::vector<int> write’ redeclared as different kind of entity
    4 | vector<int> write, read;
      |             ^~~~~
In file included from /usr/include/c++/11/bits/atomic_wait.h:44,
                 from /usr/include/c++/11/bits/atomic_base.h:41,
                 from /usr/include/c++/11/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/11/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from answer.code:1:
/usr/include/unistd.h:366:16: note: previous declaration ‘ssize_t write(int, const void*, size_t)’
  366 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
      |                ^~~~~
answer.code:4:20: error: ‘std::vector<int> read’ redeclared as different kind of entity
    4 | vector<int> write, read;
      |                    ^~~~
In file included from /usr/include/unistd.h:1166,
                 from /usr/include/c++/11/bits/atomic_wait.h:44,
                 from /usr/include/c++/11/bits/atomic_base.h:41,
                 from /usr/include/c++/11/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/11/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/unistd.h:34:1: note: previous declaration ‘ssize_t read(int, void*, size_t)’
   34 | read (int __fd, void *__buf, size_t __nbytes)
      | ^~~~
answer.code: In function ‘int main()’:
answer.code:41:14: error: request for member ‘push_back’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   41 |         read.push_back(cur);
      |              ^~~~~~~~~
answer.code:47:15: error: request for member ‘push_back’ in ‘write’, which is of non-class type ‘ssize_t(int, const void*, size_t)’ {aka ‘long int(int, const void*, long unsigned int)’}
   47 |         write.push_back(put);
      |               ^~~~~~~~~
answer.code:52:29: error: request for member ‘size’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   52 |     for(int i = 3; i < read.size(); i++){
      |                             ^~~~
answer.code:54:17: error: request for member ‘size’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   54 |         if(read.size() >= 2 * n){
      |                 ^~~~
answer.code:56:44: error: request for member ‘size’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   56 |             for(int j = 0, k = i; k < read.size(); k++, j++){
      |                                            ^~~~
answer.code:57:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |                 if(read[k] != write[j]){
      |                          ^
answer.code:57:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |                 if(read[k] != write[j]){
      |                                      ^
answer.code:57:28: error: comparison between distinct pointer types ‘ssize_t (*)(int, void*, size_t)’ {aka ‘long int (*)(int, void*, long unsigned int)’} and ‘ssize_t (*)(int, const void*, size_t)’ {aka ‘long int (*)(int, const void*, long unsigned int)’} lacks a cast [-fpermissive]
   57 |                 if(read[k] != write[j]){
      |                    ~~~~~~~~^~~~~~~~~~~
answer.code:73:14: error: request for member ‘push_back’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   73 |         read.push_back(cur);
      |              ^~~~~~~~~
answer.code:79:15: error: request for member ‘push_back’ in ‘write’, which is of non-class type ‘ssize_t(int, const void*, size_t)’ {aka ‘long int(int, const void*, long unsigned int)’}
   79 |         write.push_back(put);
      |               ^~~~~~~~~
answer.code:82:20: error: request for member ‘size’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   82 |         while(read.size() >= 2 * p)
      |                    ^~~~
answer.code:86:44: error: request for member ‘size’ in ‘read’, which is of non-class type ‘ssize_t(int, void*, size_t)’ {aka ‘long int(int, void*, long unsigned int)’}
   86 |             for(int j = 0, k = p; k < read.size(); k++, j++){
      |                                            ^~~~
answer.code:87:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   87 |                 if(read[k] != write[j]){
      |                          ^
answer.code:87:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   87 |                 if(read[k] != write[j]){
      |                                      ^
answer.code:87:28: error: comparison between distinct pointer types ‘ssize_t ...