The 6th Zhejiang Provincial Collegiate Programming Contest->Problem I:A Stack or A Queue?
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3210
题意:给出stack和queue的定义,一个是先进后出(FILO),一个是先进先出(FIFO),每个样例都有两行,每行n个,判断它们的属性。(我每次都是用最笨的方法。。)
#include<bits/stdc++.h>
using namespace std;
int main() {
int t,n,k,r,h,i,j;
int a[][];
cin>>t;
while(t--) {
cin>>n;
k=,r=;
for(i=; i<; i++)
for(j=; j<n; j++)
cin>>a[i][j];
for(i=,j=,h=n-; j<n,h>=; j++,h--) {
if(a[i][j]!=a[i+][h])
k=;
}
for(j=,i=; j<n; j++) {
if(a[i][j]!=a[i+][j])
r=;
}
if(k&&!r)
printf("stack\n");
else if(r&&!k)
printf("queue\n");
else if(k&&r)
printf("both\n");
else
printf("neither\n");
}
return ;
}
The 6th Zhejiang Provincial Collegiate Programming Contest->Problem I:A Stack or A Queue?的更多相关文章
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial ...
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
- The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club
Doki Doki Literature Club Time Limit: 1 Second Memory Limit: 65536 KB Doki Doki Literature Club ...
随机推荐
- Unity Rigidbody 刚体中的Angular Drag和Freeze Position/Rotation
Rigidbody中 Angular Drag (角阻力):同样指的是空气阻力,只不过是用来阻碍物体旋转的.如果设置成无限的话,物体会立即停止旋转.如果设置成0,物体在上升过程中,会发生侧翻旋转. ...
- Ubuntu 15.04 中结束进程的命令
今天在尝试用ubuntu进行goAgent,一开始提示没有权限,无法复制证书文件,这个问题好办,只要在命令前面加个sudo获取超级管理员权限就可以了: 后来又提示:Socket Adress alre ...
- SQL按照日、周、月、年统计数据
写sql语句分别按日,星期,月,季度,年统计销售额 --按日 select sum(consume),day([date]) from consume_record where year([date] ...
- 新年第一次分享sqlserver技术
走向DBA[MSSQL篇] - 从SQL语句的角度提高数据库的访问性能 最近公司来一个非常虎的DBA,10几年的经验,这里就称之为蔡老师吧,在征得我们蔡老同意的前提下 ,我们来分享一下蔡老给我们带来的 ...
- iOS开发——model类模板(过滤null和ID)
说明:model类模板已默认过滤null值,附加特殊情况的关键字ID名的冲突(需手动去掉注释代码).MyMessageModel为示例的名字.可以自己随便起. 1.自己创建一个继承与N ...
- [GeekBand] 探讨C++新标准之新语法——C++ 11~14
一. 可变参数模板(Variadic Templates) 在C++11中,出现了参数数目可变的模板,这部分在之前C++高级编程的时候就有学习到. 其实,在C中就有类似的设定.最常用的printf() ...
- 隐藏win7盘符
1.隐藏盘符: //新建注册表,隐藏X盘符 int regeditme() { HKEY hkey; DWORD dwLastError= ;//隐藏X盘2^25 J:2^9=512 X:盘符与挂载的 ...
- 关于C++引用的一些注意点
C++的引用首先跟指针的最大区别就是引用不是一个对象,而指针是一个对象:其次引用在其定义时就要初始化,而指针可以不用. ; int &rval = val; 此时rval就绑定了val,其实就 ...
- [DevExpress]RepositoryItemComboBox 数据绑定
关键代码: public static void Bind<T>(this RepositoryItemComboBox combox, ICollection source) { /*说 ...
- 解决xtraFinder在EI下不能使用问题
在EI (10.11)下,由于SIP(System Integrity Protection)机制,导致一些第三方插件不能使用,如xtrafinder. 要想使用,在目前的情况下,启用的方法:一种是安 ...