QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674595#9251. Graph Changingwoodie_0064#WA 0ms3688kbC++201.3kb2024-10-25 16:48:132024-10-25 16:48:13

Judging History

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

  • [2024-10-25 16:48:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-10-25 16:48:13]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 1e5 + 3;
int T;
int n, num;


void work(){
	int q;cin >> q;
	while(q--) {
		int t,n,k,x,y;cin >> t >> n >> k >> x >> y;
		if(x < y) swap(x,y);
		if(t == 0) {
			cout << x - y << '\n';
			continue;
		}
		if(k == 1) {
			cout << "1\n";
			continue;
		}
		if(n == 2) {
			cout << "-1\n";
			continue;
		}
		if(n == 3) {
			if(k >= 3) cout << "-1\n";
			else if(k == 2){
				if(t > 1) cout << "-1\n";
				else {
					if(x == 2 || y == 2) cout << "-1\n";
					else cout << "1\n";
				}
			}
			continue;
		}
		if(k == 2) {
			if(t % 2 == 0) cout << x - y << '\n';
			else cout << (x - y == 1 ? 2 : 1) << '\n';
			continue;
		}
		if(k >= 3) {
			if(t != 1) cout << "-1\n";
			else {
				
				auto check = [&] (int x) {
					return x <= k && x > n - k;
				};
				
				if(x - y >= k) cout << "1\n";
				else if(check(x) || check(y)) cout << "-1\n";
				else {
					if(x <= n - k && y <= n - k)cout << "2\n";
					else if(x > k && y > k) cout << "2\n";
					else cout << "3\n";
				}
			}
			continue;
		}
	}
}


int main(){
//	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
//	cin >> T;
//	while(T--){
		work();
//	}	
	return 0;
}

詳細信息

Test #1:

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

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

input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er
time: 0ms
memory: 3688kb

input:

180
1 4 1 1 2
1 4 1 1 3
1 4 1 1 4
1 4 1 2 3
1 4 1 2 4
1 4 1 3 4
1 4 2 1 2
1 4 2 1 3
1 4 2 1 4
1 4 2 2 3
1 4 2 2 4
1 4 2 3 4
1 4 3 1 2
1 4 3 1 3
1 4 3 1 4
1 4 3 2 3
1 4 3 2 4
1 4 3 3 4
1 4 4 1 2
1 4 4 1 3
1 4 4 1 4
1 4 4 2 3
1 4 4 2 4
1 4 4 3 4
1 4 5 1 2
1 4 5 1 3
1 4 5 1 4
1 4 5 2 3
1 4 5 2 4
1 4 5 ...

output:

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

wrong answer 10th lines differ - expected: '3', found: '2'