Submission #287716

# Submission time Handle Problem Language Result Execution time Memory
287716 2020-08-31T22:46:59 Z luciocf popa (BOI18_popa) C++14
100 / 100
101 ms 500 KB
#include <bits/stdc++.h>
#include "popa.h"
 
using namespace std;
 
int solve(int n, int *l, int *r)
{
	stack<int> stk;
 
	for (int i = 0; i < n; i++)
	{
		l[i] = r[i] = -1;

		while (stk.size() && query(stk.top(), i, i, i))
		{
			l[i] = stk.top();
			stk.pop();
		}
 
		if (stk.size()) r[stk.top()] = i;
 
		stk.push(i);
	}
 
 	int root;

 	while (stk.size())
 	{
 		root = stk.top();
 		stk.pop();
 	}

 	return root;
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:33:10: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |   return root;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 380 KB Output is correct
2 Correct 100 ms 384 KB Output is correct
3 Correct 62 ms 384 KB Output is correct
4 Correct 86 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 372 KB Output is correct
2 Correct 99 ms 376 KB Output is correct
3 Correct 90 ms 384 KB Output is correct
4 Correct 90 ms 384 KB Output is correct