QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96548#6303. Inversionhath19260817Compile Error//C++201.5kb2023-04-14 13:50:052023-04-14 13:50:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-14 13:50:09]
  • 评测
  • [2023-04-14 13:50:05]
  • 提交

answer

#include <cstdio>
#include <cstring>

const int maxn = 2e3 + 5;
int f[maxn][maxn], rk[maxn], ans[maxn], pos[maxn], n = 0;

int ask(int x, int y) {
    if (f[x][y] != -1)
        return f[x][y];
    printf("? %d %d\n", x, y);
    fflush(stdout);
    scanf("%d", &f[x][y]);
    return f[x][y];
}

int ask_local(int x, int y) {
    if (f[x][y] != -1)
        return f[x][y];
    if (y == x + 1)
        return pos[x] > pos[y];
    return f[x][y] = ((ask_local(x + 1, y) + ask_local(x, y - 1) - ask_local(x + 1, y - 1) + (pos[x] > pos[y]) + 8) & 1);
}

int query(int x, int y) {
    if (y == x + 1)
        return ask(x, y);
    return (ask(x, y) - ask_local(x, y - 1) - ask(x + 1, y) + ask_local(x + 1, y - 1) + 8) & 1;
}

int get_pos(int x) {
    int l = 1, r = rk[0], ans = 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (query(rk[mid], x))
            r = mid - 1;
        else
            l = mid + 1, ans = l;
    }
    return ans;
}

int main() {
    memset(f, -1, sizeof(f));
    memset()
        scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        f[i][i] = 0;
    rk[0] = rk[1] = 1;
    for (int i = 2; i <= n; ++i) {
        int p = get_pos(i);
        for (int j = rk[0]; j >= p; --j)
            rk[j + 1] = rk[j], ++pos[rk[j]];
        rk[p] = i, ++rk[0];
    }
    for (int i = 1; i <= n; ++i)
        ans[rk[i]] = i;
    putchar('!');
    for (int i = 1; i <= n; ++i)
        printf(" %d", ans[i]);
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:44:11: error: too few arguments to function ‘void* memset(void*, int, size_t)’
   44 |     memset()
      |     ~~~~~~^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/cstdio:41,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note: declared here
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
answer.code: In function ‘int ask(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", &f[x][y]);
      |     ~~~~~^~~~~~~~~~~~~~~~