Algorithm


Problem Name: beecrowd | 2152

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2152

Pepe, I Already Took the Candle!

 

By Ricardo Martins, IFSULDEMINAS BR Brazil

Timelimit: 1

One day, the great hero Chapolout helped a scientist who has created many inventions. One of these inventions is a system that opens the door secret laboratory. The system consists of removing a side door of the candlestick candle, that it opens, and to put the candle back to the chandelier, the door closes. But Chapolout found that the sail was just a pretend. In fact, the scientist assistant, called Pepe, that opened the lab door, inside. A while later, the system was modified to also run the initial project. A pressure sensor placed below the chandelier candle, so that the removal of the active sail system. This system issues a log report for every time the door opened or closed, but the log is quite confusing. Every record, three whole numbers are registered, and the hour and the minute the event occurred and a value that represents the door opened or closed at the time. Pepe asks for your help to convert the log data more readable data to it.

Write a program that, given a log record, this is converted into more readable texts.

 

Input

 

The first line contains the number of test cases. Each line of a test case has three integers H, M and O, the time being, the minutes of the occurrence, and the instance itself (zero if the door closed or the door opened).

 

Output

 

For each test case, print the time of the occurrence, in due form, followed by a space, a hyphen and a space, and the phrase "A porta abriu!" or "A porta fechou!" as the occurrence recorded.

 

 

 

Input Sample Output Sample

3

15 30 1

23 50 0

0 5 1

15:30 - A porta abriu!

23:50 - A porta fechou!

00:05 - A porta abriu!

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main(void)

{
    int i, a, b, c, n;

    scanf("%i", &n);

    for (i = 0; i  <  n; ++i)
    {
        scanf("%d %d %d", &a, &b, &c);

        printf("%02d:%02d - ", a, b);

        if (c == 1)
            printf("A porta abriu!\n");

        else
            printf("A porta fechou!\n");
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 15 30 1 23 50 0 0 5 1

Output

x
+
cmd
15:30 - A porta abriu! 23:50 - A porta fechou! 00:05 - A porta abriu!

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>

using namespace std;

int main() {

    int t;
    cin >> t;
    while(t--)
    {
        int a,b,c;
        cin >> a >> b >> c;
        if(a < 10)
        cout << "0";
        cout << a;
        cout << ":";
        if(b  <  10)
        cout << "0";
        cout << b;
        if(c == 1>
        cout << " - A porta abriu!\n";
        else
        cout << " - A porta fechou!\n";

    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 15 30 1 23 50 0 0 5 1

Output

x
+
cmd
15:30 - A porta abriu! 23:50 - A porta fechou! 00:05 - A porta abriu!

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const number = lines.shift();
for(let i = 0; i  <  number; i++){
  let [a, b, c] = lines.shift().trim().split(" ");
  if(a.length == 2 && b.length == 2){
     c == 1 ? console.log(`${a}:${b} - A porta abriu!`) : console.log(`${a}:${b} - A porta fechou!`);
  }
  else{
    if(a.length == 1 && b.length == 1)
    c == 1 ? console.log(`0${a}:0${b} - A porta abriu!`) : console.log(`0${a}:0${b} - A porta fechou!`);
    else if(a.length == 2 && b.length == 1){
      c == 1 ? console.log(`${a}:0${b} - A porta abriu!`) : console.log(`${a}:0${b} - A porta fechou!`);
    }
    else{
      c == 1 ? console.log(`0${a}:${b} - A porta abriu!`) : console.log(`0${a}:${b} - A porta fechou!`);
    }
  }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 15 30 1 23 50 0 0 5 1

Output

x
+
cmd
15:30 - A porta abriu! 23:50 - A porta fechou! 00:05 - A porta abriu!
Advertisements

Demonstration


Previous
#2147 Beecrowd Online Judge Solution 2147 Galopeira Solution in C, C++, Java, Js and Python
Next
#2159 Beecrowd Online Judge Solution 2159 Approximate Number of Primes Solution in C, C++, Java, Js and Python