33分其余RE
查看原帖
33分其余RE
1174222
Matthew_xh楼主2024/4/29 14:46

3, 6, 8能过(猜测是无法相遇的能过). 其余的都RE.

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#define ll long long
using namespace std;

char map[12][12];

struct Person
{
    int now_x;
    int now_y;
    int next_x = -1;
    int next_y = 0;
};

void Move(Person &p)
{
    if (map[p.now_x + p.next_x][p.now_y + p.next_y] == '*')
    {
        swap(p.next_x, p.next_y);
        p.next_y = -p.next_y;
    }
    else
    {
        p.now_x += p.next_x;
        p.now_y += p.next_y;
    }
}

int main()
{
    for (int i = 0; i < 12; i++)
    {
        map[i][11] = '*';
        map[i][0] = '*';
        map[0][i] = '*';
        map[11][i] = '*';
    }
    Person cow, man;
    for (int i = 1; i <= 10; i++)
    {
        for (int j = 1; j <= 10; j++)
        {
            cin >> map[i][j];
            if (map[i][j] == 'C')
            {
                cow.now_x = i;
                cow.now_y = j;
            }
            else if (map[i][j] == 'F')
            {
                man.now_x = i;
                man.now_y = j;
            }
        }
    }
    int time = 0;
    while (time < 160000)
    {
        Move(cow);
        Move(man);
        time++;
        if (cow.now_x == man.now_x && cow.now_y == man.now_y)
        {
            cout << time << endl;
            return 1;
        }
    }
    cout << 0 << endl;
    return 0;
}
2024/4/29 14:46
加载中...