Submission #159060


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();

    writefln("%(%s\n%)", probB(bs));
  }
}


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 0
Code Size 1918 Byte
Status
Exec Time 191 ms
Memory 3704 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 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 27 ms 892 KB
subtask0_sample-02.txt 23 ms 780 KB
subtask0_sample-03.txt 20 ms 928 KB
subtask1_01.txt 20 ms 808 KB
subtask1_02.txt 21 ms 928 KB
subtask1_03.txt 21 ms 800 KB
subtask1_04.txt 20 ms 924 KB
subtask1_05.txt 21 ms 932 KB
subtask1_06.txt 20 ms 928 KB
subtask1_07.txt 21 ms 928 KB
subtask1_08.txt 21 ms 928 KB
subtask1_09.txt 31 ms 1052 KB
subtask1_10.txt 55 ms 2080 KB
subtask1_11.txt 107 ms 2648 KB
subtask1_12.txt 80 ms 2204 KB
subtask1_13.txt 112 ms 2532 KB
subtask1_14.txt 157 ms 3236 KB
subtask1_15.txt 132 ms 2600 KB
subtask1_16.txt 175 ms 3236 KB
subtask1_17.txt 191 ms 3612 KB
subtask1_18.txt 138 ms 2596 KB
subtask1_19.txt 188 ms 3604 KB
subtask1_20.txt 191 ms 3704 KB