QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#862076#8830. Breaking BaddsptWA 1ms8032kbC++231.6kb2025-01-18 21:42:132025-01-18 21:42:32

Judging History

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

  • [2025-01-18 21:42:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8032kb
  • [2025-01-18 21:42:13]
  • 提交

answer

#include <vector>
#include <stdio.h>
using namespace std;
vector<int> e; bool h[6][64][5];
int n, g[1001], a[1001][1001], b[1001][1001], f[1001][1001];
void work(const int x)
{
    e.push_back(g[1]); e.push_back(g[x]);
    for (int i(2), c(0); i <= n; ++i) if (c != x)
    {
        g[++c] = g[i];
        for (int j(2), d(0); j <= n; ++j) if (d != x) b[c][++d] = a[i][j];
    }
    n -= 2;
    for (int i(1); i <= n; ++i) for (int j(1); j <= n; ++j) a[i][j] = b[i][j];
}

int main()
{
    scanf("%d", &n);
    for (int i(1); i <= n; ++i)
    {
        g[i] = i;
        for (int j(1); j <= n; ++j) scanf("%d", &a[i][j]), f[i][j] = a[i][j];
    }
    for (int i(1); i <= 4 && n >= 2; ++i)
    {
        bool d(false);
        for (int j(2); j <= n && !d; ++j)
            if ((a[i][i] + a[j][j]) % 5 != (a[i][j] + a[j][i]) % 5)
            {
                work(j); d = true;
                break;
            }
        if (!d) break;
    }
    if ((int)size(g) == 8) puts("YYYYY");
    else
    {
        const int m(size(e)); int c(0);
        for (int i(1); i <= n; ++i) c = (c + a[i][i]) % 5;
        for (int i(0); i < m; ++i) for (int j(0); j < m; ++j) a[i][j] = f[e[i]][e[j]];
        h[0][0][c] = true;
        for (int i(0); i < m; ++i) for (int j(0); j < 1 << m; ++j)
            for (int k(0); k < 5; ++k) if (h[i][j][k])
                for (int d(0); d < m; ++d) if (!(j >> d & 1))
                    h[i + 1][j | 1 << d][(k + a[i][d]) % 5] = true;
        for (int i(0); i < 5; ++i) putchar(h[m][(1 << m) - 1][i] ? 'Y' : 'N');
        putchar('\n');
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 8032kb

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

score: 0
Accepted
time: 0ms
memory: 5972kb

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 8032kb

input:

4
0 0 1 0
0 1 0 1
0 0 0 0
1 1 0 0

output:

NYYNN

result:

wrong answer 1st words differ - expected: 'YYYYN', found: 'NYYNN'