QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#334015#4325. Kraljicelukap_0 0ms3660kbC++142.8kb2024-02-20 23:22:422024-02-20 23:22:42

Judging History

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

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

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, 2);
    play (1, 3);
    play (2, 1);
    play (2, 2);
    play (3, 4);
    play (1, 4);
    play (3, 1);
    play (3, 2);
    play (3, 3);
    play (4, 1);
    play (4, 3);
    play (4, 2);
    play (4, 4);
}

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][y];
        sum += mat[x][i];
    }

//    cout << "AAAAAAA " << sum << "\n";

    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];
    }

//    cout << "AAAAA " << x << ' ' << y << ' ' << sum << "\n";
    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) == 0) {
            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: 3576kb

input:

1

output:

1
1 1

result:

ok 1 queen(s)

Test #2:

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

input:

2

output:

1
1 1

result:

ok 1 queen(s)

Test #3:

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

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: -6
Wrong Answer
time: 0ms
memory: 3576kb

input:

4

output:

13
1 2
1 3
2 1
2 2
3 4
1 4
3 1
3 2
3 3
4 1
4 3
4 2
4 4

result:

wrong answer the cell (1, 3) is attacking by 1 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%