Submission #1355476

#TimeUsernameProblemLanguageResultExecution timeMemory
1355476otariusXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngl(chrono::steady_clock::now().time_since_epoch().count());

// #define int long long
// #define int unsigned long long

// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>

// const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 5 * 1e5 + 15;

void solve(int n) {
    int a[n + 1], b[n + 1];
    for (int i = 1; i <= n - 1; i++) a[i] = query(i, i + 1);
    for (int i = 1; i <= n - 2; i++) b[i] = query(i, i + 2);

    bool diff[n + 1]; diff[1] = 1;
    for (int i = 2; i < n; i++) {
        if (a[i - 1] + a[i] == b[i - 1]) diff[i] = diff[i - 1];
        else diff[i] = (diff[i - 1] ^ 1);
    }

    vector<int> ans;
    int mn = 1, cur = 1;
    for (int i = 2; i <= n; i++) {
        if (flg[i - 1]) {
            cur -= a[i - 1]; mn = min(mn, cur); ans.pb(cur);
        } else {
            cur += a[i - 1]; mn = min(mn, cur); ans.pb(cur);
        }
    }

    for (int &i : cur) i += 1 - mn;

    int pos1, posn;
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] == 1) pos1 = i;
        if (ans[i] == n) posn = i;
    }

    if (pos1 < posn) {
        for (int i = 0; i < ans.size(); i++)
            answer(i + 1, ans[i]);
        return;
    }

    ans.clear();
    mn = 1; cur = 1;
    for (int i = 2; i <= n; i++) {
        if (flg[i - 1]) {
            cur += a[i - 1]; mn = min(mn, cur); ans.pb(cur);
        } else {
            cur -= a[i - 1]; mn = min(mn, cur); ans.pb(cur);
        }
    }

    for (int &i : cur) i += 1 - mn;
    for (int i = 0; i < ans.size(); i++)
        answer(i + 1, ans[i]);
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:38:45: error: 'query' was not declared in this scope
   38 |     for (int i = 1; i <= n - 1; i++) a[i] = query(i, i + 1);
      |                                             ^~~~~
xylophone.cpp:39:45: error: 'query' was not declared in this scope
   39 |     for (int i = 1; i <= n - 2; i++) b[i] = query(i, i + 2);
      |                                             ^~~~~
xylophone.cpp:50:13: error: 'flg' was not declared in this scope
   50 |         if (flg[i - 1]) {
      |             ^~~
xylophone.cpp:57:19: error: 'begin' was not declared in this scope
   57 |     for (int &i : cur) i += 1 - mn;
      |                   ^~~
xylophone.cpp:57:19: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166,
                 from xylophone.cpp:1:
/usr/include/c++/13/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/13/filesystem:50,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200:
/usr/include/c++/13/bits/fs_dir.h:607:3: note:   'std::filesystem::__cxx11::begin'
  607 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
xylophone.cpp:57:19: error: 'end' was not declared in this scope
   57 |     for (int &i : cur) i += 1 - mn;
      |                   ^~~
xylophone.cpp:57:19: note: suggested alternatives:
/usr/include/c++/13/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/bits/fs_dir.h:612:3: note:   'std::filesystem::__cxx11::end'
  612 |   end(recursive_directory_iterator) noexcept
      |   ^~~
xylophone.cpp:67:13: error: 'answer' was not declared in this scope
   67 |             answer(i + 1, ans[i]);
      |             ^~~~~~
xylophone.cpp:74:13: error: 'flg' was not declared in this scope
   74 |         if (flg[i - 1]) {
      |             ^~~
xylophone.cpp:81:19: error: 'begin' was not declared in this scope
   81 |     for (int &i : cur) i += 1 - mn;
      |                   ^~~
xylophone.cpp:81:19: note: suggested alternatives:
/usr/include/c++/13/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/13/bits/fs_dir.h:607:3: note:   'std::filesystem::__cxx11::begin'
  607 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
xylophone.cpp:81:19: error: 'end' was not declared in this scope
   81 |     for (int &i : cur) i += 1 - mn;
      |                   ^~~
xylophone.cpp:81:19: note: suggested alternatives:
/usr/include/c++/13/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/bits/fs_dir.h:612:3: note:   'std::filesystem::__cxx11::end'
  612 |   end(recursive_directory_iterator) noexcept
      |   ^~~
xylophone.cpp:83:9: error: 'answer' was not declared in this scope
   83 |         answer(i + 1, ans[i]);
      |         ^~~~~~