编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#101585 #1437. [L3-2] Ice World Accepted 100 89 ms 3332 K C++ / 4.7 K Claes 2024-03-13 18:46:16
显示原始代码
#include <bits/stdc++.h>
using namespace std;
int ww[2][35][35][35][3][3];
int xy[4] = { 0, 1, 0, -1 };
int yy[4] = { 1, 0, -1, 0 };
int n, a1, b1, c1, d1, a2, b2, c2, d2;
void dfs(int ab, int x1, int y1, int x2, int stg, int rf) {
    int y2 = n - (x1 + y1 - 2 - (n - x2));
    if (ab != 0) {
        y2++;
    }
    //	cout<< ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' ' << rf << endl ;
    if (stg == 1 && abs(x1 - x2) + abs(y1 - y2) <= 1) {
        ww[ab][x1][y1][x2][stg][rf] = 1;
        //		cout<<"A" << ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' '
        //<< rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
        return;
    }
    if (stg == 2 && abs(x1 - x2) + abs(y1 - y2) <= 1) {
        ww[ab][x1][y1][x2][stg][rf] = 2;
        //		cout<<"B" << ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' '
        //<< rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
        return;
    }
    if (rf == 1 && (x1 == x2 || y1 == y2)) {
        //		cout<< rf << ' ' << ( rf == 1 ) << endl ;
        ww[ab][x1][y1][x2][stg][rf] = 1;
        //		cout<<"C" << ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' '
        //<< rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
        return;
    }
    if (rf == 2 && (x1 == x2 || y1 == y2)) {
        ww[ab][x1][y1][x2][stg][rf] = 2;
        //		cout<<"D" << ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' '
        //<< rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
        return;
    }
    if (x1 == n && y1 == n && x2 == 1 && y2 == 1) {
        ww[ab][x1][y1][x2][stg][rf] = 0;
        return;
    }
    if (ab == 0) {
        int al2 = 1;
        for (int i = 0; i < 2; i++) {
            int tx = x1 + xy[i];
            int ty = y1 + yy[i];
            if (tx <= 0 || tx > n || ty <= 0 || ty > n)
                continue;
            int tstg = stg;
            int trf = rf;
            if (stg == 0) {
                if (x1 == a1 && y1 == b1 && tx == c1 && ty == d1) {
                    tstg = 1;
                }
                if (x1 == c1 && y1 == d1 && tx == a1 && ty == b1) {
                    tstg = 1;
                }
            }
            if (rf == 0) {
                if (x1 == a2 && y1 == b2 && tx == c2 && ty == d2) {
                    trf = 1;
                }
                if (x1 == c2 && y1 == d2 && tx == a2 && ty == b2) {
                    trf = 1;
                }
            }
            if (ww[1][tx][ty][x2][tstg][trf] == -1) {
                dfs(1 - ab, tx, ty, x2, tstg, trf);
            }
            if (ww[1][tx][ty][x2][tstg][trf] == 1) {
                ww[ab][x1][y1][x2][stg][rf] = 1;
                //	cout<< ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' ' <<
                //rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
                return;
            }
            if (ww[1][tx][ty][x2][tstg][trf] != 2) {
                al2 = 0;
            }
        }
        if (al2 == 1) {
            ww[ab][x1][y1][x2][stg][rf] = 2;
        } else {
            ww[ab][x1][y1][x2][stg][rf] = 0;
        }
    } else {
        int al1 = 1;
        for (int i = 2; i < 4; i++) {
            int tx = x2 + xy[i];
            int ty = y2 + yy[i];
            if (tx <= 0 || tx > n || ty <= 0 || ty > n)
                continue;
            int tstg = stg;
            int trf = rf;
            //			cout<< x2 << ' ' << y2 << ' ' << tx << ' ' << ty << endl ;
            if (stg == 0) {
                //				cout<< "A\n" ;
                //				cout<< c1 << ' ' << d1 << ' ' << a1 << ' ' << b1 << endl ;
                if (x2 == a1 && y2 == b1 && tx == c1 && ty == d1) {
                    //					cout<< "1\n" ;
                    tstg = 2;
                }
                if (x2 == c1 && y2 == d1 && tx == a1 && ty == b1) {
                    //					cout<< "2\n" ;
                    tstg = 2;
                }
            }
            if (rf == 0) {
                if (x2 == a2 && y2 == b2 && tx == c2 && ty == d2) {
                    trf = 2;
                }
                if (x2 == c2 && y2 == d2 && tx == a2 && ty == b2) {
                    trf = 2;
                }
            }
            if (ww[0][x1][y1][tx][tstg][trf] == -1) {
                dfs(1 - ab, x1, y1, tx, tstg, trf);
            }
            if (ww[0][x1][y1][tx][tstg][trf] == 2) {
                ww[ab][x1][y1][x2][stg][rf] = 2;
                //	cout<< ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' ' <<
                //rf << ' ' << ww[ab][x1][y1][x2][stg][rf] << endl ;
                return;
            }
            if (ww[0][x1][y1][tx][tstg][trf] != 1) {
                al1 = 0;
            }
        }
        if (al1 == 1) {
            ww[ab][x1][y1][x2][stg][rf] = 1;
        } else {
            ww[ab][x1][y1][x2][stg][rf] = 0;
        }
    }
    //	cout<< ab << ' ' << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << stg << ' ' << rf << ' ' <<
    //ww[ab][x1][y1][x2][stg][rf] << endl ;
    return;
}
int main() {
    int t;
    cin >> t;
    while (t--) {
        memset(ww, -1, sizeof(ww));
        cin >> n >> a1 >> b1 >> c1 >> d1 >> a2 >> b2 >> c2 >> d2;
        //		cout<< a1 << ' ' << b1 << ' ' << c1 << ' ' << d1 << endl ;
        dfs(0, 1, 1, n, 0, 0);
        if (ww[0][1][1][n][0][0] == 0) {
            cout << "0\n";
        } else if (ww[0][1][1][n][0][0] == 1) {
            cout << "Alice\n";
        } else {
            cout << "Bob\n";
        }
    }
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:5 ms
内存:3332 KiB

输入文件(1.in

20
2 2 1 2 2 1 1 1 2
2 1 1 2 1 1 1 1 2
2 2 1 2 2 2 1 2 2
2 1 2 2 2 2 1 2 2
2 1 1 1 2 1 1 1 2
2 1 1 2
<262 bytes omitted>

答案文件(1.out

Alice
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alic
<14 bytes omitted>

用户输出

Alice
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:5 ms
内存:3328 KiB

输入文件(2.in

20
5 5 3 5 4 2 4 3 4
5 2 3 3 3 2 2 2 3
4 2 1 2 2 3 4 4 4
6 1 2 1 3 1 2 2 2
6 5 1 5 2 6 5 6 6
4 4 3 4
<262 bytes omitted>

答案文件(2.out

Bob
Alice
Bob
Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice

用户输出

Bob
Alice
Bob
Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:6 ms
内存:3328 KiB

输入文件(3.in

20
3 1 3 2 3 1 2 1 3
6 6 2 6 3 5 4 5 5
4 4 2 4 3 1 2 2 2
3 1 3 2 3 2 2 3 2
3 2 2 3 2 1 3 2 3
5 4 1 5
<262 bytes omitted>

答案文件(3.out

Alice
Bob
Alice
0
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
0
Alice
Bob
Bob
Alice
Bob

用户输出

Alice
Bob
Alice
0
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
0
Alice
Bob
Bob
Alice
Bob

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:8 ms
内存:3316 KiB

输入文件(4.in

20
5 4 3 4 4 2 3 2 4
4 3 4 4 4 3 4 4 4
3 2 1 2 2 2 3 3 3
4 1 4 2 4 1 1 1 2
4 1 1 1 2 4 1 4 2
6 3 4 3
<262 bytes omitted>

答案文件(4.out

Alice
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Alice
Alice
Alice
Bob
Bo
<2 bytes omitted>

用户输出

Alice
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Alice
Bob
Alice
Alice
Alice
Bob
Bob

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:5 ms
内存:3328 KiB

输入文件(5.in

20
3 2 2 3 2 1 1 1 2
6 5 5 5 6 1 5 2 5
3 2 3 3 3 2 1 3 1
5 1 3 1 4 2 3 2 4
5 2 3 3 3 2 5 3 5
4 1 2 1
<262 bytes omitted>

答案文件(5.out

Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Bob
0
Alice
Alice
Bob
Alice

用户输出

Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Alice
Alice
Bob
Bob
0
Alice
Alice
Bob
Alice

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:8 ms
内存:3328 KiB

输入文件(6.in

20
9 4 2 4 3 4 7 5 7
9 3 7 4 7 4 4 5 4
10 2 9 3 9 9 8 10 8
9 4 1 5 1 7 7 7 8
9 8 7 9 7 4 1 5 1
10 7 
<276 bytes omitted>

答案文件(6.out

Bob
Alice
Bob
Bob
Alice
Bob
Alice
Bob
Alice
Alice
Alice
Bob
Bob
Bob
0
0
Alice
Alice
Alice
Bob

用户输出

Bob
Alice
Bob
Bob
Alice
Bob
Alice
Bob
Alice
Alice
Alice
Bob
Bob
Bob
0
0
Alice
Alice
Alice
Bob

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:5 ms
内存:3328 KiB

输入文件(7.in

20
10 4 2 5 2 8 1 8 2
9 9 3 9 4 6 3 7 3
10 4 6 5 6 3 4 3 5
9 7 9 8 9 1 6 2 6
9 7 7 7 8 6 8 7 8
9 4 3
<274 bytes omitted>

答案文件(7.out

Alice
Bob
Alice
0
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Alice
Alice
Alice

用户输出

Alice
Bob
Alice
0
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Alice
Alice
Alice

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:8 ms
内存:3328 KiB

输入文件(8.in

20
12 11 6 11 7 4 7 5 7
10 3 7 4 7 7 1 8 1
18 9 16 10 16 12 10 12 11
22 12 13 13 13 4 9 5 9
5 4 2 4 
<344 bytes omitted>

答案文件(8.out

Alice
Alice
Bob
Alice
Bob
Alice
Bob
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Alice
Bob
Alice
Bob
Alice

用户输出

Alice
Alice
Bob
Alice
Bob
Alice
Bob
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Alice
Bob
Alice
Bob
Alice

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:16 ms
内存:3264 KiB

输入文件(9.in

20
5 3 2 4 2 4 2 4 3
6 5 3 5 4 3 2 4 2
5 4 5 5 5 4 1 5 1
8 5 6 5 7 7 5 7 6
21 3 4 3 5 18 21 19 21
15
<339 bytes omitted>

答案文件(9.out

Alice
0
Bob
Bob
Bob
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Alice
Alice

用户输出

Alice
0
Bob
Bob
Bob
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Alice
Alice

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:23 ms
内存:3328 KiB

输入文件(10.in

20
30 16 8 16 9 9 24 9 25
30 6 6 7 6 15 23 16 23
30 28 23 28 24 8 12 9 12
30 22 24 23 24 28 28 29 28
<399 bytes omitted>

答案文件(10.out

Bob
Bob
0
Bob
Alice
Bob
Bob
Alice
Bob
Bob
Bob
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob

用户输出

Bob
Bob
0
Bob
Alice
Bob
Bob
Alice
Bob
Bob
Bob
Alice
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob

系统信息

Exited with return code 0