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?的更多相关文章

  1. 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 ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. 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 ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. Asp.Net生命周期

    最近回顾了一些新知识,在网上搜索了一下生命周期的相关知识:在这里与大家一起分享一下: Asp.net是微软.Net战略的一个组成部分.它相对以前的Asp有了很大的发展,引入了许多的新机制.本文就Asp ...

  2. Android 侧滑菜单的简单实现(SlidingMenu)

    在我还没有学习Android的时候就用过侧滑菜单的APP,当时第一个感觉是:哇塞,这效果不错!当然,现在自己都已经学Android了,这效果当然也要做出来啊~ SlidingMenu是一种比较新的设置 ...

  3. sql常识-IN 操作符

    IN 操作符 IN 操作符允许我们在 WHERE 子句中规定多个值. SQL IN 语法 SELECT column_name(s) FROM table_name WHERE column_name ...

  4. Nginx+Tomcat实现反向代理与动静分离

    1. 什么是动静分离  所谓动静分离就是通过nginx(或apache等)来处理用户端请求的静态页面,tomcat(或weblogic)处理动态页面,从而达到动静页面访问时通过不同的容器来处理. 2. ...

  5. Build Firefox 编译Firefox

    准备 选择需要的firefox版本 http://hg.mozilla.org/releases/ 选择最新的build工具 http://ftp.mozilla.org/pub/mozilla.or ...

  6. js 验证电话号 座机及手机号

    function CheckTel() { /*验证电话号码 验证规则:区号+号码,区号以0开头,3位或4位号码由7位或8位数字组成 区号与号码之间可以无连接符,也可以“-”连接 如010888888 ...

  7. C# WinForm打开IE浏览器并访问网址

    C# WinForm 打开浏览器并访问网址代码: System.Diagnostics.Process.Start("iexplore.exe", "http://kel ...

  8. windows下tomcat切割日志按照日期输出

    windows下tomcat默认不会把应用的日志信息输出在日志文件中的,只会在控制台打印. 解决方法: 1,下载工具cronolog-1.6.1-win32.zip,并解压. 2,把cronolog. ...

  9. Hibernate的单向OneToMany、单向ManyToOne

    单向OneToMany 一个用户有多张照片,User----->Images是一对多关系,在数据库中Images维护一个外键useid 1.在映射关系的主控方Image这边,我们什么都不做.(为 ...

  10. Visual Studio 2015和.Net 2015 预览版在线安装和ISO镜像安装光盘下载

    微软刚刚宣布了 Visual Studio 2015和.Net 2015 预览版,并同时提供了下载. 微软在纽约正进行中的#Connect# 全球开发者在线大会上宣布了Visual Studio 20 ...