Bzoj hundreds of thousands of colors violent

Source: Internet
Author: User

Given a sequence, two operations are provided:

1. query the numbers in the [L, R] interval.

2. Single-point Modification

N, m <= 1 W

Decision tree? Chair tree? No! This question is only violent for 2 S. Don't think it's complicated! Please try it out!

Discretization of numbers! The tag is replaced by a timestamp! 675b second cut! Not so cool!

... Well, if you think this is meaningless, you can try a tree-type set of bitsets, which should be faster.

In short, the holiday progress is 50%: 66.7% million dead-end

# Include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # define M 10010 using namespace STD; int n, m, a [m], map [1001001], TOT; int f [M + 1000], T, ans; int main () {int I, j, X, Y; char P [10]; cin> N> m; for (I = 1; I <= N; I ++) {scanf ("% d", & X); If (! Map [x]) map [x] = ++ tot; A [I] = map [X];} for (I = 1; I <= m; I ++) {scanf ("% S % d", P, & X, & Y); If (P [0] = 'R') {If (! Map [y]) map [y] = ++ tot; A [x] = map [y];} else {ans = 0; ++ T; for (j = x; j <= y; j ++) if (F [A [J]! = T) ++ ans, F [A [J] = T; printf ("% d \ n", ANS );}}}


Bzoj hundreds of thousands of colors violent

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.