Submission #217874

#TimeUsernameProblemLanguageResultExecution timeMemory
217874KoalaMuchJJOOII 2 (JOI20_ho_t2)C++14
0 / 100
6 ms2688 KiB
#include<bits/stdc++.h> using namespace std; const int N = 2e5+5; int dp[N][3]; char s[N]; int get(char c) { if(c=='J') return 0; else if(c=='O') return 1; return 2; } int main() { int n,k; scanf("%d %d %s",&n,&k,s+1); memset(dp,127,sizeof dp); for(int i=n-1;i>=0;i--) { dp[i][get(s[i+1])] = i+1; for(int j=0;j<3;j++) dp[i][j] = min(dp[i][j],dp[i+1][j]); } int cur = 0,st = 1e9,en = 0; for(int i=0;i<3;i++) { for(int j=1;j<=k;j++) { if(cur>n) return !puts("-1"); cur = dp[cur][i]; st = min(st,cur),en = max(en,cur); } } printf("%d\n",en-st+1-3*k); return 0; }

Compilation message (stderr)

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:15:10: 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...