URI Online Judge Solution 1062 Rails - Solution in C, C++, Java, Python and C# - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, September 19, 2017

URI Online Judge Solution 1062 Rails - Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1002 Area of a Circle - Solution in C, C++, Java, Python and C#


URI Online Judge Solution 1062 Rails | Data Structure
URI Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1062

Problem Name: 1062 Rails solution
Problem Number : URI - 1062 Rails code
Online Judge : URI Online Judge Solution
Category: Data Structure
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1062 Rails - Solution in C, C++, Java, Python and C#

URI 1062 problem simple input output:

Input SampleOutput Sample
5
5 4 3 2 1
1 2 3 4 5
5 4 1 2 3
0
6
1 3 2 5 4 6
0
0
Yes
Yes
No

Yes

URI Solution 1062 Rails Code in CPP / URI 1062 in C++:


#include <cstdio>
#include <stack>

using namespace std;

#define sc1(a) scanf("%d", &a)
#define fr(i, a, n) for(int i = (a); i < (n); i++)
#define fe(i, a, n) for(int i = (a); i <= (n); i++)

typedef stack<int> si;
 
int vet[1005];

int main(int argc, char const *argv[])
{
 int i, curr, n, top;

 while(sc1(n) && n)
 {
  while(sc1(vet[0]) && vet[0])
  {
   fr(i, 1, n)
    sc1(vet[i]);

   si p;
   curr = 0;

   fe(i, 1, n)
   {
    p.push(i);

    while(p.size() > 0 && vet[curr] == p.top())
    {
     curr++;
     p.pop();
    }
   }

   (p.size() == 0) ? puts("Yes") : puts("No");
  }

  printf("\n");
 }

 return 0;
}

URI Solution 1062 Rails Code / URI 1062 solution in CPP:



URI Solution 1062 Rails Code / URI 1062 solution in Java:

URI Solution 1062 Rails Code / URI 1062 solution in  Python:

URI Solution 1062 Rails Code / URI 1062 solution in  C# (C Sharp):


Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks



Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1062 Rails  code in C, URI 1062 Rails code in C++, URI 1062 Rails  solution in C, URI solution, URI 1062 Rails solution in C,URI 1062 Rails solution in C++-CPP,URI 1062 Rails solution in C# (C sharp),URI 1062 Rails solution in Java,URI 1062 Rails solution in Python,

No comments:

Post a Comment