1 solutions

  • 0
    @ 2025-3-21 14:18:24

    O(N)O(N)

    直接根据题目描述枚举操作即可,为了方便,可以先将他们的出拳输赢打表记录

    #include<bits/stdc++.h>
    using namespace std;
    const int N=210;
    int a[N],b[N];
    int g[5][5]={
        {0,-1,1,1,-1},
        {1,0,-1,1,-1},
        {-1,1,0,-1,1},
        {-1,-1,1,0,1},
        {1,1,-1,-1,0},
    };
    int main()
    {
        int n,n1,n2;
        cin>>n>>n1>>n2;
        for(int i=0;i<n1;i++)
        {
            cin>>a[i];
        }
        for(int i=0;i<n2;i++)
        {
            cin>>b[i];
        }
        int res1=0,res2=0;
        for(int i=0;i<n;i++)
        {
            int x=a[i%n1],y=b[i%n2];
            if(g[x][y]>0) res1++;
            else if(g[x][y]<0) res2++;
        }
        cout<<res1<<" "<<res2<<endl;
        return 0;
    }
    
    • 1

    Information

    ID
    1106
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By