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 ...
随机推荐
- Apache配置多端口多站点
配置httpd.conf 监听多个端口 复制代码 代码如下:# Listen: Allows you to bind Apache to specific IP addresses and/or # ...
- OC2_引用计数
// // Dog.h // OC2_引用计数 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxuemin ...
- 双网卡route配置
目前仅适用于windows: 192.168.*.*网段适用于上外网的 10网段适用于内网 route add 10.0.0.0 mask 255.0.0.0 10.34.6.1route add 1 ...
- javascript笔记——js的阻塞特性[转载]
JS具有阻塞特性,当浏览器在执行js代码时,不能同时做其它事情,即<script>每次出现都会让页面等待脚本的解析和执行(不论JS是内嵌的还是外链的),JS代码执行完成后,才继续渲染页面. ...
- spring aop配置及用例说明(1)
欢迎转载交流,博客地址http://www.cnblogs.com/shizhongtao/p/3469776.html 首先,什么是aop,其实通俗一点讲就是,再方法执行时候我们加入其它业务逻辑.比 ...
- [GeekBand] STL与泛型编程(3)
本篇文章主要介绍泛型算法中的变易.排序.数值算法. 一. 变易算法 所谓变易算法是指那些改变容器中的对象的操作. 1.1 copy组 template <class InputIterator, ...
- private继承
private继承并不如public继承一样具有is-a的关系. ------------------------------------------------------------------- ...
- Poj 2109 / OpenJudge 2109 Power of Cryptography
1.Link: http://poj.org/problem?id=2109 http://bailian.openjudge.cn/practice/2109/ 2.Content: Power o ...
- linux开机启动增加tomcat启动项
需求:开发环境(linux)重启后,每次需手动启动相关应用较为繁琐,如设置为开机自动启动则可减少此工作量. google下,参考了以下博文较好解决了问题: 1. 简单说明 Centos下设置程序开机自 ...
- 单纯形法C++实现
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4156685.html 使用单纯型法来求解线性规划,输入单纯型法的松弛形式,是一个大矩阵,第一 ...