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 ...
随机推荐
- laravel 查询随机数据
laravel 中 随机搜索数据 $tweet = Tweet::where('id',$id) ->orderBy(\DB::raw('RAND()')) ->take(1) -> ...
- opencv常用数据结构
2019/10/29 1.Mat 成员函数:cols.rows.channels.ptr获取任意行的首地址.at处理像素 2.InputArray/OutArray相当于Mat 2019/11/4 1 ...
- wangeditor视频
wangeditor网址http://www.wangeditor.com/ 目前使用的是3.11版本 使用步骤 1.引用wangEditor.min.js 2.代码 2.1 取得函数var E = ...
- Unity PhysicsScene测试
应该是unity 2018.3中加入的功能,对象可以放置于不同的物理场景中. 一个Scene对应一个物理场景(PhysicsScene),若想放入独立的物理场景测试创建一个Scene即可.见下图gif ...
- Java自学-接口与继承 多态
Java的多态 操作符的多态 +可以作为算数运算,也可以作为字符串连接 类的多态 父类引用指向子类对象 示例 1 : 操作符的多态 同一个操作符在不同情境下,具备不同的作用 如果+号两侧都是整型,那么 ...
- iOS - 适配 iOS 13 之工兵连扫雷
iOS 13 支持适配的机型 目前最新 iPhone 11.iPhone 11 Pro和iPhone 11 Pro Max iPhone X.iPhone XR.iPhone XS.iPhone XS ...
- Jest单元测试进阶
Jest 命令行窗口中的指令 在学习Jest单元测试入门的时候,给Jest命令提供了一个参数 --watchAll, 让它监听测试文件或测试文件引入的文件的变化,从而时时进行测试.但这样做也带来一个问 ...
- 数据库-如何创建SQL Server身份验证用户
1.简介 默认安装SQL Server数据库后,SQL Server通过工具SQL Server Management Studio(SSMS)采用“Windows身份验证”方式登录,需要设置相应用户 ...
- Windows - CMD窗口UTF8编码乱码问题的解决!
问题描述 用MS-DOC打开 UTF-8 的文件时, 显示乱码问题根源 CMD默认是Windows系统默认编码(GBK), 用GBK格式来解码UTF-8的文件当然会出现乱码.解决方案 ...
- UIDatePicker基本使用
UIDatePicker提供了一个快速选择日期和时间的控件,他是UIControl的子类,专门用于日期时间的选择.其样式可以通过UIDatePicker的属性进行灵活设置,同时也可以获取到当前UIDa ...