제출 #989862

#제출 시각아이디문제언어결과실행 시간메모리
989862aaaaaarrozMiners (IOI07_miners)C++17
100 / 100
51 ms348 KiB
    #include "bits/stdc++.h"
    #define pb(x) push_back(x)
    using namespace std;
    const int N = 1e5+5;
    const int INF = 1e9+10;
    char s[N];
    int bit[] = {0, 1, 1, 2, 1, 2, 2, 3};
    int dp[4][4][4][4], odp[4][4][4][4];
    int f(int x, int y, int z){
        int mask = 0;
        if (x) mask |= (1<<(x-1));
        if (y) mask |= (1<<(y-1));
        if (z) mask |= (1<<(z-1));
        return bit[mask];
    }
    int main(){
        // freopen("file.in", "r", stdin);
        // freopen("file.out", "w", stdout);
        int n, c;
        scanf("%d", &n);
        scanf("%s", s);
        for (int x = 0; x < 4; x++)
            for (int y = 0; y < 4; y++)
                for (int xp = 0; xp < 4; xp++)
                    for (int yp = 0; yp < 4; yp++)
                        dp[x][y][xp][yp] = -INF;
        dp[0][0][0][0] = 0;
        for (int i = 0; i < n; i++){
            for (int x = 0; x < 4; x++)
                for (int y = 0; y < 4; y++)
                    for (int xp = 0; xp < 4; xp++)
                        for (int yp = 0; yp < 4; yp++)
                            odp[x][y][xp][yp] = -INF;
            if (s[i] == 'M') c = 1;
            else if(s[i] == 'F') c = 2;
            else c = 3;
            for (int x = 0; x < 4; x++)
                for (int y = 0; y < 4; y++)
                    for (int xp = 0; xp < 4; xp++)
                        for (int yp = 0; yp < 4; yp++){
                            odp[y][c][xp][yp] = max(odp[y][c][xp][yp], dp[x][y][xp][yp] + f(x, y, c));
                            odp[x][y][yp][c] = max(odp[x][y][yp][c], dp[x][y][xp][yp] + f(xp, yp, c));
                        }
            memcpy(dp, odp, sizeof dp);
        }
        int answer = 0;
        for (int x = 0; x < 4; x++)
            for (int y = 0; y < 4; y++)
                for (int xp = 0; xp < 4; xp++)
                    for (int yp = 0; yp < 4; yp++)
                        answer = max(answer, dp[x][y][xp][yp]);
        printf("%d\n", answer);
    }

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

miners.cpp: In function 'int main()':
miners.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
miners.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...