首先先生成三个程序: $ g++ a+b.cpp -o a+b $ g++ a+b2.cpp -o a+b2 $ g++ make.cpp -o make 然后生成数据 $ ./make > in.txt 然后运行两个程序 $ ./a+b < in.txt > out.txt $ ./a+b2 < in.txt > ans.txt 最后对拍 $ diff out.txt ans.txt 输出的结果可以man diff查阅一下相关文档中关于输出含义的内容 注:上面的$都是命令提示符,复制粘贴时不需要
阅读更多题意:给一个方阵,k个查询,每个查询求某个方阵的最大值和最小值之差。
思路:二维rmq.同时用到最大值和最小值的话可以把初始化写在一起。
/* *********************************************** Author :111qqz Created Time :2016年05月16日 星期一 18时31分23秒 File Name :code/poj/2019.cpp ************************************************ */
1#include <cstdio> 2#include …
阅读更多题意:n位长的数字串(n<=1000),删掉m个(m<=n),使得剩下的数字串表示的数字最小。 忽略前导0.
思路:暴力搞就可以。要注意每位数字是有一定位置的范围的。比如当前是第i位数字,后面还要取n-m-i位数字,那么第i位数字最多只能取到第k位,k=m+i,因为这样才能保证后面还有n-m-i位数字。
阅读更多1636: [Usaco2007 Jan]Balanced Lineup
Time Limit: 5 Sec Memory Limit: 64 MB Submit: 680 Solved: 493 [Submit][Status][Discuss]
Description
For the daily milking, Farmer John's N cows (1 <= N <= 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some …
阅读更多1689: [Usaco2005 Open] Muddy roads 泥泞的路
Time Limit: 5 Sec Memory Limit: 64 MB Submit: 311 Solved: 227 [Submit][Status][Discuss]
Description
Farmer John has a problem: the dirt road from his farm to town has suffered in the recent rainstorms and now contains (1 <= N <= 10,000) mud pools. Farmer John has a …
阅读更多