Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

找到错误了,终于变成了 TLE

Posted by xiaxia at 2006-02-16 12:01:49 on Problem 2749
In Reply To:严重精神崩溃,求救!!!(注释程序) Posted by:first at 2006-02-15 23:57:42
严重精神崩溃,求救!!!(注释程序)
Posted by first at 2006-02-15 23:57:42.0 on Problem 2749 
--------------------------------------------------------------------------------

参照报告写得 二分法 + 2sat  贡献n多wa
我写了注释那位看看 问题在那。 无限感激!!!!
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

#define min(a, b)  ((a) < (b) ? (a):(b))
#define max(a, b)  ((a) > (b) ? (a):(b))

#define MAXIN 500

int N, A, B;
int sx1, sy1, sx2, sy2;
int xy[MAXIN][2];     //坐标
int dist[MAXIN][2];  //距离 
int Dij;
bool G[MAXIN*2][MAXIN*2];   //邻接图矩阵
bool TG[MAXIN*2][MAXIN*2];  //备份矩阵
bool visited[MAXIN*2];   //访问标志
int  finished[MAXIN*2];  //完成顺序 
int  cid[MAXIN*2];   //强连通分量的id

就是这个index定义有问题,这样整个程序只初始化1次
而希望的是每次搜索初始化一次,大意大衣阿。
void fDFS(int i)  //2sat第一遍的  DFS
{
	static int index = 0;	
	visited[i] = true; 
    int k;
	for(k = 0; k < 2*N; k ++)
	{
		if(G[i][k] && !visited[k])
              fDFS(k);
	}
	finished[index++] = i; //储存完成顺序
}

 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator