【BZOJ 3569】DZY Loves Chinese II

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3569
数据生成器:http://paste.ubuntu.com/23227745/

这个题,是我到目前为止,做过的最妙的一道题
没有之一

给每一个非树边搞一个权值
然后亦或到它所覆盖的每一条树边上去
考虑不联通的情况:删掉了一条树边和所有覆盖他的非树边
及一个子集的亦或和为0
于是像求线性基一样,判一下是否线性无关即可

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 100000+9;
const int M = 1000000+9;
const int MOD = 9999971; 
const int SGZ = 40;

int head[N],nxt[M],to[M],n,m,q,val[M];
int vis[N],c[SGZ],cnt,bas[SGZ],sym[N];

inline int read(){
	char c=getchar(); int ret=0,f=1;
	while (c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0') {ret=ret*10+c-'0';c=getchar();}
	return ret*f;
}

inline void Add_Edge(int u, int v) {
	static int T = 1;
	to[++T] = v; nxt[T] = head[u]; head[u] = T; 
	to[++T] = u; nxt[T] = head[v]; head[v] = T; 
}

void DFS1(int w, int f) {
	vis[w] = 1;
	for (int i=head[w];i;i=nxt[i]) if (to[i] != f) {
		if (vis[to[i]]) {
			int W = rand()*(rand()%MOD); val[i] ^= W; val[i^1] ^= W;
			sym[w] ^= W; sym[to[i]] ^= W;	
		} else DFS1(to[i],w);
	}
}

void DFS2(int w, int f) {
	for (int i=head[w];i;i=nxt[i]) if (to[i] != f && !val[i]) 
		DFS2(to[i], w), val[i] ^= sym[to[i]], 
		val[i^1] ^= sym[to[i]], sym[w] ^= sym[to[i]];
}

inline bool update(int w) {
	for (int i=0,tmp=val[w];i<=30;i++) if (tmp&(1<<i)) {
		if (!bas[i]) {bas[i] = tmp; return false;}
		else {tmp ^= bas[i]; if (!tmp) return true;}
	} return val[w]?false:true;
}

int main(){
	srand(9999971); n = read(); m = read(); 
	for (int i=1;i<=m;i++) Add_Edge(read(),read());
	DFS1(1,1); DFS2(1,1);
	for (int q=read(),k,tag;q;q--) {
		k = read(); tag = 1; memset(bas,0,sizeof(bas));
		for (int i=1;i<=k;i++) c[i] = read()^cnt;
		for (int i=1;i<=k && tag;i++) if (update(c[i]*2)) puts("Disconnected"), tag = 0;
		if (tag) puts("Connected"), cnt++;
	}
	return 0;
}

88 thoughts to “【BZOJ 3569】DZY Loves Chinese II”

  1. I really like your blog.. very nice colors & theme.
    Did you make this website yourself or did you hire someone to do it for you?
    Plz respond as I’m looking to design my own blog and would like
    to find out where u got this from. thank you

  2. Excellent post. I was checking constantly this blog
    and I am impressed! Extremely useful info particularly the last part 🙂 I care
    for such information much. I was seeking this certain info for a long time.
    Thank you and good luck.

  3. Hi there, I do believe your web site could possibly be having web browser compatibility issues.
    Whenever I look at your web site in Safari, it looks fine however when opening in I.E., it has some overlapping issues.
    I simply wanted to give you a quick heads up! Other than that, excellent blog!

  4. I used to be suggested this blog through my cousin. I
    am not sure whether or not this post is written via him as no one else know such
    detailed approximately my problem. You are wonderful! Thanks!

  5. Oh my goodness! Incredible article dude! Thanks, However I am going through problems with
    your RSS. I don’t know why I cannot subscribe to it.

    Is there anybody else having identical RSS issues? Anybody who knows the solution will
    you kindly respond? Thanks!!

  6. Hi! I’m at work surfing around your blog from my new iphone 3gs!
    Just wanted to say I love reading through
    your blog and look forward to all your posts! Carry on the fantastic work!

  7. I believe what you wrote was very logical. But, think on this, what
    if you were to write a awesome headline? I ain’t suggesting your content is not good.,
    but suppose you added a title that makes people want more?

    I mean 【BZOJ 3569】DZY Loves Chinese II – Qizy's Database is kinda
    boring. You might look at Yahoo’s home page and see how
    they create post headlines to grab viewers interested.
    You might add a related video or a related picture or two to grab
    readers excited about what you’ve got to say. Just my opinion, it would make your posts a little livelier.

  8. You’re so interesting! I don’t believe I have read anything
    like this before. So good to discover another person with
    a few original thoughts on this topic. Seriously..
    thank you for starting this up. This site is something that is needed on the internet, someone with a bit of
    originality!

  9. Hi there would you mind stating which blog platform you’re working with?

    I’m looking to start my own blog in the near future but I’m having
    a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique.
    P.S My apologies for getting off-topic but I had to ask!

  10. Hmm it appears like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog blogger but I’m still new to the
    whole thing. Do you have any helpful hints for inexperienced blog writers?
    I’d definitely appreciate it.

  11. Hey there! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly?
    My blog looks weird when browsing from my iphone4.

    I’m trying to find a template or plugin that might be able to resolve this problem.
    If you have any recommendations, please share.
    Appreciate it!

  12. Pretty nice post. I simply stumbled upon your weblog and wished to mention that
    I have truly loved browsing your blog posts. After all I’ll be subscribing on your rss feed
    and I am hoping you write again soon! pof natalielise

  13. Thank you a bunch for sharing this with all people you actually know what you are speaking approximately!
    Bookmarked. Kindly additionally talk over with
    my website =). We will have a hyperlink change agreement among us pof natalielise

  14. Hello there, I found your blog by means of Google at the same
    time as looking for a comparable matter, your website came
    up, it appears to be like good. I have bookmarked it in my google bookmarks.

    Hi there, just become alert to your blog through Google, and found that it is truly informative.

    I am gonna watch out for brussels. I will appreciate if you happen to continue this in future.
    Numerous other people will be benefited from your writing.
    Cheers! plenty of fish natalielise

  15. I must thank you for the efforts you have put in writing this
    site. I’m hoping to check out the same high-grade blog posts from you later on as well.
    In truth, your creative writing abilities has encouraged
    me to get my own, personal site now 😉

  16. My spouse and I stumbled over here different page and thought I might as
    well check things out. I like what I see so now i’m following you.
    Look forward to looking into your web page repeatedly.

  17. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

    You clearly know what youre talking about, why throw away your intelligence on just posting
    videos to your site when you could be giving us
    something enlightening to read?

  18. I don’t even know the way I ended up right here, however I believed this put
    up was once great. I do not recognize who you’re but certainly you are going
    to a famous blogger if you happen to are not already. Cheers!

  19. Hi! I could have sworn I’ve been to this blog
    before but after browsing through some of the posts I realized it’s new
    to me. Anyways, I’m certainly happy I discovered it and I’ll be bookmarking
    it and checking back often!

  20. Fantastic items from you, man. I’ve take into account your stuff prior
    to and you’re just too fantastic. I really like what you’ve acquired right
    here, certainly like what you are stating and the best way by which you assert it.
    You make it enjoyable and you continue to take care of to keep it sensible.
    I can’t wait to read much more from you. This is really a terrific site.

  21. I’m impressed, I must say. Rarely do I come across a blog that’s equally educative and interesting, and without
    a doubt, you’ve hit the nail on the head.
    The issue is something that too few folks are speaking intelligently about.
    I am very happy I found this in my search for something concerning
    this.

  22. Thank you for some other informative blog. The place else may I get that type of information written in such a perfect manner?
    I have a challenge that I’m just now working on, and
    I’ve been at the glance out for such information.

  23. You’ve made some decent points there. I checked on the internet for additional information about the issue and found most
    individuals will go along with your views on this web
    site.

  24. You’re so awesome! I don’t suppose I’ve read anything like this before.
    So nice to discover somebody with original thoughts on this issue.
    Really.. many thanks for starting this up.
    This web site is one thing that is needed on the web, someone with
    a bit of originality!

  25. We stumbled over here from a different page and thought
    I may as well check things out. I like what I see so
    now i’m following you. Look forward to checking out your web page repeatedly.

  26. Yesterday, while I was at work, my sister stole my apple ipad
    and tested to see if it can survive a forty foot drop, just so she can be a youtube
    sensation. My apple ipad is now destroyed and she
    has 83 views. I know this is totally off topic but I had to share it with someone!

  27. It is perfect time to make a few plans for the longer
    term and it’s time to be happy. I’ve read this submit and if I may I wish to recommend you some fascinating issues or
    suggestions. Perhaps you could write subsequent articles relating to this article.

    I wish to learn even more issues approximately
    it!

  28. This is the right site for anyone who hopes to understand this topic.
    You realize so much its almost tough to argue with you (not that I really will need to…HaHa).
    You certainly put a brand new spin on a topic which has
    been discussed for decades. Wonderful stuff, just wonderful!

  29. I’m not sure where you’re getting your info, but good
    topic. I needs to spend some time learning much more or understanding
    more. Thanks for magnificent info I was looking for this info for my mission.

  30. Having read this I believed it was extremely enlightening.
    I appreciate you taking the time and energy to put this content together.
    I once again find myself personally spending
    a significant amount of time both reading and leaving comments.

    But so what, it was still worthwhile!

  31. This is very interesting, You’re a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your great post.
    Also, I have shared your website in my social
    networks!

  32. I’m not sure exactly why but this weblog is loading very slow for
    me. Is anyone else having this problem or is it a issue on my end?
    I’ll check back later and see if the problem still exists.

  33. Hi! I know this is kinda off topic but I was wondering if you knew where
    I could locate a captcha plugin for my comment form? I’m using
    the same blog platform as yours and I’m having problems finding one?
    Thanks a lot!

  34. This is the right web site for anyone who wishes to find out about this topic.

    You know a whole lot its almost hard to argue with you (not
    that I personally would want to…HaHa). You certainly put a
    fresh spin on a subject that’s been discussed for decades. Great stuff, just excellent!

  35. Excellent beat ! I wish to apprentice while you amend your site, how could i
    subscribe for a blog web site? The account helped me a acceptable
    deal. I had been tiny bit acquainted of this your broadcast provided
    bright clear concept

  36. An impressive share! I have just forwarded this onto a colleague who has been doing a
    little research on this. And he actually ordered me dinner due to the fact that I found it for him…
    lol. So allow me to reword this…. Thanks for the meal!!
    But yeah, thanks for spending time to discuss this issue here
    on your internet site.

  37. hi!,I like your writing so so much! proportion we
    keep up a correspondence more approximately your post on AOL?
    I need a specialist in this space to unravel my problem.
    Maybe that is you! Taking a look forward to see you.

  38. Greetings from Ohio! I’m bored to death at work so I
    decided to browse your website on my iphone during lunch break.

    I really like the information you provide here and can’t wait to take a look when I get home.

    I’m surprised at how quick your blog loaded on my mobile ..
    I’m not even using WIFI, just 3G .. Anyhow, superb blog!

  39. each time i used to read smaller articles or reviews that as well clear their motive,
    and that is also happening with this article which I am reading
    at this time.

  40. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience
    with something like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.

  41. Hmm it seems like your blog ate my first comment
    (it was extremely long) so I guess I’ll just sum it up what I
    submitted and say, I’m thoroughly enjoying your blog.

    I too am an aspiring blog blogger but I’m still new to the whole thing.
    Do you have any tips for novice blog writers? I’d genuinely appreciate it.

  42. What’s Happening i’m new to this, I stumbled upon this I’ve discovered It absolutely
    helpful and it has aided me out loads. I hope to give
    a contribution & help different users like its aided me.
    Great job.

  43. Hi would you mind sharing which blog platform you’re using?
    I’m looking to start my own blog in the near future but I’m having a hard time making
    a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most blogs and I’m looking for
    something completely unique. P.S Sorry for being off-topic but I had to
    ask!

  44. I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to create my own blog and would like to find out where u got this from.
    many thanks

  45. Thank you for sharing excellent informations. Your site is very cool. I’m impressed by the details that you’ve on this site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my pal, ROCK! I found just the information I already searched all over the place and simply could not come across. What an ideal website.

  46. Hey! I just wanted to ask if you ever have any issues with hackers?

    My last blog (wordpress) was hacked and I ended up losing months of hard work due
    to no backup. Do you have any solutions to prevent hackers?

  47. Hello! Quick question that’s completely off topic. Do you
    know how to make your site mobile friendly? My site looks weird
    when browsing from my iphone. I’m trying to find a template or plugin that might be able to fix this problem.
    If you have any suggestions, please share. Thank you!

  48. We absolutely love your blog and find almost all of your post’s to be precisely what I’m looking for.
    Would you offer guest writers to write content available for you?
    I wouldn’t mind creating a post or elaborating on many of
    the subjects you write concerning here. Again, awesome web site!

  49. I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to design my own blog and would like to find out
    where u got this from. thanks a lot

  50. This is very interesting, You are a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your excellent post.
    Also, I’ve shared your website in my social networks!

  51. We’re a group of volunteers and opening a new scheme in our community.
    Your web site provided us with valuable info to work on. You’ve done an impressive job and our whole community will be grateful to you.

  52. Wonderful goods from you, man. I’ve understand your
    stuff previous to and you are just extremely magnificent.
    I actually like what you’ve acquired here, really like what you’re saying and the way in which you say it.
    You make it enjoyable and you still take care of to keep it smart.
    I can not wait to read far more from you. This is actually a terrific website.

  53. I’m not that much of a internet reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back later on. Cheers

  54. Hello! Do you use Twitter? I’d like to follow you if that would be okay.
    I’m definitely enjoying your blog and look forward to new updates.

  55. When someone writes an post he/she retains the idea of a user in his/her mind that how a user can know it.
    So that’s why this paragraph is amazing. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *