QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617174 | #9251. Graph Changing | ucup-team4153# | WA | 0ms | 3640kb | C++20 | 1.8kb | 2024-10-06 14:17:36 | 2024-10-06 14:17:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int solve0(int n,int k,int x,int y){
if(abs(x-y)==1)return 1;
else return -1;
}
int solve1(int n,int k,int x,int y){
if(abs(x-y)>=k)return 1;
if((abs(x-1)>=k && abs(1-y)>=k) || ((abs(x-n)>=k && abs(n-y)>=k)))return 2;
if((abs(x-1)>=k && abs(1-n)>=k && abs(n-y)>=k) || (abs(x-n)>=k && abs(n-1)>=k && abs(1-y)>=k))return 3;
return -1;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int q;cin>>q;
while(q--){
int t,n,k,x,y;
cin>>t>>n>>k>>x>>y;
if(t==0){
cout<<solve0(n,k,x,y)<<'\n';
continue;
}else if(t==1){
cout<<solve1(n,k,x,y)<<'\n';
continue;
}
if(k==1){
cout<<1<<'\n';
}else if(k==2){
if(t&1)cout<<solve1(n,k,x,y)<<'\n';
else cout<<solve0(n,k,x,y);
}else if(k==3){
if(n>=4 && n<=7 && t==2){
if(n==4){
cout<<-1<<'\n';
}else if(n==5){
if((x==2 && y==4) || (x==4 || y==2)){
cout<<1<<'\n';
}else{
cout<<-1<<'\n';
}
}else if(n==6){
if((x==2 && y==4) || (x==4 || y==2)){
cout<<1<<'\n';
}else{
cout<<-1<<'\n';
}
}else if(n==7){
if((x==3 && y==5) || (x==5 || y==3)){
cout<<1<<'\n';
}else{
cout<<-1<<'\n';
}
}
}else{
cout<<-1<<'\n';
}
}else{
cout<<-1<<'\n';
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3640kb
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-1'