QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#682918 | #9251. Graph Changing | louhao088 | WA | 0ms | 3864kb | C++98 | 2.5kb | 2024-10-27 17:55:24 | 2024-10-27 17:55:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXQ=1e6,MAXV=1e9;
const int Code[]={0,2,4,0,1,3};
const int Code2[]={0,0,1,3,2,4};
inline int ABS(int x) {return x>0 ? x : -x;}
int q,t,n,K,x,y;
int dis[7][7];
int main()
{
dis[1][2] = 2; dis[1][3] = 2; dis[1][4] = 1; dis[1][5] = 1; dis[1][6] = 1;
dis[2][3] = 2; dis[2][4] = 3; dis[2][5] = 1; dis[2][6] = 1;
dis[3][4] = 3; dis[3][5] = 3; dis[3][6] = 1;
dis[4][5] = 2; dis[4][6] = 2;
dis[5][6] = 2;
scanf("%d",&q);
while(q--)
{
scanf("%d %d %d %d %d",&t,&n,&K,&x,&y);
if(x>y) swap(x,y);
if(t==0) {printf("%d\n",y-x);continue;}
if(n<=K) {puts("-1");continue;}
if(K==1) {puts("1");continue;}
if(K==2)
{
if(n==3)
{
if(t==1 && x==1 && y==3) puts("1");
else puts("-1");
continue;
}
if(t&1)
{
if(y-x>1) puts("1");
else puts("2");
}
else printf("%d\n",y-x);
continue;
}
if(K>=4)
{
if(t==1)
{
if(y-x>=K) {puts("1");continue;}
if((x-1>=K && y-1>=K) || (n-x>=K && n-y>=K)) {puts("2");continue;}
puts("3");
}
else puts("-1");
continue;
}
if(n>7)
{
if(t==1)
{
if(y-x>=K) puts("1");
else puts("2");
}
else puts("-1");
continue;
}
if(n==4)
{
if(t==1 && x==1 && y==4) puts("1");
else puts("-1");
continue;
}
if(n==5)
{
if(t==1)
{
if(x==3 || y==3) {puts("-1");continue;}
printf("%d\n",ABS(Code[x]-Code[y]));
}
else if(t==2 && x==2 && y==4) puts("1");
else puts("-1");
continue;
}
if(t>3) {puts("-1");continue;}
if(t==2)
{
if(1<x && y<6) printf("%d\n",ABS(Code2[x]-Code2[y]));
else puts("-1");
continue;
}
if(t==3)
{
if(x==2 && y==5) puts("1");
else puts("-1");
}
if(t==1)
{
// if (x > y) swap(x, y);
printf("%d\n", dis[x][y]);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
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: 3596kb
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: 3668kb
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 2 3 2 3 3 1 2 2 3 3 1 3 2 3 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