답안 #790467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790467 2023-07-22T17:04:42 Z Username4132 Mađioničar (COI22_madionicar) C++14
13 / 100
1327 ms 836 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=400010;
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)/2)<<1) + 1);
        else mx = max(mx, ((len[i]/2)<<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);
      |     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 336 KB Output is correct
2 Correct 101 ms 344 KB Output is correct
3 Correct 86 ms 352 KB Output is correct
4 Correct 104 ms 344 KB Output is correct
5 Correct 185 ms 440 KB Output is correct
6 Correct 159 ms 312 KB Output is correct
7 Correct 161 ms 324 KB Output is correct
8 Correct 178 ms 344 KB Output is correct
9 Correct 194 ms 336 KB Output is correct
10 Correct 108 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 336 KB Output is correct
2 Correct 101 ms 344 KB Output is correct
3 Correct 86 ms 352 KB Output is correct
4 Correct 104 ms 344 KB Output is correct
5 Correct 185 ms 440 KB Output is correct
6 Correct 159 ms 312 KB Output is correct
7 Correct 161 ms 324 KB Output is correct
8 Correct 178 ms 344 KB Output is correct
9 Correct 194 ms 336 KB Output is correct
10 Correct 108 ms 340 KB Output is correct
11 Runtime error 1327 ms 836 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1177 ms 796 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 336 KB Output is correct
2 Correct 101 ms 344 KB Output is correct
3 Correct 86 ms 352 KB Output is correct
4 Correct 104 ms 344 KB Output is correct
5 Correct 185 ms 440 KB Output is correct
6 Correct 159 ms 312 KB Output is correct
7 Correct 161 ms 324 KB Output is correct
8 Correct 178 ms 344 KB Output is correct
9 Correct 194 ms 336 KB Output is correct
10 Correct 108 ms 340 KB Output is correct
11 Runtime error 1327 ms 836 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -