QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#334010#4325. Kraljicelukap_0 0ms3660kbC++142.7kb2024-02-20 23:15:342024-02-20 23:15:35

Judging History

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

  • [2024-02-20 23:15:35]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3660kb
  • [2024-02-20 23:15:34]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e3 + 500;

int n;
vector<pair<int, int> > rj;
int mat[MAXN][MAXN];

void play (int x, int y) {
    rj.push_back ({x, y});
    mat[x][y] = 1;
}

void tri () {
    play (2, 3);
    play (3, 1);
    play (2, 2);
    play (1, 1);
    play (3, 3);
    play (3, 2);
    play (1, 2);
    play (1, 3);
    play (2, 1);
}

void cetiri () {
    play (1, 1);
    play (2, 4);
    play (1, 4);
    play (2, 1);
    play (3, 1);
    play (4, 1);
    play (4, 4);
    play (3, 4);
    play (1, 2);
    play (2, 2);
    play (4, 3);
    play (2, 3);
    play (3, 3);
    play (3, 2);
}

void par (int x) {
    play (x - 2, x);
    play (x - 2, x - 1);
    play (x - 1, x);
    play (x - 1, x - 2);
    play (x, x - 2);
    play (x - 1, x - 1);
    play (x, x - 1);
    play (x, x);
}

void nepar (int x) {
    play (x - 1, x);
    play (x - 2, x - 1);
    play (x, x - 1);
    play (x - 1, x - 1);
    play (x - 2, x);
    play (x, x - 2);
    play (x - 1, x - 2);
    play (x, x);
}

int provjeri (int x, int y) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += mat[i][x];
        sum += mat[x][i];
    }

    int nx = x, ny = y;
    while (nx > 0 && ny > 0) {
        nx--;
        ny--;
        sum += mat[nx][ny];
    }
    nx = x, ny = y;
    while (nx <= n && ny <= n) {
        nx++;
        ny++;
        sum += mat[nx][ny];
    }
    nx = x, ny = y;
    while (nx <= n && ny > 0) {
        nx++;
        ny--;
        sum += mat[nx][ny];
    }
    nx = x, ny = y;
    while (nx > 0 && ny <= n) {
        nx--;
        ny++;
        sum += mat[nx][ny];
    }

    return sum % 2;
}

void solve (int x) {
    if (x == 3) {
        tri ();
        return;
    }
    if (x == 4) {
        cetiri ();
        return;
    }

    solve (x - 2);

    for (int i = 0; i < x - 3; i++) {
        if (provjeri (x - 1, i + 1) == 0) {
            play (x - 1, i + 1);
            play (x, i + 1);
        }
        else {
            play (x, i + 1);
            play (x - 1, i + 1);
        }

        if (provjeri (i + 1, x - 1)) {
            play (i + 1, x - 1);
            play (i + 1, x);
        }
        else {
            play (i + 1, x);
            play (i + 1, x - 1);
        }
    }

    if (x % 2 == 0) par (x);
    else nepar (x);
}

int main () {
    ios_base::sync_with_stdio (false);
    cin.tie (0);

    cin >> n;

    if (n == 1) {
        play (1, 1);
    }
    else if (n == 2) {
        play (1, 1);
    }
    else solve (n);

    cout << rj.size () << "\n";
    for (auto it: rj) cout << it.first << ' ' << it.second << "\n";

    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 0ms
memory: 3660kb

input:

1

output:

1
1 1

result:

ok 1 queen(s)

Test #2:

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

input:

2

output:

1
1 1

result:

ok 1 queen(s)

Test #3:

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

input:

3

output:

9
2 3
3 1
2 2
1 1
3 3
3 2
1 2
1 3
2 1

result:

ok 9 queen(s)

Test #4:

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

input:

4

output:

14
1 1
2 4
1 4
2 1
3 1
4 1
4 4
3 4
1 2
2 2
4 3
2 3
3 3
3 2

result:

ok 14 queen(s)

Test #5:

score: -6
Wrong Answer
time: 0ms
memory: 3644kb

input:

5

output:

25
2 3
3 1
2 2
1 1
3 3
3 2
1 2
1 3
2 1
4 1
5 1
1 5
1 4
4 2
5 2
2 5
2 4
4 5
3 4
5 4
4 4
3 5
5 3
4 3
5 5

result:

wrong answer the cell (4, 1) is attacking by 5 queen(s)

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%