제출 #202891

#제출 시각아이디문제언어결과실행 시간메모리
202891MKopchev새로운 문제 (POI11_roz)C++14
80 / 100
401 ms6212 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=1e6+42; int n; vector<int> seen[26]; int get_inp() { char ret; scanf("%c",&ret); while('a'>ret||ret>'z')scanf("%c",&ret); return ret-'a'; } int ask(int big,int small) { if(seen[big].size()==0||seen[small].size()==0)return 0; int mx=0,current=0; int l=0,r=0,last_in=0; while(l<seen[big].size()||r<seen[small].size()) { if(l==seen[big].size()) { current=max(current-1,0); r++; last_in=0; } else if(r==seen[small].size()) { current=current+1; l++; last_in++; } else if(seen[big][l]<seen[small][r]) { current=current+1; l++; last_in++; } else { current=max(current-1,0); r++; last_in=0; } mx=max(mx,current-(current==last_in)); } return mx; } int main() { scanf("%i",&n); for(int i=1;i<=n;i++) seen[get_inp()].push_back(i); int output=0; for(int big=0;big<26;big++) for(int small=0;small<26;small++) if(big!=small)output=max(output,ask(big,small)); printf("%i\n",output); return 0; }

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

roz.cpp: In function 'int ask(int, int)':
roz.cpp:19:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(l<seen[big].size()||r<seen[small].size())
           ~^~~~~~~~~~~~~~~~~
roz.cpp:19:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(l<seen[big].size()||r<seen[small].size())
                               ~^~~~~~~~~~~~~~~~~~~
roz.cpp:21:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(l==seen[big].size())
            ~^~~~~~~~~~~~~~~~~~
roz.cpp:27:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if(r==seen[small].size())
                 ~^~~~~~~~~~~~~~~~~~~~
roz.cpp: In function 'int get_inp()':
roz.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%c",&ret);
     ~~~~~^~~~~~~~~~~
roz.cpp:10:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     while('a'>ret||ret>'z')scanf("%c",&ret);
                            ~~~~~^~~~~~~~~~~
roz.cpp: In function 'int main()':
roz.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...