Submission #927620

#TimeUsernameProblemLanguageResultExecution timeMemory
927620AiperiiiJJOOII 2 (JOI20_ho_t2)C++14
13 / 100
2091 ms860 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb push_back using namespace std; signed main(){ int n,k; cin>>n>>k; string s;cin>>s; int mn=1e9; string t=""; for(int i=0;i<k;i++)t+='J'; for(int i=0;i<k;i++)t+='O'; for(int i=0;i<k;i++)t+='I'; for(int i=0;i<s.size();i++){ if(s[i]=='J'){ int pos=0,cnt=0; for(int j=i;j<s.size();j++){ if(s[j]==t[pos])pos++; else cnt++; if(pos==t.size()){ mn=min(mn,cnt); break; } } } } if(mn==1e9)mn=-1; cout<<mn<<"\n"; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:17:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
ho_t2.cpp:20:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int j=i;j<s.size();j++){
      |                         ~^~~~~~~~~
ho_t2.cpp:23:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |                 if(pos==t.size()){
      |                    ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...