Submission #201272

#TimeUsernameProblemLanguageResultExecution timeMemory
201272arnold518JJOOII 2 (JOI20_ho_t2)C++14
100 / 100
32 ms1780 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3e5; const int INF = 987654321; int N, K, ans=INF; char S[MAXN+10]; vector<int> J, O, I; int main() { int i, j; scanf("%d%d%s", &N, &K, S+1); for(i=1; i<=N; i++) { if(S[i]=='J') J.push_back(i); else if(S[i]=='O') O.push_back(i); else I.push_back(i); int val=N+10, it; it=lower_bound(I.begin(), I.end(), val)-I.begin()-K; if(it<0) continue; val=I[it]; it=lower_bound(O.begin(), O.end(), val)-O.begin()-K; if(it<0) continue; val=O[it]; it=lower_bound(J.begin(), J.end(), val)-J.begin()-K; if(it<0) continue; val=J[it]; ans=min(ans, i-val+1-3*K); } if(ans==INF) ans=-1; printf("%d", ans); }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:30:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(it<0) continue; val=I[it];
   ^~
ho_t2.cpp:30:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(it<0) continue; val=I[it];
                      ^~~
ho_t2.cpp:32:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(it<0) continue; val=O[it];
   ^~
ho_t2.cpp:32:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(it<0) continue; val=O[it];
                      ^~~
ho_t2.cpp:34:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(it<0) continue; val=J[it];
   ^~
ho_t2.cpp:34:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(it<0) continue; val=J[it];
                      ^~~
ho_t2.cpp:18:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
ho_t2.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s", &N, &K, S+1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...