Skip to content

Commit

Permalink
Improve input
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Jul 29, 2024
1 parent 1c07e69 commit 1e801aa
Show file tree
Hide file tree
Showing 4 changed files with 1,185 additions and 16 deletions.
32 changes: 18 additions & 14 deletions solutions/beecrowd/1047/1047.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
int main() {
std::int16_t hi, mi, hf, mf, mr, hr;

scanf("%d %d %d %d", &hi, &mi, &hf, &mf);
while (scanf("%d %d %d %d", &hi, &mi, &hf, &mf) != EOF) {
hr = hf - hi;
if (hr < 0) {
hr += 24;
}

hr = hf - hi;
if (hf - hi < 0) {
hr = 24 + hf - hi;
}
mr = mf - mi;
if (mf - mi < 0) {
mr += 60;
hr--;
}

mr = mf - mi;
if (mf - mi < 0) {
mr = 60 + mf - mi;
hr--;
}
if (hr < 0) {
hr += 24;
}

if (hf == hi && mf == mi) {
printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
} else {
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", hr, mr);
if (hf == hi && mf == mi) {
printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
} else {
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", hr, mr);
}
}

return 0;
Expand Down
15 changes: 15 additions & 0 deletions solutions/beecrowd/1047/generate_in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euo pipefail

for start_hour in $(seq 0 2); do
for start_minute in $(seq 0 3) $(seq 56 59); do
for end_hour in $(seq 0 2); do
for end_minute in $(seq 0 3) $(seq 56 59); do
echo -n "${start_hour} ${start_minute} "
echo "${end_hour} ${end_minute}"
done
done
done
done

Loading

0 comments on commit 1e801aa

Please sign in to comment.