Submission #202888

#TimeUsernameProblemLanguageResultExecution timeMemory
202888MKopchevDifference (POI11_roz)C++14
20 / 100
416 ms6460 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; while(l<seen[big].size()||r<seen[small].size()) { if(l==seen[big].size()) { current=max(current-1,0); r++; } else if(r==seen[small].size()) { current=current+1; l++; } else if(seen[big][l]<seen[small][r]) { current=current+1; l++; } else { current=max(current-1,0); r++; } mx=max(mx,current); } 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; }

Compilation message (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:26: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:48: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...