QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#123999#6677. Puzzle: SashiganeUSP_USP_USP#WA 1ms3492kbC++232.8kb2023-07-14 02:48:032023-07-14 02:48:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 02:48:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3492kb
  • [2023-07-14 02:48:03]
  • 提交

answer

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

#define all(x) x.begin(),x.end()
#define int long long
#define pb push_back

void dbg_out() { cerr << endl; }
template<typename H, typename... T>
void dbg_out(H h, T... t){ cerr << ' '  << h; dbg_out(t...);}
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }

void solve_grid (int x, int y, int n, int m, vector<array<int, 4>> &ans) {
    if (n == 2) {
        assert (m > 2);
        ans.pb ({x, y, 1, m - 2});
        ans.pb ({x + 1, y + m - 1, -1, - (m - 2)});
        return;
    }
    if (m == 2) {
        assert (n > 2);
        ans.pb ({x, y, n - 2, 1});
        ans.pb ({x + n - 1, y + 1, - (n - 2), -1});
        return;
    }
    
    ans.pb ({x, y, n - 1, m - 1});
    solve_grid (x + 1, y + 1, n - 1, m - 1, ans);
}

void solve(){
    int n, bi, bj;
    cin >> n >> bi >> bj;

    bool troca = false;
    if (bi > bj) {
        swap (bi, bj);
        troca = true;
    }

    vector<array<int, 4>> ans;
    while (n > max (bi, bj)) {
        ans.pb ({n, n, - (n - 1), - (n - 1)});
        n--;
    }
    assert (bj == n);

    if (n == 2) {
        if (bi == 2) ans.pb ({1, 1, 1, 1});
        else {
            assert (bi == 1);
            ans.pb ({2, 1, -1, 1});
        }
    }
    else if (n == 3) {
        if (bi == 3) {
            ans.pb ({1, 1, 2, 2});
            ans.pb ({2, 2, 1, 1});
        }
        else if (bi == 2) {
            ans.pb ({1, 1, 2, 2});
            ans.pb ({3, 2, -1, 1});
        }
        else {
            ans.pb ({2, 2, -1, 1});
            ans.pb ({3, 1, -2, 2});
        }
    }
    else if (n > 3) {
        if (bi == n) {
            ans.pb ({1, n, n - 2, - (n - 2)});
            ans.pb ({2, 1, -1, n - 2});
            solve_grid (3, 1, n - 2, n - 1, ans);
        }
        else if (bi == n - 1) {
            ans.pb ({1, n, n - 3, - (n - 1)});
            ans.pb ({n, n - 1, -(n - 2), 1});
            solve_grid (2, 1, n - 1, n - 2, ans);
        }
        else if (bi == 2) {
            ans.pb ({1, n, n - 2, 1});
            ans.pb ({n, n, - (n - 3), - (n - 1)});
            solve_grid (1, 1, n - 1, n - 2, ans);
        }
        else if (bi == 1) {
            ans.pb({n, n, - (n - 2), - (n - 2)});
            ans.pb ({n - 1, 1, 1, n - 2});
            solve_grid (1, 1, n - 2, n - 1, ans);
        }
        else {
            ans.pb ({1, n, bi - 2, - (n - 1)});
            ans.pb ({n, n, - (n - bi - 1), - (n - 1)});
            solve_grid (2, 1, n - 2, n - 1, ans);
        }
    }
    cout << "Yes\n";
    cout << ans.size () << "\n";
    for (auto [x, y, xx, yy] : ans) {
        if (troca) swap (x, y), swap (xx, yy);
        cout << x << " " << y << " " << xx << " " << yy << "\n";
    }
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0);
	solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3492kb

input:

5 3 4

output:

Yes
5
5 5 -4 -4
1 4 1 -3
4 3 -2 1
2 1 1 1
4 2 -1 -1

result:

ok Correct. (1 test case)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3396kb

input:

1 1 1

output:

Yes
0

result:

ok Correct. (1 test case)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3408kb

input:

3 2 3

output:

Yes
2
1 1 2 2
3 2 -1 1

result:

ok Correct. (1 test case)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

10 10 5

output:

Yes
10
10 1 -9 3
10 10 -9 -4
1 2 8 7
2 3 7 6
3 4 6 5
4 5 5 4
5 6 4 3
6 7 3 2
7 8 1 1
9 9 -1 -1

result:

ok Correct. (1 test case)

Test #5:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

10 5 7

output:

Yes
10
10 10 -9 -9
9 9 -8 -8
8 8 -7 -7
1 7 3 -6
7 7 -1 -6
2 1 4 5
3 2 3 4
4 3 2 3
5 4 1 1
6 6 -1 -1

result:

ok Correct. (1 test case)

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3404kb

input:

10 9 2

output:

Yes
10
10 10 -9 -9
9 1 1 7
9 9 -8 -6
1 1 6 7
2 2 5 6
3 3 4 5
4 4 3 4
5 5 2 3
6 6 1 1
7 8 -1 -1

result:

wrong answer position (10,1) covered twice. (test case 1)