Submission #790462

# Submission time Handle Problem Language Result Execution time Memory
790462 2023-07-22T17:00:08 Z Username4132 Mađioničar (COI22_madionicar) C++14
13 / 100
1229 ms 776 KB
#include<iostream>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)

const int MAXN=200010;
int n, len[MAXN];

bool isPalindrome(int l, int r){
    if(l==r) return true;
    if(l==0 || r==2*n) return false;
    int ret;
    l = (l+2)/2, r = (r+1)/2;
    if(l==r) return true;
    printf("? %d %d\n", l, r);
    fflush(stdout);
    scanf("%d", &ret);
    return ret;
}

int main(){
    scanf("%d", &n);
    int l=0, r=0, mx=0;
    forsn(i, 1, 2*n){
        len[i]=max(0, min(r-i, len[l+r-i]));
        while(isPalindrome(i-len[i], i+len[i])) ++len[i];
        if(i+len[i] > r) l=i-len[i], r=i+len[i];
    }
    forsn(i, 1, 2*n){
        if(i&1) mx = max(mx, (((len[i]-1)>>1)<<1) + 1);
        else mx = max(mx, ((len[i]>>1)<<1));
    }
    printf("! %d\n", mx);
}

Compilation message

Main.cpp: In function 'bool isPalindrome(int, int)':
Main.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &ret);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 182 ms 372 KB Output is correct
2 Correct 123 ms 328 KB Output is correct
3 Correct 102 ms 472 KB Output is correct
4 Correct 248 ms 316 KB Output is correct
5 Correct 132 ms 436 KB Output is correct
6 Correct 122 ms 312 KB Output is correct
7 Correct 234 ms 424 KB Output is correct
8 Correct 185 ms 288 KB Output is correct
9 Correct 173 ms 348 KB Output is correct
10 Correct 104 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 372 KB Output is correct
2 Correct 123 ms 328 KB Output is correct
3 Correct 102 ms 472 KB Output is correct
4 Correct 248 ms 316 KB Output is correct
5 Correct 132 ms 436 KB Output is correct
6 Correct 122 ms 312 KB Output is correct
7 Correct 234 ms 424 KB Output is correct
8 Correct 185 ms 288 KB Output is correct
9 Correct 173 ms 348 KB Output is correct
10 Correct 104 ms 328 KB Output is correct
11 Runtime error 1229 ms 672 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1131 ms 776 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 372 KB Output is correct
2 Correct 123 ms 328 KB Output is correct
3 Correct 102 ms 472 KB Output is correct
4 Correct 248 ms 316 KB Output is correct
5 Correct 132 ms 436 KB Output is correct
6 Correct 122 ms 312 KB Output is correct
7 Correct 234 ms 424 KB Output is correct
8 Correct 185 ms 288 KB Output is correct
9 Correct 173 ms 348 KB Output is correct
10 Correct 104 ms 328 KB Output is correct
11 Runtime error 1229 ms 672 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -