Submission #919490

# Submission time Handle Problem Language Result Execution time Memory
919490 2024-02-01T01:36:29 Z NK_ Mađioničar (COI22_madionicar) C++17
13 / 100
961 ms 860 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

template<class T> using V = vector<T>;
using vi = V<int>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;

	auto ask = [&](int l, int r) {
		if (l < 0 || r >= N) return 0;
		cout << "? " << l + 1 << " " << r + 1 << endl;
		int res; cin >> res; return res;
	};

	int ANS = 1;

	// odd
	{
		vi ans(N); int lo = 0, hi = 0;
		for(int i = 0; i < N; i++) {
			if (i > 0) {
				ans[i] = min(hi - i, ans[hi - i + lo]);
				ans[i] = max(0, ans[i]);
			}
			while(ask(i - ans[i] - 1, i + ans[i] + 1)) ++ans[i];
			if (ans[i] + i > hi) lo = i - ans[i], hi = i + ans[i];
		}

		// for(auto& x : ans) cout << x << " ";
		// cout << nl;

		int bst = *max_element(begin(ans), end(ans));
		ANS = max(ANS, 2 * bst + 1);
	}

	// even
	{
		vi ans(N, -1); int lo = 0, hi = 0;
		for(int i = 1; i < N; i++) {
			// cout << lo << " " << hi << " " << hi - i + 1 + lo << endl;
			if (i > 1) ans[i] = min(hi - i + 1, ans[hi - i + 1 + lo]);
			// cout << ans[i] << endl;

			while(ask(i - 1 - ans[i] - 1, i + ans[i] + 1)) ++ans[i];
			if (ans[i] + i > hi) lo = i - 1 - ans[i], hi = i + ans[i];
		}

		// for(auto& x : ans) cout << x << " ";
		// cout << nl;

		int bst = *max_element(begin(ans), end(ans));
		ANS = max(ANS, 2 * bst + 2);
	}

	cout << "! " << ANS << endl;



	exit(0-0);
}
# Verdict Execution time Memory Grader output
1 Correct 100 ms 344 KB Output is correct
2 Correct 67 ms 344 KB Output is correct
3 Correct 62 ms 344 KB Output is correct
4 Correct 90 ms 344 KB Output is correct
5 Correct 86 ms 596 KB Output is correct
6 Correct 83 ms 344 KB Output is correct
7 Correct 135 ms 344 KB Output is correct
8 Correct 102 ms 344 KB Output is correct
9 Correct 116 ms 344 KB Output is correct
10 Correct 82 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 344 KB Output is correct
2 Correct 67 ms 344 KB Output is correct
3 Correct 62 ms 344 KB Output is correct
4 Correct 90 ms 344 KB Output is correct
5 Correct 86 ms 596 KB Output is correct
6 Correct 83 ms 344 KB Output is correct
7 Correct 135 ms 344 KB Output is correct
8 Correct 102 ms 344 KB Output is correct
9 Correct 116 ms 344 KB Output is correct
10 Correct 82 ms 344 KB Output is correct
11 Correct 811 ms 852 KB Output is correct
12 Correct 579 ms 600 KB Output is correct
13 Correct 592 ms 600 KB Output is correct
14 Runtime error 961 ms 712 KB Execution killed with signal 13
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 860 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 100 ms 344 KB Output is correct
2 Correct 67 ms 344 KB Output is correct
3 Correct 62 ms 344 KB Output is correct
4 Correct 90 ms 344 KB Output is correct
5 Correct 86 ms 596 KB Output is correct
6 Correct 83 ms 344 KB Output is correct
7 Correct 135 ms 344 KB Output is correct
8 Correct 102 ms 344 KB Output is correct
9 Correct 116 ms 344 KB Output is correct
10 Correct 82 ms 344 KB Output is correct
11 Correct 811 ms 852 KB Output is correct
12 Correct 579 ms 600 KB Output is correct
13 Correct 592 ms 600 KB Output is correct
14 Runtime error 961 ms 712 KB Execution killed with signal 13
15 Halted 0 ms 0 KB -