제출 #1127244

#제출 시각아이디문제언어결과실행 시간메모리
1127244KerimBowling (BOI15_bow)C++20
16 / 100
1096 ms400 KiB
/* Baltic Olympiad in Informatics 2015 * Problem: BOW/Bowling * Very slow solution (should pass only first subtask) * Author: Karol Pokorski */ #include <cstdio> #include <algorithm> using namespace std; typedef long long int LL; const int MAXN = 10; const int MAXSEQ = 21; int numFrames, seqScore[MAXN], mySeqScore[MAXN]; char seqMoves[MAXSEQ+1], mySeqMoves[MAXSEQ+1]; LL result; int Value(int pos) { if ((mySeqMoves[pos] >= '0') && (mySeqMoves[pos] <= '9')) return mySeqMoves[pos]-'0'; if ((mySeqMoves[pos] == 'x') || (mySeqMoves[pos] == ':')) return 10; if (mySeqMoves[pos] == '/') return 10-Value(pos-1); return 0; } bool Check() { for (int i = 0; i < numFrames-1; i++) if (Value(2*i) + Value(2*i+1) > 10) return false; for (int i = 0; i < numFrames-1; i++) if ((Value(2*i) == 10) && (mySeqMoves[2*i+1] == '/')) return false; for (int i = 0; i < numFrames-1; i++) if ((Value(2*i) + Value(2*i+1) == 10) && (seqMoves[2*i+1] >= '0') && (seqMoves[2*i+1] <= '9')) return false; if ((Value(2*numFrames-2) != 10) && (Value(2*numFrames-2) + Value(2*numFrames-1) > 10)) return false; if ((Value(2*numFrames-2) + Value(2*numFrames-1) < 10) && (Value(2*numFrames) > 0)) return false; if ((Value(2*numFrames-2) == 10) && (Value(2*numFrames-1) < 10) && (Value(2*numFrames-1) + Value(2*numFrames) > 10)) return false; if ((Value(2*numFrames-2) == 10) && (mySeqMoves[2*numFrames-1] == '/')) return false; if (((Value(2*numFrames-2) != 10) || (Value(2*numFrames-1) == 10)) && (mySeqMoves[2*numFrames] == '/')) return false; if ((seqMoves[2*numFrames] == '-') && (Value(2*numFrames-2) + Value(2*numFrames-1) >= 10)) return false; if ((Value(2*numFrames-2) + Value(2*numFrames-1) == 10) && (Value(2*numFrames-2) != 10) && (seqMoves[2*numFrames-1] >= '0') && (seqMoves[2*numFrames-1] <= '9')) return false; //zla linijka //if ((Value(2*numFrames-1) + Value(2*numFrames) == 10) && (seqMoves[2*numFrames] >= '0') && (seqMoves[2*numFrames] <= '9')) return false; char secondMove = seqMoves[2 * numFrames - 1], thirdMove = seqMoves[2 * numFrames]; int move1 = Value(2 * numFrames - 2), move2 = Value(2 * numFrames - 1), move3 = Value(2 * numFrames); //moje poprawki if ((secondMove == 'x') && (move1 != 10)) return false; //koniec moich poprawek //moje poprawki if (thirdMove == 'x') { if(move2 != 10 && ((move1 == 10 && move2 == 0) || (move1 + move2 < 10))) { return false; } } if ((thirdMove == '0') && move1 + move2 < 10) return false; if ((move1 == 10 || move1 + move2 != 10)&&(move2 != 10) &&(move2+move3 == 10) && (thirdMove >= '0') && (thirdMove <= '9')) return false; //koniec moich poprawek int score = 0; for (int i = 0; i < numFrames-1; i++) { if (Value(2*i) == 10) { int nextMove = Value(2*i+2); int nextNextMove = ((nextMove < 10) || (i == numFrames-2)) ? Value(2*i+3) : Value(2*i+4); score += nextMove + nextNextMove; } else if (Value(2*i) + Value(2*i+1) == 10) { int nextMove = Value(2*i+2); score += nextMove; } score += Value(2*i) + Value(2*i+1); mySeqScore[i] = score; } score += Value(2*numFrames-2) + Value(2*numFrames-1) + Value(2*numFrames); mySeqScore[numFrames-1] = score; for (int i = 0; i < numFrames; i++) if ((seqScore[i] != -1) && (mySeqScore[i] != seqScore[i])) return false; return true; } void Go(int pos) { if (pos == 2*numFrames+1) { if (Check()) result++; return; } if (seqMoves[pos] == '?') { for (int i = 0; i <= 10; i++) { mySeqMoves[pos] = i+'0'; Go(pos+1); } } else { mySeqMoves[pos] = seqMoves[pos]; Go(pos+1); } } int main() { int numQueries; scanf("%d", &numQueries); while (numQueries--) { scanf("%d", &numFrames); scanf("%s", seqMoves); for (int i = 0; i < numFrames; i++) scanf("%d", &seqScore[i]); for (int i = 0; i < numFrames-1; i++) if (seqMoves[2*i+1] == '-') seqMoves[2*i] = 'x'; result = 0LL; Go(0); printf("%Ld\n", result); } return 0; }

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

bow.cpp: In function 'int main()':
bow.cpp:106:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |     scanf("%d", &numQueries);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
bow.cpp:109:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |         scanf("%d", &numFrames);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
bow.cpp:110:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  110 |         scanf("%s", seqMoves);
      |         ~~~~~^~~~~~~~~~~~~~~~
bow.cpp:112:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  112 |             scanf("%d", &seqScore[i]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...