Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
112153 | 张之隽 | 环形密码 | C++ | Wrong Answer | 1 MS | 272 KB | 704 | 2025-03-08 15:13:44 |
#include <iostream> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> passwords(N); for (int i = 0; i < N; ++i) { cin >> passwords[i]; } vector<bool> visited(N, false); int index = 0; int count = 0; cout << "翻译后的数字密码: "; while (count < N) { if (!visited[index]) { if (M == 1) { visited[index] = true; cout << passwords[index] << " "; M = passwords[index]; count++; } else { M--; } } index = (index + 1) % N; } return 0; }
------Input------
10 3 8 3 6 3 4 10 3 10 3 2
------Answer-----
6 3 3 10 8 3 3 2 10 4
------Your output-----
翻译后的数字密码: 6 3 3 10 8 3 3 2 10 4