• Codeforces Round #490 (Div. 3)


    稳。。。。

    题目区分度太小了。。。

    A. Mishka and Contest

    直接模拟

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int MAXN = 1e6 + 10;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int a[MAXN], vis[MAXN];
    int main() {
    #ifdef WIN32
    //    freopen("a.in", "r", stdin);
    #endif
        int N = read(), k = read();
        for(int i = 1; i <= N; i++) a[i] = read();
        int ans = 0;
        for(int i = 1; i <= N; i++) 
            if(a[i] <= k) ans++, vis[i] = 1;
            else break;
        for(int i = N; i >= 1; i--) 
            if(a[i] <= k && vis[i] == 0) ans++;
            else break;
        printf("%d", ans);
        return 0;
    }
    A

    B. Reversing Encryption

    直接模拟

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int MAXN = 1e6 + 10;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    char s[MAXN];
    int N;
    void print(char *s) {
        for(int i = 1; i <= N; i++)
            putchar(s[i]); puts("");
    }
    int main() {
    #ifdef WIN32
    //    freopen("a.in", "r", stdin);
    #endif
        scanf("%d", &N);
        scanf("%s", s + 1);
        for(int i = 1; i <= N; i++) 
            if(N % i == 0)
                reverse(s + 1, s + i + 1);
        print(s);
        return 0;
    }
    B

    C. Alphabetic Removals

     直接模拟

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<vector>
    using namespace std;
    const int MAXN = 1e6 + 10;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int N, K;
    vector<int>v[27];
    char s[MAXN];
    int main() {
    #ifdef WIN32
    //    freopen("a.in", "r", stdin);
    #endif
        N = read(), K = read();
        scanf("%s", s + 1);
        for(int i = 1; i <= N; i++) 
            v[s[i] - 'a'].push_back(i);
        for(int i = 0; i <= 25 && K > 0; i++)
                for(int j = 0; j < v[i].size()&& K > 0; j++, K--) 
                    s[v[i][j]] = '#';
        for(int i = 1; i <= N; i++) 
            if(s[i] != '#')
                putchar(s[i]);
        return 0;
    }
    C

    E. Reachability from the Capital

    tarjan完后求有多少个入度为$0$的点

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<stack>
    using namespace std;
    const int MAXN = 1e6 + 10;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int N, M, S;
    struct Edge {
        int u, v, nxt;
    }E[MAXN];
    int head[MAXN], num = 1;
    inline void AddEdge(int x, int y) {
        E[num] = (Edge){x, y, head[x]};
        head[x] = num++;
    }
    stack<int>s;
    int dfn[MAXN], low[MAXN], color[MAXN], colornum = 0, tot = 0, vis[MAXN], siz[MAXN];
    void tarjan(int x) {
        dfn[x] = low[x] = ++tot;
        s.push(x);
        vis[x] = 1;
        for(int i = head[x]; i != -1; i = E[i].nxt) {
            int to = E[i].v;
            if(!dfn[to]) tarjan(to), low[x] = min(low[x], low[to]);
            else if(vis[to]) low[x] = min(low[x], dfn[to]);
        }
        if(dfn[x] == low[x]) {
            int h;
            colornum++;
            do {
                h = s.top(); s.pop();
                color[h] = colornum;
                vis[h] = 0;
            }while(h != x);
        }
    }
    bool happen[MAXN];
    vector<int> v[MAXN];
    int ans = 0;
    void dfs(int x) {
        vis[x] = 1;
        for(int i = 0; i < v[x].size(); i++) {
            int to = v[x][i];
            if(!vis[to])
                ans++, dfs(to);
        }
    }
    int inder[MAXN];
    int main() {
    #ifdef WIN32
        //freopen("a.in", "r", stdin);
    #endif    
        memset(head, -1, sizeof(head));
        N = read(); M = read(); S = read();
        for(int i = 1; i <= M; i++) {
            int x = read(), y = read();
            AddEdge(x, y);
        }
        for(int i = 1; i <= N; i++) 
            if(!color[i])
                tarjan(i);
        memset(vis, 0, sizeof(vis));
        for(int i = 1; i <= N; i++) 
            for(int j = head[i]; j != -1; j = E[j].nxt) 
                if(color[E[j].u] != color[E[j].v])
                    inder[color[E[j].v]]++;
        for(int i = 1; i <= colornum; i++)
            if(inder[i] == 0)
                ans++;
        if(inder[color[S]] == 0) ans--;
        printf("%d", ans);
        return 0;
    }
    E
  • 相关阅读:
    数据恢复:解决ORA600[kghstack_free2][kghstack_err+0068]一例
    Oracle latch闩原理示意图
    MySQL Query Analyzer查询分析器
    Oracle GoldenGate Monitor架构图
    Oracle Row cache lock图解
    没有Metalink账号的同学可以观赏下,My Oracle Support的主界面
    Oracle Goldengate Director软件截面图
    Oracle Unbreakable Enterprise Kernel Faster than Redhat?
    从Win32过渡到MFC
    naked 函数调用
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9235264.html
Copyright © 2020-2023  润新知