2020牛客暑期多校训练营(第八场)G. Game SET(暴力就完事)

题目传送
思路:
恶心的暴力…不过多锻炼锻炼自己写代码的能力也还行

AC代码

#include 
inline long long read(){char c = getchar();long long x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) (x)&(-x)
const int N = 2e5 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int ans[10][11000];
string str;
string s1[10],s2[10],s3[10],s4[10];
void solve(int num)
{
    int tt = 0;
    string s = "";
    for(int i = 0;i < str.size();i++)
    {
        if(str[i] == '[') continue;
        if(str[i] == ']')
        {
            if(tt == 0)
            {
                for(int j = 0;j < 4;j++)
                {
                    if(s == s1[j])
                    {
                        ans[tt++][num] = j;
                        break;
                    }
                }
            }
            else if(tt == 1)
            {
                for(int j = 0;j < 4;j++)
                {
                    if(s == s2[j])
                    {
                        ans[tt++][num] = j;
                        break;
                    }
                }
            }
            else if(tt == 2)
            {
                for(int j = 0;j < 4;j++)
                {
                    if(s == s3[j])
                    {
                        ans[tt++][num] = j;
                        break;
                    }
                }
            }
            else if(tt == 3)
            {
                for(int j = 0;j < 4;j++)
                {
                    if(s == s4[j])
                    {
                        ans[tt++][num] = j;
                        break;
                    }
                }
            }
            s = "";
            continue;
        }
        s += str[i];
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    s1[0] = "*";s1[1] = "one";s1[2] = "two";s1[3] = "three";
    s2[0] = "*";s2[1] = "diamond";s2[2] = "squiggle";s2[3] = "oval";
    s3[0] = "*";s3[1] = "solid";s3[2] = "striped";s3[3] = "open";
    s4[0] = "*";s4[1] = "red";s4[2] = "green";s4[3] = "purple";
    int t;
    cin >> t;
    for(int i = 1;i <= t;i++)
    {
        int n,flag = 0;
        cin >> n;
        for(int j = 0;j < n;j++)
        {
            cin >> str;
            solve(j);
        }
        for(int k1 = 0;k1 < n;k1++)
        {
            if(flag) break;
            for(int k2 = k1+1;k2 < n;k2++)
            {
                if(flag) break;
                for(int k3 = k2+1;k3 < n;k3++)
                {
                    int k4 = 0;
                    for(k4 = 0;k4 < 4;k4++)
                    {
                        if(ans[k4][k1] == 0 || ans[k4][k2] == 0 || ans[k4][k3] == 0)
                            continue;
                        else if(ans[k4][k1] == ans[k4][k2] && ans[k4][k2] == ans[k4][k3])
                            continue;
                        else if(ans[k4][k1] != ans[k4][k2] && ans[k4][k2] != ans[k4][k3] && ans[k4][k1] != ans[k4][k3])
                            continue;
                        else
                            break;
                    }
                    if(k4 == 4)
                    {
                        flag = 1;
                        printf("Case #%d: %d %d %d\n",i,k1+1,k2+1,k3+1);
                        break;
                    }
                }
            }
        }
        if(!flag) printf("Case #%d: -1\n",i);
    }
}

你可能感兴趣的:(牛客)