제출 #445614

#제출 시각아이디문제언어결과실행 시간메모리
445614jamezzzJJOOII 2 (JOI20_ho_t2)C++17
100 / 100
8 ms1484 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, int> li; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; mt19937 rng(time(0)); int n,k; deque<int> dq[3]; char c[200005]; int main(){ sf("%d%d",&n,&k); sf(" %s",&c); for(int i=0;i<n;++i){ if(c[i]=='J')dq[0].push_back(i); if(c[i]=='O')dq[1].push_back(i); if(c[i]=='I')dq[2].push_back(i); } int ans=INF; while(true){ if(sz(dq[0])<k)break; while(!dq[1].empty()&&dq[1].front()<dq[0][k-1])dq[1].pop_front(); if(sz(dq[1])<k)break; while(!dq[2].empty()&&dq[2].front()<dq[1][k-1])dq[2].pop_front(); if(sz(dq[2])<k)break; ans=min(ans,dq[2][k-1]-dq[0][0]+1-3*k); dq[0].pop_front(); } if(ans==INF)ans=-1; pf("%d\n",ans); }

컴파일 시 표준 에러 (stderr) 메시지

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:31:8: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[200005]' [-Wformat=]
   31 |  sf(" %s",&c);
      |       ~^  ~~
      |        |  |
      |        |  char (*)[200005]
      |        char*
ho_t2.cpp:30:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  sf("%d%d",&n,&k);
      |    ^
ho_t2.cpp:31:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  sf(" %s",&c);
      |    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...