QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#597724 | #9251. Graph Changing | DBsoleil | WA | 0ms | 3584kb | C++23 | 2.8kb | 2024-09-28 18:32:52 | 2024-09-28 18:32:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int q,t,n,k,x,y;
int to[8][8][8];
int main(){
ios_base::sync_with_stdio(false);
cin>>q;
while(q--){
cin>>t>>n>>k>>x>>y;
cout<<t<<" "<<n<<" "<<k<<" "<<x<<" "<<y<<" ";
if(n==2&&k>1){cout<<"-1\n";continue;}
if(x>=y)swap(x,y);
if(k==1){
if(t==0){
cout<<y-x<<"\n";
}else cout<<1<<"\n";
}else if(k==2){
if(t==0){
cout<<y-x<<"\n";
}else if(n==2)cout<<-1<<"\n";
else if(n==3){
if(t==1&&y-x==2)cout<<1<<"\n";
else cout<<-1<<"\n";
}else if(n==4){
if(t==1){
if(y-x>=2)cout<<1<<"\n";
else if(x==2)cout<<3<<"\n";
else cout<<2<<"\n";
}else if(t==2&&y-x==1&&x!=2)cout<<1<<"\n";
else cout<<-1<<"\n";
}else if(t&1){
if(y-x==1)cout<<2<<"\n";
else cout<<1<<"\n";
}else{
cout<<y-x<<"\n";
}
}else if(k==3&&n<7){
if(n<=3){
if(t==0)cout<<y-x<<"\n";
else cout<<"-1\n";
}else if(n==4){
if(t==0)cout<<y-x<<"\n";
else if(t==1){
if(y-x==3)cout<<1<<"\n";
else cout<<"-1\n";
}else cout<<"-1\n";
}else if(n==5){
if(t==0)cout<<y-x<<"\n";
else if(t==1){
if(y-x>=3)cout<<1<<"\n";
else if(y==4&&x==2)cout<<3<<"\n";
else cout<<"-1\n";
}else cout<<"-1\n";
}else if(n==6){
if(t==0)cout<<y-x<<"\n";
else if(t==1){
if(y-x>=3)cout<<1<<"\n";
else if(y-x==1&&x!=3)cout<<2<<"\n";
else if(x==1||y==6)cout<<2<<"\n";
else cout<<3<<"\n";
}if(t==2){
if(x==1||y==6)cout<<-1<<"\n";
else{
if(x==3)x=4;
else if(x==4)x=3;
if(y==3)y=4;
else if(y==4)y=3;
cout<<abs(y-x)<<"\n";
}
}else cout<<-1<<"\n";
}
}else{
if(t==0)cout<<y-x<<"\n";
else if(t==1){
if(y-x>=k)cout<<"1\n";
else if(x>k||n-y>=k){
cout<<"2\n";
}else if(y>k&&n-x>=k){
cout<<"3\n";
}else cout<<"-1\n";
}else cout<<"-1\n";
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
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:
1 5 3 2 4 3 1 10 4 2 4 2 2 10 5 2 4 -1 1 3 2 1 3 1 1 3 2 1 2 -1
result:
wrong answer 1st lines differ - expected: '3', found: '1 5 3 2 4 3'