OJ笔记
1.未考虑程序没有输出导致的格式错误:
原代码:(即使没有输出,ans集合元素为0,也输出了空格)
set<int>::iterator it=ans.begin();
while(it!=ans.end()){
if(it!=ans.begin())
O(" ");
O("%05d",*it);
it++;
}
OL("");
AC代码:
if(ans.size()>){
set<int>::iterator it=ans.begin();
while(it!=ans.end()){
if(it!=ans.begin())
O(" ");
O("%05d",*it);
it++;
}
OL("");
}
2.编程时尽量避开程序已经定义的词汇,例如time
今天编多重标尺的单源最短路径的题目(做了一个晚上,敲了200行代码,吐了),最后还编译失败,就是因为定义了time
OJ笔记的更多相关文章
- C++笔记(6)——关于OJ的单点测试和多点测试
单点测试 PAT使用的就是单点测试(LeetCode应该也是单点测试).单点测试中系统会判断每组数据的输出结果是否正确,正确则通过测试并获得这则测试的分值.题目的总得分等于通过的数据的分值之和. 代码 ...
- 算法学习笔记(LeetCode OJ)
================================== LeetCode的一些算法题,都是自己做的,欢迎提出改进~~ LeetCode:http://oj.leetcode.com == ...
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- Leetcode 笔记 110 - Balanced Binary Tree
题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...
- Leetcode 笔记 100 - Same Tree
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
- Leetcode 笔记 99 - Recover Binary Search Tree
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
- Leetcode 笔记 98 - Validate Binary Search Tree
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
- Leetcode 笔记 101 - Symmetric Tree
题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...
随机推荐
- SQL系列(八)—— 分组(group by)
在很多场景时,需要对数据按照某条件进行分组统计其数量.平均值等等.有这种需求,SQL自然也有解决方式. 在SQL中通过group by子句对结果按某条件进行分组.语法: select count(co ...
- JavaScript由来
在互联网时代,网速还很差劲的时候,表单输入数据的合法性验证需要与服务器交换数据,从而加重了使用者的负担. 网景公司为了解决这种简单问题开发了JavaScript.在1995年2月网景公司在发布自己的浏 ...
- Ubuntu安装MySQL配置远程登录、utf8mb4字符集
2019/11/19, Ubuntu Server 18.04,MySQL 5.7 摘要:Ubuntu Server 18.04 安装MySQL 5.7 并配置远程登录.utf8mb4字符集 由于My ...
- delegate、Action、Func的用法
委托的特点 委托类似于 C++ 函数指针,但它们是类型安全的. 委托允许将方法作为参数进行传递. 委托可用于定义回调方法. 委托可以链接在一起. delegate的用法 delegate void B ...
- Neo私钥到地址
基础名词 Neo是个区块链工程,地址,公钥,私钥,地址脚本,base58,sha256,ripemd160,ECCsa,secp256k1,secp25r1这些词都是区块链技术相关的,或是新东西或者有 ...
- 一步一步学Spring Boot 2 微服务项目实战 - 黄文毅-2018年8月第一次印刷
properties 配置文件的优先级高于.yml .在properties文件中配置了server.port=8080 同时在.yml中配置了server.port=8090 Spring Boo ...
- 16、css实现div中图片占满整个屏幕
<div class="img"></div> .img{ background: url("../assets/image/img.png&qu ...
- jQuery的内部运行机制和原理
jQuery的优点: jQuery是一个非常优秀的JavaScript库,与Prototype,YUI,Mootools等众多的Js类库相比,它剑走偏锋,从Web开发实用的角度出发,抛除了其它Lib中 ...
- Android studio module生成jar包,module中引用的第三方库没有被引用,导致java.lang.NoClassDefFoundError错误。
android studio 创建了一个Module生成jar包,这个module中有引用一些第三方的类库,比如 gson,volley等. 但是生成的jar包里,并没有将gson,volley等第三 ...
- Django 之 restframework 频率组件的使用
Django 之 restframework 频率组件的使用以及源码分析 频率组件的使用 第一步,先写一个频率类,继承SimpleRateThrottle 一定要在这个类里面配置一个scop='字符串 ...