搜索-F

本文介绍了一种通过鼠标点击选定图像中对象的方法,并计算所选对象边界的周长。利用深度优先搜索遍历对象的所有部分,判断边界条件来计算周长。
  • 原题

    Description
    Technicians in a pathology lab analyze digitized images of slides. Objects on a slide are selected for analysis by a mouse click on the object. The perimeter of the boundary of an object is one useful measure. Your task is to determine this perimeter for selected objects.
    >
    The digitized slides will be represented by a rectangular grid of periods, ‘.’, indicating empty space, and the capital letter ‘X’, indicating part of an object. Simple examples are
    >
    XX Grid 1 .XXX Grid 2
    XX .XXX
    .XXX
    …X
    ..X.
    >
    X…
    >
    An X in a grid square indicates that the entire grid square, including its boundaries, lies in some object. The X in the center of the grid below is adjacent to the X in any of the 8 positions around it. The grid squares for any two adjacent X’s overlap on an edge or corner, so they are connected.
    >
    XXX
    XXX Central X and adjacent X’s
    XXX
    >
    An object consists of the grid squares of all X’s that can be linked to one another through a sequence of adjacent X’s. In Grid 1, the whole grid is filled by one object. In Grid 2 there are two objects. One object contains only the lower left grid square. The remaining X’s belong to the other object.
    >
    The technician will always click on an X, selecting the object containing that X. The coordinates of the click are recorded. Rows and columns are numbered starting from 1 in the upper left hand corner. The technician could select the object in Grid 1 by clicking on row 2 and column 2. The larger object in Grid 2 could be selected by clicking on row 2, column 3. The click could not be on row 4, column 3.
    >
    >
    One useful statistic is the perimeter of the object. Assume each X corresponds to a square one unit on each side. Hence the object in Grid 1 has perimeter 8 (2 on each of four sides). The perimeter for the larger object in Grid 2 is illustrated in the figure at the left. The length is 18.
    >
    Objects will not contain any totally enclosed holes, so the leftmost grid patterns shown below could NOT appear. The variations on the right could appear:
    >
    Impossible Possible
    >
    XXXX XXXX XXXX XXXX
    X..X XXXX X… X…
    >
    XX.X XXXX XX.X XX.X
    XXXX XXXX XXXX XX.X
    >
    ….. ….. ….. …..
    >
    ..X.. ..X.. ..X.. ..X..
    >
    .X.X. .XXX. .X… …..
    >
    ..X.. ..X.. ..X.. ..X..
    >
    ….. ….. ….. …..
    Input
    The input will contain one or more grids. Each grid is preceded by a line containing the number of rows and columns in the grid and the row and column of the mouse click. All numbers are in the range 1-20. The rows of the grid follow, starting on the next line, consisting of ‘.’ and ‘X’ characters.
    >
    The end of the input is indicated by a line containing four zeros. The numbers on any one line are separated by blanks. The grid rows contain no blanks.
    Output
    For each grid in the input, the output contains a single line with the perimeter of the specified object.
    Sample Input
    2 2 2 2
    XX
    XX
    6 4 2 3
    .XXX
    .XXX
    .XXX
    …X
    ..X.
    X…
    5 6 1 3
    .XXXX.
    X….X
    ..XX.X
    .X…X
    ..XXX.
    7 7 2 6
    XXXXXXX
    XX…XX
    X..X..X
    X..X…
    X..X..X
    X…..X
    XXXXXXX
    7 7 4 4
    XXXXXXX
    XX…XX
    X..X..X
    X..X…
    X..X..X
    X…..X
    XXXXXXX
    0 0 0 0
    Sample Output
    8
    18
    40
    48
    8

  • 思路解析
    根据输入的网格和初始坐标,输出从初始坐标出发走过并围成的图形周长。

  • AC代码

#include<iostream>
#include<cstring>
using namespace std;
#define MAX 25
char map[MAX][MAX];
int visit[MAX][MAX];
int dir[8][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}};
int r, c, sum;
void dfs(int x, int y)
{
    visit[x][y] = 1;
    for(int i = 0; i < 8; i++)
    {
        int p = x + dir[i][0];
        int q = y + dir[i][1];
        if(p >= 1 && p <= r && q >= 1 && q <= c)
        {
            if(map[p][q] == 'X' && visit[p][q] == 0)
            {
                dfs(p, q);
            }
            else if(map[p][q]=='.' && (p == x || q == y))
            {
                sum++;
            }
        }
        else if (p == x || q == y)
        {
            sum++;
        }
    }
}
int main()
{
    int i, j, x, y;
    while(cin >> r >> c >> x >> y)
    {
        if(x + y + r + c == 0) break;
        for(i = 1; i <= r; i++)
        {
            for(j = 1; j <= c; j++)
            {
                visit[i][j] = 0;
            }
        }
        for(i=1; i <= r; i++)
        {
            for(j = 1; j <= c; j++)
            {
                cin >> map[i][j];
            }
        }
        sum = 0;
        dfs(x, y);
        cout << sum << endl;
    }
    return 0;
}
<think>好的,我需要帮助用户查找modetest命令中-F参数的用法或功能。首先,我应该回顾用户提供的引用内容,看看是否有提到-F参数的相关信息。根据用户提供的引用[1]、[2]、[3],这些引用主要讨论了modetest的常用参数如-s、-P、-c、-e等,但并没有提到-F参数。这说明用户提供的参考资料中可能没有关于-F参数的详细信息。接下来,我需要考虑是否在其他常见的modetest文档或使用说明中存在-F参数的说明。通常,Linux的DRM调试工具modetest的参数可能会因版本或驱动的不同而有所变化。如果用户提供的引用中没有-F参数,可能需要查找其他来源的信息。例如,可以查阅modetest的官方文档、man页面,或者通过运行modetest --help来查看所有可用参数。不过,根据用户当前的提问,他们可能已经尝试过这些方法但没有找到相关信息,因此转向寻求帮助。在这种情况下,我需要基于现有的知识和可能的常见参数用法进行推断。通常,参数中的-F可能代表某种格式(Format)、帧缓冲(Framebuffer)或全屏(Fullscreen)等。但这些都是推测,需要进一步验证。 另外,考虑到modetest的其他参数如-P用于设置平面,-s用于设置模式,-w用于设置属性,-F可能是一个不太常用的参数,或者可能是新版本中新增的功能。如果无法在现有资料中找到确切信息,可能需要建议用户查阅其特定版本的modetest帮助文档,或者直接运行modetest-F来查看是否有错误提示或用法说明,这可能会提供线索。 此外,还可以建议用户检查modetest的源代码,如果他们有访问权限的话,以查看-F参数的具体实现。但这可能超出了普通用户的操作范围。综合来看,虽然用户提供的引用中没有-F参数的信息,但基于常见参数命名习惯和功能,可以推测-F可能与帧缓冲、格式或全屏模式有关。不过,为了确保准确性,最好建议用户查阅官方文档或使用帮助命令来获取最准确的信息。</think>关于`modetest`命令中的`-F`参数,目前提供的引用资料中未明确提及该参数的功能。不过,根据DRM/KMS调试工具的参数命名惯例和相关功能推测,`-F`可能与**帧缓冲(Framebuffer)配置**或**格式强制指定**相关,例如强制设置像素格式(如RGB888、YUV420等)或刷新帧缓冲属性。 --- ### 建议排查方法: 1. **查看帮助文档** 运行命令 `modetest --help` 或 `man modetest`,检查输出中是否包含`-F`的说明。 ```bash modetest --help | grep -F '-F' ``` 2. **实验性测试** 尝试组合使用`-F`与其他参数(如设置分辨率`-s`),观察输出或显示效果的变化: ```bash modetest -F <format> -s <connector_id>:1920x1080@60 ``` 3. **查阅代码或更新日志** 若为开源工具,可通过DRM项目仓库(如[libdrm](https://gitlab.freedesktop.org/mesa/drm))搜索`-F`参数的提交记录或代码注释[^1]。 --- ### 常见参数类比参考: - `-s`: 设置显示模式与分辨率[^2] - `-P`: 配置平面(Plane)属性[^1] - `-w`: 修改对象属性(如色彩范围、旋转)[^1] - `-F`可能类似`@<format>`(在`-s`参数中指定像素格式)[^3],但需进一步验证。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值