• Educational Codeforces Round 18 A B 码力 比赛


      比赛链接: https://vjudge.net/contest/180067#overview

          A: New Bus Route

      题目描述: 略

      解题思路: 排序

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstring>
    #include <iterator>
    #include <cmath>
    #include <algorithm>
    #include <stack>
    #include <deque>
    #include <map>
    #define lson l, m, rt<<1
    #define rson m+1, r, rt<<1|1
    #define mem0(a) memset(a,0,sizeof(a))
    #define meminf(a) memset(a,0x3f,sizeof(a))
    #define fi(n) for(i=0;i<n;i++)
    #define fj(m) for(j=0;j<m;j++)
    #define sca(x) scanf("%d",&x)
    #define scalld(x) scanf("%I64d",&x)
    #define print(x) printf("%d
    ",x)
    #define printlld(x) printf("%I64d
    ",x)
    #define d printf("=======
    ")
    typedef long long ll;
    using namespace std;
    
    const int INF = 1e11;
    const int maxn = 2e5 + 100;
    ll a[maxn];
    
    int main() {
        int n;
        scanf( "%d", &n );
        for( int i = 0; i < n; i++ ) {
            scanf( "%lld", a+i );
        }
        sort(a, a+n);
        ll mind = INF;
        for( int i = 1; i < n; i++ ) {
            ll temp = abs(a[i] - a[i-1]);
            mind = min( mind, temp );
        }
        int cnt = 0;
        for( int i = 1; i < n; i++ ) {
            ll temp = abs(a[i]-a[i-1]);
            if( mind == temp ) {
                cnt++;
            }
        }
        printf( "%lld %d
    ", mind, cnt );
        return 0;
    }
    View Code

      思考: 自己INF开小了, WA了, 心太大

          B: Counting-out Rhyme  

      题目描述: 约瑟夫环

      解题思路: 暴力

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstring>
    #include <iterator>
    #include <cmath>
    #include <algorithm>
    #include <stack>
    #include <deque>
    #include <map>
    #define lson l, m, rt<<1
    #define rson m+1, r, rt<<1|1
    #define mem0(a) memset(a,0,sizeof(a))
    #define meminf(a) memset(a,0x3f,sizeof(a))
    #define fi(n) for(i=0;i<n;i++)
    #define fj(m) for(j=0;j<m;j++)
    #define sca(x) scanf("%d",&x)
    #define scalld(x) scanf("%I64d",&x)
    #define print(x) printf("%d
    ",x)
    #define printlld(x) printf("%I64d
    ",x)
    #define d printf("=======
    ")
    typedef long long ll;
    using namespace std;
    
    const int INF = 1e11;
    const int maxn = 500;
    int a[maxn];
    int b[maxn];
    
    int main() {
        int n, k;
        cin >> n >> k;
        for( int i = 1; i <= k; i++ ) {
            cin >> a[i];
        }
        for( int i = 0; i < n; i++ ) {
            b[i] = i;
        }
        int cur = 0;
        int temp = n;
        for( int i = 1; i <= k; i++ ) {
            int mod = a[i] % temp;
    //        cout << mod << endl;
    //        cout << mod << endl;
            while( 1 ) {
                if( b[cur] == -1 ) cur = (cur + 1) % n;
                if( mod == 0 ) {
                    while( b[cur] == -1 ) {
                        cur = (cur+1) % n;
                    }
                    break;
                }
                if( b[cur] >= 0 ) {
                    cur = (cur + 1) % n;
                    mod--;
                }
            }
    //        cout << cur << endl;
            b[cur] = -1;
            if( i == 1 ) {
                cout << cur+1;
            }
            else {
                cout << " " << cur+1;
    //            cout << " " << cur+1;
            }
            while( 1 ) {
                cur = (cur+1) % n;
                if( b[cur] >= 0 ) break;
            }
    //        cout << cur << endl;
            temp--;
        }
        cout << endl;
        return 0;
    }
    View Code

      思考: 做的麻烦了, 我这么做很容易出错, 应该直接放进set里

      

      比赛总结: C做不出来 , 本来想拿DP做, 状态方程也转移出来了, 但是还是有的地方考虑不周到, 感觉自己现在做题有点儿不顺, 今晚儿打CF

     

    https://vjudge.net/contest/180067#overview

  • 相关阅读:
    英国下院通过法案允许合成人兽胚胎
    老外关于思考时间的问与答
    性能测试中用LambdaProbe监控Tomcat
    BT下载原理
    汽车维修行业呼吁大学生加入修车行列
    一个女研究生(高级测试工程师)的职业选择
    微软称20日验证Windows与Office 盗版将黑屏 网友评论
    Xbox摇身变NAS:BT的使用问题与性能测试
    李开复建言大学生:求职中不要把钱看得太重
    IBM雇员将罢工15分钟 为抗议公司裁员
  • 原文地址:https://www.cnblogs.com/FriskyPuppy/p/7390634.html
Copyright © 2020-2023  润新知