답안 #990551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990551 2024-05-30T15:56:52 Z alexdd Mađioničar (COI22_madionicar) C++17
13 / 100
5000 ms 1640 KB
#include<bits/stdc++.h>
using namespace std;
int n,cntq;
int p[100005];
bool query(int le, int ri)
{
    if(le<1 || ri>n || le>ri)
        return 0;
    if(le==ri)
        return 1;
    cntq++;
    if(cntq>200000)
    {
        while(1);
    }
    int aux;
    cout<<"? "<<le<<" "<<ri<<endl;
    cin>>aux;
    return aux;
}
signed main()
{
    cin>>n;
    int le=1,ri=1,mxm=1;
    for(int i=1;i<n;i++)
    {
        p[i] = max(0, min(ri-i, p[le + (ri-i)]));
        while(query(i-p[i],i+p[i]))
            p[i]++;
        if(i+p[i] > ri)
        {
            le = i-p[i];
            ri = i+p[i];
        }
        mxm = max(mxm, 2*p[i]-1);
    }
    le=1;
    ri=1;
    for(int i=1;i<n;i++)
    {
        p[i] = max(0, min(ri-i-1, p[le+(ri-i)-1]));
        while(query(i-p[i],i+1+p[i]))
            p[i]++;
        if(i+1+p[i] > ri)
        {
            le = i-p[i];
            ri = i+1+p[i];
        }
        mxm = max(mxm, 2*p[i]);
    }
    cout<<"! "<<mxm<<endl;
    return 0;
}
/**
neven

1 2 3 4 5 6 7 8 9
    l       r
    a b c b a

1 2 3 4 5 6 7 8 9
    l         r
    a b c c b a
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 852 KB Output is correct
2 Correct 76 ms 444 KB Output is correct
3 Correct 73 ms 444 KB Output is correct
4 Correct 169 ms 428 KB Output is correct
5 Correct 153 ms 440 KB Output is correct
6 Correct 144 ms 608 KB Output is correct
7 Correct 173 ms 684 KB Output is correct
8 Correct 100 ms 448 KB Output is correct
9 Correct 156 ms 676 KB Output is correct
10 Correct 69 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 852 KB Output is correct
2 Correct 76 ms 444 KB Output is correct
3 Correct 73 ms 444 KB Output is correct
4 Correct 169 ms 428 KB Output is correct
5 Correct 153 ms 440 KB Output is correct
6 Correct 144 ms 608 KB Output is correct
7 Correct 173 ms 684 KB Output is correct
8 Correct 100 ms 448 KB Output is correct
9 Correct 156 ms 676 KB Output is correct
10 Correct 69 ms 680 KB Output is correct
11 Execution timed out 5080 ms 1520 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5065 ms 1640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 852 KB Output is correct
2 Correct 76 ms 444 KB Output is correct
3 Correct 73 ms 444 KB Output is correct
4 Correct 169 ms 428 KB Output is correct
5 Correct 153 ms 440 KB Output is correct
6 Correct 144 ms 608 KB Output is correct
7 Correct 173 ms 684 KB Output is correct
8 Correct 100 ms 448 KB Output is correct
9 Correct 156 ms 676 KB Output is correct
10 Correct 69 ms 680 KB Output is correct
11 Execution timed out 5080 ms 1520 KB Time limit exceeded
12 Halted 0 ms 0 KB -