# comiz

re: 说题~[未登录] comiz 2007-11-15 22:02
24是因为之前排过序了,出现四个1位置相同的情况肯定是4!种,如果使用了相同的数就跳过,理论上是要计算43680*43680次,但是我也没测试过有没有超时,你能不能现把你写的意思告诉我?
re: 说题~ comiz 2007-11-11 19:01

private void solve()
{
int count=0,n=0;
for(int i=0;i<43680;i+=24)
for(int j=i+24;j<43680;j+=24)
if((A[i].flag&A[j].flag)==0)
for(int k=0;k<24;k++)
for(int l=0;l<24;l++)
if(A[i+k].result==A[j+l].result)
No[A[i+k].flag|A[j+l].flag]++;

for(count=0;count<two(16);count++)
if(No[count]!=0&&No[(two(16)-1)^count]!=0)
{
n+=No[count]*No[(two(16)-1)^count];
}
Console.WriteLine("count:"+(n/2).ToString());

}

re: 说题~ comiz 2007-11-11 00:29

re: a problem of maze comiz 2007-11-04 19:35
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;

namespace TroytownKeeper
{

public class TroytownKeeper
{
string [] maze;
bool [,]used=new bool[100,100];
int sum=0;
public TroytownKeeper()
{

}

public int LimeLiters(string [] maze)
{
this.maze=maze;
for(int x=0;x<maze.GetLength(0);x++)
{
if(maze[x][0]=='.') dfs(x,0);
if(maze[x][maze[0].Length-1]=='.') dfs(x,maze[0].Length-1);
}
for(int y=0;y<maze[0].Length-1;y++)
{
if(maze[0][y]=='.') dfs(0,y);
if(maze[maze.GetLength(0)-1][y]=='.') dfs(maze.GetLength(0)-1,y);
}

for(int x=0;x<maze.GetLength(0);x++)
for(int y=0;y<maze[0].Length;y++)
if(maze[x][y]=='#')
{
//upside
if(x==0)
sum++;
if(x<maze.Length-1&&used[x+1,y])
sum++;
//leftside
if(y==0)
sum++;
if(y>0&&used[x,y-1])
sum++;
//underside
if(x==maze.Length-1)
sum++;
if(x>0&&used[x-1,y])
sum++;
//rightside
if(y==maze[0].Length-1)
sum++;
if(y<maze[0].Length-1&&used[x,y+1])
sum++;
}
return sum;
}

static void Main(string[] args)
{
TroytownKeeper TK=new TroytownKeeper();
string [] str={"##..#"
,"#.#.#"
,"#.#.#"
,"#####"};
int count=TK.LimeLiters(str);
Console.WriteLine(count.ToString());
}

void dfs(int x,int y)
{
used[x,y]=true;
if(x<maze.GetLength(0)&&maze[x+1][y]=='.'&&!used[x+1,y]) dfs(x+1,y);
if(y<maze[0].Length&&maze[x][y+1]=='.'&&!used[x,y+1]) dfs(x,y+1);
if(x>0&&maze[x-1][y]=='.'&&!used[x-1,y]) dfs(x-1,y);
if(y>0&&maze[x][y-1]=='.'&&!used[x,y-1]) dfs(x,y-1);
}
}
}

 < 2024年6月 >
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

• 随笔 - 2
• 文章 - 0
• 评论 - 1
• 引用 - 0

•