Exemple #1
0
void Updata(int now, int pos, int k)
{
	if(TN.l == TN.r)
	{
		TN.data = k;
		PushUp(TT);
		return ;
	}
	int mid = (TN.l + TN.r) >> 1;
	if(pos > mid)
		Updata(TR, pos, k);
	else
		Updata(TL, pos, k);
}
Exemple #2
0
void find(int rank)
{
	int i,flag;
	for(i=0,flag=0;i<27;i++)
	{
 		if(!visit[i]&&Yes(i))
		{
			level[rank][0]++;
			level[rank][level[rank][0]]='A'+i;
			visit[i]=1;
			flag=1;
		}
	}
	if(flag==0)
	{
		return;
	}
	for(i=1;i<=level[rank][0];i++)
	{
		Up(level[rank][i]-'A');
	}
	for(i=1;i<=level[rank][0];i++)
	{
		Updata(level[rank][i]-'A');
	}
	find(rank+1);
}
Exemple #3
0
bool CControl_class::Save()
{
	if(m_data->GetId().empty())
	{
		m_data->CreateId();

		string sql = "insert into tab_class values('";
		sql += m_data->GetId();
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_name);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_pName);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_contact);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_num);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_tellPhone);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_detail);
		sql += "','";
		sql += CControl_bace::s_user.GetId();
		sql += "','";
		sql += m_dateChange.GetCurTimes();
		sql +="','0')";
		//return CADOOperate::ExecuteSQL(sql);
		return g_sqlite.DirectStatement(m_dateChange.Unicode2Utf8(sql));

	}

	return Updata();
}
Exemple #4
0
int main()
{
    int n,Q,cmd,a,b,k,t;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&v[i]);
        for(k=1;k<=10;k++)
            for(int i=0;i<k;i++)
                Build(TT[id(i,k)],1,1/k,n/k+1);
        scanf("%d",&Q);
        while(Q--)
        {
            scanf("%d",&cmd);
            if(cmd == 1)
            {
                scanf("%d%d%d%d",&a,&b,&k,&t);
                Updata(TT[id(a,k)],1,a/k,a/k+(b-a)/k+1,t);  
            }
            else
            {
                scanf("%d",&a);
                int tmp = 0;
                for(k=1;k<=10;k++)
                    tmp += Query(TT[id(a,k)],1,a/k,a/k+1);
                printf("%d\n",tmp+v[a]);
            }
        }
    }
    return 0;
}
Exemple #5
0
/*
*函数名称:DoMsg(int x, int y, int action)
*函数介绍:用户消息响应函数
*输入参数:(x,y)棋盘位置 action 动作  0鼠标经过 1鼠标左键
*输出参数:无
*返回值  :无
*/
bool Managers::DoMsg(int x, int y, int action)
{
	if(PAUSE)
		return false;
	if(Game_State<0 || Game_State>1)
		return false;
	if(action==1 && (Game_State==PlayerAc || !Game_Type))
	{
		if(PointCh==NULL)
		{
			if(map[x][y]-1==Game_State)
			{
				PointCh=Search(x,y);
				return true;
			}
			else
				return false;
		}
		else if((PointCh->color && Game_State==1) ||(!PointCh->color && Game_State==0))
		{
			if(PointCh->x==x && PointCh->y==y)
			{
				PointCh=NULL;
				return true;
			}else if(Moveto(PointCh,x,y,true))
			{
				Updata();
				return true;
			}
			else if(map[x][y]==Game_State+1)
			{
				PointCh=Search(x,y);
				return true;
			}
			else
			{
				PointCh=NULL;
				return false;
			}
		}
		else
		{
			PointCh=NULL;
			return false;
		}
	}
	else if(action==0 && (Game_State==PlayerAc || !Game_Type))
	{
		if(PointCh!=NULL)
		{
			if(Moveto(PointCh,x,y,false))
			{
				return true;
				//在(x,y)处高亮显示
			}
		}
	}
	return false;
}
Exemple #6
0
void Updata(int node, int father){
	for(Node *p = link[node].next_; p; p = p->next_){
		if(p->number_ != father){
			if(p->number_ > result[node])
				result[node] = p->number_;
			Updata(p->number_, node);
		}
	}
}
Exemple #7
0
void Updata(Tnode* T,int u,int l,int r,int up)
{
    if(T[u].l == l && T[u].r == r)
    {
        T[u].delta += up;
        return ;
    }
    else
        T[u].sum += up*(r-l);
    int mid = MID(T[u].l,T[u].r);
    if(l >= mid)
        Updata(T,R(u),l,r,up);
    else
        if(r <= mid)
            Updata(T,L(u),l,r,up);
        else
        {
            Updata(T,L(u),l,mid,up);
            Updata(T,R(u),mid,r,up);
        }
}
Exemple #8
0
void Updata(int i,int j,char a)
{
	if(i<1||j<1||i>h||j>w||skymap[i][j]=='0'||output[i][j]==a)
		return;
	output[i][j]=a;
	Updata(i-1,j-1,a);
	Updata(i-1,j,a);
	Updata(i-1,j+1,a);
	Updata(i,j-1,a);
	Updata(i,j+1,a);
	Updata(i+1,j-1,a);
	Updata(i+1,j,a);
	Updata(i+1,j+1,a);
}
Exemple #9
0
		inline void Insert(int h, int d) {
			if (l == r) {
				sum = d; if (d == 1) {
					bmax = vmax - 1;cmin = 1;
				}
				if (d == -1) {
					bmin = 1; cmax = vmax - 1;
				}
				return;
			}
			int mid = (l + r) >> 1;
			if (h <= mid) ch[0]->Insert(h, d); else ch[1]->Insert(h, d);
			Updata();
		}
Exemple #10
0
	inline void Work(void) {
		for (int i = 1; i <= n; i++) {
			int t = T[hash[i]];
			L[t].insert(pair(i, 0));
		}
		for (int i = 1; i <= n; i++) Updata(T[hash[i]]);
		for (int i = 1; i <= m; i++) {
			int l1 = List[i].l1, l2 = List[i].l2, p1 = List[i].p1, p2 = List[i].p2;
			Int64 delta1 = (Int64) (a[l1][p1] - a[l2][p2]) * pow[l - p2], 
			      delta2 = (Int64) (a[l2][p2] - a[l1][p1]) * pow[l - p1];
			std::swap(a[l1][p1], a[l2][p2]);
			int t1 = T[hash[l1]], t2 = T[hash[l2]];
			L[t1].erase(pair(l1, Ans[l1])); L[t2].erase(pair(l2, Ans[l2]));
			hash[l1] += delta2, hash[l2] += delta1;
			int t3 = T[hash[l1]], t4 = T[hash[l2]];
			L[t3].insert(pair(l1, Ans[l1])); L[t4].insert(pair(l2, Ans[l2]));
			Updata(t3); Updata(t4);
		}
		for (int i = 1; i <= n; i++) {
			int t = T[hash[i]];
			Updata(t);
		}
		for (int i = 1; i <= n; i++) printf("%d\n", Ans[i]);
	}
Exemple #11
0
int main(){
	scanf("%d%d", &total_node_number, &root);
	Init();
	for(int i = 1; i < total_node_number; ++i){
		scanf("%d%d", &node1, &node2);
		link[node1].next_ = new Node(node2, link[node1].next_);
		link[node2].next_ = new Node(node1, link[node2].next_);
		link_number[node1]++;
		link_number[node2]++;
	}
	Updata(root);
	scanf("%d", &total_query_number);
	for(int i = 0; i < total_query_number; ++i){
		scanf("%d", &node1);
		printf("%d\n", result[node1]);
	}
	return 0;
}
Exemple #12
0
void tpsort(Graph *tu)
{
	int i,j,k,g,flag = 0,t,m1,m2,m=0;
	Stack z;
	z.length = 0;
	while((!flag) && (m<tu->length))
	{
		m++;
		for (i = 1; i<tu->length; i++)
		{
			t = 0;
			for ( j = 1; j<=z.length; j++)
			{
				if (i==z.data[j])
					t=1;
			}
			if(tu->tou[i].next == NULL && t==0)
			{
				Push(&z,i);
				Updata(tu,i);
				//print(*tu);
				break;
			}
		}
		m1=1;
		for (g=1; g<=tu->length; g++)
		{
			m2=0;
			for ( k = 1; k<=z.length;k++)
			{
				if(z.data[k]==g)
					m2=1;
			}
			if(m2 == 0)
				m1 = m2;
		}
		flag = m1;
		//printf("%-8s",tu->tou[g].ch);break;
	}
	if(m>tu->length)
		printf("Impossible!!!");//puts("@@");
	else
		Get(z,tu);puts("");
}
Exemple #13
0
int main()
{
	while(~scanf("%d %d", &n, &m))
	{
		BuildTree(1, 1, n);
		for(int i = 0; i < m; ++ i)
		{
			char c[2];
			scanf("%s", c);
			int a, b;
			scanf("%d %d", &a, &b);
			if(c[0] == 'Q')
				printf("%d\n",Query(1, a, b));
			else
				Updata(1, a, b);
		}
	}
	return 0;
}
Exemple #14
0
bool CControl_company::Save()
{
	if(CControl_bace::s_user.GetId().empty() || CControl_bace::s_company.GetId().empty())
	{
		if(CControl_bace::s_company.GetId().empty())
			m_data->CreateId();
		else
			m_data->SetId(CControl_bace::s_company.GetId());

		string sql = "insert into tab_company values('";
		sql += m_data->GetId();
		sql += "','";
		sql += CControl_bace::s_user.GetId();
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_companyName);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_address);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_tellPhone);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_tellMan);
		sql += "','";
		sql += m_dateChange.CStringtostring(m_data->m_detail);
		sql += "','";
		sql += CControl_bace::s_user.GetId();
		sql += "','";
		sql += m_dateChange.GetCurTimes();
		sql +="','0')";
		//return CADOOperate::ExecuteSQL(sql);
		return g_sqlite.DirectStatement(m_dateChange.Unicode2Utf8(sql));
	}
	else
	{
		return Updata();
	}
}
Exemple #15
0
int main()
{
	int i,j,k1,k2,al;
	FILE *fin  = fopen ("starry.in", "r");
    FILE *fout = fopen ("starry.out", "w");
	fscanf(fin,"%d %d",&w,&h);
	for(i=1;i<=h;i++)
	{
		fscanf(fin,"%s",&skymap[i][1]);
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			output[i][j]='0';
		}
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(visit[i][j])
				continue;
			if(skymap[i][j]=='0')
				visit[i][j]=1;
			else
			{
				r=d=0;
				l=u=1000;
				search(i,j);
				memset(tmp,0,sizeof(tmp));
				memset(tmap,0,sizeof(tmap));
				for(k1=u;k1<=d;k1++)
				{
					for(k2=l;k2<=r;k2++)
					{
						tmp[k1-u+1][k2-l+1]=skymap[k1][k2];
					}
				}	
				ni=d-u+1;
				nj=r-l+1;
				make(i-u+1,j-l+1);	
				cmn=(ni<<8|nj)<(nj<<8|ni)?(ni<<8|nj):(nj<<8|ni);
				al=Judge();
				if(al==0)
				{
					Updata(i,j,'a'+total-1);
				}
				else
				{
					Updata(i,j,'a'+al-1);
				}
			}
		}
	}
	for(i=1;i<=h;i++)
	{
		fprintf(fout,"%s\n",&output[i][1]);
	}
	return 0;
}