結果
問題 | No.1868 Teleporting Cyanmond |
ユーザー |
![]() |
提出日時 | 2022-03-10 19:32:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 587 bytes |
コンパイル時間 | 2,073 ms |
コンパイル使用メモリ | 193,368 KB |
最終ジャッジ日時 | 2025-01-28 08:00:00 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N;cin >> N;vector<int>R(N-1);for(int i = 0; i < N-1; i++) {cin >> R[i];R[i]--;}if(R[0] == N-1) {cout << 1 << endl;return 0;}int n = 0,cnt = 0;while (true) {int nxt = n;for(int i = n+1; i <= R[n]; i++) {if(R[nxt] < R[i]) {nxt = i;}}cnt++;if(R[nxt] == N-1) {cnt++;break;}n = nxt;}cout << cnt << endl;}