| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 833 人关注过本帖
标题:求指教,麻烦各位看看这道竞赛题.
只看楼主 加入收藏
hana_flower
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-7-22
结帖率:0
收藏
 问题点数:0 回复次数:7 
求指教,麻烦各位看看这道竞赛题.
In this problem you will be given a number of scenarios. Each scenario begins with a line containing two digits X and Y (separated by a space) representing the length and width of the grid (0 < X, Y <= 30). A scenario in which X and Y are both 0 marks the end of input.

The second line of the scenario is a single digit M (0 < M <= 1000) which gives the number of items located by the archaeologists. This is followed by M lines each containing the X and Y coordinates of the grid cell in which an item was found. Note that the grid coordinate system starts at 0, 0 and that several items may be found in a particular cell, so cell coordinates may be repeated.

Following the M lines of item locations there is a list of cell references for which the total number of found items is required. The first line of this section is a single integer, N, which gives the number of cells (0 < N <= (X * Y)). There follows N lines each containing the X and Y coordinates of a cell.

Output consists of a single line for each scenario. It contains the total number of items found in the N cells listed.

For example:

Input Output
2 3     2
4       3
0 1
1 0
0 1
1 2
1
0 1
10 10
8
4 5
3 4
0 0
1 5
9 9
5 6
3 4
9 9
3
9 9
4 5
6 3
0 0

这是老师今天留给我们的题目,我英文水平有限,题和这道题的关系都有点看不明白,请教与网络,请大家帮帮忙。
搜索更多相关主题的帖子: scenario single problem number second 
2012-08-13 18:44
demonleer
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:10
帖 子:483
专家分:1225
注 册:2012-6-4
收藏
得分:0 
X Y表示格网的长和宽,X Y都为0时输入结束。

M表示的是在这个格网里总共有的宝贝数量,接下来的M行表示每个宝贝所在的单元坐标,这些坐标从0开始。有些单元里可能会有好多宝贝,所以坐标有可能会是重复的。

N表示的是参考的单元数目,接下来的N行表示这些单元的坐标。

输出就是这些参考单元所包含的宝贝总数。

比如 X = 2 Y =3表示的格网如下:

2 |__|__|
1 |__|__|
0 |__|__|
    0  1

题中给出 0 1这个单元有两个宝贝,所以输出2。

英文水平有限,不知道对不对。
2012-08-13 19:47
ldzy
Rank: 5Rank: 5
等 级:职业侠客
威 望:1
帖 子:64
专家分:339
注 册:2012-7-30
收藏
得分:0 
如果For example里的数据列表无误,就是我理解错了。
2012-08-13 20:21
demonleer
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:10
帖 子:483
专家分:1225
注 册:2012-6-4
收藏
得分:0 
你把题目的OJ地址发上来,我去测下。
2012-08-13 21:06
demonleer
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:10
帖 子:483
专家分:1225
注 册:2012-6-4
收藏
得分:0 
你给的地址我不知道用的是什么检测系统,我这边没问题,那边各种错误。

COMPILE ERROR.
cc1: warnings being treated as errors
main.c:3: error: missing braces around initializer
main.c:3: error: (near initialization for 'itms[0]')
Further testing aborted.
---------------------------------------------------------------------
终于对了,把数组初始化的方式改变下就行了。

Correct
Marks for this submission: 2.00/2.00. Accounting for previous tries, this gives 1.00/2.00.


程序代码:
#include <stdio.h>

int itms[30][30];
int answer[1000] = {0};

void print_answer(int n)
{
    int i = 0;
    while (i<n) printf("%d\n",answer[i++]);
}

void reset_fun(int (*trgt)[30])
{
    int i = 0, j = 0;
    for (; i<30; i++)
    for (j=0; j<30; j++) *(*(trgt+i)+j) = 0;
}

int main()
{
    int M, N, i = 0, X, Y, x, y, k = 0;
    while (1)
    {
        scanf("%d%d",&X,&Y);
        if (X==0&&Y==0) break;
        reset_fun(itms);
        for (i=0,scanf("%d",&M); i<M; itms[x][y]++,i++)
        scanf("%d%d",&x,&y);
        for (i=0,scanf("%d",&N); i<N; answer[k]+=itms[x][y],i++)
        scanf("%d%d",&x,&y);
        k++;
    }
    print_answer(k);
    return 0;
}


[ 本帖最后由 demonleer 于 2012-8-14 10:51 编辑 ]
2012-08-14 10:21
demonleer
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:10
帖 子:483
专家分:1225
注 册:2012-6-4
收藏
得分:0 
以下是引用demonleer在2012-8-13 19:47:19的发言:

X Y表示格网的长和宽,X Y都为0时输入结束。

M表示的是在这个格网里总共有的宝贝数量,接下来的M行表示每个宝贝所在的单元坐标,这些坐标从0开始。有些单元里可能会有好多宝贝,所以坐标有可能会是重复的。

N表示的是参考的单元数目,接下来的N行表示这些单元的坐标。

输出就是这些参考单元所包含的宝贝总数。

比如 X = 2 Y =3表示的格网如下:

2 |__|__|
1 |__|__|
0 |__|__|
    0  1

题中给出 0 1这个单元有两个宝贝,所以输出2。

英文水平有限,不知道对不对。


题目的大概意思就是这样,只要判断给定的单元中有多少个宝贝就行了,此题比较水。
2012-08-14 10:56
hao02171990
Rank: 2
等 级:论坛游民
帖 子:17
专家分:17
注 册:2012-6-20
收藏
得分:0 
太强悍了!
2012-08-14 11:48
li361li
Rank: 2
等 级:论坛游民
帖 子:35
专家分:43
注 册:2010-1-29
收藏
得分:0 
膜拜,非此题水,而是你英语太强
表示最讨厌做英文的题
2012-08-14 15:07
快速回复:求指教,麻烦各位看看这道竞赛题.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015330 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved