Submission #1232633

#TimeUsernameProblemLanguageResultExecution timeMemory
1232633rhm_ganXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "xylophone.h"

void solve(int N) {
	vector<int> res(N + 1);

	int l = 1, r = N;
	while (query(l, r - 1) == N - 1) r--;
	while (query(l + 1, r) == N - 1) l++;

	res[l] = 1;
	res[r] = N;

	int mx = 0, id = 0, k = 1e9;
	for (int i = r + 1; i <= N; i++) {
		int x = query(r, i);
		if (x == mx) {
			int y = query(id, i);
			res[i] = k + y;
		}
		else {
			res[i] = N - x;
			mx = max(mx, x);
		}
		if (res[i] < k) {
			k = res[i];
			id = i;
		}
	}

	mx = id = k = 0;
	for (int i = l - 1; i >= 1; i--) {
		int x = query(i, l);
		if (x == mx) {
			int y = query(i, id);
			res[i] = k - y;
		}
		else {
			res[i] = x + 1;
			mx = max(mx, x);
		}
		if (res[i] > k) {
			k = res[i];
			id = i;
		}
	}

	mx = id = k = 0;
	for (int i = l + 1; i < r; i++) {
		int x = query(l, i);
		if (x == mx) {
			int y = query(id, i);
			res[i] = k - y;
		}
		else {
			res[i] = x + 1;
			mx = max(mx, x);
		}
		if (res[i] > k) {
			k = res[i];
			id = i;
		}
	}

	for (int i = 1; i <= N; i++) {
		answer(i, res[i]);
	}
}

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:5:9: error: 'vector' was not declared in this scope
    5 |         vector<int> res(N + 1);
      |         ^~~~~~
xylophone.cpp:5:9: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
xylophone.cpp:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> res(N + 1);
      |                ^~~
xylophone.cpp:11:9: error: 'res' was not declared in this scope
   11 |         res[l] = 1;
      |         ^~~
xylophone.cpp:23:30: error: 'max' was not declared in this scope
   23 |                         mx = max(mx, x);
      |                              ^~~
xylophone.cpp:23:30: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
xylophone.cpp:40:30: error: 'max' was not declared in this scope
   40 |                         mx = max(mx, x);
      |                              ^~~
xylophone.cpp:40:30: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
xylophone.cpp:57:30: error: 'max' was not declared in this scope
   57 |                         mx = max(mx, x);
      |                              ^~~
xylophone.cpp:57:30: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~