제출 #1365468

#제출 시각아이디문제언어결과실행 시간메모리
1365468IwanttobreakfreeMiners (IOI07_miners)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    int dp[4][4][4][4][2];
    for (int j1 = 0; j1 < 4; ++j1) {
        for (int j2 = 0; j2 < 4; ++j2) {
            for (int j3 = 0; j3 < 4; ++j3) {
                for (int j4 = 0; j4 < 4; ++j4) {
                    dp[j1][j2][j3][j4][0] = dp[j1][j2][j3][j4][1] = -1e9;
                }
            }
        }
    }
    dp[0][0][0][0][0] = dp[0][0][0][0][1] = 0;
    for (int i = 0; i < n; ++i) {
        char c = s[i]
        int cur = 0;
        if (c == 'M') cur = 1;
        else if (c == 'F') cur = 2;
        else cur = 3;

        for (int j1 = 0; j1 < 4; ++j1) {
            for (int j2 = 0; j2 < 4; ++j2) {
                for (int j3 = 0; j3 < 4; ++j3) {
                    for (int j4 = 0; j4 < 4; ++j4) {
                        set<int> s1;
                        s1.insert(cur);
                        s1.insert(j1);
                        s1.insert(j2);
                        s1.erase(0);
                        dp[cur][j1][j3][j4][1] = max(dp[j1][j2][j3][j4][0] + (int)s1.size(), dp[cur][j1][j3][j4][1]);
                        s1.clear();
                        s1.insert(cur);
                        s1.insert(j3);
                        s1.insert(j4);
                        s1.erase(0);
                        dp[j1][j2][cur][j3][1] = max(dp[j1][j2][j3][j4][0] + (int)s1.size(), dp[j1][j2][cur][j3][1]);
                    }
                }
            }
        }

        for (int j1 = 0; j1 < 4; ++j1) {
            for (int j2 = 0; j2 < 4; ++j2) {
                for (int j3 = 0; j3 < 4; ++j3) {
                    for (int j4 = 0; j4 < 4; ++j4) {
                        dp[j1][j2][j3][j4][0] = dp[j1][j2][j3][j4][1];
                        ans = max(ans, dp[j1][j2][j3][j4][0]);
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}

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

miners.cpp: In function 'int main()':
miners.cpp:24:9: error: expected ',' or ';' before 'int'
   24 |         int cur = 0;
      |         ^~~
miners.cpp:25:23: error: 'cur' was not declared in this scope
   25 |         if (c == 'M') cur = 1;
      |                       ^~~
miners.cpp:26:28: error: 'cur' was not declared in this scope
   26 |         else if (c == 'F') cur = 2;
      |                            ^~~
miners.cpp:27:14: error: 'cur' was not declared in this scope
   27 |         else cur = 3;
      |              ^~~
miners.cpp:34:35: error: 'cur' was not declared in this scope
   34 |                         s1.insert(cur);
      |                                   ^~~