QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#688810#9251. Graph Changingreal_sigma_team#WA 0ms3716kbC++231.2kb2024-10-30 13:42:522024-10-30 13:42:53

Judging History

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

  • [2024-10-30 13:42:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3716kb
  • [2024-10-30 13:42:52]
  • 提交

answer

#include<bits/stdc++.h>

int main() {
	std::cin.tie(nullptr)->sync_with_stdio(false);

	int q;
	std::cin >> q;
	while (q--) {
		int64_t t, n, k, x, y;
		std::cin >> t >> n >> k >> x >> y;
		if (x > y) std::swap(x, y);
		if (t == 0) std::cout << std::abs(x - y) << '\n';
		else if (k == 1) std::cout << "1\n";
		else if (k == 2) {
			if (n == 2) std::cout << "-1\n";
			else if (n == 3) {
				if (t == 1 && x == 1 && y == 3) std::cout << "1\n";
				else std::cout << "-1\n";
			} else if (t % 2 == 0) std::cout << std::abs(x - y) << '\n';
			else std::cout << (std::abs(x - y) == 1 ? 2 : 1) << '\n';
		} else if (t == 1) {
			if (std::abs(x - y) >= k) std::cout << "1\n";
			else if (std::max(n - x, x - 1) < k || std::max(n - y, y - 1) < k) std::cout << "-1\n";
			else if (std::min(n - x, n - y) >= k || std::min(x - 1, y - 1) >= k) std::cout << "2\n";
			else std::cout << "3\n";
		} else if (k > 3) {
			std::cout << "-1\n";
		} else if (k == 3) {
			if (t > 2) std::cout << "-1\n";
			else {
				if (n == 5 && x == 2 && y == 4) std::cout << "1\n";
				else if (n == 6 && x == 3 && y == 4) std::cout << "1\n";
				else std::cout << "-1\n";
			} 
		} else {
			assert(false);
		}
	}
}

詳細信息

Test #1:

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

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

input:

30
1 2 1 1 2
1 2 2 1 2
1 2 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 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'