Submission #959976

# Submission time Handle Problem Language Result Execution time Memory
959976 2024-04-09T11:33:18 Z pcc Mađioničar (COI22_madionicar) C++17
38 / 100
1164 ms 2540 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")

#define pii pair<int,int>
#define fs first
#define sc second
#define ll long long

const int mxn = 2e5+10;
int N;
int Z[mxn];

bool check(int l,int r){
	assert((r-l)%2==0);
	if(l<=0||r>=N*2)return false;
	assert(l<=r);
	if(l%2==0)l++,r--;
	if(r<=l)return true;
	cout<<"? "<<(l+1)/2<<' '<<(r+1)/2<<endl;
	/*
	cerr<<"? "<<l<<' '<<r<<endl;
   */
	int re;
	cin>>re;
	return re;
}

int main(){
	cin>>N;
	int cen = 1,rp = 2;
	Z[1] = 1;
	for(int i = 2;i<N*2;i++){
		//cerr<<i<<":"<<cen<<','<<rp<<endl;
		if(i>=rp);
		else if(Z[cen*2-i]+i<rp){
			Z[i] = Z[cen*2-i];
			continue;
		}
		else if(Z[cen*2-i]+i>rp){
			Z[i] = rp-i;
			continue;
		}
		cen = i,rp = max(i+1,rp);
		while(check(cen*2-rp,rp))rp++;
		Z[i] = rp-i;
		//cerr<<i<<"::"<<Z[i]<<endl;
	}
	//for(int i = 1;i<N*2;i++)cerr<<Z[i]<<' ';cerr<<endl;
	int ans = 0;
	for(int i = 1;i<N*2;i++){
		if(i&1)ans = max(ans,(Z[i]+1)/2*2-1);
		else{
			ans = max(ans,Z[i]-(Z[i]&1));
		}
	}
	cout<<"! "<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 80 ms 1104 KB Output is correct
2 Correct 96 ms 1372 KB Output is correct
3 Correct 89 ms 728 KB Output is correct
4 Correct 94 ms 1472 KB Output is correct
5 Correct 90 ms 984 KB Output is correct
6 Correct 80 ms 1224 KB Output is correct
7 Correct 91 ms 868 KB Output is correct
8 Correct 89 ms 712 KB Output is correct
9 Correct 107 ms 984 KB Output is correct
10 Correct 75 ms 1216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 1104 KB Output is correct
2 Correct 96 ms 1372 KB Output is correct
3 Correct 89 ms 728 KB Output is correct
4 Correct 94 ms 1472 KB Output is correct
5 Correct 90 ms 984 KB Output is correct
6 Correct 80 ms 1224 KB Output is correct
7 Correct 91 ms 868 KB Output is correct
8 Correct 89 ms 712 KB Output is correct
9 Correct 107 ms 984 KB Output is correct
10 Correct 75 ms 1216 KB Output is correct
11 Correct 874 ms 2124 KB Output is correct
12 Correct 703 ms 2316 KB Output is correct
13 Correct 676 ms 1856 KB Output is correct
14 Correct 866 ms 2484 KB Output is correct
15 Correct 726 ms 2236 KB Output is correct
16 Correct 1164 ms 2096 KB Output is correct
17 Correct 1062 ms 1876 KB Output is correct
18 Correct 779 ms 2284 KB Output is correct
19 Correct 1030 ms 1616 KB Output is correct
20 Correct 777 ms 2540 KB Output is correct
21 Correct 717 ms 2076 KB Output is correct
22 Correct 676 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1107 ms 2492 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 80 ms 1104 KB Output is correct
2 Correct 96 ms 1372 KB Output is correct
3 Correct 89 ms 728 KB Output is correct
4 Correct 94 ms 1472 KB Output is correct
5 Correct 90 ms 984 KB Output is correct
6 Correct 80 ms 1224 KB Output is correct
7 Correct 91 ms 868 KB Output is correct
8 Correct 89 ms 712 KB Output is correct
9 Correct 107 ms 984 KB Output is correct
10 Correct 75 ms 1216 KB Output is correct
11 Correct 874 ms 2124 KB Output is correct
12 Correct 703 ms 2316 KB Output is correct
13 Correct 676 ms 1856 KB Output is correct
14 Correct 866 ms 2484 KB Output is correct
15 Correct 726 ms 2236 KB Output is correct
16 Correct 1164 ms 2096 KB Output is correct
17 Correct 1062 ms 1876 KB Output is correct
18 Correct 779 ms 2284 KB Output is correct
19 Correct 1030 ms 1616 KB Output is correct
20 Correct 777 ms 2540 KB Output is correct
21 Correct 717 ms 2076 KB Output is correct
22 Correct 676 ms 2256 KB Output is correct
23 Runtime error 1107 ms 2492 KB Execution killed with signal 13
24 Halted 0 ms 0 KB -