Submission #22978

# Submission time Handle Problem Language Result Execution time Memory
22978 2017-05-01T01:58:06 Z model_code Bowling (BOI15_bow) C++11
26 / 100
0 ms 1124 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:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &numQueries);
                             ^
bow.cpp:29:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &numFrames);
                                ^
bow.cpp:30:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", seqMoves);
                              ^
bow.cpp:32:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &seqScore[i]);
                                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1124 KB Output is correct
2 Correct 0 ms 1124 KB Output is correct
3 Correct 0 ms 1124 KB Output is correct
4 Correct 0 ms 1124 KB Output is correct
5 Correct 0 ms 1124 KB Output is correct
6 Correct 0 ms 1124 KB Output is correct
7 Correct 0 ms 1124 KB Output is correct
8 Correct 0 ms 1124 KB Output is correct
9 Correct 0 ms 1124 KB Output is correct
10 Correct 0 ms 1124 KB Output is correct
11 Correct 0 ms 1124 KB Output is correct
12 Correct 0 ms 1124 KB Output is correct
13 Correct 0 ms 1124 KB Output is correct
14 Correct 0 ms 1124 KB Output is correct
15 Correct 0 ms 1124 KB Output is correct
16 Correct 0 ms 1124 KB Output is correct
17 Correct 0 ms 1124 KB Output is correct
18 Correct 0 ms 1124 KB Output is correct
19 Correct 0 ms 1124 KB Output is correct
20 Correct 0 ms 1124 KB Output is correct
21 Correct 0 ms 1124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1124 KB Output isn't correct
2 Halted 0 ms 0 KB -