荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: kaman (天外飞仙), 信区: ACMICPC
标 题: [合集]FT!!!昨天的A题!!!!
发信站: 荔园晨风BBS站 (Tue Jun 1 11:04:21 2004), 站内信件
posidone (海王波赛冬) 于Fri Apr 2 08:34:01 2004提到:
昨晚回宿舍之后,完全凭记忆把A题的程序写了一遍。
找雁鸿要测试数据,居然第一次运行就全部过掉了!!!
气死我也!!!
posidone (海王波赛冬) 于Fri Apr 2 08:35:29 2004提到:
此题程序如下:
#include<stdio.h>
int a[4][4];
int x,y;
int test(int k)
{
int i,j;
int u1,u2,u3,u4;
u1=0;
u2=0;
u3=0;
u4=0;
for(i=0;i<4;i++)
{
u1=0;
u2=0;
for(j=0;j<4;j++)
{
if(a[i][j]!=k) u1=1;
if(a[j][i]!=k) u2=1;
}
if(u1==0||u2==0) return 1;
if(a[i][i]!=k) u3=1;
if(a[i][3-i]!=k) u4=1;
}
if(u3==0||u4==0) return 1;
return 0;
}
int search(int k,int t)
{
int i,j;
if(test(-k)==1) return 0;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(a[i][j]==0)
{
a[i][j]=k;
if(search(-k,t+1)==0)
{
a[i][j]=0;
if(t==1)
{
x=i;
y=j;
}
return 1;
}
a[i][j]=0;
}
}
}
return 0;
}
void main()
{
int i,j,k;
char c;
freopen("win.in","r",stdin);
freopen("win.out","w",stdout);
while(1)
{
scanf("%c\n",&c);
if(c=='$') break;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
scanf("%c",&c);
if(c=='x') a[i][j]=1;
if(c=='o') a[i][j]=-1;
if(c=='.') a[i][j]=0;
}
scanf("%c",&c);
}
k=search(1,1);
if(k==1) printf("(%d,%d)",x,y);
else printf("#####");
printf("\n");
}
}
kaman (天外飞仙) 于Fri Apr 2 10:53:34 2004提到:
太慢了,if you o it like this
posidone (海王波赛冬) 于Fri Apr 2 13:19:20 2004提到:
网速慢阿。
我连不上bbs啊,不然早就发了!
alec (AlecMonkeyKing) 于Fri Apr 2 20:54:23 2004提到:
还是死搜吗?时间呢?
alec (AlecMonkeyKing) 于Fri Apr 2 20:55:46 2004提到:
他不是说这个慢拉,它的意思和我的一样指你的程序运行需要的时间太多
kaman (天外飞仙) 于Fri Apr 2 20:56:35 2004提到:
re~~~~~~~~
posidone (海王波赛冬) 于Fri Apr 2 22:30:25 2004提到:
测试没有超时!!!
4秒
kaman (天外飞仙) 于Fri Apr 2 22:32:09 2004提到:
if the contest take it a little more strict,it will be time-out.
alec (AlecMonkeyKing) 于Fri Apr 2 22:52:11 2004提到:
i think so, but when you in the contest if you can make sure the
time limit is much more than 4s, and the n is not too large. it
is ok. any way when we in the contest the first thing is solve
the problem in time and get the Accept.
i believe there is some better arithmetic of this problem.
if i got time i will try to find it out.
hey kaman, did you find it?
kaman (天外飞仙) 于Fri Apr 2 22:56:10 2004提到:
I find a way which seems better,but no make sure.
I will try it later.
alec (AlecMonkeyKing) 于Fri Apr 2 22:57:10 2004提到:
good, try it now ok?
posidone (海王波赛冬) 于Fri Apr 2 23:01:59 2004提到:
告诉我你的算法。
kaman (天外飞仙) 于Fri Apr 2 23:10:36 2004提到:
I try it first,tell you tomorrow
bakey (飘云) 于Sat Apr 3 16:24:37 2004提到:
kaman (天外飞仙) 于Sat Apr 3 19:05:09 2004)
提到:
设一个时间变量,前后相减.
或拿个秒表,大概测一测,很明显的
#include<windows.h>
.
.
.
DWORD time=timeGetTime();
.
.
.
time=timeGetTime()-time;
.
.
.
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店