Submission #92904

# Submission time Handle Problem Language Result Execution time Memory
92904 2019-01-05T14:01:42 Z Pajaraja popa (BOI18_popa) C++17
0 / 100
262 ms 262144 KB
#include <bits/stdc++.h>
#include "popa.h"
#define MAXN 1007
using namespace std;
int ls[MAXN],rs[MAXN],dml[MAXN],dmr[MAXN];
int rek(int lt,int rt)
{
	if(lt>rt) return -1;
	int l;
	for(int i=lt;i<=rt;i++) {if(dml[i]<=lt && dmr[i]>=rt)  l=i; break;}
	ls[l]=rek(lt,l-1);
	rs[l]=rek(l+1,rt);
	return l;
}
int solve(int N,int* Left,int* Right)
{
	stack<int> st; st.push(-1);	
	for(int i=0;i<N;i++)
	{
		while(st.size()>1 && !query(st.top(),st.top(),st.top(),i)) {dmr[st.top()]=i-1; st.pop();}
		dml[i]=st.top()+1;
		st.push(i);
	}
	while(!st.size()>1) {dmr[st.top()]=N-1; st.pop();}
	int a=rek(0,N-1);
	for(int i=0;i<N;i++) Left[i]=ls[i];
	for(int i=0;i<N;i++) Right[i]=rs[i];
	return a;
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:24:18: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
  while(!st.size()>1) {dmr[st.top()]=N-1; st.pop();}
                  ^
popa.cpp:24:8: note: add parentheses around left hand side expression to silence this warning
  while(!st.size()>1) {dmr[st.top()]=N-1; st.pop();}
        ^~~~~~~~~~
        (         )
popa.cpp:24:18: warning: comparison of constant '1' with boolean expression is always false [-Wbool-compare]
  while(!st.size()>1) {dmr[st.top()]=N-1; st.pop();}
        ~~~~~~~~~~^~
popa.cpp: In function 'int rek(int, int)':
popa.cpp:12:7: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
  rs[l]=rek(l+1,rt);
  ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 238 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 260 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 262 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -