Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
122162 唐诗阳 18排列骨头 C++ Wrong Answer 0 MS 264 KB 1837 2025-06-14 16:42:41

Tests(0/1):


Code:

#include <iostream> #include <vector> using namespace std; vector<int> findBonePositions() { const int total = 30; const int bones = 15; const int step = 9; // 0 represents carrot, 1 represents bone vector<int> sequence(total, 0); // Start with the final 15 bones // We'll work backwards to find their initial positions // The positions after all removals (just bones) vector<int> finalPositions; for (int i = 0; i < bones; ++i) { finalPositions.push_back(i); } // Now simulate the removal process in reverse int currentSize = bones; int currentPos = 0; for (int round = 1; round <= total - bones; ++round) { // Calculate where the insertion would have been currentPos = (currentPos - step) % currentSize; if (currentPos < 0) { currentPos += currentSize; } // Insert a carrot at this position finalPositions.insert(finalPositions.begin() + currentPos, -1); // -1 represents carrot currentSize++; } // Now mark the bone positions in the initial sequence for (int pos : finalPositions) { if (pos != -1) { sequence[pos] = 1; } } return sequence; } int main() { vector<int> bonePositions = findBonePositions(); cout << "Initial arrangement (0=carrot, 1=bone):" << endl; for (int i = 0; i < 30; ++i) { cout << bonePositions[i] << " "; if ((i + 1) % 10 == 0) cout << endl; } cout << endl; cout << "Bone positions (1-based): "; for (int i = 0; i < 30; ++i) { if (bonePositions[i] == 1) { cout << i + 1 << " "; } } cout << endl; return 0; }


Run Info:

------Input------
0
------Answer-----
1 2 3 4 10 11 13 14 15 17 20 21 25 28 29
------Your output-----
Initial arrangement (0=carrot, 1=bone): 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bone positions (1-based): 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15