QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#608565 | #9251. Graph Changing | propane | WA | 1ms | 3652kb | C++20 | 2.6kb | 2024-10-03 23:13:23 | 2024-10-03 23:13:24 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int t, n, k, x, y;
cin >> t >> n >> k >> x >> y;
if (x > y) swap(x, y);
if (k == 1){
if (t == 0){
cout << y - x << '\n';
}
else{
cout << 1 << '\n';
}
}
else if (n == 2){
if (t == 0){
cout << y - x << '\n';
}
else{
cout << -1 << '\n';
}
}
else if (k == 2){
if (n == 3){
if (t == 0){
cout << y - x << '\n';
}
else if (t == 1){
if (x == 1 and y == 3){
cout << 1 << '\n';
}
else{
cout << -1 << '\n';
}
}
else{
cout << -1 << '\n';
}
}
else if (t % 2 == 0){
cout << y - x << '\n';
}
else{
if (y - x >= 2){
cout << 1 << '\n';
}
else if (n - x >= k and n - y >= k){
cout << 2 << '\n';
}
else if (x - 1 >= k and y - 1 >= k){
cout << 2 << '\n';
}
else{
cout << 3 << '\n';
}
}
}
else{
if (t == 0){
cout << y - x << '\n';
}
else if (t > 1){
cout << -1 << '\n';
}
else{
if (max(x - 1, n - x) < k or max(y - 1, n - y) < k){
cout << -1 << '\n';
}
else{
if (y - x >= k){
cout << 1 << '\n';
}
else if (n - x >= k and n - y >= k){
cout << 2 << '\n';
}
else if (x - 1 >= k and y - 1 >= k){
cout << 2 << '\n';
}
else{
cout << 3 << '\n';
}
}
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
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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