Wednesday, May 3, 2017

URI 1521Solution - The Guilty - Solution in C++ | Ad Hoc

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 comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.