QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617219 | #9251. Graph Changing | ucup-team4153# | WA | 0ms | 3620kb | C++20 | 2.0kb | 2024-10-06 14:28:35 | 2024-10-06 14:28:35 |
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(n==2){
cout<<-1<<'\n';
}else{
if(t&1)cout<<solve1(n,k,x,y)<<'\n';
else cout<<solve0(n,k,x,y)<<"\n";
}
}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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
5 1 5 3 2 4 1 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