제출 #790474

#제출 시각아이디문제언어결과실행 시간메모리
790474Username4132Mađioničar (COI22_madionicar)C++14
13 / 100
1571 ms684 KiB
#include<iostream> #include<cassert> 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=1, r=1, mx=0; forsn(i, 1, 2*n){ assert(l+r-i >= 0); 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)*2) + 1); else mx = max(mx, ((len[i]/2)*2)); } printf("! %d\n", mx); }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool isPalindrome(int, int)':
Main.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d", &ret);
      |     ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...