QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641638#9251. Graph Changingucup-team4479WA 0ms3708kbC++231.3kb2024-10-14 21:48:412024-10-14 21:48:41

Judging History

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

  • [2024-10-14 21:48:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-14 21:48:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int t, n, k, x, y;
int ans[10][5][10][10]; // n, t, x, y, k = 3
void ask(int x, int y) {
    if (abs(x - y) >= k) cout << 1 << endl;
    else if (x - 1 >= k || n - y >= k) cout << 2 << endl;
    else if (n - x >= k && y - 1 >= k) cout << 3 << endl;
    else cout << -1 << endl;
}
void solve() {
    cin >> t >> n >> k >> x >> y;
    if (x > y) swap(x, y);
    if (k == 1) {
        cout << 1 << endl;
        return;
    }
    if (k > 3 && t > 1) {
        cout << -1 << endl;
        return;
    }
    if (t == 0) {
        cout << abs(x - y) << endl;
        return;
    }
    if (t == 1) {
        ask(x, y);
        return;
    }
    if (k == 2) {
        if (t & 1) ask(x, y);
        else cout << abs(x - y) << endl;
        return;
    }
    if (k == 3) {
        if (n >= 8 || t > 3) cout << -1 << endl;
        else cout << ans[n][t][x][y] << endl;
    }
}
int main() {
    memset(ans, -1, sizeof(ans));
    ans[7][2][3][5] = 1;
    ans[6][2][2][4] = ans[6][2][3][4] = ans[6][2][3][5] = 1;
    ans[6][2][2][3] = ans[6][2][4][5] = 2;
    ans[6][2][2][5] = 3;
    ans[6][3][2][5] = 1;
    ans[5][2][2][4] = 1;
    int q;
    cin >> q;
    while (q--) solve();
    return 0;
}
/*
5
1 5 3 2 4
1 10 4 2 4
2 10 5 2 4
1 3 2 1 3
1 3 2 1 2
*/

详细

Test #1:

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

input:

5
1 5 3 2 4
1 10 4 2 4
2 10 5 2 4
1 3 2 1 3
1 3 2 1 2

output:

3
2
-1
1
-1

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3708kb

input:

30
1 2 1 1 2
1 2 2 1 2
1 2 3 1 2
1 2 4 1 2
1 2 5 1 2
1 2 6 1 2
2 2 1 1 2
2 2 2 1 2
2 2 3 1 2
2 2 4 1 2
2 2 5 1 2
2 2 6 1 2
3 2 1 1 2
3 2 2 1 2
3 2 3 1 2
3 2 4 1 2
3 2 5 1 2
3 2 6 1 2
4 2 1 1 2
4 2 2 1 2
4 2 3 1 2
4 2 4 1 2
4 2 5 1 2
4 2 6 1 2
5 2 1 1 2
5 2 2 1 2
5 2 3 1 2
5 2 4 1 2
5 2 5 1 2
5 2 6 1 2

output:

1
-1
-1
-1
-1
-1
1
1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
1
1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1

result:

wrong answer 8th lines differ - expected: '-1', found: '1'