# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
546014 |
2022-04-06T04:08:49 Z |
tmn2005 |
JJOOII 2 (JOI20_ho_t2) |
C++17 |
|
12 ms |
3288 KB |
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define int long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define NeedForSpeed ios::sync_with_stdio(0), cin.tie(0)
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
int n, m, k, res = 1e9;
vector<int> a, b, c;
string p;
int get(int i, int j){
int lb = upper_bound(all(a), i) - a.begin();
int ub = upper_bound(all(c), j) - c.begin();
if(lb < k || c.size() - ub < k)return 1e9;
int tmp = a[lb-k];
int cmp = c[ub+k-1];
return cmp - tmp + 1 - k * 3;
}
void solve(){
cin>>n>>k>>p;
for(int i=0; i<n; i++){
if(p[i] == 'J')a.pb(i);
if(p[i] == 'O')b.pb(i);
if(p[i] == 'I')c.pb(i);
}
for(int i=0; i<b.size()-k+1; i++){
res = min(res, get(b[i], b[i+k-1]));
}
cout<<(res == 1e9 ? -1 : res)<<"\n";
}
main(){
NeedForSpeed;
int T = 1;
// cin >> T;
while(T--){
solve();
}
return 0;
}
Compilation message
ho_t2.cpp: In function 'long long int get(long long int, long long int)':
ho_t2.cpp:35:29: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
35 | if(lb < k || c.size() - ub < k)return 1e9;
| ~~~~~~~~~~~~~~^~~
ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:51:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
51 | for(int i=0; i<b.size()-k+1; i++){
| ~^~~~~~~~~~~~~
ho_t2.cpp: At global scope:
ho_t2.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
56 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
316 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
320 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
316 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
320 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
10 ms |
2360 KB |
Output is correct |
37 |
Correct |
12 ms |
2880 KB |
Output is correct |
38 |
Correct |
10 ms |
2860 KB |
Output is correct |
39 |
Correct |
10 ms |
2968 KB |
Output is correct |
40 |
Correct |
11 ms |
3004 KB |
Output is correct |
41 |
Correct |
11 ms |
2992 KB |
Output is correct |
42 |
Correct |
10 ms |
2904 KB |
Output is correct |
43 |
Correct |
7 ms |
1832 KB |
Output is correct |
44 |
Correct |
7 ms |
2116 KB |
Output is correct |
45 |
Correct |
10 ms |
2960 KB |
Output is correct |
46 |
Correct |
9 ms |
2960 KB |
Output is correct |
47 |
Correct |
8 ms |
2992 KB |
Output is correct |
48 |
Correct |
9 ms |
2984 KB |
Output is correct |
49 |
Correct |
6 ms |
1864 KB |
Output is correct |
50 |
Correct |
10 ms |
2992 KB |
Output is correct |
51 |
Correct |
9 ms |
3020 KB |
Output is correct |
52 |
Correct |
5 ms |
2364 KB |
Output is correct |
53 |
Correct |
6 ms |
2912 KB |
Output is correct |
54 |
Correct |
6 ms |
3288 KB |
Output is correct |
55 |
Correct |
4 ms |
3280 KB |
Output is correct |
56 |
Correct |
3 ms |
3288 KB |
Output is correct |