Submission #312930

# Submission time Handle Problem Language Result Execution time Memory
312930 2020-10-14T17:35:46 Z Temmie Xylophone (JOI18_xylophone) C++17
Compilation error
0 ms 0 KB
#include "xylophone.h"
#include <bits/stdc++.h>

void solve() {
std::ios::sync_with_stdio(0); std::cin.tie(0);
std::vector <int> d1, d2, ans(n);
for (int i = 0; i < n - 1; i++) {
d1.push_back(query(i + 1, i + 2));
d2.push_back(query(i + 1, i + 3));
}
ans[0] = 0;
ans[1] = d1[0];
for (int i = 2; i < n; i++) {
ans[i] = ans[i - 1];
if (d1[i - 2] + d1[i - 1] == d2[i - 2]) {
if(ans[i - 2] < ans[i - 1]) ans[i] += d1[i - 1];
else ans[i] -= d1[i - 1];
} else {
if (ans[i - 2] < ans[i - 1]) ans[i] -= d1[i - 1];
else ans[i] += d1[i - 1];
}
}
int l = 1 << 30;
for (int x : ans) l = std::min(l, x);
for (int& x : ans) x += -mn + 1;
if (min_element(ans.begin(), ans.end()) > max_element(ans.begin(), ans.end())) {
for (int& x : ans) x = n - x + 1;
}
for (int i = 0; i < n; i++) answer(i + 1, ans[i]);
}

Compilation message

xylophone.cpp: In function 'void solve()':
xylophone.cpp:6:31: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 | std::vector <int> d1, d2, ans(n);
      |                               ^
      |                               yn
xylophone.cpp:25:26: error: 'mn' was not declared in this scope; did you mean 'yn'?
   25 | for (int& x : ans) x += -mn + 1;
      |                          ^~
      |                          yn