Ejemplo n.º 1
0
int main(){
    int cnt = 1;
    while(cin >> r >> x1 >> y01 >> x2 >> y2, r||x1||y01||x2||y2){
	cnr.clear();
	if(y2 <= 0){
	    y2 *= -1; y01 *= -1;
	    swap(y01, y2);
	}
	if(x2 <= 0){
	    x2 *= -1; x1 *= -1;
	    swap(x1, x2);
	}
	cnr.pb(P(x1,y01)); cnr.pb(P(x2,y01));
	cnr.pb(P(x2,y2)); cnr.pb(P(x1,y2));
	if(y01 < 0){
	    rep(i,4) cnr[i] = rotate(cnr[i], PI/2);
	    P tmp = cnr[3];
	    rep(i,3) cnr[i+1] = cnr[i];
	    cnr[0] = tmp;
	}
	x1 = cnr[0].real(); y01 = cnr[0].imag();
	x2 = cnr[2].real(); y2 = cnr[2].imag();
	w = x2 - x1; h = y2 - y01;
	cerr << "Case" << cnt++ << ": ";
	if(x1 < 0) solve1();
	else solve2();
    }
    return 0;
}
int main ()
{
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; i ++)
	{
		string line = ConsoleReadLine ();
		if (line == "")
		    line = ConsoleReadLine ();
		vector <string> splitted = vector <string> (Split (line, " ->"));
		int from = atoi (splitted [0].c_str ());
		for (int i = 1 ; i < (int)splitted.size () ; i ++)
		{
			int to = atoi (splitted [i].c_str ());
			graph.addEdge (from, to, 0);
		}
	}
	visited = new bool [n];
	for (int i = 0 ; i < n ; i ++)
		DFS (i);
	if (no_result)
		cout << "No cycles found\n";
	else
	    for (auto& x : output)
		cout << x;
	delete[] visited;
}
Ejemplo n.º 3
0
int main()
{
  const Point<2> p1(0.0, 0.0), p2(1.0, 1.0);
  dealii::Triangulation<2> triangulation;
  dealii::GridGenerator::hyper_rectangle(triangulation, p1, p2);
  triangulation.refine_global(num_levels);

  const F<2> f;
  const G<2> g;

  // Create a TensorFunction from two scalar Functions
  const auto psi = internal::TensorFunctionFromScalarFunctions<2>(f, g);

  // Generate a bunch of random poins in the unit square
  std::random_device device;
  std::mt19937 rng;
  rng.seed(device());
  std::uniform_real_distribution<> u(0, 1);

  const size_t num_points = 32;
  std::vector<Point<2> > points(num_points);
  for (size_t k = 0; k < num_points; ++k) {
    points[k][0] = u(rng);
    points[k][1] = u(rng);
  }

  // Check that the TensorFunction and its coordinate functions agree at a
  // few points
  for (size_t k = 0; k < num_points; ++k) {
    const Point<2>& p = points[k];
    const Tensor<1, 2> v = psi.value(p);
    Tensor<1, 2> w;
    w[0] = f.value(p);
    w[1] = g.value(p);

    check((v - w).norm() < 1.0e-15);
  }

  return 0;
}
Ejemplo n.º 4
0
		bool GetLog(bool ma_success) const { return g->GetLog(ma_success); }
Ejemplo n.º 5
0
		bool GetDisplay(bool ma_success) const { return g->GetDisplay(ma_success); }
Ejemplo n.º 6
0
		void SetLog(bool b) const { g->SetLog(b); }
Ejemplo n.º 7
0
		void SetLog(size_t idx, bool b) const
		{
			g->SetLog(idx, b);
		}
Ejemplo n.º 8
0
		void SetDisplay(bool b) const { g->SetDisplay(b); }
Ejemplo n.º 9
0
 length() { return p.size(); }
Ejemplo n.º 10
0
    qs.resize(k - 1);
    return qs;
}

// ベクトルp, qのなす角(q->pの方向が正)
double thetaPP(P p, P q) {
    int sgn = cross(q, p) > 0 ? +1 : -1;
    return sgn * acos(dot(p, q) / abs(p) / abs(q));
}

// lがx軸となす角
double thetaL(L l) {
    return thetaPP(l.v, P(1, 0));
}

G rotG(G g, P p, double theta) {
    rep(i, g.size()) {
        g[i] = rotP(g[i], p, theta);
    }
    return g;
}

P centroidG(G g) {
    int n = g.size();
    double x = 0, y = 0;
    rep(i, n) {
        x += g[i].real();
        y += g[i].imag();
    }
    return P(x / n, y / n);
}
Ejemplo n.º 11
0
__declspec(dllexport ) bool WINAPI crea()
{
	return g.crea();
}
Ejemplo n.º 12
0
    void ack() {
	foo( 0 );
    }
Ejemplo n.º 13
0
__declspec(dllexport ) bool WINAPI DeleteEdge(int a,int b)
{
	return g.Delete_Edge(a,b);
}
Ejemplo n.º 14
0
__declspec(dllexport ) bool WINAPI CaminoMinimo(int s,int t)
{
	return g.camino_minimo_prim(s,t);
}
Ejemplo n.º 15
0
__declspec(dllexport ) bool WINAPI DeleteNode(int n)
{
	return g.Delete_Node(n);
}
Ejemplo n.º 16
0
__declspec(dllexport ) bool WINAPI InsertEdge(double p,int a,int b)
{
	return g.Insert_Edge(p,a,b);
}
Ejemplo n.º 17
0
__declspec(dllexport ) bool WINAPI InsertNode(int n,int x,int y)
{
	return g.Insert_Node(n,x,y);
}
Ejemplo n.º 18
0
		const RichBool::detail::String& GetName(size_t idx) const
		{ return idx==GetSize() ? GetLevelName(2) : g->GetName(idx); }
Ejemplo n.º 19
0
Archivo: main.cpp Proyecto: CCJY/coliru
 void operator()()
 {
     assert( g.constructed() );
     r = run( &g, first_index, last_index );
 }
Ejemplo n.º 20
0
		bool Has(const char *groupName) const
		{
			return g->Has(groupName);
		}
Ejemplo n.º 21
0
		// these are const, because GroupHolder is not the owner of g.
		void SetDisplay(size_t idx, bool b) const
		{
			g->SetDisplay(idx, b);
		}
Ejemplo n.º 22
0
		bool GetDisplay(size_t idx) const
		{ return g->GetDisplay(idx); }
Ejemplo n.º 23
0
 void m4 () {
     g.m3 ();
 }
Ejemplo n.º 24
0
		bool GetLog(size_t idx) const
		{ return g->GetLog(idx); }
Ejemplo n.º 25
0
Archivo: main.cpp Proyecto: CCJY/coliru
 void init(const int *p, int n, int b, int e){
     g.init( p, n );
     first_index = b;
     last_index = e;
     r.checksum = r.maxflips = 0;
 }