本文发表于 298 天前,其中的信息可能已经事过境迁
文章摘要 FakeGPT
加载中...|
B4210 [常州市赛 2022] 最早对决
题目简述
有
首先把
现在如果编号分别为
解题思路
很明显,两人中只要有一人不为种子选手,那么他们最早会在第一轮相遇。
我们注意到,两个选手的位置离的越近,他们相遇的越早。但是选手的位置是随机分配的,我们该怎么办呢?
没错,打表。
我们记录下所有种子选手可能在的所有位置,只要找到一个最小值即可。(注意,两个选手不能在同一个位置)
代码实现
cpp
#include<bits/stdc++.h>
using namespace std;
int s,t,minn=INT_MAX;
int pos[33][16]={
{0},{1},{128},{64,65},{64,65},{32,33,96,97},
{32,33,96,97},{32,33,96,97},{32,33,96,97},
{16,17,48,49,80,81,112,113},{16,17,48,49,80,81,112,113},
{16,17,48,49,80,81,112,113},{16,17,48,49,80,81,112,113},
{16,17,48,49,80,81,112,113},{16,17,48,49,80,81,112,113},
{16,17,48,49,80,81,112,113},{16,17,48,49,80,81,112,113},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121},
{8,9,24,25,40,41,56,57,72,73,88,89,104,105,120,121}
};
int work(int x){
int res=0;
while(x){
res++;
x=x/2;
}
return res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>s>>t;
if(s>32||t>32){
cout<<1;
return 0;
}
for(int i=0;i<=15;i++){
if(pos[s][i]==0)break;
for(int j=0;j<=15;j++){
if(pos[t][j]==0)break;
if(pos[s][i]!=pos[t][j])
minn=min(minn,abs(pos[s][i]-pos[t][j]));
}
}
cout<<work(minn)<<endl;
return 0;
}B4210 [常州市赛 2022] 最早对决 题解https://80yearoldboy.github.io/posts/2025/0915
赞赏博主
