Submission #245150

#TimeUsernameProblemLanguageResultExecution timeMemory
245150uacoder123JJOOII 2 (JOI20_ho_t2)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); lli test=1; for(;test>0;--test) { int n,l,r,k,c=0,ans=0; string s; cin>>n>>k>>s; l=0; r=s.size()-1; while(l<s.size()&&s[l]!='J') l++; while(l<s.size()&&c!=k) { if(s[l]!='J') ans++; else c++; l++; } if(c!=k) { cout<<"-1"<<endl; exit(0); } c=0; while(r>l&&s[r]!='I') r--; while(r>l&&c!=k) { if(s[r]!='I') ans++; else c++; r--; } if(c!=k) { cout<<"-1"<<endl; exit(0); } c=0; while(l<=r&&c!=k) { if(s[l]!='O') ans++; else c++; l++; } if(c!=k) { cout<<"-1"<<endl; exit(0); } cout<<ans<<endl; } return(0); }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:30:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(l<s.size()&&s[l]!='J')
           ~^~~~~~~~~
ho_t2.cpp:32:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(l<s.size()&&c!=k)
           ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...