QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#597742#9251. Graph ChangingDBsoleilWA 1ms3724kbC++232.8kb2024-09-28 18:36:512024-09-28 18:36:52

Judging History

你现在查看的是最新测评结果

  • [2024-09-28 18:36:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3724kb
  • [2024-09-28 18:36:51]
  • 提交

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;
    int S=q,T=0;
    while(q--){
        T++;
        cin>>t>>n>>k>>x>>y;
        // if(S==180&&T==44)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 cout<<y-x<<"\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: 100
Accepted
time: 0ms
memory: 3600kb

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: 3572kb

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: 3720kb

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 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
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
2
1
1
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...

result:

ok 180 lines

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3724kb

input:

300
1 5 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
-1
-1
1
1
-1
3
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
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
...

result:

wrong answer 21st lines differ - expected: '2', found: '-1'