葉林
Linked with GitHub
# ZeroJudge - g308: pB. 跳跳布朗尼(Brownie) ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=g308 ###### tags: `ZeroJudge` `模擬` ```cpp= #include <iostream> using namespace std; const static auto Initialize = []{ cin.sync_with_stdio(false); cin.tie(nullptr); return nullptr; }(); int main() { bool brownie[1000]; int slots, target, jumpto, teleports[1000], eats; while (cin >> slots >> target) { eats = 0; for (int i = 0; i < slots; ++i) cin >> teleports[i]; for (int i = 0; i < slots; ++i) cin >> brownie[i]; do { if (brownie[target]) ++eats; jumpto = teleports[target]; teleports[target] = -1; target = jumpto; } while (teleports[target] != -1); cout << eats << '\n'; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up