QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#641649#9251. Graph Changingucup-team4479WA 1ms3708kbC++231.6kb2024-10-14 21:52:542024-10-14 21:52:54

Judging History

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

  • [2024-10-14 21:52:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-10-14 21:52:54]
  • 提交

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 (n == 1) {
        cout << 0 << endl;
        return;
    }
    if (t == 0) {
        cout << abs(x - y) << endl;
        return;
    }
    if (k == 1) {
        cout << 1 << endl;
        return;
    }
    if (k > 3 && t > 1) {
        cout << -1 << endl;
        return;
    }
    if (t == 1) {
        ask(x, y);
        return;
    }
    if (k == 2) {
        if (n >= 4) {
            if (t & 1) ask(x, y);
            else cout << abs(x - y) << endl;
        } else if (n == 3) {
            if (t == 2 && x == 1 && y == 3) cout << 1 << endl;
            else cout << -1 << endl;
        } else if (n == 2) {
            cout << -1 << 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: 3708kb

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: 0
Accepted
time: 0ms
memory: 3648kb

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:

ok 30 lines

Test #3:

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

input:

90
1 3 1 1 2
1 3 1 1 3
1 3 1 2 3
1 3 2 1 2
1 3 2 1 3
1 3 2 2 3
1 3 3 1 2
1 3 3 1 3
1 3 3 2 3
1 3 4 1 2
1 3 4 1 3
1 3 4 2 3
1 3 5 1 2
1 3 5 1 3
1 3 5 2 3
1 3 6 1 2
1 3 6 1 3
1 3 6 2 3
2 3 1 1 2
2 3 1 1 3
2 3 1 2 3
2 3 2 1 2
2 3 2 1 3
2 3 2 2 3
2 3 3 1 2
2 3 3 1 3
2 3 3 2 3
2 3 4 1 2
2 3 4 1 3
2 3 4 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
-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
-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 23rd lines differ - expected: '-1', found: '1'