• Educational Codeforces Round 92 (Rated for Div. 2)


    B读错题了, 一直wa,心态炸了, 直接不打了, 分掉惨了

    B是可以反复横条的, 还以为是每个位置只能向左走一次, 这读题水平阿!

    A

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
     
    int main() {
        IO;
        for (cin >> _; _; --_) {
            int l, r; cin >> l >> r;
            int a = l, b = r / 2;
            if (a > b || 2 * a > r) cout << -1 << ' ' << -1 << '
    ';
            else cout << a << ' ' << 2 * a << '
    '; 
        }
        return 0;
    }
    

    B

    记忆化搜索

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k, z;
    int a[N], f[N][6];
     
    int dfs(int w, int c) {
        if (c < 0 || w + (z - c) * 2 - 1 > k || w > n) return 0;
        if (f[w][c]) return f[w][c];
     
        if (c == 0 || w == 1) return f[w][c] = a[w] + dfs(w + 1, c);
     
        if (w + (z - c) * 2 + 1 <= k)
            return f[w][c] = a[w] + max(dfs(w + 1, c), a[w - 1] + dfs(w, c - 1));
        else if (w + (z - c) * 2 <= k)
            return f[w][c] = a[w] + max(a[w - 1], a[w + 1]);
        else return f[w][c] = a[w];
    }
     
    int main() {
        IO;
        for (cin >> _; _; --_) {
            cin >> n >> k >> z;
            rep(i, 1, n) memset(f[i], 0, sizeof f[i]);
     
            rep(i, 1, n) cin >> a[i];
     
            cout << dfs(1, z) << '
    ';
        }
        return 0;
    }
    

    C

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(0); cin.tie(0);
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
    int a[10][10], b[100], c[10];
     
    int main() {
        IO;
        for (cin >> _; _; --_) {
            string s; cin >> s;
            memset(b, 0, sizeof b);
            memset(a, 0, sizeof a);
            memset(c, 0, sizeof c);
     
            rep (i, 0, s.size() - 1) { 
                int ch = s[i] - '0';
                ++c[ch];
     
                rep (j, 0, 9) 
                    if (a[j][ch] && j != ch) ++b[j * 10 + ch], a[j][ch] = 0;
     
                rep (j, 0, 9) 
                    if (j != ch) a[ch][j] = 1;
            }
     
            sort(b, b + 100);
            sort(c, c + 10);
     
            cout << s.size() - max(2 * b[99], c[9]) << '
    ';
        }
        return 0;
    }
    
  • 相关阅读:
    关于观察者模式和发布/订阅模式
    git:error: Your local changes to the following files would be overwritten by merge:
    node中几个路径的梳理
    centOS 开启服务器后无法访问(大坑啊)
    文件上传简记
    自建nodejs服务器(一:有个服务器)
    nodejs上使用sql
    express笔记
    windows下node配置npm全局路径(踩坑)
    DropMaster
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/13407459.html
Copyright © 2020-2023  润新知