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;
 
T[] readlnSome(T)(){
    return array(readln().split().map!(a => to!T(a))());
}
 
 
T readlnOne(T)(){
    return to!T(readln().split()[0]);
}
 
 
void main()
{
  version(A)
  {
    uint[][] tiles;
    foreach(i; 0 .. 4)
        tiles ~= readlnSome!uint()[0 .. 4];

    writeln(probA(tiles));
  }

  version(B)
  {
    uint[] bs;
    foreach(i; 0 .. readlnOne!uint())
        bs ~= readlnOne!uint();

    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
Task B - Your Numbers are XORed...
User k3kaimu
Language D (DMD 2.060)
Score 100
Code Size 1976 Byte
Status
Exec Time 192 ms
Memory 3612 KB

Test Cases

Set Name Score / Max Score Test Cases
All 100 / 100 subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt 21 ms 744 KB
subtask0_sample-02.txt 20 ms 920 KB
subtask0_sample-03.txt 20 ms 800 KB
subtask1_01.txt 19 ms 924 KB
subtask1_02.txt 20 ms 928 KB
subtask1_03.txt 20 ms 928 KB
subtask1_04.txt 20 ms 764 KB
subtask1_05.txt 19 ms 800 KB
subtask1_06.txt 20 ms 928 KB
subtask1_07.txt 21 ms 804 KB
subtask1_08.txt 21 ms 836 KB
subtask1_09.txt 28 ms 1180 KB
subtask1_10.txt 54 ms 2076 KB
subtask1_11.txt 103 ms 2720 KB
subtask1_12.txt 78 ms 2208 KB
subtask1_13.txt 108 ms 2584 KB
subtask1_14.txt 153 ms 3188 KB
subtask1_15.txt 128 ms 2592 KB
subtask1_16.txt 172 ms 3232 KB
subtask1_17.txt 192 ms 3608 KB
subtask1_18.txt 128 ms 2580 KB
subtask1_19.txt 185 ms 3612 KB
subtask1_20.txt 185 ms 3612 KB