Getting local file by JavaScript
HTML
<input id="fileChooser1" type="file" onchange="openFile()"/>
function openFile() { var fileChooser1 = document.getElementById('fileChooser1'); var reader = new FileReader(); reader.onload = function () { alert(reader.result); }; reader.readAsText(fileChooser1.files[0], "UTF-8"); }
AOJ 2206 Compile
ぷよぷよです.
綺麗じゃない気がするけど,とりあえず通ったのでよし.
以下に注意.
- 同時消しあり
- 4つ以上くっついたブロックが消えるとき,隣にお邪魔があったら一緒に消える
上記を見落としていたこともあり,2時間半かかった….
// AOJ 2206 accepted 2012-01-09 // お邪魔を消すこと,同時消しの考慮を忘れていた.(問題文をちゃんと読んでなかった) #include <iostream> #include <cstring> #include <vector> #include <cstdio> using namespace std; const int COLS = 6; const int ROWS = 12; const char CLEAR = '*'; char memo_board[ROWS][COLS]; // 確認用 void print(char board[ROWS][COLS]){ for (int y=0; y<ROWS; y++) { printf("%2d ",y); for (int x=0; x<COLS; x++) { cout << board[y][x]; } cout << endl; } } // つなげてみる int connect(char block, int x, int y, int count) { int ret = count; for (int dx=-1; dx<=1; dx++) { for (int dy=-1; dy<=1; dy++) { if (dx == dy) continue; if (dx * dy != 0) continue; if (0 <= x + dx && x + dx < COLS && 0 <= y + dy && y + dy < ROWS) { if (memo_board[y+dy][x+dx] == block) { memo_board[y+dy][x+dx] = CLEAR; ret += connect(block, x+dx, y+dy, 1); } else if (memo_board[y+dy][x+dx] == 'O') { //お邪魔 memo_board[y+dy][x+dx] = CLEAR; } } } } return ret; } // '*'になっているブロックを消す void clear(char board[ROWS][COLS]) { //消す for (int x=0; x<COLS; x++) { // 新しいx列目を生成 vector<char> newRow; for (int y=ROWS-1; y>=0; y--) { if (board[y][x] == CLEAR) continue; newRow.push_back(board[y][x]); } for (int y=newRow.size(); y<ROWS; y++) { newRow.push_back('.'); } // x列目に適用 for (int y=ROWS-1; y>=0; y--) { board[y][x] = newRow[ROWS-1-y]; } } } int main() { int n = 0; cin >> n; for (int i=0; i<n; i++) { char board[ROWS][COLS]; // input board for (int y=0; y<ROWS; y++) { for (int x=0; x<COLS; x++) { cin >> board[y][x]; } } // start int rensa = 0; bool canClear; do { canClear = false; for (int startX=0; startX<COLS; startX++) { for (int startY=ROWS-1; startY>=0; startY--) { //退避 memcpy(memo_board, board, sizeof(board)); //つなげてみて,4つ以上つながるなら消す char block = board[startY][startX]; if (block == 'O' || block == '.' || block == CLEAR) continue; memo_board[startY][startX] = CLEAR; if (connect(block, startX, startY, 1) >= 4) { //print(memo_board); memcpy(board, memo_board, sizeof(board)); canClear = true; } } } // 可能なら消す if (canClear) { clear(board); rensa++; } } while (canClear); cout << rensa << endl; } return 0; }
Let'snote CF-T7 SSD換装
Let'snote CF-T7DW6AJRのHDDをSSDに換装しました.
Intel SSD 320 Series 120GBを使いました.Amazonで¥15,450で購入.
手順
HDDのデータをSSDへコピー.Intel Data Migration Softwareを使う.
IntelのSSD移行方法解説ページ.
「Intel Data Migration Software」というツールで,HDDからSSDへのコピーができるらしい.
http://www.intel.com/jp/consumer/Shop/diy/features/ssd/migration/index.htm
リカバリー領域も含めて,すべてコピーしました.
コピー時に設定などは特にしていません.
Lets'noteの蓋をあけてSSDに入れ替える
ねじ位置など分解方法はこちらのサイトを参考にしました.
http://musicsys.ddo.jp/dosblog/2007/10/cft7letsnotehdd.html
裏面のコピーを取って,それに取り外したねじを貼り付けておくと間違えずに済みます.
ねじも固くないし,力ずくでとりはずすような箇所もありませんでした.
粘着テープを張り替えるとか,ケーブルに細工するなどの不可逆な操作も不要です.
5分くらいであっけなく終わりました.
AOJ 0029
#include <iostream> #include <string> #include <map> using namespace std; int main(){ map<string, int> words; char s[32]; while(scanf("%s",s) != EOF) { if ('A' <= s[0] && s[0] <= 'Z') s[0]=s[0]+'a'-'A'; string word = s; map<string, int>::iterator p = words.find(word); if (p != words.end()) { words[word]++; } else { words[word] = 1; } } int maxFreq = 0; string maxFreqWord = ""; string longestWord = ""; unsigned int longestLen = 0; for (map<string, int>::iterator p=words.begin(); p!=words.end(); p++) { if (p->second > maxFreq) { maxFreq = p->second; maxFreqWord = p->first; } if ((p->first).size() > longestLen) { longestLen = (p->first).size(); longestWord = p->first; } } cout << maxFreqWord << " " << longestWord << endl; return 0; }
AOJ 0011
#include <iostream> #include <vector> using namespace std; struct line { int begin; int end; }; int main(){ int w=0,n=0; int b,e; char comma; cin >> w >> n; vector<line> hlines; int answers[31]; for (int i=0; i<n; i++) { cin >> b >> comma >> e; line yoko = {b,e}; hlines.push_back(yoko); } for (int i=1; i<=w; i++) { int pos = i; for (int j=0; j<n; j++) { line yoko = hlines[j]; if (yoko.begin == pos) { pos = yoko.end; } else if (yoko.end == pos) { pos = yoko.begin; } } answers[pos] = i; } for (int i=1; i<=w; i++) { cout << answers[i] << endl; } return 0; }
OpenCVでフルスクリーン表示(ウィンドウ枠なし)
通常OpenCVでは、ウィンドウ枠なしでフルスクリーンにすることができません。
そこで、Windows APIでウィンドウ枠を消します。
テスト環境
windowNameというウィンドウをフルスクリーン化します。
なお、cvで始まっているメソッド以外はWindows APIです。
// windowNameを持つウィンドウを検索 HWND windowHandle = ::FindWindowA(NULL, windowName); if (NULL != windowHandle) { // ウィンドウスタイル変更(メニューバーなし、最前面) SetWindowLongPtr(windowHandle, GWL_STYLE, WS_POPUP); SetWindowLongPtr(windowHandle, GWL_EXSTYLE, WS_EX_TOPMOST); // 最大化する ShowWindow(windowHandle, SW_MAXIMIZE); cvSetWindowProperty(windowName, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN ); // ディスプレイサイズを取得 int mainDisplayWidth = GetSystemMetrics(SM_CXSCREEN); int mainDisplayHeight = GetSystemMetrics(SM_CYSCREEN); // クライアント領域をディスプレーに合わせる SetWindowPos(windowHandle, NULL, 0, 0, mainDisplayWidth, mainDisplayWidth, SWP_FRAMECHANGED | SWP_NOZORDER); } ... cvShowImage(windowName, image