QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641638 | #9251. Graph Changing | ucup-team4479 | WA | 0ms | 3708kb | C++23 | 1.3kb | 2024-10-14 21:48:41 | 2024-10-14 21:48:41 |
Judging History
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'