Submission #747719

#TimeUsernameProblemLanguageResultExecution timeMemory
747719prairie2022JJOOII 2 (JOI20_ho_t2)C++14
100 / 100
10 ms1544 KiB
#include <bits/stdc++.h> //#define int long long #define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); #define end {cout << ans; return 0;} using namespace std; int main(){ int n, k, ans = -1; string s; cin >> n >> k >> s; deque<int> dq[3]; for(int i=0; i<n; i++) dq[(s[i]=='I'?2:0)^(s[i]=='O')].push_back(i); while(1){ if(dq[0].size()<k) end while(!dq[1].empty() && dq[1].front()<dq[0][k-1]) dq[1].pop_front(); if(dq[1].size()<k) end while(!dq[2].empty() && dq[2].front()<dq[1][k-1]) dq[2].pop_front(); if(dq[2].size()<k) end ans = min((ans==-1)?n:ans, dq[2][k-1]-dq[0][0]+1-k*3); dq[0].pop_front(); } }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:16:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         if(dq[0].size()<k) end
      |            ~~~~~~~~~~~~^~
ho_t2.cpp:18:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |         if(dq[1].size()<k) end
      |            ~~~~~~~~~~~~^~
ho_t2.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if(dq[2].size()<k) end
      |            ~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...