output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int format;
string st, h, m;
int main() {
cin >> format;
cin >> st;
int ans = 0;
if (st[3] >= '6') {
ans++;
st[3] = '0';
}
if (format == 24) {
if (st[0] > '2') {
st[0] = '1';
ans++;
}
if (st[0] == '2' && st[1] > '3') {
ans++... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int hours;
cin >> hours;
int h, m;
cin >> h;
cin.ignore();
cin >> m;
while (m > 59) m -= 10;
if (hours == 24) {
while (h > 23) {
h -= 10;
}
} else {
while (h > 12) {
h -= 10;
}
if (!h) {
h = 10;
}
}
... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
long i, j, m, n, p, q, r, s, a, b;
string aa, bb;
int main() {
cin >> n;
scanf("%ld:%ld", &a, &b);
if (n == 12) {
if (a == 0)
aa = "01";
else if (a >= 13) {
p = a % 10;
if (p == 0) {
aa = "10";
} else
aa += '0', aa += (a... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char s[10];
scanf("%d%s", &n, s);
int a = (s[0] - '0') * 10 + (s[1] - '0');
int b = (s[3] - '0') * 10 + (s[4] - '0');
if (n == 12) {
if (a == 0)
s[1] = '1';
else if (a > 12) {
if (s[1] == '0')
s[0] = '1';
els... | ### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
int main() {
int f, h, m;
scanf("%d", &f);
scanf("%d:%d", &h, &m);
if (m > 59) m %= 10;
if (f == 24 && h >= 24) h = 10 + h % 10;
if (f == 12 && h == 0) h = 1;
if (f == 12 && h > 12) {
if (h % 10 == 0)
h = 10;
else
h %= 10;
}
if (h < 10) printf("0");
print... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int x;
string a;
void input() {
cin >> x;
cin >> a;
}
void solve() {
if ((a[3] - '0') >= 6) {
a[3] = '0';
}
int h = 10 * (a[0] - '0') + (a[1] - '0');
if (x == 24) {
if (h >= 24) {
a[0] = '0';
}
} else {
if (h > 12) {
if (a[1] != '0'... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s, a, b;
char c;
string str;
cin >> n;
cin >> str;
m = ((str[0] - '0') * 10) + (str[1] - '0');
s = ((str[3] - '0') * 10) + (str[4] - '0');
if (n == 12) {
if (m < 1) {
m = 1;
}
if (m > 12) {
b = m % 10;
a =... | ### Prompt
Create a solution in CPP for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
int main() {
int a, b, c;
scanf("%d", &c);
scanf("%02d:%02d", &a, &b);
if (b >= 60) b = b % 10;
if (a > c || a == 24) a = a % 10;
if (c == 12 && a == 0) a = 10;
printf("%02d:%02d", a, b);
return 0;
}
| ### Prompt
Create a solution in CPP for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int hours;
scanf("%d", &hours);
int h, s;
char c;
scanf(" %d %c %d", &h, &c, &s);
if (hours == 12)
while (h > hours) h -= 10;
if (hours == 24)
while (h >= hours) h -= 10;
while (s > 59) s -= 60;
if (hours == 12 && h == 0) h = 1;
if (... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
const int maxn = 5e2 + 10;
using namespace std;
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
long long f = 1;
while (q) {
if (q & 1) f = f * p;
p = p * p;
q >>= 1;
}
return f;
}
long long my_min(lon... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int h1, h0, m1, m0;
int type;
char c;
cin >> type;
int hour, min;
cin >> hour >> c >> min;
h1 = hour / 10;
h0 = hour % 10;
m1 = min / 10;
m0 = min % 10;
if (m1 > 5) m1 = 4;
if (type == 12) {
if (h1 == 0 && h0 != 0) {
;
} el... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 100000;
int dif(string s1, string s2) {
int r = 0;
for (int i = 0; i < s1.length(); i++)
if (s1[i] != s... | ### Prompt
Create a solution in CPP for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
string str, cmp, sec;
int main() {
ios::sync_with_stdio(false);
int i, j, x, y, n, m;
cmp = sec = "";
cin >> n;
if (n == 24) {
cin >> str;
cmp = cmp + str[0];
cmp = cmp + str[1];
sec = sec + str[3];
sec = sec + str[4];
if (cmp > "23") str[0... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int h, m, f;
cin >> f >> s;
h = (s[0] - 48) * 10 + (s[1] - 48);
m = (s[3] - 48) * 10 + (s[4] - 48);
if (f == 24) {
if (h >= 24) {
if (s[1] != '0')
s[0] = '0';
else
s[0] = '1';
}
} else {
if (h > 12... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int format;
cin >> format;
int hour, minute;
char isto;
cin >> hour >> isto >> minute;
if (format == 12) {
if (hour > 12 && hour % 10 != 0)
hour = hour % 10;
else if (hour > 12 && hour % 10 == 0)
hour = 10;
else if (hour == 0... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 6005;
const long long oo = 1e6;
int main() {
int n;
string s;
cin >> n >> s;
int a = (s[3] - '0') * 10 + s[4] - '0';
if (a > 59) {
s[3] = '0';
}
if (n == 24) {
int a = (s[0] - '0') * 10 + s[1] - '0';
if (a > 23) {
s[0] = '0';
... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
const double GRS = (1 + sqrt(5)) / 2;
long long power(int X, int P) {
long long ans = 1;
for (int i = 1; i <= P; i++) {
ans = ans * (long long)X;
}
return ans;
}
long long ABS(long long A, long long B) {
long long ret = A - B;
if (ret < 0) return -ret;
ret... | ### Prompt
Generate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 2 * 1e5 + 10;
const double PI = acos(-1.0), EPS = 1e-9;
int N, s;
int arr[MX];
int main() {
cin >> N;
string s;
cin >> s;
if (N == 12) {
int f = s[0] - '0', ss = s[1] - '0';
if (f == 0 && ss == 0) {
s[0] = '1';
} else if (f == 1) {
... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int h, m, t;
char f;
cin >> t;
cin >> h >> f >> m;
if (t == 24) {
int a = h / 10 % 10;
int b = h % 10;
if (a > 2) a = 1;
if (a == 2 && b >= 4) b = 1;
h = 10 * a + b;
a = m / 10 % 10;
b = m % ... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int c, a, b;
scanf("%d", &c);
scanf("%02d:%02d", &a, &b);
if (b >= 60) b %= 10;
if (a > c || a == 24) {
a %= 10;
}
if (c == 12 && a == 0) a = 10;
printf("%02d:%02d", a, b);
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, p, q, i, k;
char me[6], me1[6];
scanf("%d", &a);
scanf("%s", me);
if (a == 12) {
p = 0;
i = 0;
p = (p * 10) + (me[0] - '0');
p = (p * 10) + (me[1] - '0');
if (!p) {
me1[i++] = me[0];
me1[i++] = 1 + '0';
} ... | ### Prompt
Create a solution in CPP for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long format;
cin >> format;
string str;
cin >> str;
if (format == 12) {
if (str[0] != '0' && str[0] != '1') {
if (str[1] == '0') {
str[0] = '1';
} else {
str[0] = '0';
}
}
if (str[0] == '0') {
i... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, h, m;
char c;
cin >> n;
cin >> h >> c >> m;
if (n == 24) {
if (h < 0) h = 00;
if (h > 23) h %= 10;
if (m > 59) m %= 10;
}
if (n == 12) {
if (h < 1) h = 01;
if (h > 12) {
if (h % 10 != 0) h %= 10;
if (h % 10 =... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
int main() {
int m;
char s[100];
int hour = 0, min = 0;
scanf("%d", &m);
scanf("%s", s);
hour = 10 * (s[0] - '0') + s[1] - '0';
min = 10 * (s[3] - '0') + s[4] - '0';
if (m == 24) {
if (hour > 23) hour %= 10;
if (min > 59) min %= 10;
} else {
if (hour > 12 && hour %... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int typ, hh, mm;
int main() {
cin >> typ >> hh;
cin.ignore();
cin >> mm;
if (mm / 10 > 5) mm = 50 + mm % 10;
if (typ == 12 && !hh) hh = 1;
if (typ == 12 && hh > 12) {
if (hh % 10)
hh = hh % 10;
else
hh = 10;
}
if (typ == 24 && hh > 23) hh... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
string n;
cin >> n;
string str;
cin >> str;
if (n == "12") {
if (str.substr(0, 2) == "00") {
str[1] = '1';
if (str.substr(3, 2) <= "59") {
cout << str << endl;
return 0;
} else ... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
char foo[10];
int main() {
int x;
scanf("%d", &x);
int h, m;
scanf("%d:%d", &h, &m);
if (x == 12) {
if (h == 0)
h++;
else if (h > 12) {
while (h > 12) h -= 10;
}
} else {
if (h > 23) {
while (h > 23) h -= 10;
}
}
while (... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int h1, h2, m1, m2;
cin >> h1;
char c;
cin >> c;
cin >> m1;
if (m1 > 59) {
m1 = m1 % 10;
}
if (n == 12) {
if (h1 > 12) {
h1 = h1 % 10;
}
}
if (n == 24) {
if (h1 >= 24) {
h1 = h1 % 10;
}
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
if (n == 12) {
if ((s[0] > '1') && (s[1] != '0'))
s[0] = '0';
else if (s[0] > '1' && s[1] == '0')
s[0] = '1';
else if (s[0] == '1' && s[1] > '2')
s[0] = '0';
else if (s[0] == '0' &... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int f, g;
string s;
cin >> f >> s;
int hours = (s[0] - '0') * 10 + (s[1] - '0'),
minutes = (s[3] - '0') * 10 + (s[4] - '0');
if (minutes > 59) minutes %= 10;
if (f == 12) {
if (hours == 0)
hours = 1;
else if (hours > 12) {
... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
char h1, h0, del, m1, m0;
cin >> h1 >> h0 >> del >> m1 >> m0;
if (m1 > '5') {
m1 = '0';
}
if (n == 12 && h1 == '1' && h0 > '2') {
h0 = '0';
}
if (h1 > '2' || (h1 == '2'... | ### Prompt
Create a solution in cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double epos = 1e-8;
const int maxn = 200009;
char s[maxn];
int main() {
int n;
scanf("%d", &n);
scanf("%s", s);
int hour = (s[0] - '0') * 10 + s[1] - '0';
int m = (s[3] - '0') * 10 + s[4] - '0';
if (n == 12) {
if (hour == 12... | ### Prompt
In cpp, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n;
cin >> n;
int a, b;
char x;
cin >> a >> x >> b;
if (n == 12) {
if (0 < a && a < 13) {
} else if (a == 0) {
a = 10;
} else if (a < 20) {
a = 10;
} else if (a % 10 == ... | ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int diff(string a, string b) {
if (a == b) return 0;
if (a[0] == b[0] || a[1] == b[1]) return 1;
return 2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int format;
cin >> format;
string time;
cin >> time;
string h, m;
h = time[0];
h = h +... | ### Prompt
In cpp, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, h;
string s;
cin >> n >> s;
m = (s[3] - '0') * 10 + s[4] - '0';
if (m > 59) {
s[3] = '0';
}
if (n == 24) {
h = (s[0] - '0') * 10 + s[1] - '0';
if (h > 23) {
if (s[0] - '0' > 2)
s[0] = '0';
else if (s[1] - ... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
if (n == 24) {
if (s[0] >= '0' && s[0] <= '2') {
if (s[1] >= '4' && s[0] == '2') {
s[0] = '0';
}
} else {
s[0] = '0';
}
if (!(s[3] >= '0' && s[3] <= '5')) {
s[3] = '0... | ### Prompt
In CPP, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = INT_MAX;
const int MAX_N = 50005;
template <typename T>
inline T sqr(T a) {
return a * a;
};
int n, h, m;
int main(int argc, char const *argv[]) {
scanf("%d", &n);
scanf("%d:%d", &h, &m);
if (n == 24) {
if (h > 23) h... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int change(int a) {
if (a >= 0 && a <= 59)
return a;
else {
return a % 10;
}
}
int change24(int a) {
if (a >= 0 && a <= 23)
return a;
else
return a % 10;
}
int change12(int a) {
if (a >= 1 && a <= 12)
return a;
else {
if (a % 10 == 0) {... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int a = s[0] - 48, b = s[1] - 48, c = s[3] - 48, d = s[4] - 48;
int x = 10 * a + b, y = 10 * c + d;
if (n == 12) {
if (x > 12) {
if (b == 0) {
a = 1;
} else
a = 0;
} else if ... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (~scanf("%d", &a)) {
int flag1, flag2;
flag1 = flag2 = 0;
scanf("%d:%d", &b, &c);
if (a == 12) {
if (b > 12 || b == 0) {
b %= 10;
if (b == 0) {
b = 10;
} else
flag1 = 1;
... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int format;
string s;
cin >> format >> s;
if (format == 12) {
if (s[0] == '0')
if (s[1] == '0') s[1] = '2';
if (s[1] > '2')
if (s[0] > '0') s[0] = '0';
if (s[3] > '5') s[3] = '0';
if (s[0] > '1') {
if (s[1] < '3')
... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
while (b) b ^= a ^= b ^= a %= b;
return a;
}
void readStrn(char a[], long n) {
for (register long i = 0; i < n; i++) a[i] = getchar();
getchar();
}
void readStr(char a[], long &n) {
n = 0;
for (register char c = getchar(... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
string s, q = "", p = "";
cin >> s;
int hr = (s[0] - '0') * 10 + (s[1] - '0');
int min = (s[3] - '0') * 10 + (s[4] - '0');
if (!(min >= 0 && min <= 59)) min = 2 * 10 + (s[4] - '0');
if (min >= 0 && min <= 9) {
q = to_string(... | ### Prompt
Generate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
string s;
cin >> s;
if (t == 12) {
if (s.at(0) >= '2') {
if (s.at(1) == '0')
s.at(0) = '1';
else
s.at(0) = '0';
} else if (s.at(0) == '1') {
if (s.at(1) >= '3') s.at(1) = '0';
} else {
... | ### Prompt
Create a solution in cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
char arr[5];
int main() {
int n;
cin >> n;
string s;
cin >> s;
int min = (s[3] - '0') * 10 + (s[4] - '0');
if (min > 59) {
s[3] = s[3] - '6' + '0';
}
int l = (s[0] - '0') * 10 + (s[1] - '0');
if (n == 24) {
if (l > 23) {
s[0] = '0';
}
}... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int clockFormat;
cin >> clockFormat;
char dummy;
int h, m;
cin >> h >> dummy >> m;
if (clockFormat == 12) {
if (h >= 1 && h <= 12) {
if (h < 10) cout << 0;
cout ... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, c, d;
char s[20];
while (~scanf("%d", &n)) {
scanf("%s", s);
a = s[0] - '0';
b = s[1] - '0';
c = s[3] - '0';
d = s[4] - '0';
int h = a * 10 + b, m = c * 10 + d;
if (m > 59) c = 0;
if (n == 24) {
if (h > 2... | ### Prompt
Generate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, j, k;
string s;
cin >> n;
cin >> s;
if (n == 24) {
if (s[3] > '5') s[3] = '0';
if (s[0] > '2')
s[0] = '0';
else if (s[0] == '2')
if (s[1] >= '4') s[1] = '0';
} else if (n == 12) {
if (s[3] > '5') s[3] = '0';
if... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
bool notinrange(string s) {
if (s[0] >= '0' && s[0] <= '5') {
return true;
}
return false;
}
bool notinrange1(string s) {
if (s[0] == '0' || s[0] == '1') {
return true;
}
if (s[0] == '2') {
if (s[1] == '0' || s[1] == '3' || s[1] == '2') {
retur... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int maxn = 2005;
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
long long po(long long a, long long b, long long mod) {
long long res = 1;
a %= mod;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a ... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
char a[10];
scanf("%s", a);
int x = a[3] - '0';
if (x > 5) a[3] = '0';
x = a[0] - '0';
x = x * 10;
x = x + (a[1] - '0');
if (n == 24) {
if (x > 23) a[0] = '0';
} else {
if (x > 12) {
if (a[1] == '0') {... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
int main() {
int f;
scanf("%d", &f);
char s[20];
scanf("%s", s);
if (s[3] >= '6') s[3] = '0';
if (s[0] > '2') s[0] = '1';
if (f == 12) {
if (s[0] > '1') {
if (s[1] != '0')
s[0] = '0';
else
s[0] = '1';
}
if (s[0] == '1' && s[1] > '2') {
... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long mo = 1e9 + 7;
const int oo = 1 << 30;
struct edge {
int u, v;
int w;
edge() { u = v = w = 0; }
edge(int a, int b, int c) : u(a), v(b), w(c) {}
};
int main() {
int type;
cin >> type;
string s;
cin >> s;
int ans = ... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
int f, h, m;
scanf("%d", &f);
scanf("%d:%d", &h, &m);
if (m >= 60) m -= 60;
if (f == 12) {
if (h > 12) h = h % 10;
if (!h) h = 10;
} else {
if (h >= 24) h = h % 10;
}
printf("%02d:%02d\n", h, m);
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int format;
cin >> format;
string str;
cin >> str;
int hh = (str[0] - '0') * 10 + (str[1] - '0');
int mm = (str[3] - '0') * 10 + (str[4] - '0');
if (format == 12) {
if (str[1] == '0') {
str[0] = '... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, h;
char z[10];
cin >> n >> z;
h = 0;
if (z[3] >= '6') {
z[3] = '0';
}
h += (z[0] - '0') * 10;
h += z[1] - '0';
if (n == 12) {
if (h > 12) {
if (z[0] > '1') {
z[0] = '1';
if (z[1] > '2') {
z[0] ... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string str;
cin >> str;
if (n == 24) {
if (str[0] > '2' || (str[0] == '2' && str[1] > '3')) {
char ch = '0';
str[0] = ch;
}
} else if (n == 12) {
if (str[0] > '1') {
char ch;
ch = str[1] == '0' ? ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
scanf("%lld", &n);
char s[10];
getchar();
scanf("%s", s);
if (n == 24) {
if (s[0] > '2') s[0] = '0';
if (s[0] == '2' && s[1] >= '4') s[1] = '0';
if (s[3] > '5') s[3] = '0';
} else {
if (s[0] == '1' && s[1] > '2') s[0] ... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int num;
string str;
cin >> num;
cin >> str;
if (str[3] >= '6') str[3] = '0';
if (num == 12) {
if (str[0] >= '2' || (str[0] == '1' && str[1] > '2') ||
(str[0] == '0' && str[1] == '0')) {
str[0] = '0';
if (str[1] == '0') str[0... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
char ch;
long long a, b;
cin >> a >> ch >> b;
if (n == 12 && a > n && a % 10 == 0) a = 10;
if (a > n) a %= 10;
if (b > 59) b %= 10;
if (n == 12 && a == 0) a = 1;
if (n == 24 &&... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int f, a, b;
scanf("%d", &f);
scanf("%d:%d", &a, &b);
if (b > 59) b %= 10;
if (a > f or a == 24) a %= 10;
if (a == 0 and f == 12) a = 10;
printf("%02d:%02d", a, b);
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
puts(f ? "YES" : "NO");
exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
x += y;
if (x >= mod) x -= mod;
... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int a, b, clock[2], mode, min[2];
char c;
do {
cin >> mode;
} while (mode != 12 && mode != 24);
cin >> a >> c >> b;
clock[0] = a / 10;
clock[1] = a % 10;
min[0] = b / 10;
min[1] = b % 10;
if (b > 59) {
b -= 40;
... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
string t;
cin >> t;
string s;
cin >> s;
int h = 10 * (s[0] - '0') + (s[1] - '0');
int m = 10 * (s[3] - '0') + (s[4] - '0');
if (t == "24" && h > 23) {
s[0] = '0';
} else if (t == "12" && h > 12 && s[1] != '0') {
s[0] = '0';
} else if (... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int df(int a, int b) {
int ans = 0;
if (a % 10 != b % 10) ++ans;
if (a / 10 != b / 10) ++ans;
return ans;
}
int main() {
int x;
cin >> x;
int m1, m2;
int h, m;
scanf("%d:%d", &h, &m);
m2 = m % 10;
m /= 10;
if (m >= 6)
m1 = 0;
else
m1 = m;
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
int main() {
int n;
scanf("%d", &n);
string S;
cin >> S;
int out[5] = {0};
if (n == 24) {
if (S[0] == '0' || S[0] == '1') {
out[0] = S[0] - '0';
out[1] = S[1] ... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int n;
char ti[10];
int main() {
scanf("%d", &n);
scanf("%s", ti);
if (ti[3] >= '6') ti[3] = '0';
if (n == 12) {
if (ti[0] == '1' && ti[1] > '2')
ti[0] = '0';
else if (ti[0] > '1') {
if (ti[1] == '0')
ti[0] = '1';
else
ti[0]... | ### Prompt
Develop a solution in Cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int format;
int hours;
char colon;
int minutes;
int main() {
cin >> format;
cin >> hours >> colon >> minutes;
string ans = "";
if (format == 24) {
if (hours > 23) {
hours = hours % 10;
if (hours == 0) hours = 10;
}
if (minutes > 59) {
m... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
string calc(int val) {
char ss[20];
sprintf(ss, "%02d", val);
return string(ss);
}
int get(int h, int m, int hh, int mm) {
string one = calc(h) + calc(m);
string two = calc(hh) + calc(mm);
int res = 0;
for (int i = 0; i < 4; ++i) {
res += (int)(one[i] != t... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int format;
cin >> format;
string t;
cin >> t;
vector<int> time{t[0] - '0', t[1] - '0', t[3] - '0', t[4] - '0'};
if (format == 12) {
if (time[0] > 1) {
t[0] = '0';
time[0] = 0;
if (... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
uint16_t format;
cin >> format;
string time;
cin >> time;
time[3] >= '6' ? time[3] = '0' : time[3];
if (format == 12) {
if (time[0] >= '1' && time[1] >= '3')
time[0] = '0';
else if (time[0] >= '2' && time[1] != '0')
time[0] = '0'... | ### Prompt
Generate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int n;
int cal(int x, int y) {
int res = 0;
res += (x % 10) != (y % 10);
res += (x / 10) != (y / 10);
return res;
}
string ti(int x, int y) {
string res = "";
res.push_back(char((x / 10) + '0'));
res.push_back(char((x % 10) + '0'));
res.push_back(':');
res... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int f;
string x;
int H, M;
bool hd, md;
void print(int x) {
if (x >= 10)
cout << x;
else
cout << '0' << x;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> f;
cin >> x;
H = (x[0] - '0') * 10 + x[1] - '0';
M = x[3] * 10 + x[4] - ... | ### Prompt
Develop a solution in CPP to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
int v[104];
int c[103];
int v1[104];
long long gcd(long long i, long long j) {
if (i % j == 0) return j;
return gcd(j, i % j);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long n;
string s;
cin >> n >> ... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
using ii = pair<long long int, long long int>;
class prioritize {
public:
bool operator()(ii &p1, ii &p2) { return p1.first < p2.first; }
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n;
cin >> n;
string s;
c... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
string s;
cin >> s;
int h = 10 * (s[0] - '0') + (s[1] - '0');
int m = 10 * (s[3] - '0') + (s[4] - '0');
if (n == 24) {
if (h < 0 || h >= 24) h = h % 10 + 10;
} else {
if (h < 1 || h > 12) ... | ### Prompt
In Cpp, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
int main() {
char str[10];
int n, ans = 0;
scanf("%d", &n);
scanf("%s", str);
int hr = (str[0] - 48) * 10 + str[1] - 48;
int mn = (str[3] - 48) * 10 + str[4] - 48;
if (n == 12 and (hr == 0 or hr > 12)) {
if (str[1] == 48)
str[0] = 49;
else
... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > getStep(int nh, int nm, int h, int m) {
pair<int, pair<int, int> > ret;
ret.second = make_pair(nh, nm);
ret.first += nh / 10 != h / 10;
ret.first += nh % 10 != h % 10;
ret.first += nm % 10 != m % 10;
ret.first += nm / 10 != m / 10;
r... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, h, m;
scanf("%d", &n);
scanf("%d:%d", &h, &m);
if (n == 12) {
if (h == 0) h = 1;
if (h > 12) {
if (h % 10)
h = h % 10;
else
h = 10;
}
} else {
if (h > 23) {
h = h % 10;
}
}
if (m > 59) {... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
int HH, MM;
char ch;
cin >> a;
cin >> HH >> ch >> MM;
if (a == 24) {
if (HH > 23) {
HH = HH % 10;
}
if (MM > 59) MM = MM % 10;
} else {
if (HH > 12) {
HH = HH % 10;
if (HH == 0) HH = 10;
} else {
... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int mod, h, m;
char c;
cin >> mod >> h >> c >> m;
if (mod == 12) {
if (h == 0) {
cout << "01";
} else if (h <= 12) {
if (h < 10) cout << 0;
cout << h;
} else if (h > 12) {
if (h % 10 == 0)
cout << 10;
el... | ### Prompt
Create a solution in CPP for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int cmd, h, m;
scanf("%d", &cmd);
scanf("%d:%d", &h, &m);
m = m % 60;
if (cmd == 12) {
if (h == 0) h = 10;
if (h > 12) {
if (h % 10 == 0)
h = 10;
else
h = h % 10;
}
} else {
if (h >= 24) {
h %= 10;
... | ### Prompt
In cpp, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
char a1, a2, b1, b2;
cin >> a1 >> a2 >> b1 >> b1 >> b2;
if (n == 24) {
if ((a1 - '0') * 10 + a2 - '0' > 23) {
a1 = '0';
}
} else {
if (a1 - '0' == 1 && (a1 - '0') * 10 + a2 - '0' > 12) a2 = '0';
if ((a1 - '0') ... | ### Prompt
Generate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
int n;
while (cin >> n >> s) {
if (n == 12) {
if (s[0] == '0') {
if (s[1] == '0') s[0] = '1';
}
if (s[0] == '1') {
if (s[1] > '2') s[0] = '0';
}
if (s[0] > '1') {
if (s[1] == '0')
... | ### Prompt
Develop a solution in cpp to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int hour;
cin >> hour;
string s;
cin >> s;
if (hour == 12) {
if (s[0] == '0') {
if (s[1] == '0') {
s[1] = '1';
}
if (s[3] >= '6') {
s[3] = '0';
}
} else if (s[0] == '1') {
if (s[1] >= '3') {
... | ### Prompt
Please create a solution in Cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
void solve(int tp) {
assert(tp == 12 || tp == 24);
string tm;
cin >> tm;
assert((int)(tm).size() == 5 && tm[2] == ':');
int bst = 10;
string ans = "";
for (int rm = 0; rm < 60; rm++) {
int l = (tp == 12 ? 1 : 0);
int r = (tp == 12 ? 13 : 24);
for (... | ### Prompt
Your task is to create a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
int main() {
int t, m, n, a, b, c, d;
do scanf("%d", &n);
while ((n != 12) && (n != 24));
scanf("%d:%d", &t, &m);
a = t % 10;
b = m % 10;
c = m / 10;
d = t / 10;
if (n == 24) {
if ((d > 2) || ((d == 2) && (a > 3))) d = 0;
if (c > 5) c = 0;
} else {
if (c > 5) c =... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, m, count = 0;
char a[10001], a1 = '6';
cin >> n;
for (i = 0; i < 5; i++) cin >> a[i];
if (n == 12) {
if (a[1] == '0' && a[0] == '0') a[1] = '1';
if ((int)a[3] >= 54) a[3] = '0';
if ((int)a[0] >= 49 && (int)a[1] > 50) a[0] = '0... | ### Prompt
Please formulate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int ar[101];
int main() {
int n, ans;
string t;
while (cin >> n >> t) {
int h, m;
if (n == 12) {
h = (t[0] - '0') * 10 + (t[1] - '0');
m = (t[3] - '0') * 10 + (t[4] - '0');
if (t[0] == '0' && t[1] == '0')
t[1... | ### Prompt
Please formulate a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
string s;
cin >> s;
if (n == 24) {
if (s[0] == '2' && s[1] > '3') {
s[0] = '1';
} else if (s[0] > '2') {
s[0] = '1';
}
} else {
if (s[0] == '1' && s[1] > '2') {
s[0] = '0';
} else if (s[0] ==... | ### Prompt
Please create a solution in cpp to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 1e5 + 5;
int n, m, h, hh, mm;
int main() {
scanf("%d", &n);
scanf("%d:%d", &h, &m);
hh = h / 10;
h = h % 10;
mm = m / 10;
m = m % 10;
switch (n) {
case 12:
if (hh > 1) {
if (h == 0)
hh = ... | ### Prompt
Generate a CPP solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given a ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, h, m;
scanf("%d%d:%d", &t, &h, &m);
if (t == 12) {
if (h / 10 >= 2) {
if (h % 10 == 0)
h = 10;
else
h = h % 10;
}
if (h / 10 == 1 && h % 10 >= 3) h = 10;
if (h == 0) h = 1;
} else {
if (h / 10 >= 3)... | ### Prompt
In CPP, your task is to solve the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
char s[10];
scanf("%d %s", &t, s);
if (t == 12) {
if (s[0] > '1' || (s[0] == '1' && s[1] >= '3')) s[0] = '0';
if ((s[0] == '0') && (s[1] == '0')) s[0] = '1';
if (s[3] > '5') s[3] = '0';
} else {
if (s[0] > '2' || (s[0] == '2' &&... | ### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
int main() {
int h1, m1, h2, m2, n, H, M;
scanf("%d", &n);
scanf("%d:%d", &H, &M);
h1 = H / 10;
h2 = H % 10;
m1 = M / 10;
m2 = M % 10;
if (m1 > 5) m1 = 0;
if (n == 24) {
if ((h1 * 10 + h2) >= 24) h1 = 1;
}
if (n == 12) {
if ((h1 * 10 + h2) > 12) {
if (h2 == 0... | ### Prompt
Create a solution in cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
char op[4];
char s[16];
int hh, mm;
int ans = 0;
cin >> op >> s;
hh = (s[0] - '0') * 10 + (s[1] - '0');
mm = (s[3] - '0') * 10 + (s[4] - '0');
if (mm > 59) {
s[3] = '0';
}
if (op[0] == '1') {
... | ### Prompt
Construct a CPP code solution to the problem outlined:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are giv... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int type;
cin >> type;
string t;
cin >> t;
if (type == 12) {
if (t[0] > '1' && t[1] <= '2') t[0] = '1';
if (t[0] > '1' || t[0] == '1' && t[1] > '2') t[0] = '0';
if (t[0] == t[1] && t[0] == '0') t[1] = '2';
} else {
if (t[0] > '2' || ... | ### Prompt
Create a solution in Cpp for the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are given ... |
#include <bits/stdc++.h>
using namespace std;
const long long MX = 3e5 + 9;
const long double pi = acos(-1);
const long long mod = 1e9 + 7;
bool cmp(int a, int b) { return a > b; }
long long po(long long a, long long b) {
if (b == 0) {
return 1;
}
long long x = po(a, b / 2);
x *= x % mod;
if (b % 2) {
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
Yo... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int f;
cin >> f;
string g;
cin >> g;
if (f == 12) {
if (g[0] > '1' && g[1] > '0')
g[0] = '0';
else if (g[0] > '1' && g[1] == '0')
g[0] = '1';
else if (g[0] == '1' && g[1] > '2')
g[0] = '0';
else if (g[0] == '0' && g[1... | ### Prompt
Please formulate a cpp solution to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
int main() {
int t, h1, h2, m1, m2, hh, mm;
scanf("%d", &t);
scanf("%1d%1d:%1d%1d", &h1, &h2, &m... | ### Prompt
Please create a solution in CPP to the following problem:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
int i, j, k, t, n, m, count = 0;
string A;
cin >> t;
cin >> A;
if (A[3] > '5') {
A[3] = '0';
}
if (t == 24) {
if (A[0] > '2') A[0] = '0';
if (A[0] == '2' && A[1] > '3') A[1] = '3';
} else if (... | ### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.