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

Автор zeosutt, 12 лет назад, По-английски

As you might know, stderr doesn't affect a judgement. Therefore, if you use stderr instead of stdout for debugging, you won't get WA even if you forget to delete (or comment out) the lines for debugging.

Of course, you can never get AC if your solution is wrong in the first place :)

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

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится
vector<int> adj[N];

void dfs(int node, int level) {
	cerr << node << " " << level << "\n";
	// do something
	for (int neighbor : adj[node])
		dfs(neighbor);
}

the runtime of the above code would surely decrease if the cerr statements were removed.
and if the recursion runs for nearly 106 nodes, it could easily result in the solution getting TLE instead of AC.

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

Deleting cerr's when submitting can be done in a following way: 1. Replace (Ctrl+R in Kate)

  1. cerr -> //cerr

:P

Defining own macros is a good idea, but sometimes we want something mote than just printing the value of a variable (for example additional comments written by us to make them readable). By the way if we have macro in our code like that LOG(x) and use it in a code, we should take care of line with that define in a replace method I explained earlier :P.

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

It doesn't give WA but actually it does give TLE check out 76023053 gives TLE and the other 76022926 is Accepted.

So it's always better to comment out or delete stderr statements before submitting

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

I'm getting WA while using stderr. wrong solution using cerr (debug(u)) 178151957. Correct solution by commenting that line 178151812. Am I missing something?

  • »
    »
    4 года назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    It has nothing to do with cerr rather your for-loop and #define debug(x).

    When you uncomment

    // for(auto u: temp) debug(u)

    m[h]++;

    m[h] get incremented because for-loop never finds a ; neither after you debug(u) nor in your #define debug(u)

    Either put a ; in #define debug(u) ; or after debug(x) in for loop or wrap it in {}.