QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124001#6677. Puzzle: SashiganeUSP_USP_USP#AC ✓1ms3568kbC++232.8kb2023-07-14 03:07:102023-07-14 03:07:11

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 03:07:11]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3568kb
  • [2023-07-14 03:07:10]
  • 提交

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 - 1, 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();
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

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: 0ms
memory: 3388kb

input:

1 1 1

output:

Yes
0

result:

ok Correct. (1 test case)

Test #3:

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

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: 1ms
memory: 3452kb

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

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: 0
Accepted
time: 1ms
memory: 3448kb

input:

10 9 2

output:

Yes
10
10 10 -9 -9
8 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:

ok Correct. (1 test case)

Test #7:

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

input:

10 6 10

output:

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

result:

ok Correct. (1 test case)

Test #8:

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

input:

10 8 4

output:

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

result:

ok Correct. (1 test case)

Test #9:

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

input:

999 396 693

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #10:

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

input:

999 963 827

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #11:

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

input:

999 871 185

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #12:

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

input:

999 787 812

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #13:

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

input:

999 396 199

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #14:

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

input:

999 1 1

output:

Yes
998
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #15:

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

input:

999 163 1

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #16:

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

input:

999 999 1

output:

Yes
999
999 999 -997 -997
1 998 997 1
1 1 997 996
2 2 996 995
3 3 995 994
4 4 994 993
5 5 993 992
6 6 992 991
7 7 991 990
8 8 990 989
9 9 989 988
10 10 988 987
11 11 987 986
12 12 986 985
13 13 985 984
14 14 984 983
15 15 983 982
16 16 982 981
17 17 981 980
18 18 980 979
19 19 979 978
20 20 978 977
...

result:

ok Correct. (1 test case)

Test #17:

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

input:

999 1 969

output:

Yes
999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
984 984 -983 -983
983 ...

result:

ok Correct. (1 test case)

Test #18:

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

input:

999 999 780

output:

Yes
999
999 1 -998 778
999 999 -998 -218
1 2 997 996
2 3 996 995
3 4 995 994
4 5 994 993
5 6 993 992
6 7 992 991
7 8 991 990
8 9 990 989
9 10 989 988
10 11 988 987
11 12 987 986
12 13 986 985
13 14 985 984
14 15 984 983
15 16 983 982
16 17 982 981
17 18 981 980
18 19 980 979
19 20 979 978
20 21 978 ...

result:

ok Correct. (1 test case)

Test #19:

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

input:

999 1 999

output:

Yes
999
999 999 -997 -997
998 1 1 997
1 1 996 997
2 2 995 996
3 3 994 995
4 4 993 994
5 5 992 993
6 6 991 992
7 7 990 991
8 8 989 990
9 9 988 989
10 10 987 988
11 11 986 987
12 12 985 986
13 13 984 985
14 14 983 984
15 15 982 983
16 16 981 982
17 17 980 981
18 18 979 980
19 19 978 979
20 20 977 978
...

result:

ok Correct. (1 test case)

Test #20:

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

input:

999 686 999

output:

Yes
999
1 999 684 -998
999 999 -312 -998
2 1 996 997
3 2 995 996
4 3 994 995
5 4 993 994
6 5 992 993
7 6 991 992
8 7 990 991
9 8 989 990
10 9 988 989
11 10 987 988
12 11 986 987
13 12 985 986
14 13 984 985
15 14 983 984
16 15 982 983
17 16 981 982
18 17 980 981
19 18 979 980
20 19 978 979
21 20 977 ...

result:

ok Correct. (1 test case)

Test #21:

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

input:

999 999 999

output:

Yes
999
1 999 997 -997
2 1 -1 997
3 1 996 997
4 2 995 996
5 3 994 995
6 4 993 994
7 5 992 993
8 6 991 992
9 7 990 991
10 8 989 990
11 9 988 989
12 10 987 988
13 11 986 987
14 12 985 986
15 13 984 985
16 14 983 984
17 15 982 983
18 16 981 982
19 17 980 981
20 18 979 980
21 19 978 979
22 20 977 978
23...

result:

ok Correct. (1 test case)

Test #22:

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

input:

1000 757 728

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #23:

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

input:

1000 132 993

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
1 993 130 -992
993 993 -860 -992
2 1 990 991
3 2 989 990
4 3 988 989
5 4 987 988
6 5 986 987
7 6 985 986
8 7 984 985
9 8 983 984
10 9 982 983
11 10 981 982
12 11 9...

result:

ok Correct. (1 test case)

Test #24:

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

input:

1000 703 499

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #25:

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

input:

1000 910 298

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #26:

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

input:

1000 171 322

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #27:

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

input:

1000 1 1

output:

Yes
999
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
98...

result:

ok Correct. (1 test case)

Test #28:

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

input:

1000 480 1

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #29:

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

input:

1000 1000 1

output:

Yes
1000
1000 1000 -998 -998
1 999 998 1
1 1 998 997
2 2 997 996
3 3 996 995
4 4 995 994
5 5 994 993
6 6 993 992
7 7 992 991
8 8 991 990
9 9 990 989
10 10 989 988
11 11 988 987
12 12 987 986
13 13 986 985
14 14 985 984
15 15 984 983
16 16 983 982
17 17 982 981
18 18 981 980
19 19 980 979
20 20 979 9...

result:

ok Correct. (1 test case)

Test #30:

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

input:

1000 1 339

output:

Yes
1000
1000 1000 -999 -999
999 999 -998 -998
998 998 -997 -997
997 997 -996 -996
996 996 -995 -995
995 995 -994 -994
994 994 -993 -993
993 993 -992 -992
992 992 -991 -991
991 991 -990 -990
990 990 -989 -989
989 989 -988 -988
988 988 -987 -987
987 987 -986 -986
986 986 -985 -985
985 985 -984 -984
9...

result:

ok Correct. (1 test case)

Test #31:

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

input:

1000 1000 161

output:

Yes
1000
1000 1 -999 159
1000 1000 -999 -838
1 2 998 997
2 3 997 996
3 4 996 995
4 5 995 994
5 6 994 993
6 7 993 992
7 8 992 991
8 9 991 990
9 10 990 989
10 11 989 988
11 12 988 987
12 13 987 986
13 14 986 985
14 15 985 984
15 16 984 983
16 17 983 982
17 18 982 981
18 19 981 980
19 20 980 979
20 21 ...

result:

ok Correct. (1 test case)

Test #32:

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

input:

1000 1 1000

output:

Yes
1000
1000 1000 -998 -998
999 1 1 998
1 1 997 998
2 2 996 997
3 3 995 996
4 4 994 995
5 5 993 994
6 6 992 993
7 7 991 992
8 8 990 991
9 9 989 990
10 10 988 989
11 11 987 988
12 12 986 987
13 13 985 986
14 14 984 985
15 15 983 984
16 16 982 983
17 17 981 982
18 18 980 981
19 19 979 980
20 20 978 9...

result:

ok Correct. (1 test case)

Test #33:

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

input:

1000 759 1000

output:

Yes
1000
1 1000 757 -999
1000 1000 -240 -999
2 1 997 998
3 2 996 997
4 3 995 996
5 4 994 995
6 5 993 994
7 6 992 993
8 7 991 992
9 8 990 991
10 9 989 990
11 10 988 989
12 11 987 988
13 12 986 987
14 13 985 986
15 14 984 985
16 15 983 984
17 16 982 983
18 17 981 982
19 18 980 981
20 19 979 980
21 20 ...

result:

ok Correct. (1 test case)

Test #34:

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

input:

1000 1000 1000

output:

Yes
1000
1 1000 998 -998
2 1 -1 998
3 1 997 998
4 2 996 997
5 3 995 996
6 4 994 995
7 5 993 994
8 6 992 993
9 7 991 992
10 8 990 991
11 9 989 990
12 10 988 989
13 11 987 988
14 12 986 987
15 13 985 986
16 14 984 985
17 15 983 984
18 16 982 983
19 17 981 982
20 18 980 981
21 19 979 980
22 20 978 979
...

result:

ok Correct. (1 test case)

Test #35:

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

input:

2 1 1

output:

Yes
1
2 2 -1 -1

result:

ok Correct. (1 test case)

Test #36:

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

input:

2 1 2

output:

Yes
1
2 1 -1 1

result:

ok Correct. (1 test case)

Test #37:

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

input:

2 2 1

output:

Yes
1
1 2 1 -1

result:

ok Correct. (1 test case)

Test #38:

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

input:

2 2 2

output:

Yes
1
1 1 1 1

result:

ok Correct. (1 test case)

Test #39:

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

input:

810 114 514

output:

Yes
810
810 810 -809 -809
809 809 -808 -808
808 808 -807 -807
807 807 -806 -806
806 806 -805 -805
805 805 -804 -804
804 804 -803 -803
803 803 -802 -802
802 802 -801 -801
801 801 -800 -800
800 800 -799 -799
799 799 -798 -798
798 798 -797 -797
797 797 -796 -796
796 796 -795 -795
795 795 -794 -794
794 ...

result:

ok Correct. (1 test case)

Test #40:

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

input:

810 514 114

output:

Yes
810
810 810 -809 -809
809 809 -808 -808
808 808 -807 -807
807 807 -806 -806
806 806 -805 -805
805 805 -804 -804
804 804 -803 -803
803 803 -802 -802
802 802 -801 -801
801 801 -800 -800
800 800 -799 -799
799 799 -798 -798
798 798 -797 -797
797 797 -796 -796
796 796 -795 -795
795 795 -794 -794
794 ...

result:

ok Correct. (1 test case)