Submission #546013

#TimeUsernameProblemLanguageResultExecution timeMemory
546013tmn2005JJOOII 2 (JOI20_ho_t2)C++17
0 / 100
1 ms316 KiB
#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<<"\n"; } main(){ NeedForSpeed; int T = 1; // cin >> T; while(T--){ solve(); } return 0; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...