답안 #1114547

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114547 2024-11-19T07:31:08 Z NotLinux Mađioničar (COI22_madionicar) C++17
13 / 100
3724 ms 448 KB
// Author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
int n;
int ask(int l , int r){
	if(l < 1 or r > n)return 0;
	cout << "? " << l << " " << r << endl;
	int x;
	cin >> x;
	return x;
}
void solve(){
	cin >> n;
	int r = 1 , ans = 1;
	int sayac = 0;
	for(int i = 1;i<=n;i++){
		r = max(r , i);
		while((r+1) <= n and (i-(r-i)-1) >= 1 and ask(i-(r-i)-1 , r+1)){
			r++;
			sayac++;
			if(sayac > 1e6){
				cout << "! 1" << endl;
				return;
			}
		}
		ans = max(ans , 2 * (r - i) + 1);
	}
	r = 1;
	for(int i = 1;i<n;i++){
		r = max(r , i);
		while((r+1) <= n and (i-(r-i)) >= 1 and ask(i-(r-i) , r+1)){
			r++;
			sayac++;
			if(sayac > 1e6){
				cout << "! 1" << endl;
				return;
			}
		}
		ans = max(ans , 2 * (r - i));
	}
	cout << "! " << ans << endl;
	return;
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
	cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 464 ms 444 KB Output is correct
2 Correct 281 ms 444 KB Output is correct
3 Correct 283 ms 440 KB Output is correct
4 Correct 509 ms 444 KB Output is correct
5 Correct 478 ms 440 KB Output is correct
6 Correct 398 ms 444 KB Output is correct
7 Correct 462 ms 440 KB Output is correct
8 Correct 387 ms 448 KB Output is correct
9 Correct 504 ms 444 KB Output is correct
10 Correct 301 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 464 ms 444 KB Output is correct
2 Correct 281 ms 444 KB Output is correct
3 Correct 283 ms 440 KB Output is correct
4 Correct 509 ms 444 KB Output is correct
5 Correct 478 ms 440 KB Output is correct
6 Correct 398 ms 444 KB Output is correct
7 Correct 462 ms 440 KB Output is correct
8 Correct 387 ms 448 KB Output is correct
9 Correct 504 ms 444 KB Output is correct
10 Correct 301 ms 444 KB Output is correct
11 Runtime error 3703 ms 448 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3724 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 464 ms 444 KB Output is correct
2 Correct 281 ms 444 KB Output is correct
3 Correct 283 ms 440 KB Output is correct
4 Correct 509 ms 444 KB Output is correct
5 Correct 478 ms 440 KB Output is correct
6 Correct 398 ms 444 KB Output is correct
7 Correct 462 ms 440 KB Output is correct
8 Correct 387 ms 448 KB Output is correct
9 Correct 504 ms 444 KB Output is correct
10 Correct 301 ms 444 KB Output is correct
11 Runtime error 3703 ms 448 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -