Блог пользователя devanshsaxena16

Автор devanshsaxena16, история, 6 лет назад, По-английски

So I made submission of problem https://mirror.codeforces.com/problemset/problem/154/B having submission 54472940 but giving tle on test case 1 while running efficiently and giving correct answer in codeblocks in my pc. Please help if there is any error in my code.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, # |
Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

A little work in the custom test tool reveals that something is wrong with your logic that handles the cases that are preceded with the '-' character. It is possibly an infinite loop or undefined behavior. I am not going to spoil the fun of debugging for you. So I'll leave it to you to find out the root cause from here.

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Just don't create static arrays locally ... create them globally with MAXN size i am refering to

bool vis[n]={false};
ll freq[n+1]={0};
set<ll> br[n+1];

just move them to the global scope and make them like this

bool vis[MAXN]={false};
ll freq[MAXN]={0};
set<ll> br[MAXN];

and get AC :)