题面:

题意:
就是题目有点长,写起来直接写就好啦。

有一个长度为 232,0≤i<2322^{32},0\le i <2^{32}232,0≤i<232 数组 MMM , MiM_iMi​ 是一个 323232 位的无符号整数。

有以下三种地址表示形式:
#(number) 立即寻址:表示 numbernumbernumber 是一个常量。

$(index) 直接寻址:即下标为 index 的存储单元,即 M(index)。

@(index) 间接寻址:即下标为 M(index) 的存储单元,即 M(M(index))。

有以下八个操作:
MOVEab,即将b的值赋值给aMOVE\ \ a\ \ b,即将 b 的值赋值给 aMOVE  a  b,即将b的值赋值给a

INPUTa,将读入的值赋值给aINPUT\ \ a ,\ \ 将读入的值赋值给 aINPUT  a,  将读入的值赋值给a

OUTPUTa,输出a的值。OUTPUT\ a,输出 a 的值。OUTPUT a,输出a的值。

ADDabc,即a=b+cADD\ \ a\ \ b\ \ c,\ \ \ 即 a=b+cADD  a  b  c,   即a=b+c

MULTabc,a=b∗cMULT\ \ a\ \ b\ \ c,\ \ \ a=b*cMULT  a  b  c,   a=b∗c

ANDabc,a=bandcAND\ \ a\ \ b\ \ c,\ \ \ a=b\ and\ cAND  a  b  c,   a=b and c

ORabc,a=b∣cOR\ \ a\ \ b\ \ c,\ \ \ a=b|cOR  a  b  c,   a=b∣c

XORabc,a=bxorcXOR\ \ a\ \ b\ \ c,\ \ \ a=b\ xor\ cXOR  a  b  c,   a=b xor c

现在给定一系列的指令,但是ADD,MULT,AND,OR,XORADD,MULT,AND,OR,XORADD,MULT,AND,OR,XOR 以 A,B,C,D,EA,B,C,D,EA,B,C,D,E 的形式给出,且不知道哪个对应哪一个。

再给定一系列的输入和输出,判定有多少种给 A,B,C,D,EA,B,C,D,EA,B,C,D,E 赋值的方式,使得给定的输入输出正确。

题解:
枚举120种情况,模拟即可。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
namespace onlyzhao
{#define ui unsigned int#define ll long long#define llu unsigned ll#define ld long double#define pr make_pair#define pb push_back#define lc (cnt<<1)#define rc (cnt<<1|1)#define len(x)  (t[(x)].r-t[(x)].l+1)#define tmid ((l+r)>>1)#define fhead(x) for(int i=head[(x)];i;i=nt[i])//#define max(x,y) ((x)>(y)?(x):(y))//#define min(x,y) ((x)>(y)?(y):(x))#define one(n) for(int i=1;i<=(n);i++)#define rone(n) for(int i=(n);i>=1;i--)#define fone(i,x,n) for(int i=(x);i<=(n);i++)#define frone(i,n,x) for(int i=(n);i>=(x);i--)#define fonk(i,x,n,k) for(int i=(x);i<=(n);i+=(k))#define fronk(i,n,x,k) for(int i=(n);i>=(x);i-=(k))#define two(n,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)#define ftwo(i,n,j,m) for(int i=1;i<=(n);i++) for(int j=1;j<=(m);j++)#define fvc(vc) for(int i=0;i<vc.size();i++)#define frvc(vc) for(int i=vc.size()-1;i>=0;i--)#define forvc(i,vc) for(int i=0;i<vc.size();i++)#define forrvc(i,vc) for(int i=vc.size()-1;i>=0;i--)#define cls(a) memset(a,0,sizeof(a))#define cls1(a) memset(a,-1,sizeof(a))#define clsmax(a) memset(a,0x3f,sizeof(a))#define clsmin(a) memset(a,0x80,sizeof(a))#define cln(a,num) memset(a,0,sizeof(a[0])*num)#define cln1(a,num) memset(a,-1,sizeof(a[0])*num)#define clnmax(a,num) memset(a,0x3f,sizeof(a[0])*num)#define clnmin(a,num) memset(a,0x80,sizeof(a[0])*num)#define sc(x) scanf("%d",&x)#define sc2(x,y) scanf("%d%d",&x,&y)#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)#define scl(x) scanf("%lld",&x)#define scl2(x,y) scanf("%lld%lld",&x,&y)#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)#define scf(x) scanf("%lf",&x)#define scf2(x,y) scanf("%lf%lf",&x,&y)#define scf3(x,y,z) scanf("%lf%lf%lf",&x,&y,&z)#define scs(x) scanf("%s",x+1)#define scs0(x) scanf("%s",x)#define scline(x) scanf("%[^\n]%*c",x+1)#define scline0(x) scanf("%[^\n]%*c",x)#define pcc(x) putchar(x)#define pc(x) printf("%d\n",x)#define pc2(x,y) printf("%d %d\n",x,y)#define pc3(x,y,z) printf("%d %d %d\n",x,y,z)#define pck(x) printf("%d ",x)#define pcl(x) printf("%lld\n",x)#define pcl2(x,y) printf("%lld %lld\n",x,y)#define pcl3(x,y,z) printf("%lld %lld %d\n",x,y,z)#define pclk(x) printf("%lld ",x)#define pcf2(x) printf("%.2f\n",x)#define pcf6(x) printf("%.6f\n",x)#define pcf8(x) printf("%.8f\n",x)#define pcs(x) printf("%s\n",x+1)#define pcs0(x) printf("%s\n",x)#define pcline(x) printf("%d**********\n",x)#define casett int tt;sc(tt);int pp=0;while(tt--)char buffer[100001],*S,*T;inline char Get_Char(){if (S==T){T=(S=buffer)+fread(buffer,1,100001,stdin);if (S==T) return EOF;}return *S++;}inline int read(){char c;int re=0;for(c=Get_Char();c<'0'||c>'9';c=Get_Char());while(c>='0'&&c<='9') re=re*10+(c-'0'),c=Get_Char();return re;}
};
using namespace onlyzhao;
using namespace std;const int inf=0x3f3f3f3f;
const ll lnf=0x3f3f3f3f3f3f3f3f;
const double dnf=1e9;
const int mod=998244353;
const double eps=1e-8;
const double pi=acos(-1.0);
const int hp=13331;
const int maxn=100100;
const int maxm=100100;
const int up=100100;map<ui,ui>mp;
string s[120][4];
int a[]={1,2,3,4,5};
map<int,string>mmp;
map<string,int>p;
int ans[10];void init(void)
{mmp[1]="ADD";mmp[2]="MULT";mmp[3]="AND";mmp[4]="OR";mmp[5]="XOR";p["A"]=0;p["B"]=1;p["C"]=2;p["D"]=3;p["E"]=4;
}ui in[110][110];
int k;
int cc=0;ui get(string s,int l,int r)
{ui ans=0;for(int i=l;i<=r;i++)ans=ans*10+s[i]-'0';return ans;
}bool check(int k)
{mp.clear();int ii=0;for(int i=1;i<=cc;i++){if(s[i][0]=="INPUT"){if(s[i][1][0]=='$'){ui now=get(s[i][1],1,s[i][1].size()-1);mp[now]=in[k][++ii];}else{ui now=get(s[i][1],1,s[i][1].size()-1);mp[mp[now]]=in[k][++ii];}}else if(s[i][0]=="MOVE"){ui now=0;if(s[i][2][0]=='#'){now=get(s[i][2],1,s[i][2].size()-1);}else if(s[i][2][0]=='$'){now=mp[get(s[i][2],1,s[i][2].size()-1)];}else{now=mp[mp[get(s[i][2],1,s[i][2].size()-1)]];}if(s[i][1][0]=='$'){ui cn=get(s[i][1],1,s[i][1].size()-1);mp[cn]=now;}else{ui cn=get(s[i][1],1,s[i][1].size()-1);mp[mp[cn]]=now;}}else if(s[i][0]=="OUTPUT"){ui now=0;if(s[i][1][0]=='#'){now=get(s[i][1],1,s[i][1].size()-1);}else if(s[i][1][0]=='$'){now=mp[get(s[i][1],1,s[i][1].size()-1)];}else{now=mp[mp[get(s[i][1],1,s[i][1].size()-1)]];}return now==in[k][++ii];}else{ui now1=0,now2=0;if(s[i][2][0]=='#'){now1=get(s[i][2],1,s[i][2].size()-1);}else if(s[i][2][0]=='$'){now1=mp[get(s[i][2],1,s[i][2].size()-1)];}else{now1=mp[mp[get(s[i][2],1,s[i][2].size()-1)]];}if(s[i][3][0]=='#'){now2=get(s[i][3],1,s[i][3].size()-1);}else if(s[i][3][0]=='$'){now2=mp[get(s[i][3],1,s[i][3].size()-1)];}else{now2=mp[mp[get(s[i][3],1,s[i][3].size()-1)]];}string now=mmp[a[p[s[i][0]]]];ui ans=0;if(now=="ADD"){ans=now1+now2;}else if(now=="MULT"){ans=now1*now2;}else if(now=="AND"){ans=now1&now2;}else if(now=="OR"){ans=now1|now2;}else if(now=="XOR"){ans=now1^now2;}if(s[i][1][0]=='$'){mp[get(s[i][1],1,s[i][1].size()-1)]=ans;}else{mp[mp[get(s[i][1],1,s[i][1].size()-1)]]=ans;}}}
}bool check(void)
{for(int i=1;i<=k;i++)if(check(i)==false) return false;return true;
}int main(void)
{int ct=0;int i=1;init();while(true){cc++;cin>>s[i][0];if(s[i][0]=="INPUT")cin>>s[i][1],ct++;else if(s[i][0]=="MOVE")cin>>s[i][1]>>s[i][2];else if(s[i][0]=="OUTPUT"){cin>>s[i][1];break;}else cin>>s[i][1]>>s[i][2]>>s[i][3];i++;}scanf("%d",&k);for(int i=1;i<=k;i++){for(int j=1;j<=ct+1;j++)scanf("%u",&in[i][j]);}int cnt=0;do{if(check()){cnt++;if(cnt==1){for(int i=0;i<5;i++)ans[i]=a[i];}}}while(next_permutation(a,a+5));printf("%d\n",cnt);if(cnt==1){for(int i=0;i<5;i++){if(i!=0) putchar(' ');cout<<mmp[ans[i]];}putchar('\n');}return 0;
}

石油大--2020年秋季组队训练赛第十二场---- L、The Assembly Code(模拟)相关推荐

  1. 石油大--2020年秋季组队训练赛第十二场----J、Greedy Termite(线段树)

    题面: 题意: 给定正整数 nnn 和起始位置 sss. nnn 表示有 nnn 个杆子,每个杆子由属性 (xi,hi)(x_i,h_i)(xi​,hi​) 构成,表示在 xix_ixi​ 处有一根高 ...

  2. 【upc】2020年秋季组队训练赛第十二场J Greedy Termite | 删点线段树

    状态 题目描述 There are n wooden rods vertically placed over a horizontal line. The rods are numbered 1 th ...

  3. 石油大--2020年秋季组队训练赛第十三场----B、Bouldering(最短路)

    题面: 题意: 给定一个 h∗wh*wh∗w 点阵,其中某一些点是可以走的. 这些点都有一个权值,表示如果经过当前点,则会花费的力气. 给定一个 rrr,你只能从当前点到达与你欧几里得距离不超过 rr ...

  4. 石油大--2020年秋季组队训练赛第十三场---- C、Colourful Chameleons(思维)

    题面: 题意: 有 nnn 种颜色的变色龙,其中第 iii 种颜色的变色龙有 ai,(ai>=n−1)a_i ,(a_i>=n-1)ai​,(ai​>=n−1) 只. 我每次可以选择 ...

  5. UPC 2020年秋季组队训练赛第十四场

    问题 A: Too Expensive to Buy a House 时间限制: 1 Sec 内存限制: 128 MB 题目描述 WNJXYK and DIDIDI are good friends ...

  6. 【DFS反向建图记忆化搜索】UPC Contest2592 - 2020年秋季组队训练赛第十四场 问题 D: Mysterious Treasure

    问题 D: Mysterious Treasure 时间限制: 1 Sec 内存限制: 128 MB 题目描述 WNJXYK and DIDIDI is playing a game. DIDIDI ...

  7. 【upc】2020年秋季组队训练赛第十四场 Get Strong | 折半搜索、二分

    题目描述 WNJXYK and DIDIDI are friends. They are thinking about getting strong all the time. They are pl ...

  8. 石油大--Contest2022 - 2020年秋季组队训练赛第二场--17100 Problem D、Find String in a Grid (AC自动机)

    题面: 题意: 给定一个 R∗CR*CR∗C 的字符矩阵,由大写字母构成. 有 qqq 个询问,每次给定一个由大写字母构成的字符串,问这个字符串在这个字符矩阵中出现了多少次. 某个字符串在矩阵中出现定 ...

  9. 石油大 2019年第二阶段我要变强个人训练赛第十八场 Problem N 扶桑号战列舰(线段树+区间更新+区间查询)

    链接:http://icpc.upc.edu.cn/problem.php?cid=1803&pid=13 题意:给出一个n,接下来一行给出n个数.才开始所有数为0,每次操作可以选一个区间[l ...

最新文章

  1. 利用3D打印构建衍射深度神经网络,可光速执行数字运算
  2. paper 38 :entropy
  3. 「完结」你对深度学习模型的理解是否足够深刻,这12篇文章了解下
  4. button 样式_实战PyQt5: 111-可以使用QSS样式表的部件
  5. 数学之美 系列十六(上) 不要把所有的鸡蛋放在一个篮子里 -- 谈谈最大熵模型
  6. 在一基金慈善年会上面发言
  7. 调试代码和解决问题的总体思路和 技术路线应该持有的心态
  8. Python基础教程(第2版•修订版)代码清单2-3 勘误
  9. 【Unity3D】3dsmax中带Vray材质的3D模型的导入
  10. 彩虹代刷网免授权+精美WAP端源码
  11. java-求矩形(长方形)的周长和面积案例
  12. python作业爬取xxx大学排行
  13. CentOS Stream才是未来
  14. 区块链与制造业【中美】发展报告
  15. 魔方二阶玩法[图解]
  16. EasyUI之treegrid学习
  17. gtk界面学习——显示中文提示框
  18. 8位阿里P8合著“Dubbo微服务进阶笔记”一经面世,Github上标星93K+
  19. python高斯函数表达式_编写集成高斯函数的Python函数的最佳方法是什么?
  20. 卫剑钒:《大教堂与集市》被过誉了吗?

热门文章

  1. Python中的多重继承
  2. C++ 多继承和多重继承
  3. 【无标题】华硕b760m装完系统后,无法硬盘启动,bios可识别出固态硬盘,启动设备内没有硬盘
  4. 离开家乡的人,习惯在外的漂泊,回不去了!
  5. webpack 用 webpack-parallel-uglify-plugin 加速打包报错
  6. 校验位(对256取余)
  7. 解决计算机网络问题的设备(泛洪及其连接避免泛洪问题)
  8. 使用NowSMS Gateway来接收发送短信和彩信
  9. android获取指定号码的短信,如何接收特定号码的短信信息?
  10. 免疫力低会怎么样 什么情况会导致免疫降低