QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#389390 | #4365. Clock Breaking | TWTP_TCTF | WA | 3ms | 3596kb | C++20 | 7.2kb | 2024-04-14 11:10:18 | 2024-04-14 11:10:19 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define rep(i, a, b) for(int i = a ; i < b ; i ++)
#define sz(v) (int)v.size()
#define all(v) begin(v), end(v)
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int n;
vector<string> s[105];
vector<pair<int,int>>cri;
bool is_cri[7][21];
vector<string> get_shape(char digit){
vector<string> ans;
if(digit==':'){
ans.push_back(".");
ans.push_back(".");
ans.push_back("X");
ans.push_back(".");
ans.push_back("X");
ans.push_back(".");
ans.push_back(".");
return ans;
}
if(digit>'9'||digit<'0'){
ans.push_back(".");
ans.push_back(".");
ans.push_back(".");
ans.push_back(".");
ans.push_back(".");
ans.push_back(".");
ans.push_back(".");
return ans;
}
digit-='0';
if(digit == 0){
ans.push_back(".XX.");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back("....");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
}
if(digit == 1){
ans.push_back("....");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back("....");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back("....");
}if(digit == 2){
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back(".XX.");
ans.push_back("X...");
ans.push_back("X...");
ans.push_back(".XX.");
}if(digit == 3){
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back(".XX.");
}if(digit == 4){
ans.push_back("....");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back("....");
}if(digit == 5){
ans.push_back(".XX.");
ans.push_back("X...");
ans.push_back("X...");
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back(".XX.");
}if(digit == 6){
ans.push_back(".XX.");
ans.push_back("X...");
ans.push_back("X...");
ans.push_back(".XX.");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
}if(digit == 7){
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back("....");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back("....");
}
if(digit == 8){
ans.push_back(".XX.");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
}if(digit == 9){
ans.push_back(".XX.");
ans.push_back("X..X");
ans.push_back("X..X");
ans.push_back(".XX.");
ans.push_back("...X");
ans.push_back("...X");
ans.push_back(".XX.");
}
return ans;
}
vector<string> generate(int h, int m){
vector<string> ans(7);
vector<string> d1, d2, d3, d4, empty, colon;
d1 = get_shape(h / 10 + '0');
d2 = get_shape(h % 10 + '0');
d3 = get_shape(m / 10 + '0');
d4 = get_shape(m % 10 + '0');
colon = get_shape(':');
for(int i = 0; i < 7; i++){
ans[i] += d1[i] + '.' + d2[i] + '.' + colon[i] + '.' + d3[i] + '.' + d4[i];
}
return ans;
}
pair<int, int> get_next(int h, int m){
m = (m + 1) % 60;
if(m == 0)
h = (h + 1) % 24;
return {h, m};
}
void printscreen(vector<string>any){
cout<<"****************\n";
for(auto it:any)
cout<<it<<'\n';
cout<<"****************\n";
}
bool checkSTART(int h, int m){
for(int i = 0; i < n; i++){
auto cur_grid = generate(h, m);
for(auto it : cri) {
int x = it.first;
int y = it.second;
if (cur_grid[x][y] != s[i][x][y])
return false;
}
auto nxt = get_next(h, m);
h = nxt.first;
m = nxt.second;
}
return true;
}
void build_critical(){
for(int i = 0; i < 7; i++){
for(int j = 0; j < 21; j++){
bool arr[2] = {};
for(int k = 0; k < n; k++){
arr[s[k][i][j] == 'X' ] = 1;
}
if(arr[0] == 1 && arr[1] == 1) {
cri.push_back({i, j});
is_cri[i][j] = 1;
}
}
}
}
vector<vector<string>>genrateall(vector<pair<int, int>> starts){
vector<vector<string>> ans;
for(auto start: starts){
for(int i = 0; i < n; i++){
ans.push_back(generate(start.first, start.second));
start = get_next(start.first, start.second);
}
}
return ans;
}
vector<string> populate(vector<pair<int, int>> starts){
auto ans = generate(88, 88);
for(auto it:cri)
ans[it.first][it.second]='W';
vector<vector<string>>allscreen[starts.size()];
for(int i = 0; i < starts.size(); i++){
allscreen[i] = genrateall({starts[i]});
}
for(int i = 0; i < 7; i++){
for(int j = 0; j < 21; j++){
if(ans[i][j] != 'X')
continue;
bool arr2[3] = {};
for(int k = 0; k < starts.size(); k++) {
bool arr[2] = {};
for (auto &screen: allscreen[k]) {
arr[screen[i][j] == 'X'] = 1;
}
if (arr[0] == 1 && arr[1] == 1) {
if (s[0][i][j] == 'X')
arr2[1] = 1;
else
arr2[0] = 1;
} else {
arr2[2] = 1;
}
}
if(arr2[2] == 1 || (arr2[1] == 1 && arr2[0] == 1))
ans[i][j] = '?';
else {
if(s[0][i][j] == 'X')
ans[i][j] = '1';
else
ans[i][j] = '0';
}
}
}
return ans;
}
void doWork() {
cin>>n;
for(int i = 0; i < n; i++){
for(int j = 0; j < 7; j++){
string z;
cin >> z;
s[i].push_back(z);
}
}
build_critical();
vector<pair<int, int>> starts;
for(int h = 0; h < 24; h++){
for(int m = 0; m < 60; m++){
if(checkSTART(h, m))
starts.push_back({h, m});
}
}
if(starts.size() == 0){
cout << "impossible";
}else{
auto grid = populate(starts);
for(auto &s: grid)
cout << s << '\n';
}
}
int main() {
IO
// printscreen(generate(23,50));
// return 0;
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3596kb
input:
3 ......XX.....XX...XX. .....X..X...X..X....X .....X..X.X.X..X....X .............XX...XX. .....X..X......X.X..X .....X..X......X.X..X ......XX.....XX...XX. ......XX.....XX...XX. .....X..X...X..X....X .....X..X.X.X..X....X .............XX...XX. .....X..X......X.X..X .....X..X......X.X..X ......XX......
output:
.??...WW.....??...??. ?..?.W..?...?..1.?..? ?..?.W..?.?.?..1.?..? .??...??.....11...WW. ?..?.W..?.?.W..?.1..? ?..?.W..?...W..?.1..? .??...11.....??...??.
result:
wrong answer 2nd lines differ - expected: '?..?.W..?...?..1.0..?', found: '?..?.W..?...?..1.?..?'