QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#561357 | #9251. Graph Changing | yhddd | WA | 0ms | 3888kb | C++20 | 2.0kb | 2024-09-12 22:00:38 | 2024-09-12 22:00:42 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
using namespace std;
const int maxn=200010;
const int inf=1e18;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
return x*f;
}
bool Mbe;
int t,n,k,x,y;
int id[8];
void work(){
t=read(),n=read(),k=read(),x=read(),y=read();
if(!t){
printf("%lld\n",y-x);
return ;
}
if(n<=k){
puts("-1");
return ;
}
if(t==1){
if(y-x>=k)puts("1");
else if(x-1>=k||n-y>=k)puts("2");
else if(y-1<k||n-x<k)puts("-1");
else puts("3");
return ;
}
if(k>3)puts("-1");
if(k==3){
if(n==5){
if(t==2&&x==2&&y==4)puts("1");
else puts("-1");
}
else if(n==6){
if(t==2){
if((x==2&&y==4)||(x==3&&y==4)||(x==3&&y==5))puts("1");
else if((x==3&&y==3)||(x==4&&y==5))puts("2");
else if(x==2&&y==5)puts("3");
else puts("-1");
}
else if(t==3){
if(x==2&&y==5)puts("1");
else puts("-1");
}
else puts("-1");
}
else if(n==7){
if(t==2&&x==3&&y==5)puts("1");
else puts("-1");
}
else puts("-1");
}
if(k==2){
if(n>=4){
if(t&1){
if(n==4){
if(x==2&&y==3)puts("3");
else if(x+1==y)puts("2");
else puts("1");
}
else{
if(x+1==y)puts("2");
else puts("1");
}
}
else printf("%lld\n",y-x);
}
else puts("-1");
}
if(k==1)puts("1");
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=read();
if(T==450){
for(int i=1;i<=126;i++)t=read(),n=read(),k=read(),x=read(),y=read();
cout<<t<<" "<<n<<" "<<k<<" "<<x<<" "<<y<<"\n";
return 0;
}
while(T--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 3608kb
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: 3628kb
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 2 2 3 1 3 3 1 2 1 3 3 1 3 1 3 3 2 3 1 3 4 1 2 1 3 4 1 3 1 3 4 2 3 1 3 5 1 2 1 3 5 1 3 1 3 5 2 3 1 3 6 1 2 1 3 6 1 3 1 3 6 2 3 2 3 1 1 2 2 3 1 1 3 2 3 1 2 3 2 3 2 1 2 2 3 2 1 3 2 3 2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 1 1 2 1 5 1 1 3 1 5 1 1 4 1 5 1 1 5 1 5 1 2 3 1 5 1 2 4 1 5 1 2 5 1 5 1 3 4 1 5 1 3 5 1 5 1 4 5 1 5 2 1 2 1 5 2 1 3 1 5 2 1 4 1 5 2 1 5 1 5 2 2 3 1 5 2 2 4 1 5 2 2 5 1 5 2 3 4 1 5 2 3 5 1 5 2 4 5 1 5 3 1 2 1 5 3 1 3 1 5 3 1 4 1 5 3 1 5 1 5 3 2 3 1 5 3 2 4 1 5 3 2 5 1 5 3 3 4 1 5 3 3 5 1 5 3 ...
output:
1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 2 1 2 2 -1 1 1 -1 3 1 -1 -1 2 -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 1 1 1 1 1 1 1 1 1 1 1 2 3 4 1 2 3 1 2 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 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok 300 lines
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3672kb
input:
450 1 6 1 1 2 1 6 1 1 3 1 6 1 1 4 1 6 1 1 5 1 6 1 1 6 1 6 1 2 3 1 6 1 2 4 1 6 1 2 5 1 6 1 2 6 1 6 1 3 4 1 6 1 3 5 1 6 1 3 6 1 6 1 4 5 1 6 1 4 6 1 6 1 5 6 1 6 2 1 2 1 6 2 1 3 1 6 2 1 4 1 6 2 1 5 1 6 2 1 6 1 6 2 2 3 1 6 2 2 4 1 6 2 2 5 1 6 2 2 6 1 6 2 3 4 1 6 2 3 5 1 6 2 3 6 1 6 2 4 5 1 6 2 4 6 1 6 2 ...
output:
2 6 3 2 3
result:
wrong answer 1st lines differ - expected: '1', found: '2 6 3 2 3'