# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
753819 |
2023-06-06T06:21:45 Z |
vjudge1 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
#include <sstream>
#include <fstream>
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
//WAS CREAtED BY BAISYN MUKHAMMED//
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
#define et "\n"
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ioi ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr for (int i = 0;i < n;i++)
#define fr1 for (int i = 1;i < n;i++)
#define Int int
using namespace std;
ll n,m,a1,a2,a3,ans1,ans2;
string s;
map <char,ll> mp;
pair <ll,ll> p[211111];
vector <ll> v,v1,v2;
void solve() {
cin >> n >> m >> s;
a1 = 0;
// cout << 1 << et;
for (int i = 0;i < n;i++) {
if (s[i] == 'J' && a1 < m) {
v.pb(i);
a1 ++;
}
}
if (v.size() < m) {
cout << -1;return;
}
a1 = 0;
for(int i = 0;i < n;i++) {
if (s[i] == 'O' && a1 < m && i > v.back()) {
v1.pb(i);
a1 ++;
}
}
if (v1.size() < m) {
cout << -1;return;
}
a1 = 0;
for (int i = 0;i < n;i++) {
if (s[i] == 'I' && a1 < m && i > v1.back()) {
v2.pb(i);
a2 ++;
}
}
// cout << v.size() << et;
if (v.size() < m or v1.size() < m or v2.size() < m) {
cout << -1 << et;return;
}
// for (int i = 0;i < v.size();i++) {
// cout << v[i] << ' ';
// }
// for (int i = 0;i < v1.size();i++) {
// cout << v1[i] << ' ';
// }
// for (int i = 0;i < v2.size();i++) {
// cout << v2[i] << ' ';
// }
// cout << et;
for (int i = 1;i < v.size();i++) {
ans1 += (v[i] - v[i - 1] - 1);
}
ans1 += v1[0] - v.back() - 1;
for (int i = 1;i < v1.size();i++) {
ans1 += (v1[i] - v1[i - 1] - 1);
}
ans1 += v2[0] - v1.back() - 1;
for (int i = 1;i < v2.size();i++) {
ans1 += (v2[i] - v2[i - 1] - 1);
}
cout << ans1;
}
int main () {
// ioi;
// freopen("herding.in","r",stdin);
// freopen("herding.out","w",stdout);
ll t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Compilation message
ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:45:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
45 | if (v.size() < m) {
| ~~~~~~~~~^~~
ho_t2.cpp:55:16: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
55 | if (v1.size() < m) {
| ~~~~~~~~~~^~~
ho_t2.cpp:66:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
66 | if (v.size() < m or v1.size() < m or v2.size() < m) {
| ~~~~~~~~~^~~
ho_t2.cpp:66:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
66 | if (v.size() < m or v1.size() < m or v2.size() < m) {
| ~~~~~~~~~~^~~
ho_t2.cpp:66:49: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
66 | if (v.size() < m or v1.size() < m or v2.size() < m) {
| ~~~~~~~~~~^~~
ho_t2.cpp:79:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for (int i = 1;i < v.size();i++) {
| ~~^~~~~~~~~~
ho_t2.cpp:83:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
83 | for (int i = 1;i < v1.size();i++) {
| ~~^~~~~~~~~~~
ho_t2.cpp:87:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
87 | for (int i = 1;i < v2.size();i++) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |