Submission #878360

#TimeUsernameProblemLanguageResultExecution timeMemory
878360hasan2006JJOOII 2 (JOI20_ho_t2)C++17
1 / 100
1 ms1116 KiB
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll a[N] = {}, b[N] , c[N] , d[N] , dp[N]; void solve() { int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn = 1e9 , mx = 0; cin>>n>>k; string a; cin>>a; deque<int>d[500]; for(i = 0; i < n; i++) d[a[i]].pb(i); while(d['J'].size() >= k){ while(d['O'].size() && d['O'].front() < d['J'][k - 1]) d['O'].pop_front(); while(d['I'].size() && d['I'].front() < d['O'][k - 1]) d['I'].pop_front(); if(d['J'].size() >= k && d['O'].size() >= k && d['I'].size() >= k) mn = min(mn , d['I'][k - 1] - d['J'][0] - 3 * k + 1); d['J'].pop_front(); } if(mn == 1e9) mn = -1; cout<<mn<<"\n"; } int main(){ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن

Compilation message (stderr)

ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:32:15: warning: array subscript has type 'char' [-Wchar-subscripts]
   32 |         d[a[i]].pb(i);
      |               ^
ho_t2.cpp:33:25: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while(d['J'].size() >= k){
      |           ~~~~~~~~~~~~~~^~~~
ho_t2.cpp:38:26: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if(d['J'].size() >= k && d['O'].size() >= k && d['I'].size() >= k)
      |            ~~~~~~~~~~~~~~^~~~
ho_t2.cpp:38:48: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if(d['J'].size() >= k && d['O'].size() >= k && d['I'].size() >= k)
      |                                  ~~~~~~~~~~~~~~^~~~
ho_t2.cpp:38:70: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if(d['J'].size() >= k && d['O'].size() >= k && d['I'].size() >= k)
      |                                                        ~~~~~~~~~~~~~~^~~~
ho_t2.cpp:26:9: warning: unused variable 'q' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |         ^
ho_t2.cpp:26:17: warning: unused variable 'j' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                 ^
ho_t2.cpp:26:21: warning: unused variable 'm' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                     ^
ho_t2.cpp:26:27: warning: unused variable 'z' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                           ^
ho_t2.cpp:26:30: warning: unused variable 's' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                              ^
ho_t2.cpp:26:38: warning: unused variable 'f' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                      ^
ho_t2.cpp:26:41: warning: unused variable 'l' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                         ^
ho_t2.cpp:26:45: warning: unused variable 'r' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                             ^
ho_t2.cpp:26:53: warning: unused variable 'x' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                                     ^
ho_t2.cpp:26:57: warning: unused variable 'y' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                                         ^
ho_t2.cpp:26:73: warning: unused variable 'mx' [-Wunused-variable]
   26 |     int q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn  = 1e9 , mx = 0;
      |                                                                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...