QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#389391#4365. Clock BreakingTWTP_TCTFWA 0ms3916kbC++207.5kb2024-04-14 11:16:592024-04-14 11:17:00

Judging History

你现在查看的是最新测评结果

  • [2024-04-14 11:17:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3916kb
  • [2024-04-14 11:16:59]
  • 提交

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 {
                    if(s[0][i][j] == 'X' && arr[0] == 1)
                        arr2[1] = 1;
                    else if(s[0][i][j] == '.' && arr[1] == 1)
                        arr2[0] = 1;
                    else
                        arr2[2] = 1;
                }
            }
            if(arr2[2] == 1 || (arr2[1] == 1 && arr2[0] == 1))
                ans[i][j] = '?';
            else if(arr2[0])
                    ans[i][j] = '0';
            else if(arr2[1])
                    ans[i][j] = '1';
            else
                ans[i][j] = '?';

        }
    }
    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();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3916kb

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.....??...??.
?..0.W..?...?..1.0..?
?..0.W..?.?.?..1.0..?
.??...??.....11...WW.
?..?.W..?.0.W..?.1..?
?..?.W..?...W..?.1..?
.??...11.....??...??.

result:

wrong answer 2nd lines differ - expected: '?..?.W..?...?..1.0..?', found: '?..0.W..?...?..1.0..?'