码迷,mamicode.com
首页 > 编程语言 > 详细

Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)

时间:2021-06-02 18:28:48      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:cto   display   int   lease   lap   oid   with   ecb   closed   

技术图片
#include <bits/stdc++.h>
#define please return
#define ac 0
using namespace std;
using ll = long long ;
bool vis[1003];
void solve()
{
    int n,m;
    cin>>n>>m;
    if(m>=2*n)m=m%(2*n)+2*n;
    string s;cin>>s;
    while(m--)
    {
        for(int i=0;i<n;i++){
            if(s[i]==0){
                int cnt=0;
                if(i!=0&&s[i-1]==1)cnt++;
                if(i!=n-1&&s[i+1]==1)cnt++;
                if(cnt==1)vis[i]=true;
            }
        }
        for(int i=0;i<n;i++)
        if(vis[i]){
            s[i]=1;vis[i]=false;
        }
    }
    cout<<s<<"\n";
}
int main()
{
    //ios::sync_with_stdio(false);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    please ac;
}
A

 

技术图片
#include <bits/stdc++.h>
#define please return
#define ac 0
using namespace std;
using ll = long long ;
struct node{
    int op,i,j;
};
void solve()
{
    int n;
    cin>>n;
    vector<int>a(n+1);
    vector<node>ans;
    auto add=[&](int i,int j){
        a[i]+=a[j];
        ans.push_back({1,i,j});
    };
    auto sub=[&](int i,int j){
        a[i]-=a[j];
        ans.push_back({2,j,i});
    };
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i+=2){
        int j=i+1;
        add(i,j);
        sub(j,i);
        sub(j,i);
        add(i,j);
        sub(j,i);
        sub(j,i);
    }
    cout<<ans.size()<<"\n";
    for(auto &t:ans){
        cout<<t.op<<" "<<t.i<<" "<<t.j<<"\n";
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    please ac;
}
B

 

技术图片
#include <bits/stdc++.h>
#define please return
#define ac 0
using namespace std;
using ll = long long ;
void print(vector<auto>&x){
    cout<<x[0];
    for(int i=1;i<x.size();i++){
        cout<<"."<<x[i];
    }
    cout<<"\n";
}
void solve()
{
    int n;
    cin>>n;
    vector<vector<int>>s;
    s.push_back({});
    while(n--){
        int x;cin>>x;
        if(x==1){
            vector<int>v=s.back();
            v.push_back(1);
            print(v);
            s.push_back(v);
        }
        else{
            while(s.back().back()!=x-1)s.pop_back();
            s.back().back()++;
            print(s.back());
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    please ac;
}
C

 

Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)

标签:cto   display   int   lease   lap   oid   with   ecb   closed   

原文地址:https://www.cnblogs.com/qq1415584788/p/14830168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!