Submission #64388

# Submission time Handle Problem Language Result Execution time Memory
64388 2018-08-04T09:22:36 Z Just_Solve_The_Problem popa (BOI18_popa) C++11
100 / 100
110 ms 656 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 12 ms 248 KB Output is correct
2 Correct 16 ms 436 KB Output is correct
3 Correct 16 ms 436 KB Output is correct
4 Correct 12 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 608 KB Output is correct
2 Correct 104 ms 608 KB Output is correct
3 Correct 76 ms 608 KB Output is correct
4 Correct 104 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 110 ms 656 KB Output is correct
2 Correct 63 ms 656 KB Output is correct
3 Correct 97 ms 656 KB Output is correct
4 Correct 88 ms 656 KB Output is correct