QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554140 | #9251. Graph Changing | acceon128# | WA | 0ms | 3632kb | C++17 | 1.2kb | 2024-09-09 07:47:58 | 2024-09-09 07:47:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int distance(int x, int y) {
return y - x;
}
int query1(int n, int k, int x, int y) {
int distance = y - x;
if (distance >= k) {
return 1;
}
if (max(x, n - 1 - x) < k || max(y, n - 1 - y) < k) {
return -1;
}
if (x >= k || n - 1 - y >= k) {
return 2;
}
return 3;
}
int query2(int n, int k, int t, int x, int y) {
if (k == 1) {
return 1;
} else if (k == 2) {
if (n <= 3) {
return -1;
}
if (t % 2 == 0) {
return y - x;
} else {
return y - x >= 2 ? 1 : (x >= 2 || n - 1 - y >= 2 ? 2 : 3);
}
}
return -1;
}
int query(int t, int n, int k, int x, int y) {
if (x > y) {
swap(x, y);
}
switch (t) {
case 0: return distance(x, y);
case 1: return query1(n, k, x, y);
case 2: return query2(n, k, t, x, y);
default: return -1;
}
}
int main() {
int q;
cin >> q;
while (q--) {
int t, n, k, x, y;
cin >> t >> n >> k >> x >> y;
int ans = query(t, n, k, x - 1, y - 1);
cout << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
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: 3632kb
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 13th lines differ - expected: '1', found: '-1'