Пример #1
0
//--------------------------------------------------------------------------
//-------- execute ---------------------------------------------------------
//--------------------------------------------------------------------------
void
SolverAlgorithmDriver::execute()
{
  pre_work();
  
  // assemble all interior and boundary contributions; consolidated homogeneous approach
  std::map<std::string, SolverAlgorithm *>::iterator itc;
  for ( itc = solverAlgorithmMap_.begin(); itc != solverAlgorithmMap_.end(); ++itc ) {
    itc->second->execute();
  }

  // assemble all interior and boundary contributions
  std::map<AlgorithmType, SolverAlgorithm *>::iterator it;
  for ( it = solverAlgMap_.begin(); it != solverAlgMap_.end(); ++it ) {
    it->second->execute();
  }
  
  // handle constraint (will zero out entire row and process constraint)
  for ( it = solverConstraintAlgMap_.begin(); it != solverConstraintAlgMap_.end(); ++it ) {
    it->second->execute();
  }

  // handle dirichlet
  for ( it = solverDirichAlgMap_.begin(); it != solverDirichAlgMap_.end(); ++it ) {
    it->second->execute();
  }

  post_work();
  
}
Пример #2
0
//--------------------------------------------------------------------------
//-------- execute ---------------------------------------------------------
//--------------------------------------------------------------------------
void
AlgorithmDriver::execute()
{
  pre_work();

  // assemble
  std::map<AlgorithmType, Algorithm *>::iterator it;
  for ( it = algMap_.begin(); it != algMap_.end(); ++it ) {
    it->second->execute();
  }

  post_work();

}
Пример #3
0
void solve(int n_seq)
{
	int n_query;
	scanf("%d", &n_query);
	for(int i = 0; i < n_seq; i ++)
		scanf("%d", &seq[i]);
	pre_work(n_seq);
	while(n_query --)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a --, b --;
		int len = (int)(log(b - a + 1) / log(2));
		int cnt = MAX(st[a][len], st[b - (1 << len) + 1][len]);
		int tmp = a + (1 << len) - 1;
		cnt = MAX(cnt, extre_expand(tmp, a, b));
		tmp = b - (1 << len) + 1;
		cnt = MAX(cnt, extre_expand(tmp, a, b));
		printf("%d\n", cnt);
	}
}
Пример #4
0
int main()
{
    freopen("sudoku.in", "r", stdin);
    freopen("sudoku.out", "w", stdout);

	int cs, nCase;
	int i, j, id;
	scanf("%d", &nCase);
	for (cs = 1; cs <= nCase; ++cs) {
	    printf("Case %d:\n", cs);
	    h_cnt = 0;
	    memset(col, 0, sizeof(col));
		memset(row, 0, sizeof(row));
		memset(block, 0, sizeof(block));
		for (i = 0; i < 9; ++i) {
			for (j = 0; j < 9; ++j) {
				scanf("%d", &map[i][j]);
				bit_set(col[j], map[i][j]);
                bit_set(row[i], map[i][j]);
                bit_set(block[block_id(i,j)], map[i][j]);
				if (map[i][j] == 0) {
                    hx[h_cnt] = i;
                    hy[h_cnt++] = j;
				}
			}
		}

        pre_work();
		ans_cnt = 0;
		dfs(0);
	}

    fclose(stdin);
    fclose(stdout);

	return 0;
}