关于C++输入输出优化的一点事

本文讲述了作者在解决CodeForces 1600J问题时遇到的TLE问题,通过分析发现输入输出是瓶颈,特别是大量输出时。作者通过改用stdio.h库的输入输出或者禁用iostream与stdio的同步,成功优化了代码并获得AC。强调在处理大数据输入输出时,应考虑使用scanf/printf或禁止iostream与stdio同步。
摘要由CSDN通过智能技术生成

这几天在练习CF的时候,有一题TLE了,这里是原题(CF 1600J):

J. Robot Factory
time limit per test: 1 second
memory limit per test: 256 megabytes
inputstandard input
outputstandard output
You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape: N x M.
Then in the next N lines you have M numbers. These numbers represent factory tiles and they can go from 0 to 15. Each of these numbers should be looked in its binary form. Because from each number you know on which side the tile has walls. For example number 10 in its binary form is 1010, which means that it has a wall from the North side, it doesn’t have a wall from the East, it has a wall on the South side and it doesn’t have a wall on the West side. So it goes North, East, South, West.
It is guaranteed that the construction always has walls on its edges. The input will be correct.
Your task is to print the size of the rooms from biggest to smallest.
Input
The first line has two numbers which are N and M, the size of the construction. Both are integers:
n ( 1 ≤ n ≤ 1 0 3 ) n(1≤n≤10^3)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值