Problem Address:USACO 1.4
【前言】
这道题我一共提交了19次,终于在第19次的时候过掉了。
那个内流满面啊!
一直被不知名的错误羁绊着。
Execution error: Your program had this runtime error: Bad syscall #32000175 (RT_SIGPROCMASK) [email kolstad if you think this is wrong].
Your program printed data to stderr. Here is the data:
-------------------
terminate_called_after_throwing_an_instance_of_'std::bad_alloc'
__what():__std::bad_alloc
-------------------
期间用google找到了一个有点关系的网址(百度找不到),发现里面的论坛是德文还是俄文什么的,那个晕= =
最后通过一个英文网址,猜测是否是stl栈溢出,然后修改啊修改,终于过了!
但是后来看它的analysis,好像写的好简单= =郁闷,而且不太像广搜= =
【思路】
广搜。
注意空间。
先判断再入栈:
Executing...
Test 1: TEST OK [0.000 secs, 4460 KB]
Test 2: TEST OK [0.000 secs, 4460 KB]
Test 3: TEST OK [0.108 secs, 4824 KB]
Test 4: TEST OK [0.135 secs, 4824 KB]
Test 5: TEST OK [0.135 secs, 4824 KB]
Test 6: TEST OK [0.297 secs, 4460 KB]
Test 7: TEST OK [0.405 secs, 4460 KB]
Test 8: TEST OK [0.405 secs, 4460 KB]
Test 9: TEST OK [0.405 secs, 4460 KB]
出栈后再判断:
Executing...
Test 1: TEST OK [0.000 secs, 4464 KB]
Test 2: TEST OK [0.000 secs, 4464 KB]
Test 3: TEST OK [0.162 secs, 4828 KB]
Test 4: TEST OK [0.270 secs, 4828 KB]
Test 5: TEST OK [0.243 secs, 4464 KB]
Test 6: TEST OK [0.324 secs, 4464 KB]
Test 7: TEST OK [0.324 secs, 4464 KB]
Test 8: TEST OK [0.243 secs, 4464 KB]
Test 9: TEST OK [0.243 secs, 4464 KB]
【代码】
过长不贴。
用stl可能比较好。