示例#1
0
int main() {
    vector<string> name;
    vector<int> scores;
    string n;
    int s, index;
    bool view;

    while(cin >> n >> s && n != "NoName" && s != 0) {
        if(is_overlap(n, name)) {
            cout << "Error! (overlap)" << endl;
            exit(EXIT_FAILURE);
        }

        name.push_back(n);
        scores.push_back(s);
    }

    while(cin >> s) {
        view = false;
        for(index = 0; index < name.size(); ++index) {
            if(scores[index] == s) {
                view = true;
                cout << name[index] << endl;
            }
        }
        if(view == false)
            cout << "score not found" << endl;
    }
}
示例#2
0
int main(){
	vector<string> name;
	vector<int> scores;
	string n;
	int s, index;

	while(cin >> n >> s && n != "NoName" && s != 0){
		if(is_overlap(n, name)){
			cout << "Error! (overlap)" << endl;
			exit(EXIT_FAILURE); 
		}

		name.push_back(n);
		scores.push_back(s);
	}

	while(cin >> n){
		index = find(n, name);
		if(index != -1)
			cout << scores[index] << endl;
		else
			cout << "name not found" << endl;		
	}

}
示例#3
0
INT_NODE interval_search(INT_TREE tree, INT i)
{
    INT_NODE node_x = tree -> root;
    while (node_x != NULL && !is_overlap(node_x, i))
    {
        if(node_x -> left != NULL && node_x -> left -> max >= i -> low)
        {
            node_x = node_x -> left;
        }else
        {
            node_x = node_x -> right;
        }
    }
    return node_x;
}
示例#4
0
文件: main.cpp 项目: CCJY/coliru
int main()
{
	std::vector<interval> T = {{3,5}, {1,2}, {6,8}, {4,17}};
	std::cout << is_overlap(T) << std::endl;
}
示例#5
0
void util_blitter_copy_texture_view(struct blitter_context *blitter,
                                    struct pipe_surface *dst,
                                    unsigned dstx, unsigned dsty,
                                    struct pipe_sampler_view *src,
                                    const struct pipe_box *srcbox,
                                    unsigned src_width0, unsigned src_height0)
{
   struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
   struct pipe_context *pipe = ctx->base.pipe;
   struct pipe_framebuffer_state fb_state;
   enum pipe_texture_target src_target = src->texture->target;
   unsigned width = srcbox->width;
   unsigned height = srcbox->height;

   /* Sanity checks. */
   if (dst->texture == src->texture &&
       dst->u.tex.level == src->u.tex.first_level) {
      assert(!is_overlap(srcbox->x, srcbox->x + width, srcbox->y, srcbox->y + height,
                         dstx, dstx + width, dsty, dsty + height));
   }
   /* XXX should handle 3d regions */
   assert(srcbox->depth == 1);

   /* Check whether the states are properly saved. */
   blitter_set_running_flag(ctx);
   blitter_check_saved_vertex_states(ctx);
   blitter_check_saved_fragment_states(ctx);
   blitter_check_saved_textures(ctx);
   blitter_check_saved_fb_state(ctx);

   /* Initialize framebuffer state. */
   fb_state.width = dst->width;
   fb_state.height = dst->height;

   if (util_format_is_depth_or_stencil(dst->format)) {
      pipe->bind_blend_state(pipe, ctx->blend_keep_color);
      pipe->bind_depth_stencil_alpha_state(pipe,
                                           ctx->dsa_write_depth_keep_stencil);
      pipe->bind_fs_state(pipe,
            blitter_get_fs_texfetch_depth(ctx, src_target));

      fb_state.nr_cbufs = 0;
      fb_state.zsbuf = dst;
   } else {
      pipe->bind_blend_state(pipe, ctx->blend_write_color);
      pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
      pipe->bind_fs_state(pipe,
            blitter_get_fs_texfetch_col(ctx, src_target));

      fb_state.nr_cbufs = 1;
      fb_state.cbufs[0] = dst;
      fb_state.zsbuf = 0;
   }

   /* Set rasterizer state, shaders, and textures. */
   pipe->bind_rasterizer_state(pipe, ctx->rs_state);
   pipe->bind_vs_state(pipe, ctx->vs);
   if (ctx->has_geometry_shader)
      pipe->bind_gs_state(pipe, NULL);
   pipe->bind_fragment_sampler_states(pipe, 1, &ctx->sampler_state);
   pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
   pipe->set_fragment_sampler_views(pipe, 1, &src);
   pipe->set_framebuffer_state(pipe, &fb_state);

   blitter_set_dst_dimensions(ctx, dst->width, dst->height);

   switch (src_target) {
      /* Draw the quad with the draw_rectangle callback. */
      case PIPE_TEXTURE_1D:
      case PIPE_TEXTURE_2D:
      case PIPE_TEXTURE_RECT:
         {
            /* Set texture coordinates. - use a pipe color union
             * for interface purposes.
             * XXX pipe_color_union is a wrong name since we use that to set
             * texture coordinates too.
             */
            union pipe_color_union coord;
            get_texcoords(src, src_width0, src_height0, srcbox->x, srcbox->y,
                          srcbox->x+width, srcbox->y+height, coord.f);

            /* Draw. */
            blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
                                    UTIL_BLITTER_ATTRIB_TEXCOORD, &coord);
         }
         break;

      /* Draw the quad with the generic codepath. */
      default:
         /* Set texture coordinates. */
         switch (src_target) {
         case PIPE_TEXTURE_1D_ARRAY:
         case PIPE_TEXTURE_2D_ARRAY:
         case PIPE_TEXTURE_3D:
         case PIPE_TEXTURE_CUBE:
            blitter_set_texcoords(ctx, src, src_width0, src_height0, srcbox->z,
                                  srcbox->y, srcbox->x,
                                  srcbox->x + width, srcbox->y + height);
            break;

         default:
            assert(0);
         }

         /* Draw. */
         blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0);
         ctx->base.pipe->redefine_user_buffer(ctx->base.pipe, ctx->vbuf,
                                              0, ctx->vbuf->width0);
         util_draw_vertex_buffer(ctx->base.pipe, NULL, ctx->vbuf, 0,
                                 PIPE_PRIM_TRIANGLE_FAN, 4, 2);
         break;
   }

   blitter_restore_vertex_states(ctx);
   blitter_restore_fragment_states(ctx);
   blitter_restore_textures(ctx);
   blitter_restore_fb_state(ctx);
   blitter_unset_running_flag(ctx);
}