QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617282 | #9251. Graph Changing | ucup-team4153# | WA | 0ms | 3636kb | C++20 | 3.3kb | 2024-10-06 14:44:47 | 2024-10-06 14:44:49 |
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<=3){
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==6){
if(t==2){
if(x==2){
if(y==4)cout<<1<<'\n';
else if(y==3)cout<<2<<'\n';
else if(y==5)cout<<3<<'\n';
else cout<<-1<<'\n';
}else if(x==4){
if(y==2)cout<<1<<'\n';
else if(y==3)cout<<1<<'\n';
else if(y==5)cout<<2<<'\n';
else cout<<-1<<'\n';
}else if(x==3){
if(y==2)cout<<2<<'\n';
else if(y==4)cout<<1<<'\n';
else if(y==5)cout<<1<<'\n';
else cout<<-1<<'\n';
}else if(x==5){
if(y==2)cout<<3<<'\n';
else if(y==4)cout<<2<<'\n';
else if(y==3)cout<<1<<'\n';
else cout<<-1<<'\n';
}else{
cout<<-1<<'\n';
}
}else if(t==3){
if((x==2 && y==5) || (x==5 || y==2)){
cout<<1<<'\n';
}else{
cout<<-1<<'\n';
}
}else{
cout<<-1<<'\n';
}
}else 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: 3564kb
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: 0
Accepted
time: 0ms
memory: 3636kb
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:
ok 30 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
90 1 3 1 1 2 1 3 1 1 3 1 3 1 2 3 1 3 2 1 2 1 3 2 1 3 1 3 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