版本比较
ABC421 全解
正文
增加 12 行删除 12 行
19 行未改动202122232424252627272829303160 行未改动929394959697969798991001011021031041051061071071081091101112 行未改动1141151161171181181191201201211221231231241251261272 行未改动1301311321331341341351361371382 行未改动141142143144145145146147148148149150151152153154155156157158158159160161162158 行未改动全部展开19 行未改动 cin>>s[i];}cin>>x>>t;if(s[x]==t)cout<<"Yes";else cout<<"No"; else cout<<"No";```
### B ### B
自评:红。
依照题意模拟即可。可以将数字模 $10$ 以获取其最后一位,乘 $10$ 以在最低位上留出一位的空间用来加入新的一位。60 行未改动cin>>ax>>ay>>bx>>by;cin>>n>>m>>k;//top1/2 和 tl1/2 数组存储切分前的操作序列,op1/2 和 l 数组存储切分后的操作序列。//bps 存所有的断点。上面提到的最后四个数组显然需要开两倍,因为是 m+l 量级的。//根据作者习惯,代码中 k 对应题目中 l。 //增量数组 dx 和 dy 的顺序是 UDLR。 //根据作者习惯,代码中 k 对应题目中 l。//增量数组 dx 和 dy 的顺序是 UDLR。ll tot=0;for(int i=0;i<m;i++){ char ch; cin>>ch>>tl1[i]; if(ch=='U')top1[i]=0; if(ch=='D')top1[i]=1; if(ch=='L')top1[i]=2; if(ch=='R')top1[i]=3; tot+=tl1[i]; bps[p++]=tot; bps[p++]=tot;}tot=0;for(int i=0;i<k;i++){ char ch;2 行未改动 if(ch=='D')top2[i]=1; if(ch=='L')top2[i]=2; if(ch=='R')top2[i]=3; tot+=tl2[i]; bps[p++]=tot; bps[p++]=tot;}//切分操作序列阶段 //切分操作序列阶段sort(bps,bps+p);p=unique(bps,bps+p)-bps;ll pos=0;tot=0; ll pos=0;tot=0;for(int i=0;i<m;i++){ while(pos<p&&tot+tl1[i]>=bps[pos]){ ll tmp=bps[pos]-tot; tot+=tmp;2 行未改动 l[pos]=tmp; pos++; }}pos=0;tot=0; pos=0;tot=0;for(int i=0;i<k;i++){ while(pos<p&&tot+tl2[i]>=bps[pos]){ ll tmp=bps[pos]-tot; tot+=tmp;2 行未改动 l[pos]=tmp; pos++; }}//计算阶段 //计算阶段ll ans=0;for(int i=0;i<p;i++){ //计算 //计算 if(op1[i]==op2[i]){ ans+=l[i]*(ax==bx&&ay==by); } else{ ll dis=(abs(ax-bx)+abs(ay-by))/2; if((ax!=bx||ay!=by)&&l[i]>=dis){ ans+=(ax+dx[op1[i]]*dis==bx+dx[op2[i]]*dis&&ay+dy[op1[i]]*dis==by+dy[op2[i]]*dis); } } //移动 ,注意本题是数组坐标系而不是平时用的坐标系 //移动 ,注意本题是数组坐标系而不是平时用的坐标系 ax+=dx[op1[i]]*l[i]; ay+=dy[op1[i]]*l[i]; bx+=dx[op2[i]]*l[i]; by+=dy[op2[i]]*l[i];158 行未改动全部展开