QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#861844#8830. Breaking Badcz_yxxWA 9ms9804kbC++173.8kb2025-01-18 20:10:462025-01-18 20:11:23

Judging History

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

  • [2025-01-18 20:11:23]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:9804kb
  • [2025-01-18 20:10:46]
  • 提交

answer

// sis puella oier
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
ll read(){
    ll xx = 0, f = 1; char ch = getchar();
    for (;!isdigit(ch); ch = getchar())f = (ch == '-' ? -1 : 1);
    for (; isdigit(ch); ch = getchar())xx = (xx << 3) + (xx << 1) + ch - '0';
    return xx * f;
}
int n, a[1100][1100], f[1100][(1 << 12) + 12], g[1100][(1 << 12) + 12];
int b[15][15], h[15][(1 << 12) + 12], ppc[(1 << 12) + 12];
int calc(int x, int ad){
    ad %= 5;
    return ((x << ad) | (x >> (5 - ad))) & 31;
}
int work(int m){
    for (int i = 0; i <= m; ++i)for (int s = 0; s < (1 << m); ++s)h[i][s] = 0;
    h[0][0] = 1;
    for (int i = 0; i < m; ++i)for (int s = 0; s < (1 << m); ++s)if (h[i][s]){
        for (int j = 0; j < m; ++j)if (s >> j & 1);
        else h[i + 1][s | (1 << j)] |= calc(h[i][s], b[i + 1][j + 1]);
    }
    return h[m][(1 << m) - 1];
}
signed main(){
    n = read();
    for (int i = 1; i <= n; ++i)for (int j = 1; j <= n; ++j)a[i][j] = read();
    if (n <= 12){
        for (int i = 1; i <= n; ++i)for (int j = 1; j <= n; ++j)b[i][j] = a[i][j];
        int ans = work(n);
        for (int i = 0; i < 5; ++i)if (ans >> i & 1)printf("Y");
        else printf("N"); printf("\n"); return 0;
    }
    for (int d = 1; d <= 6; ++d){
        bool fl = false;
        for (int i = d; i <= n && !fl; ++i)for (int j = d; j <= n && !fl; ++j)
            if (a[2*d-1][2*d-1] + a[i][j] != a[2*d-1][j] + a[i][2*d-1]){
                for (int k = 1; k <= n; ++k)swap(a[2*d][k], a[i][k]);
                for (int k = 1; k <= n; ++k)swap(a[k][2*d], a[k][j]);
                fl = true;
            }
        if (!fl){
            --d; d *= 2;
            for (int i = d + 2; i <= n; ++i){
                int val = (a[d + 1][d + 1] - a[i][d + 1] + 5) % 5;
                for (int j = 1; j <= n; ++j)(a[i][j] += val) %= 5;
            }
            for (int j = d + 1; j <= n; ++j){
                int val = (5 - a[d + 1][j]) % 5;
                for (int i = 1; i <= n; ++i)(a[i][j] += val) %= 5;
            }
            for (int i = d + 1; i <= n; ++i)for (int j = d + 1; j <= n; ++j)assert(a[i][j] == 0);

            f[d][0] = 1, g[d][0] = 1;
            for (int i = d; i < n; ++i)for (int s = 0; s < (1 << d); ++s)if (f[i][s] > 0){
                f[i + 1][s] |= f[i][s];
                for (int j = 0; j < d; ++j)if (s >> j & 1);
                else f[i + 1][s | (1 << j)] |= calc(f[i][s], a[i + 1][j + 1]);
            }
            for (int j = d; j < n; ++j)for (int s = 0; s < (1 << d); ++s)if (g[j][s] > 0){
                g[j + 1][s] |= g[j][s];
                for (int i = 0; i < d; ++i)if (s >> i & 1);
                else g[j + 1][s | (1 << i)] |= calc(g[j][s], a[i + 1][j + 1]);
            }

            int ans = 0; ppc[0] = 0; for (int i = 1; i < (1 << d); ++i)ppc[i] = ppc[i >> 1] + (i & 1);
            for (int s1 = 0; s1 < (1 << d); ++s1)if (f[n][s1] > 0)
            for (int s2 = 0; s2 < (1 << d); ++s2)if (g[n][s2] > 0 && ppc[s1] == ppc[s2]){
                int cx = 0;
                for (int i = 0; i < d; ++i)if ((s1 >> i & 1) == 0){
                    int cy = 0; ++cx;
                    for (int j = 0; j < d; ++j)if ((s2 >> j & 1) == 0)b[cx][++cy] = a[i][j];
                }
                int val = work(cx); int it = 0;
                for (int i = 0; i < 5; ++i)if (f[n][s1] >> i & 1)it |= calc(val, i);
                val = it; it = 0;
                for (int j = 0; j < 5; ++j)if (g[n][s2] >> j & 1)it |= calc(val, j);
                val = it; it = 0;
                ans |= val;
            }
            for (int i = 0; i < 5; ++i)if (ans >> i & 1)printf("Y");
            else printf("N"); printf("\n");
            return 0;
        }
    }
    printf("YYYYY\n");
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
0 4
4 0

output:

YNNYN

result:

ok "YNNYN"

Test #2:

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

input:

2
1 1
1 1

output:

NNYNN

result:

ok "NNYNN"

Test #3:

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

input:

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

output:

YYYYN

result:

ok "YYYYN"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

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

output:

YYYYN

result:

ok "YYYYN"

Test #5:

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

input:

10
1 4 2 0 0 2 0 1 3 3
0 3 1 4 4 1 4 0 2 2
1 4 2 0 0 2 0 1 0 3
0 3 1 4 4 1 4 0 2 2
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
4 2 0 3 3 0 3 4 1 1
2 0 3 1 1 3 1 2 4 4
1 4 2 0 0 2 0 1 3 3
3 1 4 2 2 4 2 3 0 0

output:

NYNNY

result:

ok "NYNNY"

Test #6:

score: 0
Accepted
time: 1ms
memory: 5708kb

input:

10
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
3 3 3 0 2 3 0 3 2 4
4 4 4 1 3 4 1 4 3 0
2 2 2 4 1 2 4 2 1 3
2 2 2 4 1 3 4 2 1 3
4 4 4 1 3 4 1 4 3 0
3 3 3 0 2 3 0 3 2 4
2 2 2 4 1 2 4 2 1 3
4 4 4 1 3 4 1 1 3 0

output:

YYYNY

result:

ok "YYYNY"

Test #7:

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

input:

10
1 2 0 4 2 3 4 0 2 3
0 1 4 3 1 2 3 4 1 2
4 0 3 2 0 1 2 3 0 1
1 2 0 4 2 3 4 0 2 3
3 4 2 1 4 0 1 2 4 0
0 1 4 3 1 2 3 4 1 2
2 3 1 0 3 4 0 1 3 4
3 1 1 1 4 0 1 2 4 0
1 2 0 4 2 3 4 0 2 3
1 3 0 4 2 3 4 0 2 3

output:

NYYYY

result:

ok "NYYYY"

Test #8:

score: 0
Accepted
time: 1ms
memory: 5708kb

input:

10
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
2 3 4 2 1 1 4 3 4 1
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4
3 4 0 3 2 2 0 4 0 2
0 1 2 0 4 4 2 1 2 4

output:

NYNNN

result:

ok "NYNNN"

Test #9:

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

input:

10
4 1 3 1 2 0 3 2 4 4
0 2 4 2 3 1 4 3 0 0
1 1 1 1 2 0 3 2 4 1
2 4 1 4 0 3 1 0 2 2
1 3 0 3 4 2 0 4 1 1
2 4 1 4 0 3 1 0 2 2
2 4 1 4 0 3 1 0 2 2
0 2 4 2 3 1 4 3 0 0
3 0 2 1 1 4 2 1 3 3
4 1 3 1 2 0 3 2 4 4

output:

YYYYY

result:

ok "YYYYY"

Test #10:

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

input:

10
1 2 0 2 4 2 3 1 2 1
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
4 0 3 0 2 0 1 4 0 4
0 1 4 1 3 1 2 0 1 0
0 1 4 1 3 1 2 0 1 0
3 4 2 4 1 4 0 3 4 3
0 1 4 1 3 1 2 0 1 0

output:

NNNYN

result:

ok "NNNYN"

Test #11:

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

input:

10
1 4 1 2 1 3 3 2 1 2
0 3 0 1 0 2 2 1 0 1
0 4 0 3 0 2 2 1 0 1
1 4 1 2 1 3 3 2 1 2
4 2 4 0 4 1 1 0 4 0
1 1 1 4 1 0 3 2 1 2
0 0 0 1 0 2 2 1 0 1
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3
2 0 2 3 2 4 4 3 2 3

output:

YYYYY

result:

ok "YYYYY"

Test #12:

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

input:

10
1 2 0 1 4 0 1 2 2 2
1 2 0 1 4 3 1 2 2 2
0 1 4 0 3 1 0 1 1 1
1 2 0 1 4 3 1 2 2 2
3 4 2 3 1 4 3 4 4 4
0 1 4 0 3 1 0 1 1 1
4 0 3 4 2 0 4 0 0 0
3 4 2 3 1 4 3 4 4 4
4 0 3 4 2 0 4 0 0 0
0 1 4 0 3 1 0 1 1 1

output:

YNYNY

result:

ok "YNYNY"

Test #13:

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

input:

10
1 3 0 0 2 1 3 4 3 3
3 3 0 0 4 1 3 4 3 3
1 1 3 3 2 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
4 1 3 3 0 4 1 2 1 1
2 4 1 1 3 2 4 0 4 4
0 2 4 4 1 0 2 3 2 2
3 0 2 2 4 3 0 1 0 0
3 0 2 2 4 3 0 1 0 0
4 2 4 4 1 0 2 3 2 2

output:

YYYNY

result:

ok "YYYNY"

Test #14:

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

input:

10
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
2 0 3 1 3 0 0 0 4 1
1 4 2 0 2 4 4 4 3 0
1 4 2 0 2 4 4 4 3 0
3 3 4 2 4 1 1 1 0 2
3 1 4 2 4 1 1 1 0 2
4 2 0 3 0 2 2 2 1 3
3 1 4 2 4 1 1 1 0 2
1 4 2 0 2 4 4 4 3 0

output:

YNYNN

result:

ok "YNYNN"

Test #15:

score: -100
Wrong Answer
time: 9ms
memory: 9804kb

input:

1000
3 4 1 2 4 1 0 3 0 4 1 4 3 1 4 4 1 0 1 2 3 1 0 1 3 4 4 0 3 0 3 2 2 1 0 4 1 3 3 0 3 1 3 2 2 0 3 3 2 2 3 0 4 2 1 2 1 2 1 4 2 4 1 4 2 4 3 2 0 3 0 4 2 1 2 3 3 0 2 0 3 3 1 1 0 3 4 3 2 0 4 0 3 4 4 2 3 4 2 3 4 2 1 3 2 2 4 1 0 2 2 4 0 1 2 0 4 1 3 2 3 2 2 2 1 4 4 4 2 0 0 4 4 1 3 4 0 2 2 3 1 1 3 2 3 2 3 0...

output:

YYYYY

result:

wrong answer 1st words differ - expected: 'NNNYN', found: 'YYYYY'