답안 #287709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
287709 2020-08-31T22:41:41 Z luciocf popa (BOI18_popa) C++14
0 / 100
18 ms 372 KB
#include <bits/stdc++.h>
#include "popa.h"
 
using namespace std;
 
int solve(int N, int *l, int *r)
{
	memset(l, -1, sizeof l); memset(r, -1, sizeof r);

	int n = N;
 
	stack<int> stk;
 
	for (int i = 0; i < n; i++)
	{
		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:8:16: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
    8 |  memset(l, -1, sizeof l); memset(r, -1, sizeof r);
      |                ^~~~~~~~
popa.cpp:8:41: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
    8 |  memset(l, -1, sizeof l); memset(r, -1, sizeof r);
      |                                         ^~~~~~~~
popa.cpp:35:10: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |   return root;
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB not a binary tree
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 372 KB not a binary tree
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 360 KB not a binary tree
2 Halted 0 ms 0 KB -