제출 #734901

#제출 시각아이디문제언어결과실행 시간메모리
734901rahidilbayramliJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
14 ms2000 KiB
#include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define vl vector<ll> #define sl set<ll> #define pb push_back #define all(v) v.begin(), v.end() #define f first #define s second #define ld long double using namespace std; int main() { int n, i, j, k, sz = INT_MAX, o; string s; cin >> n >> k; cin >> s; vector<int>J, O, I; for(i = 0; i < n; i++) { if(s[i] == 'J') J.pb(i); else if(s[i] == 'O') O.pb(i); else I.pb(i); } for(j = k - 1; j < J.size(); j++) { o = upper_bound(all(O), J[j]) - O.begin(); if(o + k - 1 >= O.size()) continue; o += (k - 1); i = upper_bound(all(I), O[o]) - I.begin(); if(i + k - 1 >= I.size()) continue; i += (k - 1); sz = min(sz, I[i] - J[j-k+1]+1); } if(sz == INT_MAX) cout << "-1\n"; else cout << sz - k * 3 << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(j = k - 1; j < J.size(); j++)
      |                    ~~^~~~~~~~~~
ho_t2.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if(o + k - 1 >= O.size())    continue;
      |            ~~~~~~~~~~^~~~~~~~~~~
ho_t2.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(i + k - 1 >= I.size())    continue;
      |            ~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...