QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#883985#9734. Identify ChordEstelle_NCompile Error//C++141.7kb2025-02-05 20:30:202025-02-05 20:30:22

Judging History

This is the latest submission verdict.

  • [2025-02-05 20:30:22]
  • Judged
  • [2025-02-05 20:30:20]
  • Submitted

answer

#include <cstdio>
#include <algorithm>

using namespace std;

int T, n;

int ask(int x, int y, int z = 0)
{
    printf("? %d %d\n", x, y);
    fflush(stdout);
    scanf("%d", &z);
    return z;
}

void ans(int x, int y, int z)
{
    printf("! %d %d\n", x, y);
    fflush(stdout);
    scanf("%d", &z);
}

void work()
{
    scanf("%d", &n);

    if(n <= 8)
    {
        for(int i = 1; i <= 8; ++ i)
            for(int j = i + 1; j <= 8; ++ j)
                if(ask(i, j) == 1)
                    return ans(i, j);
    }

    int u = 1, v = n / 2 + 1, w = n / 2, d = ask(u, v);
    while(d == w)
    {
        if(n & 1)
        {
            if(w == n / 2)
                ++ v, ++ w;
            else
                ++ u, -- w;
        }
        else
            ++ u, ++ v;
        d = ask(u, v);
    }

    if(d == 1)
        return ans(u, v);

    int delta = w - d;
    int x = u + 1, y = v, z = y - x, k = ask(x, y);
    if(k == 1)
        return ans(x, y);
    if(z - k == delta)
        u = x, v = y, w = z, d = k;
    else
    {
        (-- u == 0) && (u = n);
        if(u > v)
            swap(u, v);
        w = v - u, d = w - delta;
        if(d == 1)
            return ans(u, v);
    }

    int l = u, r = v - delta - 1;
    while(l <= r)
    {
        int mid = l + r >> 1;
        if(v - mid - ask(mid, v) == delta)
            r = mid - 1, x = mid;
        else
            l = mid + 1;
    }
    y = (x + delta + 1) % n;
    if(!y)
        y = n;
    if(ask(x, y) != 1)
    {
        y = ((x - delta - 1) % n + n) % n;
        if(!y)
            y = n;
    }

    ans(x, y);
}

int main()
{
    scanf("%d", &T);
    while(T --)
        work();

    return 0;
}

Details

answer.code: In function ‘void work()’:
answer.code:32:31: error: too few arguments to function ‘void ans(int, int, int)’
   32 |                     return ans(i, j);
      |                            ~~~^~~~~~
answer.code:16:6: note: declared here
   16 | void ans(int x, int y, int z)
      |      ^~~
answer.code:51:19: error: too few arguments to function ‘void ans(int, int, int)’
   51 |         return ans(u, v);
      |                ~~~^~~~~~
answer.code:16:6: note: declared here
   16 | void ans(int x, int y, int z)
      |      ^~~
answer.code:56:19: error: too few arguments to function ‘void ans(int, int, int)’
   56 |         return ans(x, y);
      |                ~~~^~~~~~
answer.code:16:6: note: declared here
   16 | void ans(int x, int y, int z)
      |      ^~~
answer.code:66:23: error: too few arguments to function ‘void ans(int, int, int)’
   66 |             return ans(u, v);
      |                    ~~~^~~~~~
answer.code:16:6: note: declared here
   16 | void ans(int x, int y, int z)
      |      ^~~
answer.code:88:8: error: too few arguments to function ‘void ans(int, int, int)’
   88 |     ans(x, y);
      |     ~~~^~~~~~
answer.code:16:6: note: declared here
   16 | void ans(int x, int y, int z)
      |      ^~~
answer.code: In function ‘int ask(int, int, int)’:
answer.code:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d", &z);
      |     ~~~~~^~~~~~~~~~
answer.code: In function ‘void ans(int, int, int)’:
answer.code:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%d", &z);
      |     ~~~~~^~~~~~~~~~
answer.code: In function ‘void work()’:
answer.code:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:93:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   93 |     scanf("%d", &T);
      |     ~~~~~^~~~~~~~~~