Google Code Jam Qualification Round Problem A
GCJ Qualification Round Problem Aでソースにあげたものと全く同一
一度画面をクリックしてinputをupload
そのあと計算がはじまって結果が表示される。
また画面をクリックするとoutputがクリップボードに保存される。
新しくはじめるには要再実行。
ASのほうの環境ととのえてなかったので、急造です。
A-Large.inでも数秒なのでご安心を。
♥0 |
Line 55 |
Modified 2009-09-04 13:37:05 |
MIT License
archived:2017-03-30 04:49:53
ActionScript3 source code
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/581i
*/
// GCJ Qualification Round Problem Aでソースにあげたものと全く同一
// 一度画面をクリックしてinputをupload
// そのあと計算がはじまって結果が表示される。
// また画面をクリックするとoutputがクリップボードに保存される。
// 新しくはじめるには要再実行。
// ASのほうの環境ととのえてなかったので、急造です。
// A-Large.inでも数秒なのでご安心を。
package
{
import flash.desktop.Clipboard;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.text.TextField;
public class Main extends Sprite
{
private var _fr : FileReference;
private var _tf : TextField;
public function Main():void
{
addChild(_tf = new TextField());
_tf.width = 1000;
_tf.height = 1000;
_tf.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(e : MouseEvent) : void
{
_tf.removeEventListener(MouseEvent.CLICK, onClick);
_fr = new FileReference();
_fr.addEventListener(Event.SELECT, function(e : Event) : void { _fr.load(); } );
_fr.addEventListener(Event.COMPLETE, onLoadComplete);
_fr.browse();
}
private function onLoadComplete(e : Event) : void
{
var input : Array = String(_fr.data).split(/[ \n]/);
var l : int = input[0];
var d : int = input[1];
var n : int = input[2];
var ret : String = "";
for (var p : int = 0; p < n; p++) {
var re : RegExp = new RegExp("^" + input[3 + d + p].replace(/\(/g, "[").replace(/\)/g, "]") + "$");
var ct : int = 0;
for (var i : int = 3; i < 3 + d; i++) {
if (re.test(input[i])) ct++;
}
ret += "Case #" + (p + 1) + ": " + ct + "\n";
}
_tf.text = ret;
this.stage.focus = _tf;
_tf.setSelection(0, ret.length);
_tf.addEventListener(MouseEvent.CLICK, onClick2);
// Clipboard.generalClipboard.setData("air:text", ret);
}
public function onClick2(e : MouseEvent) : void
{
_tf.removeEventListener(MouseEvent.CLICK, onClick2);
Clipboard.generalClipboard.setData("air:text", _tf.text);
}
}
}