QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760672#9251. Graph ChangingliuyichengRE 0ms0kbC++171.6kb2024-11-18 18:19:322024-11-18 18:19:34

Judging History

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

  • [2024-11-18 18:19:34]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-18 18:19:32]
  • 提交

answer

#include <iostream>
#include <cstdio>
using namespace std;
void solve() {
    int t, n, k, x, y;
    cin >> t >> n >> k >> x >> y;
    if (x < y) swap(x, y);
    if (!t) cout << x - y;
    else if (k >= n) cout << -1;
    else if (k == 1) cout << 1;
    else if (n == 3) cout << (t == 1 && x == 3 && y == 1 ? 1 : -1);
    else if (t == 1) {
        if (x - y >= k) cout << 1;
        else if (x <= k && x + k > n || y <= k && y + k > n) cout << -1;
        else if (y > k || x + k <= n) cout << 2;
        else cout << 3;
    } else if (k == 2) {
        if (t & 1 ^ 1) cout << x - y;
        else if (x - y >= 2) cout << 1;
        else if (n == 4) {
            if (x == 3 && y == 2) cout << 3;
            else cout << 2;
        } else cout << 2;
    } else if (k == 3 && n == 4 && t == 1) cout << (x - y == 3 ? 1 : -1);
    else if (k == 3 && n == 5) {
        if (t == 2 && x == 4 && y == 2) cout << 1;
        else cout << -1;
    } else if (k == 3 && n == 6){
        if (t == 2) {
            if (x == 6 || y == 1) cout << -1;
            else if (x == 5 && y == 2) cout << 3;
            else if (x == 3 && y == 2 || x == 5 && y == 4) cout << 2;
            else cout << 1;
        } else if (t == 3) cout << (x == 5 && y == 2 ? 1 : -1);
        else cout << -1;
    } else if (k == 3 && n == 7 && t == 2 && x == 5 && y == 3) cout << 1;
    else cout << -1;
    cout << '\n';
}
signed main() {
    freopen("graph.in", "r", stdin);
    freopen("graph.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T; cin >> T;
    while (T--) solve();
}

詳細信息

Test #1:

score: 0
Dangerous Syscalls

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:


result: