답안 #727052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727052 2023-04-20T01:29:09 Z josanneo22 Bowling (BOI15_bow) C++17
26 / 100
1 ms 340 KB
/* Baltic Olympiad in Informatics 2015
 * Problem: BOW/Bowling
 * Solution without logic of bowling (only one subtask)
 * Author: Karol Pokorski
 */

#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long int LL;

const int MAXN = 10;
const int MAXSEQ = 21;
const int MAXSCORE = 90;

int seqScore[MAXN];
LL dp[MAXN+1][MAXSCORE+1];
char seqMoves[MAXSEQ+1];

int main() {
    int numQueries;

    scanf("%d", &numQueries);

    while (numQueries--) {
        int numFrames;

        scanf("%d", &numFrames);
        scanf("%s", seqMoves);
        for (int i = 0; i < numFrames; i++)
            scanf("%d", &seqScore[i]);

        for (int frame = 0; frame <= numFrames; frame++)
            for (int score = 0; score <= MAXSCORE; score++)
                 dp[frame][score] = 0LL;

        dp[0][0] = 1LL;

        for (int frame = 0; frame < numFrames; frame++) {
            char firstMove = seqMoves[2*frame], secondMove = seqMoves[2*frame+1];
            int reqScore = seqScore[frame];

            for (int score = 0; score <= 9*frame; score++) {
                if (dp[frame][score] == 0LL) continue;

                for (int move1 = 0; move1 <= 9; move1++) {
                    if ((firstMove >= '0') && (firstMove <= '9') && (move1 != firstMove-'0')) continue;

                    for (int move2 = 0; move1+move2 <= 9; move2++) {
                        if ((secondMove >= '0') && (secondMove <= '9') && (move2 != secondMove-'0')) continue;

                        int nowScore = score + (move1+move2);
                        if ((reqScore != -1) && (nowScore != reqScore)) continue;

                        dp[frame+1][nowScore] = (dp[frame+1][nowScore] + dp[frame][score]);
                    }
                }
            }
        }

        LL result = 0LL;

        for (int score = 0; score <= MAXSCORE; score++)
            if ((score == seqScore[numFrames-1]) || (seqScore[numFrames-1] == -1))
                result = (result + dp[numFrames][score]);

        printf("%Ld\n", result);
    }

    return 0;
}

Compilation message

bow.cpp: In function 'int main()':
bow.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d", &numQueries);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
bow.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d", &numFrames);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
bow.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%s", seqMoves);
      |         ~~~~~^~~~~~~~~~~~~~~~
bow.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             scanf("%d", &seqScore[i]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 288 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 284 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 264 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 288 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -