zoukankan      html  css  js  c++  java
  • Codeforces Round #281 (Div. 2) A. Vasya and Football(模拟)

    简单题,却犯了两个错误导致WA了多次。

    第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的。。。

    二是chronologically这个词没注意,其实如果输入是按时间顺序的,就直接在线处理就行了,用不着int team1[110][110],team2[110][110]两个数组。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<map>
    #include<set>
    #include<vector>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<cctype>
    #include<sstream>
    using namespace std;
    #define pii pair<int,int>
    #define LL long long int
    const int eps=1e-8;
    const int INF=1000000000;
    const int maxn=90+10;
    char t1[25],t2[25];
    int n,t,m;
    int team1[110][110],team2[110][110];
    int r1[110],r2[110];
    char team,card;
    int main()
    {
        //freopen("in2.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        scanf("%s%s",t1,t2);
        scanf("%d",&n);
        for(int i=0; i<n; i++)
        {
            scanf("%d",&t);
            getchar();
            scanf("%c",&team);
            getchar();
            scanf("%d",&m);
            getchar();
            scanf("%c",&card);
            getchar();
            if(team=='a')
            {
                if(card=='y')
                {
                    r2[m]++;
                    if(r2[m]==2)
                        team2[t][m]=2;
                }
                else
                {
                    if(r2[m]<2)
                    {
                        r2[m]=2;
                        team2[t][m]=2;
                    }
                }
            }
            else
            {
                if(card=='y')
                {
                    r1[m]++;
                    if(r1[m]==2)
                        team1[t][m]=2;
                }
                else
                {
                    if(r1[m]<2)
                    {
                        r1[m]=2;
                        team1[t][m]=2;
                    }
                }
            }
        }
        for(int i=1; i<=90; i++)
        {
            for(int j=1; j<=99; j++)
            {
                if(team1[i][j]==2)
                {
                    printf("%s %d %d
    ",t1,j,i);
                    break;
                }
                else if(team2[i][j]==2)
                {
                    printf("%s %d %d
    ",t2,j,i);
                    break;
                }
            }
        }
        //fclose(stdin);
        //fclose(stdout);
        return 0;
    }
    我的渣代码
    #include <map>
    #include <set>
    #include <stack>
    #include <cmath>
    #include <queue>
    #include <vector>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    const int max_n = 111, inf = 1111111111;
    
    int n, f[2][max_n];
    string a[2];
    
    int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        cin >> a[0] >> a[1] >> n;
        while (n--) {
            int t, num, q, c;
            char c1, c2;
            cin >> t >> c1 >> num >> c2;
            if (c1 == 'h') {
                q = 0;
            } else {
                q = 1;
            }
            if (c2 == 'y') {
                c = 1;
            } else {
                c = 2;
            }
            if (f[q][num] < 2) {
                f[q][num] += c;
                if (f[q][num] >= 2) {
                    cout << a[q] << " " << num << " " << t << endl;
                }
            }
        }
        return 0;
    }
    BigBag大神的优美代码
  • 相关阅读:
    maven 的 oracle的Missing artifact com.oracle:******:jar:11.2.0.2.0
    [CF 191C]Fools and Roads[LCA Tarjan算法][LCA 与 RMQ问题的转化][LCA ST算法]
    公司估值(贴现现金流量法DCF)
    Shell编程学习---第五篇:Shell的输入和输出
    S3C2410 实验三——块拷贝、字拷贝(寄存器的理解)
    模板方法模式实现组合查询
    关于方程x^2+y^2=p (p为素数)的解问题
    IOS登陆+注册+抽奖+排行榜
    用PersonalRank实现基于图的推荐算法
    Redis3.0--集群安装部署
  • 原文地址:https://www.cnblogs.com/zywscq/p/4239975.html
Copyright © 2011-2022 走看看