行业知识
蓝桥杯每日一题 (递推、递归、)
2026-11-15 10:38:31
来源:互联网转载
3777. 砖块(每日一题)
后面if���件判断很巧妙,只要有一种成立就不管另一种了。
()#includeusing namespace std;//3777. 砖块//跟贪心差不多string s;int t,n;void update(char &c){ if(c=='W')c='B'; else c='W';}bool check(char c){ vectora; string ss=s; for(int i=0;i+1>s; if(!check('B')&&!check('W'))coutt; int cnt=0; for(int i=0;in>>m; for(int i=1;i>s; if(s[0]=='C') { cin>>l>>r; f[getf(l)]=getf(r); } else if(s[0]=='Q'&&s[1]=='1') { cin>>l>>r; if(getf(l)==getf(r)) { coutl>>r; if(getf(l)==getf(r)) { coutn||y>n)cnt++; else { int px=getf(x); int py=getf(y); if(t==1) { if(px==py&&(d[x]-d[y])%3)cnt++; else if(px!=py) { f[px]=py; d[px]=(d[y]-d[x]); } } else { //正常情况下应该相差1 if(px==py&&(d[x]-d[y]-1)%3)cnt++; else if(px!=py) { f[px]=py; d[px]=d[y]-d[x]+1; } } } } cout