URI 1521 Solution - The Guilty - Solution in C++ | Ad Hoc
URI Online Judge Solution 1521 Solution - The Guilty | Ad Hoc
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1521
Problem Name: URI Problem 1521 Solution - The Guilty
Problem Number : URI Problem 1521 Solution - The Guilty Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1521 20 Code in CPP:
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { int n, x, k; while(cin >> n && n) { int culp[n + 1]; for (int i = 0; i < n; ++i) { cin >> x; culp[i + 1] = x; } cin >> k; while(culp[k] != k) k = culp[k]; cout << k << endl; } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks