제출 #64388

#제출 시각아이디문제언어결과실행 시간메모리
64388Just_Solve_The_Problempopa (BOI18_popa)C++11
100 / 100
110 ms656 KiB
#include "popa.h"
#include <bits/stdc++.h>

#define pb push_back
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair

using namespace std;

const int N = (int)1e3 + 7;

int pr[N];

int solve(int n, int left[], int right[]) {
  vector < int > stk;
  int root;
  for (int i = 0; i < n; i++) {
    left[i] = right[i] = -1;
    while (!stk.empty() && query(stk.back(), i, i, i)) {
      right[stk.back()] = left[i];
      left[i] = stk.back();
      stk.pop_back();
    }
    if (!stk.empty()) right[stk.back()] = i;
    else root = i;
    stk.pb(i);
  }
  return root;
}

컴파일 시 표준 에러 (stderr) 메시지

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:30:10: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
   return root;
          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...