Created
January 20, 2011 13:23
-
-
Save rekkusu/787864 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <string> | |
#include <iostream> | |
using namespace std; | |
#define W 25 | |
#define H 25 | |
int direction[8][2] = { | |
{ -1, -2 }, | |
{ 1, -2}, | |
{ -2, -1}, | |
{ -2, 1}, | |
{ -1, 2}, | |
{ 1, 2}, | |
{ 2, -1}, | |
{ 2, 1} | |
}; | |
int mapdata[H][W]; | |
int order[H*W][2]; | |
int getmap(int x, int y){ | |
if (y < 0 || y >= H) return 1; | |
if (x < 0 || x >= W) return 1; | |
return mapdata[y][x]; | |
} | |
void getorder(int x, int y){ | |
mapdata[y][x] = 1; | |
order[0][0] = x; | |
order[0][1] = y; | |
for (int i = 1; i < H*W; i++){ | |
int a[2] = {0xff, -1}; | |
for (int j = 0; j < 8; j++){ | |
int xx = x + direction[j][0]; | |
int yy = y + direction[j][1]; | |
if (getmap(xx, yy) == 0){ | |
int movable = 0; | |
for (int k = 0; k < 8; k++){ | |
int xxx = xx + direction[k][0]; | |
int yyy = yy + direction[k][1]; | |
if (getmap(xxx, yyy) == 0) movable++; | |
} | |
if (a[0] > movable) { | |
a[0] = movable; | |
a[1] = j; | |
} | |
} | |
} | |
if (a[1] == -1) break; | |
x += direction[a[1]][0]; | |
y += direction[a[1]][1]; | |
mapdata[y][x] = 1; | |
order[i][0] = x; | |
order[i][1] = y; | |
} | |
} | |
int main(){ | |
getorder(0,0); | |
wcin.imbue(locale("japanese")); | |
wcout.imbue(locale("japanese")); | |
wstring data[H]; | |
for (int i = 0; i < H; i++){ | |
wcin >> data[i]; | |
} | |
for (int i = 0; i < W*H; i++){ | |
int x = order[i][0]; | |
int y = order[i][1]; | |
wchar_t c = data[y][x]; | |
if (c == L'x'){ | |
wcout << endl << L" "; | |
}else if (c != L'-'){ | |
wcout << c; | |
} | |
} | |
return 0; | |
} |
This file contains hidden or 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
x善類寄がのて設なとの護き々遠童考な供をがな。なま | |
の付鎖意っに少こな施生人永養う大た児額水子ど集れそ | |
な人ら続連しいくも由りてもにちえ金なで栄、をいるル | |
す幸う至国なう活隣でいはるい莫い育養ら飲誰りしのま | |
よすい飲ま生はせ自合いと訪が方をも金寄はっみかセっ | |
福るに業いに先とをる福けがもれっ付度たがに連か恵お | |
水たむて進々送不わ死付れき付摂ておあをの自う金鎖ド | |
とと工死住。のて。幸だ、で登たて今意分ろ鎖できので | |
っないこ人っ一るで寄な場寄りしろげし連あす連。ン起 | |
はいまむりくいこのあにるるのよ、善るたがだ人こ引そ | |
恵かいると、か方限いすか、らだ。うのる一めル鎖っラ | |
う何がれ多るの類がめす。だうらがこ必続の当たりドを | |
なは。れにか差り。人誰多かるx。意なはに人寄っでた | |
か、もでな大のなた付先は。かれと要くでくたた1付た | |
でらに人き格にxは破くいならち善このそ類もら。れ名 | |
今。う続きいきる寄進分む子」でな困金なば幸そのなだ | |
こま類界かはそ気ち人びのなに知持いれのいな-は匿な | |
今ま善ろくず子ち工を住自学供と貧けにお福、安は-い | |
の起つの世。供れ病打々、こ「をも気はだの-と-の、 | |
で、実意だ世、供た業金にうそのい苦のが人もで-だ- | |
かそ幸いが、x子をた発がてと、と顔うし-る-てりう | |
日のの現福い界ち現の国お開いし頃はルる買む-ろ-し | |
、なとでがこ在なのんた途1大。つなに人た-えてか乗 | |
日本な連すはでとが達国いく人人人た名ド。たを-う育 | |
かは本では鎖る伊はなさ直上る、のずにっ前1そっ名。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment