2020牛客暑期多校训练营(第八场)G Game SET

链接:https://ac.nowcoder.com/acm/contest/5673/G
来源:牛客网

SET is a real-time card game designed by Marsha Falco in 1974 and published by Set Enterprises in 1991. The deck consists of 81 unique cards that vary in four features across three possibilities for each kind of feature: number of shapes (one, two, or three), shape (diamond, squiggle, or oval), shading (solid, striped, or open), and color (red, green, or purple). Each possible combination of features (e.g. a card with [three][diamond][striped][green]) appears as a card precisely once in the deck.

In the game, certain combinations of three cards are said to make up a \textbf{set}set. For each one of the four categories of features — color, number, shape, and shading — the three cards must display that feature as a) either all the same, or b) all different. Put another way: For each feature the three cards must avoid having two cards showing one version of the feature and the remaining card showing a different version.

For example,
[three][diamond][solid][red]
[two][squiggle][solid][green]
[one][oval][solid][purple]
form a \textbf{set}set, because the shadings of the three cards are all the same, while the numbers, the colors, and the shapes among the three cards are all different.

There are some special cards which called Wild cards. Some values of a Wild card’s features can be wild, i.e they can take any value the player chooses. For example, [*][diamond][solid][red] can be regarded as [one][diamond][solid][red], [two][diamond][solid][red] or [three][diamond][solid][red].

You’re given N unique cards, you need to find any valid set. Each card is used at most once.

示例1
输入

3
3
[three][diamond][solid][red]
[two][*][solid][*]
[two][*][*][red]
5
[one][diamond][open][red]
[two][squiggle][solid][red]
[two][squiggle][*][red]
[two][diamond][solid][red]
[three][diamond][*][red]
6
[one][diamond][open][red]
[two][squiggle][*][green]
[two][squiggle][solid][green]
[two][diamond][solid][green]
[three][diamond][*][red]
[*][*][*][*]

输出

Case #1: -1
Case #2: 1 4 5
Case #3: 1 2 6

题意:
你需要找到三行 ,每一列的值都不一样,或者每一列的值都一样的组合,并且输出他们。
题解:
开始看着这个数据啊256 * 256 * 256*1000 ++,贼大然后莫名其妙的暴力过了,然后= = 赛后意识到他最多就只有四个参数,最多20个不能组成一个set。= =那么就是模拟他喽
三个for暴力跑,先把字符串处理成数字
Code:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const int maxn=300;
 
int n;
struct node
{
    int a[5];
} thi[maxn];
map<node,vector<int> >mp;
inline void f()
{
    string s;
    cin>>n;
    for(int k=1; k<=n; k++)
    {
        cin>>s;
        int l=s.size();
        int flag=0;
        string tmp;
        for(int i=0; i<l; i++)
        {
            if(s[i]=='[')
            {
                flag++;
                continue;
            }
            if(s[i]==']')
            {
                if(flag==1)
                {
                    if(tmp=="one")
                    {
                        thi[k].a[flag]=1;
                    }
                    if(tmp=="two")
                    {
                        thi[k].a[flag]=2;
                    }
                    if(tmp=="three")
                    {
                        thi[k].a[flag]=3;
                    }
                    if(tmp=="*")
                    {
                        thi[k].a[flag]=0;
                    }
                }
                else if(flag==2)
                {
                    if(tmp=="diamond")
                    {
                        thi[k].a[flag]=1;
                    }
                    if(tmp=="squiggle")
                    {
                        thi[k].a[flag]=2;
                    }
                    if(tmp=="oval")
                    {
                        thi[k].a[flag]=3;
                    }
                    if(tmp=="*")
                    {
                        thi[k].a[flag]=0;
                    }
                }
                else if(flag==3)
                {
                    if(tmp=="solid")
                    {
                        thi[k].a[flag]=1;
                    }
                    if(tmp=="striped")
                    {
                        thi[k].a[flag]=2;
                    }
                    if(tmp=="open")
                    {
                        thi[k].a[flag]=3;
                    }
                    if(tmp=="*")
                    {
                        thi[k].a[flag]=0;
                    }
                }
                else if(flag==4)
                {
                    if(tmp=="red")
                    {
                        thi[k].a[flag]=1;
                    }
                    if(tmp=="green")
                    {
                        thi[k].a[flag]=2;
                    }
                    if(tmp=="purple")
                    {
                        thi[k].a[flag]=3;
                    }
                    if(tmp=="*")
                    {
                        thi[k].a[flag]=0;
                    }
                }
                tmp.clear();
                continue;
            }
            if(flag)
            {
                tmp+=s[i];
            }
        }
    }
//    for(int i=1;i<=n;i++){
//      mp[thi[i]].push_back(i);
//  }
}
 
int solve(int l,int r)
{
    int ta[5];
    for(int i=1; i<=4; i++)
    {
        if(thi[l].a[i]=='*'||thi[r].a[i]=='*')
        {
            ta[i]=5;
        }
        else if(thi[l].a[i]==thi[r].a[i])
        {
            ta[i]=thi[l].a[i];
        }
        else
        {
            ta[i]=3^thi[l].a[i]^thi[r].a[i];
        }
    }
 
 
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    int t;
    cin>>t;
    for(int cas=1; cas<=t; cas++)
    {
        f();
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            for(int j=i+1; j<=n; j++)
            {
                int num[5]= {0};
                for(int k=1; k<=4; k++)
                {
                    if(thi[i].a[k]==0||thi[j].a[k]==0)
                    {
                        num[k]=6;
                        continue;
                    }
                    if(thi[i].a[k]==thi[j].a[k])
                    {
                        num[k]=thi[i].a[k];
                    }
                    else
                    {
                        num[k]=6-thi[i].a[k]-thi[j].a[k];
                    }
                }
                for(int k=j+1; k<=n; k++)
                {
                    int ff=1;
                    for(int mm=1; mm<=4; mm++)
                    {
                        //printf("%d %d %d %d %d\n",i,j,k,thi[k].a[mm],num[mm]);
                        if(num[mm]==6||thi[k].a[mm]==0)
                            continue;
 
                        if(thi[k].a[mm]!=num[mm])
                        {
                            ff=0;
                            break;
                        }
                    }
                    //printf("\n");
                    if(ff)
                    {
                        printf("Case #%d: %d %d %d\n",cas,i,j,k);
                        flag=1;
                        break;
                    }
                }
                if(flag)
                    break;
            }
            if(flag)
                break;
        }
        if(!flag)
        {
             printf("Case #%d: -1\n",cas);
        }
    }
    return 0;
}
/*
3
3
[three][diamond][solid][red]
[two][*][solid][*]
[two][*][*][red]
5
[one][diamond][open][red]
[two][squiggle][solid][red]
[two][squiggle][*][red]
[two][diamond][solid][red]
[three][diamond][*][red]
6
[one][diamond][open][red]
[two][squiggle][*][green]
[two][squiggle][solid][green]
[two][diamond][solid][green]
[three][diamond][*][red]
[*][*][*][*]
*/
内容概要:该论文深入研究了液压挖掘机动臂下降势能回收技术,旨在解决传统液压挖掘机能耗高的问题。提出了一种新型闭式回路势能回收系统,利用模糊PI自整定控制算法控制永磁无刷直流电动机,实现了变转速容积调速控制,消除了节流和溢流损失。通过建立数学模型和仿真模型,分析了不同负载下的系统性能,并开发了试验平台验证系统的高效性和节能效果。研究还涵盖了执行机构能量分布分析、系统元件参数匹配及电机控制性能优化,为液压挖掘机节能技术提供了理论和实践依据。此外,通过实验验证,该系统相比传统方案可降低28%的能耗,控制系统响应时间缩短40%,为工程机械的绿色化、智能化发展提供了关键技术支撑。 适合人群:从事工程机械设计、制造及维护的工程师和技术人员,以及对液压系统节能技术感兴趣的科研人员。 使用景及目标:①理解液压挖掘机闭式回路动臂势能回收系统的原理和优势;②掌握模糊PI自整定控制算法的具体实现;③学习如何通过理论建模、仿真和实验验证来评估和优化液压系统的性能。 其他说明:此研究不仅提供了详细的理论分析和数学建模,还给出了具体的仿真代码和实验数据,便于读者在实际工作中进行参考和应用。研究结果表明,该系统不仅能显著提高能源利用效率,还能延长设备使用寿命,降低维护成本,具有重要的工程应用价值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值