Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #159075

Source Code Expand

Copy
```import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.math;
import std.exception;
import std.bigint;

version = B;

}

}

void main()
{
version(A)
{
uint[][] tiles;
foreach(i; 0 .. 4)

writeln(probA(tiles));
}

version(B)
{
uint[] bs;

if(auto r = probB(bs))
writefln("%(%s\n%)", r);
else
writeln("-1");
}
}

version(A)
string probA(uint[][] tiles)
{
enum gameO = "GAMEOVER";
enum conti = "CONTINUE";

foreach(i; 0 .. 4){
foreach(j; 1 .. 4){
if(tiles[i][j] == tiles[i][j-1])
return conti;

if(tiles[j][i] == tiles[j-1][i])
return conti;
}
}

return gameO;
}

version(A)
unittest {
assert(probA([[2, 8, 2, 2],
[32, 2, 8, 8],
[4, 64, 2, 128],
[2, 8, 4, 2]]) == "CONTINUE");

assert(probA([[2, 4, 16, 4],
[8, 32, 128, 8],
[2, 64, 16, 2],
[32, 4, 32, 4]]) == "GAMEOVER");

assert(probA([[2, 4, 2, 4],
[4, 2, 4, 2],
[2, 4, 2, 4],
[4, 2, 4, 2]]) == "GAMEOVER");
}

version(B)
uint[] probB(uint[] bs)
{
uint[] dst = [0];

foreach(i, e; bs)
dst ~= dst[i] ^ e;

if(dst[0] == dst[\$-1])
return dst[0 .. \$-1];
else
return null;
}

version(B)
unittest{
assert(probB([1, 1]) == [0, 1]);
assert(probB([1, 4, 1]) is null);
assert(probB([1, 2, 3]) == [0, 1, 3]);
}
```

#### Submission Info

Submission Time 2014-04-12 21:40:50+0900 B - Your Numbers are XORed... k3kaimu D (DMD 2.060) 100 1976 Byte AC 192 ms 3612 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Case Name Status Exec Time Memory