http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3210

题意:给出stack和queue的定义,一个是先进后出(FILO),一个是先进先出(FIFO),每个样例都有两行,每行n个,判断它们的属性。(我每次都是用最笨的方法。。)

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int t,n,k,r,h,i,j;
  5. int a[][];
  6. cin>>t;
  7. while(t--) {
  8. cin>>n;
  9. k=,r=;
  10. for(i=; i<; i++)
  11. for(j=; j<n; j++)
  12. cin>>a[i][j];
  13. for(i=,j=,h=n-; j<n,h>=; j++,h--) {
  14. if(a[i][j]!=a[i+][h])
  15. k=;
  16. }
  17. for(j=,i=; j<n; j++) {
  18. if(a[i][j]!=a[i+][j])
  19. r=;
  20. }
  21. if(k&&!r)
  22. printf("stack\n");
  23. else if(r&&!k)
  24. printf("queue\n");
  25. else if(k&&r)
  26. printf("both\n");
  27. else
  28. printf("neither\n");
  29. }
  30. return ;
  31. }

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. replace替换语句

    t_sql语句:replace替换语句:update 表名 set 列名=REPLACE(列名,'替换的数据','替换后的数据')

  2. 详解Win2003 IIS6.0 301重定向带参数的问题(转摘)

      网站更换域名,把旧域名用301指到新域名来. 从iis中设置url永久转向就可以,看上去很容易,用了一会儿才发现,参数都没有带上. 从微软网站上找到如下说明,果然好使: 重定向参考 (IIS 6. ...

  3. MYfirst

    终于有了自己的博客了,啊哈哈!

  4. Ajax-Demo

    index.jsp 1 <%@ page language="java" contentType="text/html; charset=UTF-8" p ...

  5. ASP.NET下运用Memcached

    对于大型网站的高并发,在ASP.NET网站下的session性能并不高,所以造成人们一种印象,大型WEB项目使用JAVA的错觉,致使很多人吐槽微 软不给力,其实这好比拉不出怪地球引力,本文介绍Memc ...

  6. C#解析Json格式数据小结

    最近,遇到了一些不同的Json格式的数据,需要做不同处理才能转化为想要得到的结果,这里总结一下. 第一种形式:status中是{}形式,对象 string json = @"{'name': ...

  7. (转)SQLSERVER表分区的介绍(一)

    下面进入正题吧,很多时候当单张数据表的数据量比较大的时候比如千万级别条记录.上亿级别记录,如果不做优化,那么查询的效率大家清楚. 有经验的人会通过各种手段做优化,其中表分区就是其中一种手段. 个人对表 ...

  8. 高性能CSS(二)

    避免CSS表达式 CSS表达式是动态设置CSS属性的强大(但危险)方法.Internet Explorer从第5个版本开始支持CSS表达式.下面的例子中,使用CSS表达式可以实现隔一个小时切换一次背景 ...

  9. Mysql数据表的操作

    表的操作 前提:选择数据库 语法: use 数据库名; 1.创建数据表 语法: create table 表名( 字段1 字段类型 [附加属性], 字段2 字段类型 [附加属性], 字段3 字段类型 ...

  10. c#基础学习汇总----------base和this,new和virtual

    base和this是c#中的两访问关键字,目的是用于实现继承机制的访问操作,来满足对对象成员的访问,从而为多态机制提供更加灵活的处理方式. 在看<你必须知道的.Net>一书中有一个例子很好 ...