美文网首页
ABC-185(A~F)

ABC-185(A~F)

作者: _NewMoon | 来源:发表于2020-12-14 21:42 被阅读0次

    比赛地址

    个人博客

    github


    A

    /*
     * Author: Moon-light
     * 按照题意输出
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 1;
    const int mod = 1e9+7;
    
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    //
    
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        int a,b,c,d;
        cin>>a>>b>>c>>d;
    
        cout<<min(a,min(b,min(c,d)))<<endl;
        return 0;
    }
    

    B

    /*
     * Author: Moon-light
     * 按照题意边模拟边判断即可
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 1;
    const int mod = 1e9+7;
    
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    //
    LL m,n,t;
    LL a,b;
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        cin>>n>>m>>t;
        
        LL left = n;
        LL last = 0;
        m -= 1;
        cin>>a>>b;
        left -= a;
        if(left <= 0) {
            cout<<"No"<<endl;
            return 0;
        }
        left += (b-a);
        last = b;
        if(left > n) left = n;
        for(int i = 1; i<=m; i++){
            cin>>a>>b;
            left = left - (a-last);
            if(left <= 0) {
                cout<<"No"<<endl;
                return 0;
            }
            left = left + (b-a);
            if(left > n) left = n;
            last = b;
        }
        
        left = left - (t-last);
        if(left <= 0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
        return 0;
    }
    

    C

    /*
     * Author: Moon-light
     * 题意:一根木棍分成12段的切法数量,两种切法不同当且仅当切割的位置不同
     * 求组合数即可,注意一个木棍可切割的位置是n-1
     * 那么answer = C(11,n-1);
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 300;
    const int mod = 1e9+7;
    LL c[N][N];
    int n;
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    
    void solve(){
        for(int i = 0; i<N; i++){
            for(int j = 0; j<=i; j++){
                if(!j) c[i][j] = 1;
                else c[i][j] = c[i-1][j] + c[i-1][j-1];
            }
        }
    }
    //
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        cin>>n;
        solve();
        cout<<c[n-1][11]<<endl;
        return 0;
    }
    

    D

    /*
     * Author: Moon-light
     * 
     * 思路:因为不能碰到蓝色的方块,所以我们只能找蓝色方块分割开的白色序列中找最小的连续的子序列
     * 然后求次数即可,注意首尾的边界情况
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 2e5+100;
    const int mod = 1e9+7;
    LL n,m;
    LL a[N];
    
    
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    //
    
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        cin>>n>>m;
    
        for(int i = 1; i<=m; i++){
            cin>>a[i];
        }   
        sort(a+1,a+1+m);
    
        if(m == 0){
            cout<<1<<endl;
            return 0;
        }
        if(n == m) {
            cout<<0<<endl;
            return 0;
        }
        
        LL range = a[1] - 1;
        LL last = a[1];
        for(int i = 2; i<=m; i++){
            LL t = a[i] - last - 1;
            if(range  == 0) range = t;
            else if(t > 0) range = min(range,t);
            last = a[i];
        }
        if(n > last){
            if(range == 0) range = (n-last);
            else range = min(range,n-last);
        }
            
        //cout<<range<<endl;
        LL ans = 0;
        last = a[1];
        if(a[1] > 1){
            ans += (a[1]-2)/range+1;
        }
        for(int i = 2; i<=m; i++){
            int cnt = a[i]-last-1;
            ans += (cnt-1)/range+1;
            last = a[i];
        }
        if(n>last)
            ans += (n-last-1)/range + 1;
        cout<<ans<<endl; 
        return 0;
    }
    

    E

    /*
     * Author: Moon-light
     * 
     * 题意: 有两个长度分别为N和M的序列A,B
     * 删除序列A中的a个元素得到A' , 0<=a<=N
     * 删除序列B中的b个元素得到B' , 0<=b<=M
     * 使得A'的长度等于B'的长度
     * 令x = a + b
     *   y = Sum of i A'i != B'i 
     * 
     * 思路: 编辑距离模型
     * 设dp[i][j] 表示对A前i个及对B前j个元素的最小答案
     * 那么对于当前的A[i]和 B[j]
     * 有三种情况: 1.删除A[i],保留B[j] dp[i-1][j] + 1
     *              2.保留A[i],删除B[j] dp[i][j-1] + 1
     *              3.保留A[i], 保留A[j] dp[i-1][j-1] + (a[i]==b[j]?0:1)
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 1010;
    const int mod = 1e9+7;
    
    int n,m;
    int a[N],b[N];
    int dp[N][N];
    
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    //
    
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        cin>>n>>m;
    
        rep(i,1,n) cin>>a[i];
        rep(i,1,m) cin>>b[i];
    
        //initialization
        rep(i,1,n) dp[i][0] = i;
        rep(i,1,m) dp[0][i] = i;
    
        rep(i,1,n){
            rep(j,1,m){
                //删一个
                dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1);
                //不删
                dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (a[i]==b[j]?0:1));
            }
        }
        cout<<dp[n][m];
        return 0;
    }
    

    F

    /*
     * Author: Moon-light
     * 题意: 1.单点修改 Ax = Ax ^ Y
     *       2.区间查询 Ax1 ^ Ax2 ^ Ax3 ^... ^ Ay
     * 
     * 思路: 树状数组模板
    */
    #include <bits/stdc++.h>
    using namespace std;
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    #define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define lowbit(x) ((x)&(-x))
    #define sz(x) ((int)x.size())
    #define fr(x) freopen(x,'r',stdin)
    #define fw(x) freopen(x,'w',stdout)
    #define mst(x,a) memset(x,a,sizeof(x))
    #define all(a) begin(a),end(a)
    #define bitcnt(x) (__builtin_popcountll(x))
    #define rep(i,a,b) for(int i = (a);i<=(b); ++i)
    #define per(i,a,b) for(int i = (a);i>=(b); --i)
    typedef long long LL;
    typedef pair<int,int> PII;  
    typedef pair<LL,LL> PLL;
    typedef pair<double,double> PDD;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    typedef vector<double> VB;
    typedef double db;
    
    template <class T> void clear(T& a) { T().swap(a);}
    template <class T,class S>
    inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
    template <class T,class S>
    inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}
    
    //fast read(improved by fread)
    char buf[1<<21],*p1=buf,*p2=buf;
    inline int getc(){
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
    }
    inline int redi() {
        int ret = 0,f = 0;char ch = getc();
        while (!isdigit (ch)) {
            if (ch == '-') f = 1;
            ch = getc();
        }
        while (isdigit (ch)) {
            ret = ret * 10 + ch - 48;
            ch = getc();
        }
        return f?-ret:ret;
    }
    
    //global variable
    const int N = 3e5+100;
    const int mod = 1e9+7;
    int n,q,t,x,y;
    int tr[N];
    
    //functions
    LL qmi(LL a,LL k,LL mod){
        LL res = 1;
        while(k){
            if(k&1) res = res*a%mod;
            k >>= 1;
            a = a*a%mod;
        }
        return mod;
    }
    int gcd(int a,int b) {
        return b==0? a:gcd(b,a%b);
    }
    
    void update(int u,int x){
        for(int i = u; i<=n; i+=lowbit(i)){
            tr[i] ^= x;
        }
    }
    
    int query(int x){
        int res = 0;
        for(int i = x; i; i-=lowbit(i)){
            res ^= tr[i];
        }
        return res;
    }
    //
    
    
    //code from here! Come on! Have a pleasant experience~
    int main()
    {
        IO;
        cin>>n>>q;
        rep(i,1,n){
            cin>>x;
            update(i,x);
        }
    
        rep(i,1,q){
            cin>>t>>x>>y;
            if(t == 1){
                update(x,y);
            }else{
                cout<<(query(y)^query(x-1))<<endl;
            }
        }
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:ABC-185(A~F)

          本文链接:https://www.haomeiwen.com/subject/qtvbgktx.html