Submission #203207

#TimeUsernameProblemLanguageResultExecution timeMemory
203207jovan_bJJOOII 2 (JOI20_ho_t2)C++17
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int dp1[1000005]; int dp2[1000005]; int dp3[1000005]; int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; int n, k; cin >> n >> k; string s; cin >> s; deque <int> q1, q2, q3; for(int i=n-1; i>=0; i--){ dp3[i] = n; dp2[i] = n; dp1[i] = n; if(s[i] == 'J'){ q1.push_front(i); if(q1.size() > k) q1.pop_back(); if(q1.size() == k) dp1[i] = q1.back(); } if(s[i] == 'O'){ q2.push_front(i); if(q2.size() > k) q2.pop_back(); if(q2.size() == k) dp2[i] = q2.back(); } if(s[i] == 'I'){ q3.push_front(i); if(q3.size() > k) q3.pop_back(); if(q3.size() == k) dp3[i] = q3.back(); } } int res = n+5; for(int i=0; i<n; i++){ int j = dp1[i]+1; if(j >= n) continue; j = dp2[j]+1; if(j >= n) continue; j = dp3[j]; if(j >= n) continue; res = min(res, j-i+1); } if(res == n+5){ cout << -1; return 0; } cout << res-3*k; return 0; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:27:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q1.size() > k) q1.pop_back();
                ~~~~~~~~~~^~~
ho_t2.cpp:28:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q1.size() == k) dp1[i] = q1.back();
                ~~~~~~~~~~^~~~
ho_t2.cpp:32:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q2.size() > k) q2.pop_back();
                ~~~~~~~~~~^~~
ho_t2.cpp:33:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q2.size() == k) dp2[i] = q2.back();
                ~~~~~~~~~~^~~~
ho_t2.cpp:37:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q3.size() > k) q3.pop_back();
                ~~~~~~~~~~^~~
ho_t2.cpp:38:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(q3.size() == k) dp3[i] = q3.back();
                ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...