示例#1
0
文件: Ans.cpp 项目: niyuzheno1/CODES
int fkt(int x,int y)
{
 if(x == 0 && y != 0)
  return -1;
 if(y <= sz[a[x].L])
  return fkt(a[x].L,y);
 else if(y == sz[a[x].L]+1)
  return val[x];
 else if(y > sz[a[x].L]+1)
  return fkt(a[x].R,y-1-sz[a[x].L]);
}
示例#2
0
文件: Ans.cpp 项目: niyuzheno1/CODES
int main(int argc, char *argv[])
{
   
    setIO("Peak");
    read(n);read(m);read(Q);
    for(int i = 1;i<=n;i++)
     read(val[i]),sz[i] = 1,f[i] = i;
    for(int i = 1;i<=m;i++)
     read(b[i].C[0]),read(b[i].C[1]),read(b[i].C[2]);
    sort(b+1,b+1+m);
    for(int i = 1;i<=Q;i++)
     read(c[i].C[0]),read(c[i].C[2]),read(c[i].C[1]),c[i].C[3]=i;
    sort(c+1,c+1+Q);
    int l = 1;
    for(int i = 1;i<=Q;i++)
    {
     while(l <= m && b[l].C[2] <= c[i].C[2])
     {
     
      int x = b[l].C[0],y = b[l].C[1];
      if(gf(x) != gf(y))
       Union(x,y);
      l++;
     }
     splay(c[i].C[0]);
     
     ans[c[i].C[3]] = fkt(c[i].C[0],c[i].C[1]);
    }
    for(int i = 1;i<=Q;i++)
     printf("%d\n",ans[i]);
    closeIO();
    return EXIT_SUCCESS;
}
示例#3
0
time_t flt_http_lm_callbacks(cf_hash_t *head,cf_configuration_t *dc,cf_configuration_t *vc,int sock,time_t t1) {
#else
time_t flt_http_lm_callbacks(cf_hash_t *head,cf_configuration_t *dc,cf_configuration_t *vc,void *sock,time_t t1) {
#endif
  cf_module_t *mod;
  cf_last_modified_t fkt;
  size_t i;
  time_t ret;

  if(Modules[0].elements) {
    for(i=0;i<Modules[0].elements;i++) {
      mod = cf_array_element_at(&Modules[0],i);
      if(mod->cfg->last_modified) {
        fkt = (cf_last_modified_t)mod->cfg->last_modified;
        ret = fkt(head,dc,vc,sock);

        if(ret == (time_t)-1) continue;
        if(ret > t1) {
          #ifdef DEBUG
          printf("X-Debug: got it from %zu\n",i);
          #endif
          t1 = ret;
        }
      }
    }
  }

  return t1;
}
示例#4
0
 void apply_down_right(F fkt)
 {
     for(int i=0; i<L; ++i)
     {
         for(int j=0; j<L; ++j)
         {
             set_cell(j, i, fkt(get_cell(j, i)));
         }
     }
 }
示例#5
0
文件: thread.c 项目: dcatonR1/FreeRDP
/* Thread launcher function responsible for registering
 * cleanup handlers and calling pthread_exit, if not done
 * in thread function. */
static void* thread_launcher(void* arg)
{
	DWORD res = 1;
	void* rc = NULL;
	WINPR_THREAD* thread = (WINPR_THREAD*) arg;
	typedef void* (*fkt_t)(void*);
	fkt_t fkt;

	if (!thread)
	{
		WLog_ERR(TAG, "Called with invalid argument %p", arg);
		goto exit;
	}

	if (!(fkt = (fkt_t)thread->lpStartAddress))
	{
		WLog_ERR(TAG, "Thread function argument is %p", fkt);
		goto exit;
	}

	if (pthread_mutex_lock(&thread->threadIsReadyMutex))
		goto exit;

	if (!ListDictionary_Contains(thread_list, &thread->thread))
	{
		if (pthread_cond_wait(&thread->threadIsReady, &thread->threadIsReadyMutex) != 0)
		{
			WLog_ERR(TAG, "The thread could not be made ready");
			pthread_mutex_unlock(&thread->threadIsReadyMutex);
			goto exit;
		}
	}

	if (pthread_mutex_unlock(&thread->threadIsReadyMutex))
		goto exit;

	assert(ListDictionary_Contains(thread_list, &thread->thread));
	rc = fkt(thread->lpParameter);
exit:

	if (thread)
	{
		if (!thread->exited)
			thread->dwExitCode = (DWORD)(size_t)rc;

		set_event(thread);
		res = thread->dwExitCode;

		if (thread->detached || !thread->started)
			cleanup_handle(thread);
	}

	return rc;
}
示例#6
0
/* {{{ run_content_filters */
void cf_run_content_filters(cf_cfg_config_t *cfg,int mode,cf_cl_thread_t *thr,cf_string_t *content,cf_string_t *cite,const u_char *qchars) {
  int ret = FLT_OK;
  cf_handler_config_t *handler;
  size_t i;
  cf_content_filter_t fkt;

  if(cfg->modules[mode].elements) {
    for(i=0;i<cfg->modules[mode].elements;i++) {
      handler = cf_array_element_at(&cfg->modules[mode],i);
      fkt     = (cf_content_filter_t)handler->func;
      ret     = fkt(cfg,thr,content,cite,qchars);
    }
  }
}
示例#7
0
文件: thread.c 项目: LoveSn0w/FreeRDP
/* Thread launcher function responsible for registering
 * cleanup handlers and calling pthread_exit, if not done
 * in thread function. */
static void* thread_launcher(void* arg)
{
	DWORD res = -1;
	void* rc = NULL;
	WINPR_THREAD* thread = (WINPR_THREAD*) arg;

	if (!thread)
	{
		WLog_ERR(TAG, "Called with invalid argument %p", arg);
		goto exit;
	}
	else
	{
		void *(*fkt)(void*) = (void*) thread->lpStartAddress;

		if (!fkt)
		{
			WLog_ERR(TAG, "Thread function argument is %p", fkt);
			goto exit;
		}

		rc = fkt(thread->lpParameter);
	}

exit:

	if (thread)
	{
		if (!thread->exited)
			thread->dwExitCode = (DWORD)(size_t)rc;

		set_event(thread);

		res = thread->dwExitCode;
		if (thread->detached || !thread->started)
			cleanup_handle(thread);
	}
	pthread_exit((void*) (size_t) res);
	return rc;
}
示例#8
0
int flt_http_validate_cache(cf_hash_t *head,cf_configuration_t *dc,cf_configuration_t *vc,time_t lm,int sock) {
#else
int flt_http_validate_cache(cf_hash_t *head,cf_configuration_t *dc,cf_configuration_t *vc,time_t lm,void *sock) {
#endif
  cf_module_t *mod;
  cf_cache_revalidator_t fkt;
  size_t i;
  int ret = FLT_DECLINE;

  if(Modules[0].elements) {
    for(i=0;i<Modules[0].elements && (ret == FLT_OK || ret == FLT_DECLINE);i++) {
      mod = cf_array_element_at(&Modules[0],i);

      if(mod->cfg->revalidator) {
        fkt     = (cf_cache_revalidator_t)mod->cfg->revalidator;
        ret     = fkt(head,dc,vc,lm,sock);
      }
    }
  }

  return ret;
}
示例#9
0
int flt_http_header_callbacks(cf_hash_t *head,cf_hash_t *header_table,cf_configuration_t *dc,cf_configuration_t *vc,int sock) {
#else
int flt_http_header_callbacks(cf_hash_t *head,cf_hash_t *header_table,cf_configuration_t *dc,cf_configuration_t *vc,void *sock) {
#endif
  cf_module_t *mod;
  cf_header_hook_t fkt;
  size_t i;
  int ret = FLT_DECLINE;
  int retret = FLT_OK;

  if(Modules[0].elements) {
    for(i=0;i<Modules[0].elements;i++) {
      mod = cf_array_element_at(&Modules[0],i);
      if(mod->cfg->header_hook) {
        fkt = (cf_header_hook_t)mod->cfg->header_hook;
        ret = fkt(head,header_table,dc,vc,sock);

        if(ret == FLT_EXIT) retret = FLT_EXIT;
      }
    }
  }

  return retret;
}