結果
問題 |
No.1868 Teleporting Cyanmond
|
ユーザー |
|
提出日時 | 2022-04-10 15:25:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,874 bytes |
コンパイル時間 | 792 ms |
コンパイル使用メモリ | 84,596 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 03:04:29 |
合計ジャッジ時間 | 2,897 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 25 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <map> #include <queue> #include <cmath> #include<set> #include<stack> #include<deque> #include<cassert> //#include <bits/stdc++.h> #define rep(i,n) for (int i=0; i<(int)(n); i++) using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef pair<int,int> P; using Graph = vector<vector<int>>; //#define INF 10000000 class UnionFind{ public: vector<int> par; UnionFind(int n) : par(n){ for(int i=0; i<n; i++) par[i] = -1; } int root(int x){ if(par[x] == -1) return x; int next = par[x]; return root(next); } void unite(int x, int y){ int px = root(x); int py = root(y); if(px == py) return; par[px] = py; } bool same(int x, int y){ int px = root(x); int py = root(y); if(px == py) return true; else return false; } }; bool isPrime(int x){ bool prime = true; for(int i=2; i<x; i++){ if(x%i == 0){ prime = false; break; } } if(!prime) return false; return true; } //------------------------------------------------------------------------// int main(){ int n; cin >> n; vector<int> r(n+1); for(int i=1; i<n; i++){ cin >> r[i]; } int cnt = 0; int now = 1; while(r[now] != n){ int right = r[now]; int tmp = -1; int next = -1; for(int i=now; i<=right; i++){ if(tmp < r[i]){ next = i; } } now = next; cnt++; } cout << cnt + 1 << endl; return 0; }