2025山东CCPC题解

06-02 1189阅读

文章目录

  • L - Stella
  • D - Distributed System
  • I - Square Puzzle
  • E - Greatest Common Divisor
  • G - Assembly Line

    L - Stella

    题目来源:L - Stella

    2025山东CCPC题解

    解题思路

    签到题,因为给出的字母不是按顺序,可以存起来赋其值,然后在比较。

    代码实现

    #include
    #define int long long
    #define endl '\n'
    #define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
    using namespace std;
    const int N=1e5+5;
    void solve()
    {
    	mapmp;
    	mp['O']=1;
    	mp['B']=2;
    	mp['A']=3;
    	mp['F']=4;
    	mp['G']=5;
    	mp['K']=6;
    	mp['M']=7;
    	string s1,s2;
    	cin>>s1>>s2;
    	if(mp[s1[0]]
    		cout
    		cout
    		if(s1[1]
    			cout
    			cout
    			cout
    	IOS;
    	int _=1;
    	cin_;
    	while(_--)solve(); 
    	return 0;
    } 
    
    	cinnq;
    	vector
    		cinxy;
    		sum+=x/n;
    		x%=n;
    		a[y]++;
    		a[y+x]--;
    	}
    	ans[0]=a[0];
    	for(int i=1;i
    	IOS;
    	int _=1;
    	cin_;
    	while(_--)solve(); 
    	return 0;
    } 
    
    	if(op==1)
    	{
    		char t=a[0];
    		a[0]=a[2],a[2]=a[1],a[1]=t;
    		return a;
    	}
    	if(op==2)
    	{
    		char t=a[3];
    		a[3]=a[5],a[5]=a[4],a[4]=t;
    		return a;
    	}
    	if(op==3)
    	{
    		char t=a[6];
    		a[6]=a[8],a[8]=a[7],a[7]=t;
    		return a;
    	}
    }
    string xiayi(string a,int op)//下移函数 
    {
    	if(op==1)
    	{
    		char t=a[0];
    		a[0]=a[6],a[6]=a[3],a[3]=t;
    		return a;
    	 } 
    	 if(op==2)
    	 {
    	 	char t=a[1];
    	 	a[1]=a[7],a[7]=a[4],a[4]=t;
    	 	return a;
    	 }
    	 if(op==3)
    	 {
    	 	char t=a[2];
    	 	a[2]=a[8],a[8]=a[5],a[5]=t;
    	 	return a;
    	 }
    } 
    string xuanzhuan(string a)//顺时针旋转函数 
    {
    	char t=a[0];
    	a[0]=a[6],a[6]=a[8],a[8]=a[2],a[2]=t;
     	t=a[1];
     	a[1]=a[3],a[3]=a[7],a[7]=a[5],a[5]=t;
     	return a;
    }
    void bfs()
    {
    	q.push("123456789");
    	ans["123456789"]=0;
    	while(q.size())
    	{
    		string g=q.front();
    		q.pop();
    		string t;
    		t=youyi(g,1);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1;
    		t=youyi(g,2);
    		if(ans[t]==0 )q.push(t),ans[t]=ans[g]+1;
    		t=youyi(g,3);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1;
    		t=xiayi(g,1);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1;
    		t=xiayi(g,2);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1;
    		t=xiayi(g,3);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1;
    		t=xuanzhuan(g);
    		if(ans[t]==0) q.push(t),ans[t]=ans[g]+1; 
    	}
    }
    void solve()
    {
        string s;
        map
        	char ch;
        	cinch;
        	mp[ch]='0'+i;
    	}
    	for(int i=1;i
    		char ch;
    		cinch;
    		s+=mp[ch];
    	}
    	if(s=="123456789")cout
    	IOS;
    	bfs(); 
    	int _=1;
    	cin_;
    	while(_--)solve(); 
    	return 0;
    } 
    
       cinnk;
       for(int i=1;i
       	cinwt;
       	a[i]=k-w+t;
       }
       sort(a+1,a+1+n);
       for(int i=1;i
    	IOS;
    	int _=1;
    	cin_;
    	while(_--)solve(); 
    	return 0;
    } 
    
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们。

目录[+]

取消
微信二维码
微信二维码
支付宝二维码