| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么超时呢?help!!!!!!!!!#include<stdio.h>
int n,m;
int times;
int count;
int main()
{
int k,h,i,j,c,q,a[101][101];
char ch;
while(scanf("%d%d%d%d",&n,&m,&c,&q)!=EOF)
{
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
for(h=0;h<q;h++)
{
scanf("%c",&ch);
if(ch=='C')
{
scanf("%d%d%d",&i,&j,&k);
a[i][j]=k;
}
else if(ch=='Q')
{
scanf("%d",&k);
if(k>c)
printf("%c\n",'0');
else
{
int i,j,d;
count=0;
for(i=2;i<n;i++)
for(j=2;j<m;j++)
{
if((a[i][j]==a[i][j-1])&&(a[i][j]==a[i][j+1])&&
(a[i][j]==a[i-1][j])&&(a[i][j]==a[i+1][j])&&(a[i][j]==k))
{
count++;
if(i>=3&&j>=3&&i+2<=n&&j+2<=m)
{
times=1;
while(1)
{
times++;
if((i+times)>m||(j+times)>n||(i-times)<1||(j-times)<1)
break;
else if((a[i+times][j]==k)&&(a[i-times][j]==k)&&
(a[i][j+times])&&(a[i][j-times]))
count++;
else break;
}
}
}
else if(a[i][j+1]!=k)
j++;
}
printf("%d\n",count);
}
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator