Submission #207903

# Submission time Handle Problem Language Result Execution time Memory
207903 2020-03-09T11:44:33 Z Blerargh JJOOII 2 (JOI20_ho_t2) C++17
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define SORT(x) sort((x).begin(), (x).end())
#define CMPSORT(x, cp) sort((x).begin(), (x).end(), cp)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define getchar_unlocked _getchar_nolock

#define f first
#define s second
#define ins insert
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ft front
#define bk back
#define pp pop
#define ppb pop_back
#define ppf pop_front

#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';

const ll MOD = 1e9+7; //998244353
const ll MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int main(){ 
    FAST
    ll n, k;
    string ss = "";
    deque<ll> idj, ido, idi, idj1;
    cin >> n >> k;
    FOR(i, 1, n){
        char c;
        cin >> c;
        ss+=c;
        if (c == 'J') idj.pb(i);
        if (c == 'I') idi.pb(i);
    }

    ll op = INF;
    FOR(i, 1, n){
        if ((ido.empty() || idj.ft() < ido.ft()) && !idj.empty()) idj1.pb(idj.ft()), idj.ppf(); 
        while (idj1.size()>k) idj1.ppf();

        while (!idi.empty() && i > idi.ft()) idi.ppf();

        if (ss[i-1] == 'O'){
            ido.pb(i);
            if (ido.size()==k){
                ido.ppf();
                if (idj1.size()>=k && idi.size()>=k) {
                    ll ops = idi[k-1] - idj1.ft()+1;
                    ops -= k*3;
                    op = min(op, ops);
                }
            }
        }
    }
    if (op == INF) cout << "-1";
    else cout << op;
}

Compilation message

ho_t2.cpp: In function 'int main()':
ho_t2.cpp:60:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (idj1.size()>k) idj1.ppf();
                ~~~~~~~~~~~^~
ho_t2.cpp:66:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (ido.size()==k){
                 ~~~~~~~~~~^~~
ho_t2.cpp:68:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (idj1.size()>=k && idi.size()>=k) {
                     ~~~~~~~~~~~^~~
ho_t2.cpp:68:49: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (idj1.size()>=k && idi.size()>=k) {
                                       ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -