QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#784105 | #3567. Digital Clock | SGColin# | 100 ✓ | 23ms | 3712kb | C++20 | 2.8kb | 2024-11-26 13:24:40 | 2024-11-26 13:24:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
bool s[10][8];
int n;
inline void work() {
vector<vector<int>> list, ans;
rep(i, 1, n) {
string str;
vector<int> num;
cin >> str;
for (auto x : str) if (isdigit(x)) num.eb(x - '0');
list.pb(num);
}
auto check = [&](int h1, int h2, int m1, int m2) {
int h = h1 * 10 + h2;
int m = m1 * 10 + m2;
int sta[4][8]; // 0 : not determined; 1 : ok; 2 : broken
memset(sta, 0, sizeof(sta));
auto consistent = [&](int p, int x, int y) {
// should be x, but actually y
rep(i, 1, 7) {
if (!s[x][i] && !s[y][i]) continue;
else if (!s[x][i] && s[y][i]) return false;
else if (s[x][i] && s[y][i]) {
if (sta[p][i] == 0) sta[p][i] = 1;
if (sta[p][i] != 1) return false;
} else {
if (sta[p][i] == 0) sta[p][i] = 2;
if (sta[p][i] != 2) return false;
}
}
return true;
};
rep(i, 0, n - 1) {
int num[4];
num[0] = h / 10;
num[1] = h % 10;
num[2] = m / 10;
num[3] = m % 10;
rep(j, 0, 3) if (!consistent(j, num[j], list[i][j])) return false;
++m;
if (m == 60) {m = 0; ++h;}
if (h == 24) h = 0;
}
return true;
};
rep(h1, 0, 2)
rep(h2, 0, (h1 == 2 ? 3 : 9))
rep(m1, 0, 5)
rep(m2, 0, 9)
if (check(h1, h2, m1, m2)) ans.pb(vector<int>{h1, h2, m1, m2});
if (ans.empty()) {puts("none"); return;}
for (auto &res : ans) printf("%d%d:%d%d ", res[0], res[1], res[2], res[3]);
puts("");
}
int main() {
s[0][1] = s[0][2] = s[0][3] = s[0][5] = s[0][6] = s[0][7] = true;
s[1][3] = s[1][6] = true;
s[2][1] = s[2][3] = s[2][4] = s[2][5] = s[2][7] = true;
s[3][1] = s[3][3] = s[3][4] = s[3][6] = s[3][7] = true;
s[4][2] = s[4][3] = s[4][4] = s[4][6] = true;
s[5][1] = s[5][2] = s[5][4] = s[5][6] = s[5][7] = true;
s[6][1] = s[6][2] = s[6][4] = s[6][5] = s[6][6] = s[6][7] = true;
s[7][1] = s[7][3] = s[7][6] = true;
s[8][1] = s[8][2] = s[8][3] = s[8][4] = s[8][5] = s[8][6] = s[8][7] = true;
s[9][1] = s[9][2] = s[9][3] = s[9][4] = s[9][6] = s[9][7] = true;
cin.tie(0);
ios::sync_with_stdio(false);
while (cin >> n) work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 100
Accepted
time: 23ms
memory: 3712kb
input:
1 88:88 2 23:25 23:26 3 71:57 71:57 71:07 1 00:00 1 11:11 1 22:22 1 33:33 1 44:44 1 55:55 1 66:66 1 77:77 1 88:88 1 99:99 1 08:28 1 78:48 1 24:11 1 31:11 1 11:60 5 23:11 23:11 23:11 23:11 23:11 6 23:11 23:11 23:11 23:11 23:11 23:11 6 23:11 23:11 23:11 23:11 23:11 23:12 2 08:19 08:20 2 27:77 27:17 2 ...
output:
none 23:25 00:58 03:58 07:58 08:58 00:00 00:08 08:00 08:08 00:00 00:01 00:03 00:04 00:07 00:08 00:09 00:10 00:11 00:13 00:14 00:17 00:18 00:19 00:30 00:31 00:33 00:34 00:37 00:38 00:39 00:40 00:41 00:43 00:44 00:47 00:48 00:49 01:00 01:01 01:03 01:04 01:07 01:08 01:09 01:10 01:11 01:13 01:14 01:1...
result:
ok 390 lines