Last active
October 11, 2016 04:51
-
-
Save asi1024/c290a3d4f1e95e8af9a95b597e1b1b48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define REP(i,n) for(int i=0;i<(int)(n);i++) | |
#define ALL(x) (x).begin(),(x).end() | |
using namespace std; | |
vector<string> from_jfen(string s) { | |
s += "/"; | |
vector<string> res; | |
string line; | |
for (char c: s) { | |
if (c == '/') { res.push_back(line); line.clear(); } | |
else if (c == 'b') line += 'b'; | |
else REP(i,c-'0') line += '.'; | |
} | |
return res; | |
} | |
string to_jfen(const vector<string> &jfen) { | |
string res; | |
for (string s: jfen) { | |
for (char c: s) { | |
if (c == 'b') res += 'b'; | |
else if (!res.empty() && isdigit(res.back())) ++res.back(); | |
else res += '1'; | |
} | |
res += '/'; | |
} | |
return res.substr(0, res.size() - 1); | |
} | |
int main() { | |
string s; | |
int a, b, c, d; | |
while (cin >> s, s != "#") { | |
cin >> a >> b >> c >> d; | |
vector<string> board = from_jfen(s); | |
board[a-1][b-1] = '.'; | |
board[c-1][d-1] = 'b'; | |
cout << to_jfen(board) << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment