답안 #990556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990556 2024-05-30T16:06:21 Z alexdd Mađioničar (COI22_madionicar) C++17
63 / 100
5000 ms 1592 KB
#include<bits/stdc++.h>
using namespace std;
int n,cntq;

string s;
bool verif(int le, int ri)
{
    for(int i=0;i<=ri-le;i++)
        if(s[le+i]!=s[ri-i])
            return 0;
    return 1;
}

int p[100005];
bool query(int le, int ri)
{
    if(le<1 || ri>n || le>ri)
        return 0;
    if(le==ri)
        return 1;
    cntq++;
    //return verif(le,ri);
    if(cntq>200000)
    {
        while(1);
    }
    int aux;
    cout<<"? "<<le<<" "<<ri<<endl;
    cin>>aux;
    return aux;
}
signed main()
{
    cin>>n;

    /*s.resize(n+2);
    for(int i=1;i<=n;i++)
    {
        int c = rand()%26;
        s[i] = c+'a';
    }*/

    int le=1,ri=1,mxm=1;
    for(int i=1;i<=n;i++)
    {
        p[i] = max(max(0,mxm/2), 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(max(0,mxm/2), 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;
   // cout<<cntq<<" queries\n";
    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 77 ms 344 KB Output is correct
2 Correct 65 ms 444 KB Output is correct
3 Correct 83 ms 700 KB Output is correct
4 Correct 91 ms 600 KB Output is correct
5 Correct 78 ms 600 KB Output is correct
6 Correct 68 ms 344 KB Output is correct
7 Correct 56 ms 684 KB Output is correct
8 Correct 48 ms 420 KB Output is correct
9 Correct 73 ms 444 KB Output is correct
10 Correct 78 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 344 KB Output is correct
2 Correct 65 ms 444 KB Output is correct
3 Correct 83 ms 700 KB Output is correct
4 Correct 91 ms 600 KB Output is correct
5 Correct 78 ms 600 KB Output is correct
6 Correct 68 ms 344 KB Output is correct
7 Correct 56 ms 684 KB Output is correct
8 Correct 48 ms 420 KB Output is correct
9 Correct 73 ms 444 KB Output is correct
10 Correct 78 ms 688 KB Output is correct
11 Correct 817 ms 1108 KB Output is correct
12 Correct 743 ms 744 KB Output is correct
13 Correct 796 ms 948 KB Output is correct
14 Correct 783 ms 1100 KB Output is correct
15 Correct 748 ms 676 KB Output is correct
16 Correct 525 ms 708 KB Output is correct
17 Correct 613 ms 852 KB Output is correct
18 Correct 758 ms 852 KB Output is correct
19 Correct 605 ms 1192 KB Output is correct
20 Correct 734 ms 1048 KB Output is correct
21 Correct 802 ms 948 KB Output is correct
22 Correct 803 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1246 ms 936 KB Output is correct
2 Correct 631 ms 968 KB Output is correct
3 Correct 1227 ms 1024 KB Output is correct
4 Correct 994 ms 1592 KB Output is correct
5 Correct 964 ms 1044 KB Output is correct
6 Correct 1227 ms 1412 KB Output is correct
7 Correct 857 ms 1208 KB Output is correct
8 Correct 995 ms 1052 KB Output is correct
9 Correct 1020 ms 1240 KB Output is correct
10 Correct 976 ms 1024 KB Output is correct
11 Correct 737 ms 1036 KB Output is correct
12 Correct 741 ms 848 KB Output is correct
13 Correct 972 ms 940 KB Output is correct
14 Correct 1178 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 344 KB Output is correct
2 Correct 65 ms 444 KB Output is correct
3 Correct 83 ms 700 KB Output is correct
4 Correct 91 ms 600 KB Output is correct
5 Correct 78 ms 600 KB Output is correct
6 Correct 68 ms 344 KB Output is correct
7 Correct 56 ms 684 KB Output is correct
8 Correct 48 ms 420 KB Output is correct
9 Correct 73 ms 444 KB Output is correct
10 Correct 78 ms 688 KB Output is correct
11 Correct 817 ms 1108 KB Output is correct
12 Correct 743 ms 744 KB Output is correct
13 Correct 796 ms 948 KB Output is correct
14 Correct 783 ms 1100 KB Output is correct
15 Correct 748 ms 676 KB Output is correct
16 Correct 525 ms 708 KB Output is correct
17 Correct 613 ms 852 KB Output is correct
18 Correct 758 ms 852 KB Output is correct
19 Correct 605 ms 1192 KB Output is correct
20 Correct 734 ms 1048 KB Output is correct
21 Correct 802 ms 948 KB Output is correct
22 Correct 803 ms 1228 KB Output is correct
23 Correct 1246 ms 936 KB Output is correct
24 Correct 631 ms 968 KB Output is correct
25 Correct 1227 ms 1024 KB Output is correct
26 Correct 994 ms 1592 KB Output is correct
27 Correct 964 ms 1044 KB Output is correct
28 Correct 1227 ms 1412 KB Output is correct
29 Correct 857 ms 1208 KB Output is correct
30 Correct 995 ms 1052 KB Output is correct
31 Correct 1020 ms 1240 KB Output is correct
32 Correct 976 ms 1024 KB Output is correct
33 Correct 737 ms 1036 KB Output is correct
34 Correct 741 ms 848 KB Output is correct
35 Correct 972 ms 940 KB Output is correct
36 Correct 1178 ms 1124 KB Output is correct
37 Correct 1203 ms 1320 KB Output is correct
38 Execution timed out 5087 ms 1408 KB Time limit exceeded
39 Halted 0 ms 0 KB -