# Why? Too weird, correct locally but faild after submitting on case : "XOX" "XOX" "XOX"

• ``````typedef long long llong;

class Solution {
public:
int h, w;

inline llong Pair(llong x, llong y) {
return (x<<32)|y;
}

void fill(vector<vector<char> > &board, int x, int y, char c) {
char tmp=board[x][y];
queue<llong> q;
unordered_set<long> dict;
llong p=Pair(x,y);
q.push(p);
dict.insert(p);
while (!q.empty()) {
llong p = q.front();
q.pop();
int x=p>>32, y=p&(unsigned)0xffffffffll;
board[x][y]=c;
if (x>0 && board[x-1][y]==tmp && dict.find((p=Pair(x-1, y)))==dict.end())
q.push(p), dict.insert(p);
if (x<h-1 && board[x+1][y]==tmp && dict.find((p=Pair(x+1, y)))==dict.end())
q.push(p), dict.insert(p);
if (y>0 && board[x][y-1]==tmp && dict.find((p=Pair(x, y-1)))==dict.end())
q.push(p), dict.insert(p);
if (y<w-1 && board[x][y+1]==tmp && dict.find((p=Pair(x, y+1)))==dict.end())
q.push(p), dict.insert(p);
}
}

void solve(vector<vector<char> > &board) {
if (!board.size() || !board[0].size())
return;
h=board.size(), w=board[0].size();
for (int i=0;i<h;i++) {
if (board[i][0]=='O')
fill(board, i, 0, 'Q');
if (board[i][w-1]=='O')
fill(board, i, w-1, 'Q');
}
for (int i=0;i<w;i++) {
if (board[0][i]=='O')
fill(board, 0, i, 'Q');
if (board[h-1][i]=='O')
fill(board, h-1, i, 'Q');
}
for (int i=1;i<h-1;i++)
for (int j=1;j<w-1;j++)
if (board[i][j]=='O')
fill(board, i, j, 'X');
for (int i=0;i<h;i++)
for (int j=0;j<w;j++)
if (board[i][j]=='Q')
board[i][j]='O';
}
};``````

• What's the differences between local and OJ?

• Local output on this case is:

X O X

X O X

X O X

while OJ output is:

X O X

X X X

X O X

• Same problem.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.