void graph3d::grid_draw(void) { mesh_material::set_default(); VECT vn(0.0f,0.0f,-1.0f); VECT vf(0.0f,0.0f, 1.0f); GPIPE *p_gpipe = gpipe_get(); p_gpipe->screen_normal_to_world(&vn); p_gpipe->screen_normal_to_world(&vf); // v1->v2 VECT dir; dir = vf-vn; dir *= 0.5f; vn += dir; vn.y = 0.0f; VECT vl(-1.0f,0.0f,1.0f); VECT vr( 1.0f,0.0f,1.0f); p_gpipe->screen_normal_to_world(&vl); p_gpipe->screen_normal_to_world(&vr); VECT width; width = vr-vl; draw_floor_line(&vn,width.size(),2,40); }
INT solve(INT n, INT k, INT a, INT b, INT c, INT r) { VECT* m = new VECT(); MAP* used = new MAP(); gen(a, b, c, r, k, m, used); VECT* unused = new VECT(); for (INT x = 0; x < 2*k; ++x) { if (used->find(x) == used->end()) { unused->push_back(x); } } m->push_back((*unused)[0]); (*used)[(*unused)[0]] = 1; unused->pop_front(); INT last = m->size() - 1; INT limit = 2 * k; INT currval; printf("limit = %lu\n", limit); while (last != 2 * k) { if (last % 100 == 0) { printf("%d %lu\n", m->size(), last); } currval = (*m)[0]; if (unused->size() == 0) { printf("Big bad error (n=%lu, k=%lu)\n", n, k); return 0; } if (used->find(currval) == used->end()) { (*used)[currval] = 0; } if ((*used)[currval] == 0) { if (currval < (*unused)[0]) { m->push_back(currval); (*used)[currval] = 1; } else { m->push_back((*unused)[0]); (*used)[(*unused)[0]] = 1; unused->pop_front(); unused->push_back(currval); sort(unused->begin(), unused->end()); } } else if ((*used)[currval] > 1) { (*used)[currval] -= 1; m->push_back((*unused)[0]); unused->pop_front(); } else if ((*used)[currval] == 1) { if (currval < (*unused)[0]) { m->push_back(currval); } else { (*used)[currval] = 0; m->push_back((*unused)[0]); (*used)[(*unused)[0]] = 1; unused->pop_front(); unused->push_back(currval); sort(unused->begin(), unused->end()); /* x = (*unused)[unused->size() - 1]; while (true) { if (used->find(x) == used->end()) { unused->push_back(x); break; } ++x; }// */ } } m->pop_front(); ++last; } printf("Done...\n"); printf("m->size() = %lu\n", (INT)m->size()); return m->back(); }