QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342546#4084. 카드 뒤집기 게임duongnc00050 39ms23196kbC++205.3kb2024-03-01 12:33:392024-03-01 12:33:40

Judging History

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

  • [2024-03-01 12:33:40]
  • 评测
  • 测评结果:50
  • 用时:39ms
  • 内存:23196kb
  • [2024-03-01 12:33:39]
  • 提交

answer

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;

struct two_sat_solver{
private:
    int n;
    vector<vector<int>> adj;
    vector<int> val, comp, z;
public:
    vector<int> value;
    two_sat_solver(int n = 0): n(n), adj(n << 1){ }
    int add_variable(){
        adj.emplace_back();
        adj.emplace_back();
        return n ++;
    }
    void either(int u, int v){
        u = max(2 * u, -1 - 2 * u);
        v = max(2 * v, -1 - 2 * v);
        adj[u].push_back(v ^ 1);
        adj[v].push_back(u ^ 1);
    }
    void implies(int u, int v){
        either(~u, v);
    }
    void equals(int u, int v){
        either(~u, v), either(u, ~v);
    }
    void differs(int u, int v){
        either(u, v), either(~u, ~v);
    }
    void set_value(int u, bool x = true){
        x ? either(u, u) : either(~u, ~u);
    }
    void at_most_one(const vector<int> &arr){
        if((int)arr.size() <= 1) return;
        int cur = ~arr[0];
        for(auto u = 2; u < (int)arr.size(); ++ u){
            int next = add_variable();
            either(cur, ~arr[u]), either(cur, next), either(~arr[u], next);
            cur = ~next;
        }
        either(cur, ~arr[1]);
    }
    int time, comp_cnt;
    int dfs(int u){
        int low = val[u] = ++ time, v;
        z.push_back(u);
        for(auto v: adj[u]) if(!~comp[v]) low = min(low, val[v] ?: dfs(v));
        ++ time;
        if(low == val[u]){
            do{
                v = z.back();
                z.pop_back();
                comp[v] = comp_cnt;
                if(value[v >> 1] == -1) value[v >> 1] = v & 1;
            }while(v != u);
            comp_cnt ++;
        }
        return val[u] = low;
    }
    // O(n)
    bool solve(){
        value.assign(n, -1);
        val.assign(2 * n, 0);
        comp.assign(2 * n, -1);
        time = comp_cnt = 0;
        for(auto u = 0; u < n << 1; ++ u) if(!~comp[u]) dfs(u);
        for(auto u = 0; u < n; ++ u) if(comp[u << 1] == comp[u << 1 ^ 1]) return false;
        return true;
    }
    // Enumerate solutions while act_while() returns true.
    // O(n^2 + (m + n * (# of solutions found))*S/w)
    template<size_t S>
    bool enumerate_solutions(auto act_while){
        assert(2 * n <= S);
        if(!solve()) return false;
        fill(value.begin(), value.end(), -1);
        bitset<S> has_value;
        vector<vector<int>> has(comp_cnt);
        vector<bitset<S>> reachable(n << 1);
        for(auto u = 0; u < n << 1; ++ u) has[comp[u]].push_back(u);
        vector<int> vis(comp_cnt, -1);
        for(auto t = 0; t < comp_cnt; ++ t){
            int u = has[t][0];
            vis[t] = t;
            for(auto v: has[t]){
                reachable[u].set(v);
                for(auto w: adj[v]) if(vis[comp[w]] != t){
                    vis[comp[w]] = t;
                    reachable[u] |= reachable[w];
                }
            }
            for(auto v: has[t]) reachable[v] = reachable[u];
        }
        for(auto u = 0; u < n << 1; ++ u){
            if(!reachable[u][u ^ 1]) continue;
            has_value[u] = has_value[u ^ 1] = true;
            value[u >> 1] = ~u & 1;
            for(auto v = 0; v < n << 1; ++ v) if(reachable[u ^ 1][v]){
                has_value[v] = has_value[v ^ 1] = true;
                value[v >> 1] = v & 1;
            }
        }
        vector<bitset<S>> delta(comp_cnt);
        auto dfs = [&](auto self, int t)->bool{
            if(!~t) return act_while(value);
            int u = has[t][0];
            if(~value[u >> 1]) return self(self, t - 1);
            for(auto v: has[t]){
                has_value[v] = has_value[v ^ 1] = true;
                value[v >> 1] = ~v & 1;
            }
            if(!self(self, t - 1)) return false;
            for(auto v: has[t]) value[v >> 1] = v & 1;
            delta[t] = reachable[u] & ~has_value;
            for(auto v = delta[t]._Find_first(); v != S; v = delta[t]._Find_next(v)){
                has_value[v] = has_value[v ^ 1] = true;
                value[v >> 1] = v & 1;
            }
            if(!self(self, t - 1)) return false;
            for(auto v: has[t]){
                has_value[v] = has_value[v ^ 1] = false;
                value[v >> 1] = -1;
            }
            for(auto v = delta[t]._Find_first(); v != S; v = delta[t]._Find_next(v)){
                has_value[v] = has_value[v ^ 1] = false;
                value[v >> 1] = -1;
            }
            return true;
        };
        dfs(dfs, comp_cnt - 1);
        return true;
    }
};

bool reversal(int n, int m, vector<string> a) {
    two_sat_solver tss(2 * m * n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (a[i][j] == 'X') tss.differs(i * m + i % m, j * m + j % m + m * n);
            else tss.equals(i * m + i % m, j * m + j % m + m * n);
        }
    }
    return tss.solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 0ms
memory: 3672kb

input:

10 1
OOOOOOOOOX
XOXXOOOOOO
XOOXOOOXOO
OOOOOOOOOO
OOOXOOOOOO
OOXOOXXOOO
OOOOXOOOOO
XOOOOOOOXO
OOOXXOOOXO
OOOOOOOOOO

output:

0

result:

ok single line: '0'

Test #2:

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

input:

10 1
OOOOOOOOXX
OOOOOOOOXX
XXXXXXXXOO
XXXXXXXXOO
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX

output:

1

result:

ok single line: '1'

Test #3:

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

input:

10 1
OOOOOOOOXX
OOOOOOOOXX
XXXXXXXOOO
XXXXXXXXOO
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX
OOOOOOOOXX

output:

0

result:

ok single line: '0'

Test #4:

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

input:

10 1
OOXOXOOOOX
XOOOOOXOOO
OOXOOXXOOO
OOOOOOOOXO
XOOOOOXOOX
OOOOXOXOXX
OXOOXOOXOX
OXXOOXOOOO
OOOXOXOOXO
OOOOOXOOOO

output:

0

result:

ok single line: '0'

Test #5:

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

input:

10 1
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
XOXOXXXXOO
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX

output:

1

result:

ok single line: '1'

Test #6:

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

input:

10 1
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
OXOXOOOOXX
XOXOXXXXOO
OXOXOOOOXX
OXXXOOOOXX
OXOXOOOOXX

output:

0

result:

ok single line: '0'

Test #7:

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

input:

10 1
XXXXXOOOXX
OOOOOXXOXO
XOOOOXXXXO
OOXOXOOOXO
XOOOOOOOXX
XXOXXOOXOO
XOXXOXXXOX
OOOXXXOXXX
XOXXXOXOXX
OXXXXXOXOO

output:

0

result:

ok single line: '0'

Test #8:

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

input:

10 1
OOOOXXXOOX
XXXXOOOXXO
XXXXOOOXXO
XXXXOOOXXO
XXXXOOOXXO
OOOOXXXOOX
OOOOXXXOOX
XXXXOOOXXO
OOOOXXXOOX
XXXXOOOXXO

output:

1

result:

ok single line: '1'

Test #9:

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

input:

10 1
OOOOXXXOOX
XXXXOOOXXO
XXXXOOOXXO
XXXXOOOXXO
XXXXOOOXXO
OOOOXXXOOX
OOOOXXXOOX
XXXXOOOXXO
OOOOXXXOOX
XXXOOOOXXO

output:

0

result:

ok single line: '0'

Test #10:

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

input:

10 1
XXOXXXXXXX
XXXOXXXOXX
XXXXOOXOXX
XXOOXXOOOX
XXXOXXOOXX
OOXXOXOXXX
XOXOXOXXXO
XXXOOXXXOX
OXOOXXXXOO
XXOXOOOXXO

output:

0

result:

ok single line: '0'

Test #11:

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

input:

10 1
OXOOOOOOOO
OXOOOOOOOO
OXOOOOOOOO
XOXXXXXXXX
OXOOOOOOOO
OXOOOOOOOO
OXOOOOOOOO
XOXXXXXXXX
OXOOOOOOOO
OXOOOOOOOO

output:

1

result:

ok single line: '1'

Test #12:

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

input:

10 1
OXOOOOOOOO
OXOOOOOOOO
OXOOOOOOOO
XOXXXXXXXX
OXOOOOOOOX
OXOOOOOOOO
OXOOOOOOOO
XOXXXXXXXX
OXOOOOOOOO
OXOOOOOOOO

output:

0

result:

ok single line: '0'

Test #13:

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

input:

10 1
XOXXXXOXXX
XXXXOOXXXX
OOXXOXXXXX
XXXOOXXOOX
OXXXXXXXXX
XXXXXXXXOX
XXXXXXXOXO
OXXXXXXXXX
XXXOOXXXOX
XXXXXXXXXX

output:

0

result:

ok single line: '0'

Test #14:

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

input:

10 1
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO
OXXXXOXXXX
OXXXXOXXXX
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO

output:

1

result:

ok single line: '1'

Test #15:

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

input:

10 1
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO
XOOOOXOOOO
OXXXXOXXXX
OXXXXOXXXX
XOOOOXOOOO
XOOOOXOOOX
XOOOOXOOOO
XOOOOXOOOO

output:

0

result:

ok single line: '0'

Test #16:

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

input:

5 2
XOOOX
XOXOO
OXXOO
OXOOO
OOOXO

output:

0

result:

ok single line: '0'

Test #17:

score: -11
Wrong Answer
time: 0ms
memory: 3496kb

input:

5 2
XOOXX
XOOXX
OOXXO
XOOXX
OOXXO

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 50
Accepted

Test #46:

score: 50
Accepted
time: 24ms
memory: 22736kb

input:

1000 1
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOXOOOOO...

output:

0

result:

ok single line: '0'

Test #47:

score: 0
Accepted
time: 36ms
memory: 22708kb

input:

1000 1
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOXOOOOOO...

output:

1

result:

ok single line: '1'

Test #48:

score: 0
Accepted
time: 24ms
memory: 22732kb

input:

1000 1
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOOOOXOOOOOOXOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOXOOOOOO...

output:

0

result:

ok single line: '0'

Test #49:

score: 0
Accepted
time: 37ms
memory: 22824kb

input:

1000 1
XOOOOOOOOOOOXOOOOXXOOOOOOOOOOOOOXOXOOXXOOOXOXXOOOXOXOXOOOOOOOOOOOOOOOOXOOOOXOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOXOXOXOXOOOOOOOOOOOOOOOOOOOOOXOOOOOOOXOOOOOOOOOOXOOOOOOOOOOOOOOOOOOXOOOOOXOOOOOOOOOOOOOOOOOOOOXOOOOOOXOOOOOXOXOXOOOOOOOOXOOOOOOOOOOXOOXXOOOOOOXOOOXOOOOOOOOOXOXOOOOOXOOOOOOOOOOOOOOOOO...

output:

0

result:

ok single line: '0'

Test #50:

score: 0
Accepted
time: 27ms
memory: 22736kb

input:

1000 1
XXXXXXXXXXXOXXXXOOXXXXXXXXXXXXXOXOXXOOXXXOXOOXXXOXOXOXXXXXXXXXXXXXXXXOXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXOXOXOXOXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXXXXOXXXXXXXXXXXXXXXXXXOXXXXXOXXXXXXXXXXXXXXXXXXXXOXXXXXXOXXXXXOXOXOXXXXXXXXOXXXXXXXXXXOXXOOXXXXXXOXXXOXXXXXXXXXOXOXXXXXOXXXXXXXXXXXXXXXXXX...

output:

1

result:

ok single line: '1'

Test #51:

score: 0
Accepted
time: 20ms
memory: 22724kb

input:

1000 1
XXXXXXXXXXXOXXXXOOXXXXXXXXXXXXXOXOXXOOXXXOXOOXXXOXOXOXXXXXXXXXXXXXXXXOXXXXOXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXOXOXOXOXXXXXXXXXXXXXXXXXXXXXOXXXXXXXOXXXXXXXXXXOXXXXXXXXXXXXXXXXXXOXXXXXOXXXXXXXXXXXXXXXXXXXXOXXXXXXOXXXXXOXOXOXXXXXXXXOXXXXXXXXXXOXXOOXXXXXXOXXXOXXXXXXXXXOXOXXXXXOXXXXXXXXXXXXXXXXXX...

output:

0

result:

ok single line: '0'

Test #52:

score: 0
Accepted
time: 39ms
memory: 22968kb

input:

1000 1
OOXXOOOXOOOOOOOOOOOOXXOOXOXXXXOOOOOXXOOXXOOXXOXOXOOOOOXOOOOOOXOOOOOOOOXOOOOOXXOOOOOXOOOOXXXXOXOOOOXXOOOXXXOXOOXOOXOOXOXOOOXOXOXOXOOOOOOOOOXOOOOXOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOXOXOOXOXOXOXOXOOXOOOOOOXOOOOOOOOOOOOXXOOXOOOOXOOOXOOOOOOXOXOXOOOOXOOOOOOOOOOOOXOOOOOOOOXOXOOXOOOOOOXOOOOOO...

output:

0

result:

ok single line: '0'

Test #53:

score: 0
Accepted
time: 29ms
memory: 22652kb

input:

1000 1
OXXOOOXOOOOOOOOOOOOXXOOXOXXXXOOOOOXXOOXXOOXXOXOXOOOOOXOOOOOOXOOOOOOOOXOOOOOXXOOOOOXOOOOXXXXOXOOOOXXOOOXXXOXOOXOOXOOXOXOOOXOXOXOXOOOOOOOOOXOOOOXOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOXOXOOXOXOXOXOXOOXOOOOOOXOOOOOOOOOOOOXXOOXOOOOXOOOXOOOOOOXOXOXOOOOXOOOOOOOOOOOOXOOOOOOOOXOXOOXOOOOOOXOOOOOOO...

output:

1

result:

ok single line: '1'

Test #54:

score: 0
Accepted
time: 28ms
memory: 22660kb

input:

1000 1
OXXOOOXOOOOOOOOOOOOXXOOXOXXXXOOOOOXXOOXXOOXXOXOXOOOOOXOOOOOOXOOOOOOOOXOOOOOXXOOOOOXOOOOXXXXOXOOOOXXOOOXXXOXOOXOOXOOXOXOOOXOXOXOXOOOOOOOOOXOOOOXOOOXOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOXOXOOXOXOXOXOXOOXOOOOOOXOOOOOOOOOOOOXXOOXOOOOXOOOXOOOOOOXOXOXOOOOXOOOOOOOOOOOOXOOOOOOOOXOXOOXOOOOOOXOOOOOOO...

output:

0

result:

ok single line: '0'

Test #55:

score: 0
Accepted
time: 31ms
memory: 22944kb

input:

1000 1
OOOOOOXOOXXXOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOXXOOXXOXXOXOXXOOOOOOXXOXOOOXXXOOXOOOOOOOXOOOOXOOXXOOOOOOXOOOXOOOOOOOXOXOOXOXXXOXOOOOXOOOOOXOXOXXOOOXOOOOOOXXOOXOOOXOOXXOOXOXOOOOOOOOOOXOXOOXOXOXOXOOOOOOOXXOOOXOXOOOOXXXOOOOOXXOXOOXOOXOXOXOXOXOXOOOXOXOXXXOXOXOOOOXOOOXXOOXXXOOOOXOXOXXOOOXXOXXOOOOOXOOOO...

output:

0

result:

ok single line: '0'

Test #56:

score: 0
Accepted
time: 24ms
memory: 22648kb

input:

1000 1
OOOOOXOOXXXOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOXXOOXXOXXOXOXXOOOOOOXXOXOOOXXXOOXOOOOOOOXOOOOXOOXXOOOOOOXOOOXOOOOOOOXOXOOXOXXXOXOOOOXOOOOOXOXOXXOOOXOOOOOOXXOOXOOOXOOXXOOXOXOOOOOOOOOOXOXOOXOXOXOXOOOOOOOXXOOOXOXOOOOXXXOOOOOXXOXOOXOOXOXOXOXOXOXOOOXOXOXXXOXOXOOOOXOOOXXOOXXXOOOOXOXOXXOOOXXOXXOOOOOXOOOOX...

output:

1

result:

ok single line: '1'

Test #57:

score: 0
Accepted
time: 33ms
memory: 22736kb

input:

1000 1
OOOOOXOOXXXOOOOOXOOOOOOOOOOOXOOOOOOOXOOOOOXXOOXXOXXOXOXXOOOOOOXXOXOOOXXXOOXOOOOOOOXOOOOXOOXXOOOOOOXOOOXOOOOOOOXOXOOXOXXXOXOOOOXOOOOOXOXOXXOOOXOOOOOOXXOOXOOOXOOXXOOXOXOOOOOOOOOOXOXOOXOXOXOXOOOOOOOXXOOOXOXOOOOXXXOOOOOXXOXOOXOOXOXOXOXOXOXOOOXOXOXXXOXOXOOOOXOOOXXOOXXXOOOOXOXOXXOOOXXOXXOOOOOXOOOOX...

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 32ms
memory: 22816kb

input:

1000 1
XOOXOXOOXOOXXOXOOOXOOOOXOOXOXOXXXXXXXOXXOOXXXOOOXXOOOOOOOOXOOOXOXOOXOOXOOOXOXXOOOOXOOOOOXOOOXOOXOOOOOXOOOXXOOXOOOOXXXXOXXOOXXOXXXOXOOOOXXXXXXOOXXXOOXXOXOOXXXXXOXOXXXOOOXOOOXXOXXXXXOXOXOOOOOOOXXXOOXOOXXXXXXOXXOOOOXOOXOOXOXXOOXOOOXOXOXXXXOOOXOOOXXXOXXOOOOOXXOXOOOXXXXXOOOOXXOXXOOOXXXOOOOXXOXXOOX...

output:

0

result:

ok single line: '0'

Test #59:

score: 0
Accepted
time: 34ms
memory: 22732kb

input:

1000 1
XXOXOXXOXXOOXOXXXOXXXXOXXOXOXOOOOOOOXOOXXOOOXXXOOXXXXXXXXOXXXOXOXXOXXOXXXOXOOXXXXOXXXXXOXXXOXXOXXXXXOXXXOOXXOXXXXOOOOXOOXXOOXOOOXOXXXXOOOOOOXXOOOXXOOXOXXOOOOOXOXOOOXXXOXXXOOXOOOOOXOXOXXXXXXXOOOXXOXXOOOOOOXOOXXXXOXXOXXOXOOXXOXXXOXOXOOOOXXXOXXXOOOXOOXXXXXOOXOXXXOOOOOXXXXOOXOOXXXOOOXXXXOOXOOXXOX...

output:

1

result:

ok single line: '1'

Test #60:

score: 0
Accepted
time: 32ms
memory: 22724kb

input:

1000 1
XXOXOXXOXXOOXOXXXOXXXXOXXOXOXOOOOOOOXOOXXOOOXXXOOXXXXXXXXOXXXOXOXXOXXOXXXOXOOXXXXOXXXXXOXXXOXXOXXXXXOXXXOOXXOXXXXOOOOXOOXXOOXOOOXOXXXXOOOOOOXXOOOXXOOXOXXOOOOOXOXOOOXXXOXXXOOXOOOOOXOXOXXXXXXXOOOXXOXXOOOOOOXOOXXXXOXXOXXOXOOXXOXXXOXOXOOOOXXXOXXXOOOXOOXXXXXOOXOXXXOOOOOXXXXOOXOOXXXOOOXXXXOOXOOXXOX...

output:

0

result:

ok single line: '0'

Test #61:

score: 0
Accepted
time: 31ms
memory: 22876kb

input:

1000 1
XOXXOXXXXXXOXXOOXXOXOOXOXOXXOOXOOXXOOXXOXOOXXXXXXOXXXXXXXOXOOXXXXXOOOXXXOOXXXOOOOXXOOXXOXXXOXXOOXXOOXXOOXOOXOOXOXOXXXXOXOXOOOXOOOOXOXXXOXOXOXXXOXXOXOXXXXOXOXOOXXOOOXOOOXOXOXOXXOXOXXOOXXXXXOOOXOXXOXOXOXXXOOOXXOOOOXOXXOXOOOOXXOXXOOXXOOOXXXOOXOOOXOXOXOOXXXXXOOXXOOOOOOXXXXOXOOXXOXXOXXXOOOXXXXXOOO...

output:

0

result:

ok single line: '0'

Test #62:

score: 0
Accepted
time: 33ms
memory: 22724kb

input:

1000 1
XOOXOOOOOOXOOXXOOXOXXOXOXOOXXOXXOOXXOOXOXXOOOOOOXOOOOOOOXOXXOOOOOXXXOOOXXOOOXXXXOOXXOOXOOOXOOXXOOXXOOXXOXXOXXOXOXOOOOXOXOXXXOXXXXOXOOOXOXOXOOOXOOXOXOOOOXOXOXXOOXXXOXXXOXOXOXOOXOXOOXXOOOOOXXXOXOOXOXOXOOOXXXOOXXXXOXOOXOXXXXOOXOOXXOOXXXOOOXXOXXXOXOXOXXOOOOOXXOOXXXXXXOOOOXOXXOOXOOXOOOXXXOOOOOXXXO...

output:

1

result:

ok single line: '1'

Test #63:

score: 0
Accepted
time: 29ms
memory: 22860kb

input:

1000 1
XOOXOOOOOOXOOXXOOXOXXOXOXOOXXOXXOOXXOOXOXXOOOOOOXOOOOOOOXOXXOOOOOXXXOOOXXOOOXXXXOOXXOOXOOOXOOXXOOXXOOXXOXXOXXOXOXOOOOXOXOXXXOXXXXOXOOOXOXOXOOOXOOXOXOOOOXOXOXXOOXXXOXXXOXOXOXOOXOXOOXXOOOOOXXXOXOOXOXOXOOOXXXOOXXXXOXOOXOXXXXOOXOOXXOOXXXOOOXXOXXXOXOXOXXOOOOOXXOOXXXXXXOOOOXOXXOOXOOXOOOXXXOOOOOXXXO...

output:

0

result:

ok single line: '0'

Test #64:

score: 0
Accepted
time: 36ms
memory: 22868kb

input:

1000 1
OXXOOXXOXXXOOXXOXOXXXXXXXOOXXOXXXXXXXXOXXOXXXXOXXXXOOOOXXOXOOXOXXXXXOXXXXXOOXXXOOOXOXOXXXXXXXXXXXOXOXXOOXXXOOXXXXOOXXOOOXXOXXOXOXOXXXXXOXXXXOXXXOXXOXXXOXXXXXOXXXXXXOOXOXOXOXOXOXOXXXXXXXOXXXXOXXXXXXXXXOOOOOOXXXXOOOOXXXOXXOOXOXXXXXXXXXOXXOOXXXXOXXXXXXXXXOXXXOOXXOOXOOOXXXXOXOXXOXXXXOOXOXXOOXXXXX...

output:

0

result:

ok single line: '0'

Test #65:

score: 0
Accepted
time: 28ms
memory: 22648kb

input:

1000 1
XXOOXXOXXXOOXXOXOXXXXXXXOOXXOXXXXXXXXOXXOXXXXOXXXXOOOOXXOXOOXOXXXXXOXXXXXOOXXXOOOXOXOXXXXXXXXXXXOXOXXOOXXXOOXXXXOOXXOOOXXOXXOXOXOXXXXXOXXXXOXXXOXXOXXXOXXXXXOXXXXXXOOXOXOXOXOXOXOXXXXXXXOXXXXOXXXXXXXXXOOOOOOXXXXOOOOXXXOXXOOXOXXXXXXXXXOXXOOXXXXOXXXXXXXXXOXXXOOXXOOXOOOXXXXOXOXXOXXXXOOXOXXOOXXXXXO...

output:

1

result:

ok single line: '1'

Subtask #3:

score: 0
Wrong Answer

Test #66:

score: 39
Accepted
time: 28ms
memory: 22852kb

input:

1000 1
XXOOXXOXXXOOXXOXOXXXXXXXOOXXOXXXXXXXXOXXOXXXXOXXXXOOOOXXOXOOXOXXXXXOXXXXXOOXXXOOOXOXOXXXXXXXXXXXOXOXXOOXXXOOXXXXOOXXOOOXXOXXOXOXOXXXXXOXXXXOXXXOXXOXXXOXXXXXOXXXXXXOOXOXOXOXOXOXOXXXXXXXOXXXXOXXXXXXXXXOOOOOOXXXXOOOOXXXOXXOOXOXXXXXXXXXOXXOOXXXXOXXXXXXXXXOXXXOOXXOOXOOOXXXXOXOXXOXXXXOOXOXXOOXXXXXO...

output:

0

result:

ok single line: '0'

Test #67:

score: 0
Accepted
time: 34ms
memory: 23056kb

input:

1000 1
XXXXXXXXXOOXXXXOXXXXXXXXXXXOXXXXXOOOXXXOXOXXXXXXXXOXXXXOOXOXXOXXXXOOOXXXXXXXXXXOOXOXXXOOXOXXXXXXXXXXOOXXXXXXOXXOOXXXXXOOXXXXXXXXXOXXXXXXXXXXXXOXXXXXXOXXOXXOXXOOXXXXOOXOXOXXXXXXOOXOXOXXXXXOXXOXOXOXOXXOXOXOXXXXXXXOXXOXXXXXXXXXXOXXXXOOXXOXXOXXXXXXXXOXOOXXXOXOOXXXOXXXXXXXXOXXXXXXOXXXXXXOXXXXXOXXO...

output:

0

result:

ok single line: '0'

Test #68:

score: 0
Accepted
time: 22ms
memory: 22648kb

input:

1000 1
OOOOOOOOXXOOOOXOOOOOOOOOOOXOOOOOXXXOOOXOXOOOOOOOOXOOOOXXOXOOXOOOOXXXOOOOOOOOOOXXOXOOOXXOXOOOOOOOOOOXXOOOOOOXOOXXOOOOOXXOOOOOOOOOXOOOOOOOOOOOOXOOOOOOXOOXOOXOOXXOOOOXXOXOXOOOOOOXXOXOXOOOOOXOOXOXOXOXOOXOXOXOOOOOOOXOOXOOOOOOOOOOXOOOOXXOOXOOXOOOOOOOOXOXXOOOXOXXOOOXOOOOOOOOXOOOOOOXOOOOOOXOOOOOXOOXO...

output:

1

result:

ok single line: '1'

Test #69:

score: 0
Accepted
time: 33ms
memory: 22644kb

input:

1000 1
OOOOOOOOXXOOOOXOOOOOOOOOOOXOOOOOXXXOOOXOXOOOOOOOOXOOOOXXOXOOXOOOOXXXOOOOOOOOOOXXOXOOOXXOXOOOOOOOOOOXXOOOOOOXOOXXOOOOOXXOOOOOOOOOXOOOOOOOOOOOOXOOOOOOXOOXOOXOOXXOOOOXXOXOXOOOOOOXXOXOXOOOOOXOOXOXOXOXOOXOXOXOOOOOOOXOOXOOOOOOOOOOXOOOOXXOOXOOXOOOOOOOOXOXXOOOXOXXOOOXOOOOOOOOXOOOOOOXOOOOOOXOOOOOXOOXO...

output:

0

result:

ok single line: '0'

Test #70:

score: 0
Accepted
time: 33ms
memory: 23056kb

input:

1000 1
XXOOXXXXXXXXXXXXXXOXXXXXOXXXXXXOXXXXXXXXXOXXXXXXXOXXOXXXXXOXXXXXXOXXOXXXXXXXOXXOOXXXXOXXXXXXXOXOXXXXXOXXXXXXXXXXXXXOXXOXXXXXXXXXXXOXXXXXOOXXXXXXXXXXXOXXXOXXXXXXXOXOXXXXXXXXXXOXXXXOXXXOXXXXXXXOXXXXOXXXOXXXXXXXXOXOXXXXOXXOXXXXOXXXOXOXXXXXXOXXXOXXXXXXXXXXXXOXXXXOOXXXXOXXOXXXXXXXXXOXXOXOXOOXXXXXX...

output:

0

result:

ok single line: '0'

Test #71:

score: 0
Accepted
time: 31ms
memory: 22696kb

input:

1000 1
OXXOOOOOOOOOOOOOOXOOOOOXOOOOOOXOOOOOOOOOXOOOOOOOXOOXOOOOOXOOOOOOXOOXOOOOOOOXOOXXOOOOXOOOOOOOXOXOOOOOXOOOOOOOOOOOOOXOOXOOOOOOOOOOOXOOOOOXXOOOOOOOOOOOXOOOXOOOOOOOXOXOOOOOOOOOOXOOOOXOOOXOOOOOOOXOOOOXOOOXOOOOOOOOXOXOOOOXOOXOOOOXOOOXOXOOOOOOXOOOXOOOOOOOOOOOOXOOOOXXOOOOXOOXOOOOOOOOOXOOXOXOXXOOOOOOX...

output:

1

result:

ok single line: '1'

Test #72:

score: 0
Accepted
time: 24ms
memory: 22900kb

input:

1000 1
OXXOOOOOOOOOOOOOOXOOOOOXOOOOOOXOOOOOOOOOXOOOOOOOXOOXOOOOOXOOOOOOXOOXOOOOOOOXOOXXOOOOXOOOOOOOXOXOOOOOXOOOOOOOOOOOOOXOOXOOOOOOOOOOOXOOOOOXXOOOOOOOOOOOXOOOXOOOOOOOXOXOOOOOOOOOOXOOOOXOOOXOOOOOOOXOOOOXOOOXOOOOOOOOXOXOOOOXOOXOOOOXOOOXOXOOOOOOXOOOXOOOOOOOOOOOOXOOOOXXOOOOXOOXOOOOOOOOOXOOXOXOXXOOOOOOX...

output:

0

result:

ok single line: '0'

Test #73:

score: 0
Accepted
time: 32ms
memory: 22652kb

input:

1000 1
OXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXOXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXO...

output:

0

result:

ok single line: '0'

Test #74:

score: 0
Accepted
time: 32ms
memory: 22732kb

input:

1000 1
XXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXOXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXOX...

output:

1

result:

ok single line: '1'

Test #75:

score: 0
Accepted
time: 35ms
memory: 22812kb

input:

1000 1
XXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXOXXXXXXOXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXXXXXXXXOXXXXOXXXXXXXXXXXXXXXXXXXXXXXXXOXXXXXXXXOX...

output:

0

result:

ok single line: '0'

Test #76:

score: 0
Accepted
time: 34ms
memory: 23196kb

input:

1000 2
OOOXOOOXOOOXOOOOOOOOOOOOOOOOOXXOOOOOOOOOOXOOOOOOOXOOOOXOOOOOOOOOXOOOOOOOOOXOOOOOOOOXOOOOOOOOOOOOOXOOOOOXOOOOOOOOOOOOOOOOXXOOOOOXOXOOOXOOOOOOOOOOOOOOOXXOXOOOXXOOOOXXOXOOXOOOOOOOOOOOOOXOOOOOXOOOOOXOOOXOXOOOOOOOOOOOOXOOXOXOOOOXXOOOXOOOOOOOOOOOXOOXXXOOOXXOOOOOOOOXOXOOXOOOOXXOOOOOOOXOXXOOOXOXOOOOO...

output:

0

result:

ok single line: '0'

Test #77:

score: -39
Wrong Answer
time: 22ms
memory: 23056kb

input:

1000 2
OXOOOXOOOXOOOOOOOOOOOOOOOOOXXOOOOOOOOOOXOOOOOOOXOOOOXOOOOOOOOOXOOOOOOOOOXOOOOOOOOXOOOOOOOOOOOOOXOOOOOXOOOOOOOOOOOOOOOOXXOOOOOXOXOOOXOOOOOOOOOOOOOOOXXOXOOOXXOOOOXXOXOOXOOOOOOOOOOOOOXOOOOOXOOOOOXOOOXOXOOOOOOOOOOOOXOOXOXOOOOXXOOOXOOOOOOOOOOOXOOXXXOOOXXOOOOOOOOXOXOOXOOOOXXOOOOOOOXOXXOOOXOXOOOOOOO...

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'