Submission #524551

#TimeUsernameProblemLanguageResultExecution timeMemory
524551mosiashvililukaJJOOII 2 (JOI20_ho_t2)C++14
100 / 100
25 ms2000 KiB
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,K,pas; vector <int> v[5]; string s; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a>>K;pas=a+3; cin>>s;s.insert(0,"0"); for(i=1; i<=a; i++){ if(s[i]=='J') v[1].push_back(i); if(s[i]=='O') v[2].push_back(i); if(s[i]=='I') v[3].push_back(i); } for(i=1; i<=a; i++){ c=lower_bound(v[1].begin(),v[1].end(),i)-v[1].begin(); if(v[1].size()<=c+K-1) continue; c=c+K-1; d=lower_bound(v[2].begin(),v[2].end(),v[1][c]+1)-v[2].begin(); if(v[2].size()<=d+K-1) continue; d=d+K-1; e=lower_bound(v[3].begin(),v[3].end(),v[2][d]+1)-v[3].begin(); if(v[3].size()<=e+K-1) continue; e=e+K-1; zx=v[3][e]; pas=min(pas,zx-i+1); } if(pas==a+3){ cout<<-1; }else{ cout<<pas-3*K; } return 0; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:17:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |   if(v[1].size()<=c+K-1) continue;
      |      ~~~~~~~~~~~^~~~~~~
ho_t2.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |   if(v[2].size()<=d+K-1) continue;
      |      ~~~~~~~~~~~^~~~~~~
ho_t2.cpp:23:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |   if(v[3].size()<=e+K-1) continue;
      |      ~~~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...