QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688970#9251. Graph ChangingYipChip#WA 0ms3708kbC++141.3kb2024-10-30 14:36:412024-10-30 14:36:42

Judging History

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

  • [2024-10-30 14:36:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-30 14:36:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve()
{
    int t, n, k, x, y;
    cin >> t >> n >> k >> x >> y;
    if (x > y) swap(x, y);
    if (!t) return cout << y - x << "\n", void();
    if (k == 1) return cout << "1\n", void();
    if (t > 2) cout << "-1\n";
    if (t == 2)
    {
        if (k > 3) cout << "-1\n";
        if (k == 3)
        {
            if (y - x >= k) cout << "-1\n";
            else
            {
                if (x > k || y + k <= n) cout << "-1\n";
                else if (x + k <= n && y > k) cout << "1\n";
                else cout << "-1\n";
            }
        }
        if (k == 2)
        {
            if (y - x >= k) cout << "1\n";
            else
            {
                if (x > k || y + k <= n) cout << "1\n";
                else if (x + k <= n && y > k) cout << "1\n";
                else cout << "-1\n";
            }
        }
    }
    if (t == 1)
    {
        if (y - x >= k) cout << "1\n";
        else
        {
            if (x > k || y + k <= n) cout << "2\n";
            else if (x + k <= n && y > k) cout << "3\n";
            else cout << "-1\n";
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while (T -- ) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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
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