首页 > ACM题库 > HDU-杭电 > hdu 3180 Furion’s Sprout待解决[解题报告]C++
2014
03-06

hdu 3180 Furion’s Sprout待解决[解题报告]C++

Furion’s Sprout

问题描述 :

Effective Government SpokesmanEffective Government Spokesman Furion is the leader of all Night Elves in DOTA. He has a powerful and interesting skill: Szzprout. After he used this skill, several trees will grow quickly to form a square and trap enemy in this square. Now, give you the size of square and map of DOTA, please trap as many enemies as you can. If there are several solutions, show me the topmost one. If there’s still a tie, show me the leftmost one.

输入:

The first line contains an integer T indicating the number of test cases, and then follows T cases. The first line of each case contains three integer : X, the size of square, and N, the row number of map, and M, the column number of map. The rest of a case contains N lines, each contains M characters, which ‘.’ indicating an empty grid, and ‘x’ indicating an grid occupied by an enemy.
0 < T <= 20, 1 < N <= 10, 1 < M <= 10, 1 < x <= min (N, M).

输出:

The first line contains an integer T indicating the number of test cases, and then follows T cases. The first line of each case contains three integer : X, the size of square, and N, the row number of map, and M, the column number of map. The rest of a case contains N lines, each contains M characters, which ‘.’ indicating an empty grid, and ‘x’ indicating an grid occupied by an enemy.
0 < T <= 20, 1 < N <= 10, 1 < M <= 10, 1 < x <= min (N, M).

样例输入:

2

2 2 6
x.x.x.
x.xx..

3 6 3
.x.
xx.
...
.x.
.xx
..x

样例输出:

Trapped 3 enemy(ies).
x.ITx.
x.II..

Trapped 4 enemy(ies).
.x.
xx.
...
TIT
TxI
TTI


  1. 我没看懂题目
    2
    5 6 -1 5 4 -7
    7 0 6 -1 1 -6 7 -5
    我觉得第一个应该是5 6 -1 5 4 输出是19 5 4
    第二个是7 0 6 -1 1 -6 7输出是14 7 7
    不知道题目例子是怎么得出来的

  2. #include <cstdio>
    #include <algorithm>

    struct LWPair{
    int l,w;
    };

    int main() {
    //freopen("input.txt","r",stdin);
    const int MAXSIZE=5000, MAXVAL=10000;
    LWPair sticks[MAXSIZE];
    int store[MAXSIZE];
    int ncase, nstick, length,width, tmp, time, i,j;
    if(scanf("%d",&ncase)!=1) return -1;
    while(ncase– && scanf("%d",&nstick)==1) {
    for(i=0;i<nstick;++i) scanf("%d%d",&sticks .l,&sticks .w);
    std::sort(sticks,sticks+nstick,[](const LWPair &lhs, const LWPair &rhs) { return lhs.l>rhs.l || lhs.l==rhs.l && lhs.w>rhs.w; });
    for(time=-1,i=0;i<nstick;++i) {
    tmp=sticks .w;
    for(j=time;j>=0 && store >=tmp;–j) ; // search from right to left
    if(j==time) { store[++time]=tmp; }
    else { store[j+1]=tmp; }
    }
    printf("%dn",time+1);
    }
    return 0;
    }

  3. 第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。