Submission #535296

# Submission time Handle Problem Language Result Execution time Memory
535296 2022-03-10T01:09:17 Z Koying JJOOII 2 (JOI20_ho_t2) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define MEM(x, n) memset(x, n, sizeof(x))
#define pii pair<int, int>
#define pdd pair<double, double>
#define DB(x) cerr << #x << " " << x << endl;
#define endl "\n"
#define Koying ios::sync_with_stdio(0), cin.tie(0)
#define lowbit(x) x &(-x)
const int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

#define MAXN 200005

int n, k;
string s;

void sol() {
    cin >> n >> k;
    cin >> s;
    int mn = INF;
    DB(s);
    for (int i = 0; i <= n - k * 3; i++) {
        int a, b, c;
        a = b = c = 0;
        for (int j = i; j < n; j++) {
            if (a < k) {
                a += (s[j] == 'J');
                DB(a);
            }
            else if (b < k) {
                b += s[j] == 'O';
            }
            else if (c < k) {
                c += s[j] == 'I';
            }
            if (a == k && b == k && c == k) {
                cmin(mn, j - i + 1);
                break;
            }
        }
        //cout << a << " " << b << " " << c << endl;
    }
    if (mn == INf) {
        cout << -1 << endl;
        return;
    }
    cout << mn - 3 * k << endl;
}

signed main()
{
    Koying;
    int t = 1;
    //cin >> t;
    sol();
    return 0;
}

Compilation message

ho_t2.cpp: In function 'void sol()':
ho_t2.cpp:49:15: error: 'INf' was not declared in this scope; did you mean 'INF'?
   49 |     if (mn == INf) {
      |               ^~~
      |               INF
ho_t2.cpp: In function 'int main()':
ho_t2.cpp:59:9: warning: unused variable 't' [-Wunused-variable]
   59 |     int t = 1;
      |         ^