PAT1018

版权声明:欢迎转载!拒绝抄袭. https://blog.csdn.net/qq_36257146/article/details/89228768
#include <bits/stdc++.h>

using namespace std;
char action[] = {'C','J','B'};
int node[3][3] = {{0,1,-1},
                  {-1,0,1},
                  {1,-1,0}};

int Action(char c){
    for(int i = 0;i<3;i++){
        if(action[i] == c){
            return i;
        }
    }
    return 0;
}

vector<char>ans1;
vector<char>ans2;

int main() {
    int n,n1;
    char c1,c2;
    int a,b;
    int success=0,same=0,fail = 0;
    int count1[3] = {0,0,0};
    int count2[3] = {0,0,0};
    cin>>n;
    n1 = n;
    while (n1--){
        cin>>c1>>c2;
        a = Action(c1);
        b = Action(c2);
        if(node[a][b] == 1){
            success++;
            count1[a]++;
        }else if(node[a][b] == 0){//平局
            same++;
        }
        else{
            count2[b]++;
        }
    }
    int a1 = max(max(count1[0],count1[1]),count1[2]);//赢的最多的手势
    int a2 = max(max(count2[0],count2[1]),count2[2]);
    cout<<success<<" "<<same<<" "<<n-success-same<<endl;
    cout<<n-success-same<<" "<<same<<" "<<success<<endl;
    for(int i = 0;i<3;i++){
        //cout<<count1[i]<<" ";
        if(count1[i] == a1) {
            ans1.push_back(action[i]);
        }if(count2[i] == a2) {
            ans2.push_back(action[i]);
        }
    }
    sort(ans1.begin(),ans1.end());
    sort(ans2.begin(),ans2.end());
    cout<<ans1[0]<<" "<<ans2[0];
    return 0;
}
/**
10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
**/

 

展开阅读全文

没有更多推荐了,返回首页