Series of Crimes

Series of Crimes

The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.The Berland capital’s map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital.The capital’s main detective Polycarpus took a map and marked there the districts where the first three robberies had been committed as asterisks. Deduction tells Polycarpus that the fourth robbery will be committed in such district, that all four robbed districts will form the vertices of some rectangle, parallel to the sides of the map.Polycarpus is good at deduction but he’s hopeless at math. So he asked you to find the district where the fourth robbery will be committed.InputThe first line contains two space-separated integers n and m (2 ≤ n, m ≤ 100) — the number of rows and columns in the table, correspondingly.Each of the next n lines contains m characters — the description of the capital’s map. Each character can either be a “.” (dot), or an “" (asterisk). A character equals "” if the corresponding district has been robbed. Otherwise, it equals “.”.It is guaranteed that the map has exactly three characters "" and we can always find the fourth district that meets the problem requirements.OutputPrint two integers — the number of the row and the number of the column of the city district that is the fourth one to be robbed. The rows are numbered starting from one from top to bottom and the columns are numbered starting from one from left to right.
Examples
Input
3 2
.


**
Output
1 1
Input3 3
.
*…

Output
2 3
分析
找出三个标记坐标,在用两个数组分别存放x和y,在分别找出其中与另外两个不同的x,y.输出即可。
写的有点麻烦,我的思路是这样,代码还可优化

# include <stdio.h>
int main(){
 int n,m,i,j,x[10],y[10],r,sum=0,sum2=0;
 char a[200][200];
 scanf("%d%d",&n,&m);
 getchar();
 for(i=0;i<n;i++)
   gets(a[i]);
 for(i=0;i<n;i++){
   for(j=0;j<m;j++){
    if(a[i][j]=='*'){
     x[sum] = i+1;
     y[sum] = j+1;
     sum++;
    }     
   }
 } 
 for(i=0;i<2;i++)
  for(j=0;j<2-i;j++){
   if(x[j]>x[j+1]){
    r = x[j];
    x[j] = x[j+1];
    x[j+1] = r;
   }
   if(y[j]>y[j+1]){
    r = y[j];
    y[j] = y[j+1];
    y[j+1] = r;
   }   
  }   
  if(x[0]!=x[1])
   printf("%d ",x[0]);
  else
   printf("%d ",x[2]);
  if(y[0]!=y[1])
   printf("%d ",y[0]);
  else
   printf("%d ",y[2]); 
 return 0;  
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
chicago_crimes数据集是一个关于芝加哥市犯罪事件的数据库,它提供了大量有关该城市不同犯罪类型的详细信息。该数据集包含了从2001年至今的犯罪记录。 这个数据集中包含了许多字段,包括犯罪日期、犯罪类型、定罪结果、犯罪位置等等。通过分析这些数据,我们可以了解到芝加哥市各个区域的犯罪率以及不同类型犯罪的发生情况。 通过对chicago_crimes数据集的研究,我们可以发现一些有趣的趋势和模式。例如,我们可以分析不同时间段内的犯罪率是否有所变化。另外,我们还可以通过分析不同的犯罪类型,了解哪些犯罪行为在芝加哥市比较常见。 通过对这些数据的进一步研究,我们可以洞察犯罪行为的背后因素。例如,我们可以尝试找出不同地理位置和社会经济因素与犯罪之间的关联。这有助于城市规划者和执法机构更好地了解犯罪的产生原因,从而采取更有针对性的措施。 除了对犯罪行为进行研究外,chicago_crimes数据集还可以用于构建犯罪模型和预测犯罪趋势。通过分析历史数据,我们可以发现某些特定因素与不同类型的犯罪行为之间的联系,并用这些信息进行犯罪预测,以便提前采取相应的措施。 总的来说,chicago_crimes数据集提供了丰富的关于芝加哥市犯罪事件的信息,通过对这些数据的分析和研究,我们可以更好地了解犯罪行为的特征、趋势和影响因素,进而为城市治理和公共安全提供更好的支持和指导。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值