QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620384#9251. Graph Changingucup-team5071WA 0ms3656kbC++141.2kb2024-10-07 17:52:372024-10-07 17:52:37

Judging History

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

  • [2024-10-07 17:52:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-10-07 17:52:37]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

bool ava(int a,int b,int c){
	return abs(b-a) >= c;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int q;
	cin >> q;
	while(q--){
		int t,n,k,x,y;
		cin >> t >> n >> k >> x >> y;
		int dis;
		if (x > y) swap(x,y);
		if (t == 0) {
			cout << y-x << "\n";
			continue;
		}
		if (k == 1){
			cout << 1 << "\n";
		} else if (k >= n) {
			dis = -1;
		} else if (y-x >= k){
			dis = 1;
		} else {
			if (ava(x,n,k) && ava(y,n,k)){
				dis = 2;
			} else if (ava(x,1,k) && ava(y,1,k)){
				dis = 2;
			} else {
				bool flag1 = (ava(x,1,k) || ava(x,n,k));
				bool flag2 = (ava(y,1,k) || ava(y,n,k));
				if (flag1 && flag2) {
					dis = 3;
				} else {
					dis = -1;
				}
			}
		}
		if (dis == -1) {
			cout << -1 << "\n"; continue;
		} else if (t == 1){
			cout << dis << "\n"; continue;
		}else if (t == 2){
			if (dis >= k) {
				cout << 1 << "\n"; continue;
			} else {
				cout << -1 << "\n"; continue;
			}
		} else {
			if (k == 2){
				if (t & 1){
					cout << ((y-x==1)? 2 : 1)<< "\n"; continue;
				} else {
					cout << y-x << "\n"; continue;
				}
			} else {
				cout << -1 << "\n"; continue;
			}
		}
	}	
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

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: -100
Wrong Answer
time: 0ms
memory: 3592kb

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
0
-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 2nd lines differ - expected: '-1', found: '0'