Submission #923051

# Submission time Handle Problem Language Result Execution time Memory
923051 2024-02-06T13:37:54 Z Amr JJOOII 2 (JOI20_ho_t2) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
    ll res = 1;
    x = x; // % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res*x)  ; // % mod;
        y = y>>1;
        x = (x*x) ; // % mod;
    }
    return res;
}
map<char,ll> mp;
void solve()
{
    ll n , k; cin >> n >> k;
    vector<ll> pos[3];
    mp['J'] = 0, mp['O'] = 1, mp['I'] = 2;
    for(int i = 0; i < n ;i++)
    {
        char c; cin >> c;
        pos[mp[c]].push_back(i);
    }
    ll l1 = k-1, l2 = k-1;
    ll ans = -1;
    for(int l0 = k-1; l0 < pos[0].sz; l0++)
    {
        if(l1>=pos[1].sz||l2>=pos[2].sz) break;
        while(l1<pos[1].sz&&pos[1][l1-k+1]<=pos[0][l0]) l1++;
        while(l1<pos[1].sz&&l2<pos[2].sz&&pos[2][l2-k+1]<=pos[1][l1]) l2++;
        if(l1<pos[1].sz&&l2<pos[2].sz)
        {
            ans = max(ans,n-3*k-pos[0][l0-k+1]-(n-pos[2][l2]-1));
        }
        //cout << l0 << l1 << l2 << endl;
    }
    cout << ans << endl;
}
int main(){
    //freopen("friday.in","r",stdin);
    //freopen("friday.out","w",stdout);

    while(TT--)
        solve();

    return 0;
}

Compilation message

ho_t2.cpp: In function 'void solve()':
ho_t2.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int l0 = k-1; l0 < pos[0].sz; l0++)
      |                          ^
ho_t2.cpp:45:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if(l1>=pos[1].sz||l2>=pos[2].sz) break;
      |              ^
ho_t2.cpp:45:29: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if(l1>=pos[1].sz||l2>=pos[2].sz) break;
      |                             ^
ho_t2.cpp:46:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         while(l1<pos[1].sz&&pos[1][l1-k+1]<=pos[0][l0]) l1++;
      |                 ^
ho_t2.cpp:47:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         while(l1<pos[1].sz&&l2<pos[2].sz&&pos[2][l2-k+1]<=pos[1][l1]) l2++;
      |                 ^
ho_t2.cpp:47:31: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         while(l1<pos[1].sz&&l2<pos[2].sz&&pos[2][l2-k+1]<=pos[1][l1]) l2++;
      |                               ^
ho_t2.cpp:48:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(l1<pos[1].sz&&l2<pos[2].sz)
      |              ^
ho_t2.cpp:48:28: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(l1<pos[1].sz&&l2<pos[2].sz)
      |                            ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -