The data structure problem of unknown sensation

Source: Internet
Author: User

This article will list a few unconventional data structure problems.

tyvj4393 Note

The main idea is that there are several pieces of paper, each operation is to move a note, and then seek a position of all the notes on the number of the and. All the length of the note and not more than 20W, the number of notes is 10W.

First we can divide the block, but the standard solution does not know where to go, for all the note according to the length of more than the sub-class, less than the move when the violence changes, greater than the anyway, when asked to enumerate over the line.

Ask the old driver to talk about the line-tree approach ...

#include <iostream>#include<stdio.h>#include<stdlib.h>#include<algorithm>#include<string.h>#include<vector>#include<math.h>#include<limits>#include<Set>#include<map>using namespacestd;#defineSZ 233333#defineMP 450intn,m,q,lp[sz],m=1, sn=0, ln=0, Fff[sz],lid[sz],sid[sz];structLine {intSt,cnt,pos;} SMA[SZ],LAR[SZ];intMain () {scanf ("%d%d%d",&n,&m,&q);  for(intI=1; i<=m;i++) {line cur; Cur.st=m; scanf"%d%d",&cur.pos,&cur.cnt);  for(intj=0; j<cur.cnt;j++) scanf ("%d", &lp[m++]); if(CUR.CNT&GT;MP) Lar[++ln]=cur, lid[i]=Ln; ElseSma[++sn]=cur, sid[i]=SN; }     for(intI=1; i<=sn;i++)    {         for(intj=0; j<sma[i].cnt;j++) fff[sma[i].pos+j]+=lp[sma[i].st+J]; }     while(q--)    {        Charps[6];intb; scanf ("%s", PS); if(ps[0]=='Q') {scanf ("%d", &a); --A; intans=Fff[a];  for(intj=1; j<=ln;j++)            {                if(lar[j].pos<=a&&a<=lar[j].pos+lar[j].cnt-1) ans+=lp[lar[j].st+a-Lar[j].pos]; } printf ("%d\n", ans); }        Else{scanf ("%d%d",&a,&b); if(Lid[a]) {lar[lid[a]].pos=b;Continue;} intId=Sid[a];  for(intj=0; j<sma[id].cnt;j++) {Fff[sma[id].pos+j]-=lp[sma[id].st+J]; Fff[b+j]+=lp[sma[id].st+J]; } Sma[id].pos=b; }    }}

TYVJ4394 Super Space

Matrix addition, which asks the sum of a certain historical version matrix, goes back to a certain historical version.

The matrix Edge is within 1000, asking within 2000.

Can you persist two-dimensional tree nesting trees?

We found that these operations actually constituted something like a tree of operations.

In this tree of operations we consider queries, so only things on the action path will contribute.

Violent simulations can be done. So it was a stupid problem.

The code hasn't been written yet.

Well, what if I ask 10W?

In the tree Dfs when the way to modify the two-dimensional tree array seems to be OK.

What if the side length is 10W?

In the tree Dfs when the way to modify the two-dimensional line segment tree seems to be OK.

I feel like I've created a very powerful data structure problem ...

Matrix addition, which asks the sum of a certain historical version matrix, goes back to a certain historical version.

The number of matrix Bingchang queries is within 10W.

The data structure problem of unknown sensation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.