蒟蒻的来做梦8.14总结

· · 个人记录

应该没人写了笔记吧但还是放一个黑板

T637642 比较数字

#include<iostream>

using namespace std;
string s;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>s;
    for(int i=s.find("0");i<s.size();i++){
        s[i]='1';
    }
    cout<<s;
    return 0;
}

T637627 张的弓

#include<iostream>

using namespace std;
long long t;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>t;
    while(t--){
        long long n,m,k;
        cin>>n>>m>>k;
        long long ans=k/(2*n+2)*2;
        {
            long long x=1,y=1,flag=0;
            for(long long i=1;i<=k%(2*n+2);i++){
                if(flag){
                    if(x==1){
                        y++;
                        flag=0;
                    }else{
                        x--;
                    }
                }else{
                    if(x==n){
                        y++;flag=1;
                    }else{
                        x++;
                    }
                }
            }
            ans+=x+y-2;
        }
        cout<<ans<<'\n';
    }
    return 0;
}

T637602 可可口乐

#include<iostream>
#include<queue>
#include<set>
using namespace std;
string s;
class bfs_class{
    queue<pair<string,int> >q;
    set<string>st;
public:
    void run(){
        q.push(make_pair(s,0));
        st.insert(s);
        while(q.size()){
            auto tp=q.front();
            q.pop();
            auto &tpf=tp.first;
            if(tpf=="cocacola"){
                cout<<tp.second;
                return;
            }
            for(size_t i=0;i<tpf.size();i++){
                for(size_t t=0;t<tpf.size();t++){
                    if(i!=t){
                        swap(tpf[i],tpf[t]);
                        if(st.find(tpf)==st.end()){
                            q.push(make_pair(tpf,tp.second+1));
                            st.insert(tpf);
                        }
                        swap(tpf[i],tpf[t]);
                    }
                }
            }
        }
    }
}bfs;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin>>s;
    bfs.run();
    return 0;
}

T637561 小梦的守卫

本页面的全部内容在CC BY-NC-ND 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用