栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 3429 Cube Simulation

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 3429 Cube Simulation

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int idx[1010],idy[1010],idz[1010],sx[1010],sy[1010],sz[1010];int main(){char s[20];int i,j,k,n,m,x,y,z,t1,t2,t3,a,b,c;while(scanf(" %s",s)!=EOF){if(strcmp(s,"FILL")==0){printf("STARTn");scanf("%d%d%d",&x,&y,&z);for(i=0;i<x;i++)idx[i]=sx[i]=i;for(i=0;i<y;i++)idy[i]=sy[i]=i;for(i=0;i<z;i++)idz[i]=sz[i]=i;t1=z;t2=y*z;t3=x*y*z;}if(strcmp(s,"SWAP1")==0){scanf("%d%d",&x,&y);sx[idx[x]]=y;sx[idx[y]]=x;swap(idx[x],idx[y]);}if(strcmp(s,"SWAP2")==0){scanf("%d%d",&x,&y);sy[idy[x]]=y;sy[idy[y]]=x;swap(idy[x],idy[y]);}if(strcmp(s,"SWAP3")==0){scanf("%d%d",&x,&y);sz[idz[x]]=y;sz[idz[y]]=x;swap(idz[x],idz[y]);}if(strcmp(s,"FIND")==0){scanf("%d",&x);if(x>t3)continue;x--;a=x/t2;x-=a*t2;b=x/t1;x-=b*t1;c=x;printf("%d %d %dn",sx[a],sy[b],sz[c]);}if(strcmp(s,"QUERY")==0){scanf("%d%d%d",&x,&y,&z);printf("%dn",idx[x]*t2+idy[y]*t1+idz[z]+1);}}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378697.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号