QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129886#4365. Clock BreakingsilxiAC ✓4ms3760kbC++204.6kb2023-07-23 03:04:082023-07-23 03:04:08

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-23 03:04:08]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3760kb
  • [2023-07-23 03:04:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// Template {{{
#define REP(n) for (int _=0; _<(n); _++)
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

namespace std {
  template<class Fun>
  class y_combinator_result {
    Fun fun_;
  public:
    template<class T>
    explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
   
    template<class ...Args>
    decltype(auto) operator()(Args &&...args) {
      return fun_(std::ref(*this), std::forward<Args>(args)...);
    }
  };
   
  template<class Fun>
  decltype(auto) y_combinator(Fun &&fun) {
    return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
  }
} // namespace std

#define DEBUG(x) cerr << #x << ": " << x << '\n'
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) { 
  return os << '(' << p.first << ", " << p.second << ')'; 
}
template<typename T_container, 
  typename T = typename enable_if<!is_same<T_container, string>::value, 
  typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { 
  os << '['; string sep; 
  for (const T &x : v) 
    os << sep << x, sep = ", "; 
  return os << ']'; 
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

array<int, 2> pos[] = {
{0, 1},
{1, 0},
{1, 3},
{3, 1},
{4, 0},
{4, 3},
{6, 1}
};
array<int, 2> pos2[] = {
{0, 2},
{2, 0},
{2, 3},
{3, 2},
{5, 0},
{5, 3},
{6, 2}
};
int COL[] = {0, 5, 12, 17};

array<int, 7> digits[] = {
{1, 1, 1, 0, 1, 1, 1},
{0, 0, 1, 0, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1},
{1, 0, 1, 1, 0, 1, 1},
{0, 1, 1, 1, 0, 1, 0},
{1, 1, 0, 1, 0, 1, 1},
{1, 1, 0, 1, 1, 1, 1},
{1, 0, 1, 0, 0, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1},
};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int N; cin >> N;
  vector<array<int, 30>> A(N);
  vector<string> g(7);
  F0R(i, N) {
    F0R(j, 7) {
      cin >> g[j];
    }
    int cnt = 0;
    F0R(j, 4) {
      F0R(k, 7) {
        A[i][cnt++] = g[pos[k][0]][COL[j] + pos[k][1]] == 'X';
      }
    }
    A[i][cnt++] = g[2][10] == 'X';
    A[i][cnt++] = g[4][10] == 'X';
  }
  array<int, 30> which;
  F0R(d, 30) {
    int a = 0, b = 0;
    F0R(i, N) {
      if (A[i][d] == 0) a++;
      else b++;
    }
    if (a == 0) which[d] = 1;
    else if (b == 0) which[d] = 0;
    else which[d] = 2;
  }

  vector<array<int, 30>> V;
  for (int hour = 0; hour < 24; hour++) {
    for (int min = 0; min < 60; min++) {
      array<int, 30> a; F0R(d, 30) a[d] = 0;
      int cnt = 0;
      if (hour/10 > 0) F0R(i, 7) a[cnt++] = digits[hour/10][i];
      else cnt += 7;
      F0R(i, 7) a[cnt++] = digits[hour%10][i];
      F0R(i, 7) a[cnt++] = digits[min/10][i];
      F0R(i, 7) a[cnt++] = digits[min%10][i];
      a[cnt++] = 1;
      a[cnt++] = 1;
      V.push_back(a);
    }
  }

  array<char, 30> ans; F0R(d, 30) ans[d] = '#';
  int cnt = 0;
  F0R(i, sz(V)) {
    bool poss = true;
    array<char, 30> tr;
    F0R(d, 30) {
      if (which[d] == 0) {
        bool matches = 1;
        F0R(j, N) {
          if (A[j][d] != V[(i+j)%sz(V)][d]) {
            matches = false;
            break;
          }
        }
        tr[d] = matches ? '?' : '0';
      }
      else if (which[d] == 1) {
        bool matches = 1;
        F0R(j, N) {
          if (A[j][d] != V[(i+j)%sz(V)][d]) {
            matches = false;
            break;
          }
        }
        tr[d] = matches ? '?' : '1';
      }
      else if (which[d] == 2) {
        tr[d] = 'W';
        F0R(j, N) {
          if (A[j][d] != V[(i+j)%sz(V)][d]) {
            poss = false;
            break;
          }
        }
      }
      else assert(false);
    }
    if (poss) {
      cnt++;
      F0R(d, 30) {
        if (ans[d] == '?') continue;
        else ans[d] = tr[d];
      }
    }
  }
  if (cnt > 0) {
    vector<string> OUT(7, string(21, '.'));
    int c = 0;
    F0R(j, 4) {
      F0R(k, 7) {
        OUT[pos[k][0]][COL[j] + pos[k][1]] = ans[c];
        OUT[pos2[k][0]][COL[j] + pos2[k][1]] = ans[c];
        c++;
      }
    }
    OUT[2][10] = ans[c++];
    OUT[4][10] = ans[c++];
    for (auto s: OUT) {
      cout << s << '\n';
    }
  }
  else cout << "impossible\n";
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3660kb

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

result:

ok 7 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

2
......XX.....XX...XX.
...X....X...X..X.X..X
...X....X.X.X..X.X..X
......XX..........XX.
...X.X....X.X..X.X..X
...X.X......X..X.X..X
......XX.....XX...XX.

......XX.....XX......
...X....X...X..X.....
...X....X.X.X..X.....
......XX.............
...X.X....X.X..X.....
...X.X......X..X.....
......XX......

output:

impossible

result:

ok single line: 'impossible'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

3
.XX...XX.....XX...XX.
...X.X..X...X..X....X
...X.X..X.X.X..X....X
.XX..........XX...XX.
X....X..X......X.X..X
X....X..X......X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
...X.X..X...X..X....X
...X.X..X.X.X..X....X
.XX..........XX...XX.
X....X..X......X.X..X
X....X..X......X.X..X
.XX...XX......

output:

.??...WW.....??...??.
?..?.W..?...?..1.0..?
?..?.W..?.?.?..1.0..?
.??...??.....11...WW.
?..?.W..?.0.W..?.1..?
?..?.W..?...W..?.1..?
.??...11.....??...??.

result:

ok 7 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

2
.....................
.....................
..........X..........
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3660kb

input:

1
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

output:

.??...??.....??...??.
?..?.?..?...?..?.?..?
?..?.?..?.?.?..?.?..?
.??...??.....??...??.
?..?.?..?.?.?..?.?..?
?..?.?..?...?..?.?..?
.??...??.....??...??.

result:

ok 7 lines

Test #6:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

3
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

.....................
.....................
..........X..........
.....................
..........X..........
.....................
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.?..0
?..?.?..?.?.?..?.?..0
.??...??.....??...00.
?..?.?..?.?.?..?.?..0
?..?.?..?...?..?.?..0
.??...??.....??...00.

result:

ok 7 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

10
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

.....................
.....................
..........X..........
.....................
..........X..........
.....................
.............

output:

.??...??.....??...00.
?..?.?..?...?..?.0..0
?..?.?..?.?.?..?.0..0
.??...??.....??...00.
?..?.?..?.?.?..?.0..0
?..?.?..?...?..?.0..0
.??...??.....??...00.

result:

ok 7 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

25
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

.....................
.....................
..........X..........
.....................
..........X..........
.....................
.............

output:

.??...??.....00...00.
?..?.?..?...?..0.0..0
?..?.?..?.?.?..0.0..0
.??...??.....00...00.
?..?.?..?.?.?..0.0..0
?..?.?..?...?..0.0..0
.??...??.....00...00.

result:

ok 7 lines

Test #9:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

50
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

.....................
.....................
..........X..........
.....................
..........X..........
.....................
.............

output:

.??...??.....00...00.
?..?.?..?...0..0.0..0
?..?.?..?.?.0..0.0..0
.??...??.....00...00.
?..?.?..?.?.0..0.0..0
?..?.?..?...0..0.0..0
.??...??.....00...00.

result:

ok 7 lines

Test #10:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

100
.....................
.....................
..........X..........
.....................
..........X..........
.....................
.....................

.....................
.....................
..........X..........
.....................
..........X..........
.....................
............

output:

.??...00.....00...00.
?..?.?..?...0..0.0..0
?..?.?..?.?.0..0.0..0
.??...??.....00...00.
?..?.?..0.?.0..0.0..0
?..?.?..0...0..0.0..0
.??...00.....00...00.

result:

ok 7 lines

Test #11:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

1
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

output:

.??...??.....??...??.
1..?.?..?...?..?.?..?
1..?.?..?.?.?..?.?..?
.??...??.....??...??.
?..?.?..?.?.?..?.?..?
?..?.?..?...?..?.?..?
.??...??.....??...??.

result:

ok 7 lines

Test #12:

score: 0
Accepted
time: 2ms
memory: 3700kb

input:

3
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX......

output:

.??...??.....??...??.
1..?.?..?...?..?.?..?
1..?.?..?.?.?..?.?..?
.??...??.....??...??.
?..?.?..?.?.?..?.1..?
?..?.?..?...?..?.1..?
.??...??.....??...??.

result:

ok 7 lines

Test #13:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

10
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....

output:

.??...??.....??...11.
1..?.?..?...?..?.1..1
1..?.?..?.?.?..?.1..1
.??...??.....??...11.
?..?.?..?.?.?..?.1..1
?..?.?..?...?..?.1..1
.??...??.....??...11.

result:

ok 7 lines

Test #14:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

25
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....

output:

.??...??.....11...11.
1..?.?..?...?..?.1..1
1..?.?..?.?.?..?.1..1
.??...??.....??...11.
?..?.?..?.?.1..?.1..1
?..?.?..?...1..?.1..1
.??...??.....11...11.

result:

ok 7 lines

Test #15:

score: 0
Accepted
time: 3ms
memory: 3684kb

input:

50
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....

output:

.??...??.....11...11.
1..?.?..?...1..?.1..1
1..?.?..?.?.1..?.1..1
.??...??.....11...11.
?..?.?..?.?.1..?.1..1
?..?.?..?...1..?.1..1
.??...??.....11...11.

result:

ok 7 lines

Test #16:

score: 0
Accepted
time: 4ms
memory: 3720kb

input:

100
.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX.....XX...XX.

.XX...XX.....XX...XX.
X..X.X..X...X..X.X..X
X..X.X..X.X.X..X.X..X
.XX...XX.....XX...XX.
X..X.X..X.X.X..X.X..X
X..X.X..X...X..X.X..X
.XX...XX....

output:

.??...??.....11...11.
1..?.?..?...1..1.1..1
1..?.?..?.?.1..1.1..1
.??...??.....11...11.
?..?.1..?.?.1..1.1..1
?..?.1..?...1..1.1..1
.??...??.....11...11.

result:

ok 7 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

..................XX.
.....................
.....................
.....................
.....................
.....................
..............

output:

.??...??.....??...WW.
?..?.?..?...?..?.?..0
?..?.?..?.0.?..?.?..0
.??...??.....??...00.
?..?.?..?.0.?..?.?..0
?..?.?..?...?..?.?..0
.??...??.....??...00.

result:

ok 7 lines

Test #18:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

..................XX.
.....................
.....................
.....................
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
....................X
....................X
.....................
.....................
.....................
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.0..W
?..?.?..?.0.?..?.0..W
.??...??.....??...00.
?..?.?..?.0.?..?.0..0
?..?.?..?...?..?.0..0
.??...??.....??...00.

result:

ok 7 lines

Test #20:

score: 0
Accepted
time: 2ms
memory: 3760kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
....................X
....................X
.....................
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
....................X
....................X
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.?..0
?..?.?..?.0.?..?.?..0
.??...??.....??...00.
?..?.?..?.0.?..?.0..W
?..?.?..?...?..?.0..W
.??...??.....??...00.

result:

ok 7 lines

Test #22:

score: 0
Accepted
time: 2ms
memory: 3700kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
....................X
....................X
..............

output:

impossible

result:

ok single line: 'impossible'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
.....................
.....................
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.?..0
?..?.?..?.0.?..?.?..0
.??...??.....??...00.
?..?.?..?.0.?..?.?..0
?..?.?..?...?..?.?..0
.??...??.....??...WW.

result:

ok 7 lines

Test #24:

score: 0
Accepted
time: 2ms
memory: 3676kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
.................X...
.................X...
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.?..?
?..?.?..?.0.?..?.?..?
.??...??.....??...00.
?..?.?..?.0.?..?.W..0
?..?.?..?...?..?.W..0
.??...??.....??...00.

result:

ok 7 lines

Test #26:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
.....................
.................X...
.................X...
..............

output:

impossible

result:

ok single line: 'impossible'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.................X...
.................X...
.....................
.....................
.....................
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.W..0
?..?.?..?.0.?..?.W..0
.??...??.....??...00.
?..?.?..?.0.?..?.?..0
?..?.?..?...?..?.?..0
.??...??.....??...00.

result:

ok 7 lines

Test #28:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.................X...
.................X...
.....................
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #29:

score: 0
Accepted
time: 2ms
memory: 3760kb

input:

2
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
..................XX.
.....................
.....................
..............

output:

.??...??.....??...00.
?..?.?..?...?..?.?..0
?..?.?..?.0.?..?.?..0
.??...??.....??...WW.
?..?.?..?.0.?..?.0..0
?..?.?..?...?..?.0..0
.??...??.....??...00.

result:

ok 7 lines

Test #30:

score: 0
Accepted
time: 2ms
memory: 3756kb

input:

3
.....................
.....................
.....................
.....................
.....................
.....................
.....................

.....................
.....................
.....................
..................XX.
.....................
.....................
..............

output:

impossible

result:

ok single line: 'impossible'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

2
.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.

.XX..........XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
..............

output:

.WW...00.....??...??.
?..0.0..0...?..1.?..?
?..0.0..0.0.?..1.?..?
.00...00.....11...11.
0..0.0..0.0.1..?.1..?
0..0.0..0...1..?.1..?
.00...00.....??...??.

result:

ok 7 lines

Test #32:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

2
.XX..........XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.

.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
..............

output:

.WW...00.....??...??.
?..0.0..0...?..1.?..?
?..0.0..0.0.?..1.?..?
.00...00.....11...11.
0..?.0..0.0.1..?.1..?
0..?.0..0...1..?.1..?
.00...00.....??...??.

result:

ok 7 lines

Test #33:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

3
.XX..........XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.

.............XX...XX.
............X..X.X..X
............X..X.X..X
.............XX...XX.
............X..X.X..X
............X..X.X..X
..............

output:

impossible

result:

ok single line: 'impossible'

Test #34:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

42
.............XX...XX.
X..X.X.........X.X..X
X..X.X.........X.X..X
.XX..................
...X.X..X......X.....
...X.X..X......X.....
.XX..........XX......

.............XX......
X..X.X.........X.X..X
X..X.X.........X.X..X
.XX..................
...X.X..X......X.....
...X.X..X......X.....
.XX..........

output:

.??...??.....11...WW.
1..?.?..?...W..W.1..1
1..?.?..?.0.W..W.1..1
.??...??.....00...00.
?..?.?..?.0.0..1.0..0
?..?.?..?...0..1.0..0
.??...??.....11...00.

result:

ok 7 lines

Test #35:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

37
.XX...XX.....XX...XX.
X..X....X........X...
X..X....X.X......X...
.XX...............XX.
...X.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...
.XX..................
...X.X....X.X..X....X
...X.X......X..X....X
......XX.....

output:

.??...??.....11...11.
1..?.0..?...0..0.1..0
1..?.0..?.?.0..0.1..0
.??...??.....00...WW.
?..?.1..0.?.1..1.0..W
?..?.1..0...1..1.0..W
.??...WW.....WW...00.

result:

ok 7 lines

Test #36:

score: 0
Accepted
time: 3ms
memory: 3700kb

input:

47
......XX.....XX...XX.
........X...X.......X
........X.X.X.......X
.............XX......
.....X..X.X.X..X.....
.....X..X...X..X.....
.............XX...XX.

......XX.....XX...XX.
........X...X..X....X
........X.X.X..X....X
.....................
.....X..X.X.X..X.....
.....X..X...X..X.....
......XX.....

output:

.??...??.....WW...WW.
?..?.?..?...W..W.0..1
?..?.?..?.?.W..W.0..1
.??...00.....WW...00.
?..?.1..?.?.1..W.0..0
?..?.1..?...1..W.0..0
.??...WW.....11...11.

result:

ok 7 lines

Test #37:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

36
......XX.....XX...XX.
........X......X.X..X
........X......X.X..X
......XX.....XX...XX.
.....X...........X...
.....X...........X...
......XX.....XX...XX.

......XX.....XX...XX.
........X......X.X..X
........X......X.X..X
......XX.....XX...XX.
.....X..............X
.....X..............X
......XX.....

output:

.??...??.....WW...WW.
?..?.?..?...W..W.1..W
?..?.?..?.0.W..W.1..W
.??...??.....??...WW.
?..?.?..?.0.0..W.W..W
?..?.?..?...0..W.W..W
.??...??.....WW...WW.

result:

ok 7 lines